View Single Post
Old 08-12-2016, 03:48 PM   #29
Hanspeter
Connoisseur
Hanspeter doesn't litterHanspeter doesn't litter
 
Posts: 77
Karma: 150
Join Date: Jul 2014
Device: Kindel PW1, Voyager
Quote:
Originally Posted by sguerrini97 View Post
I did some simple change to the source https://github.com/sguerrini97/xmahjongg_kindle
Anyway I don't understand other's source code very well and I have no idea about the reason why the window is displayed like that.. It seems like it gets squeezed but I'm not sure
Well done that you can compile it.
Take a look at the create_window function in main.cc line 378. There could be a problem with the attributes or the parent window.
https://tronche.com/gui/x/xlib/windo...ateWindow.html

First guess would be the attributes or the parent window. The Parent Window could be the problem as a reparent to a other window works.


Also Line 343 and following looks interesting as it it talking about the color depth:
Code:
    for (int i = 0; i < nv && !best_v; i++)
    if (v[i].visualid == default_visualid)
      best_v = &v[i];
  
  if (!best_v) {
    visual = DefaultVisual(display, screen_number);
    depth = DefaultDepth(display, screen_number);
    colormap = DefaultColormap(display, screen_number);
  } else {
  
    /* Which visual to choose? This isn't exactly a simple decision, since
       we want to avoid colormap flashing while choosing a nice visual. So
       here's the algorithm: Prefer the default visual, or take a TrueColor
       visual with strictly greater depth. */
    for (int i = 0; i < nv; i++)
      if (v[i].depth > best_v->depth && v[i].c_class == TrueColor)
	best_v = &v[i];
    
    visual = best_v->visual;
    depth = best_v->depth;
    if (best_v->visualid != default_visualid)
      colormap = XCreateColormap(display, root_window, visual, AllocNone);
    else
      colormap = DefaultColormap(display, screen_number);
    
  }
  
  if (v) XFree(v);
I would try to comment out or delete the if /else at the end that it always requests the DefultColormap.

Code:
  for (int i = 0; i < nv && !best_v; i++)
    if (v[i].visualid == default_visualid)
      best_v = &v[i];
  
    visual = DefaultVisual(display, screen_number);
    depth = DefaultDepth(display, screen_number);
    colormap = DefaultColormap(display, screen_number);

  
  if (v) XFree(v);
First guesses from looking inside the code quickly with no skills in x-Windows programming

Some docu about xLib programming: http://www.sbin.org/doc/Xlib/chapt_03.html

HaPe

Last edited by Hanspeter; 08-12-2016 at 04:16 PM.
Hanspeter is offline   Reply With Quote