/[rdesktop]/sourceforge.net/trunk/rdesktop/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 498 by astrand, Tue Oct 14 12:05:27 2003 UTC revision 536 by matthewc, Fri Oct 31 04:29:57 2003 UTC
# Line 49  static XIM g_IM; Line 49  static XIM g_IM;
49  static XIC g_IC;  static XIC g_IC;
50  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
51  static Cursor g_current_cursor;  static Cursor g_current_cursor;
52    static HCURSOR g_null_cursor;
53  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
54  static BOOL g_focused;  static BOOL g_focused;
55  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
# Line 56  static BOOL g_mouse_in_wnd; Line 57  static BOOL g_mouse_in_wnd;
57  /* endianness */  /* endianness */
58  static BOOL g_host_be;  static BOOL g_host_be;
59  static BOOL g_xserver_be;  static BOOL g_xserver_be;
60    static int g_red_shift_r, g_blue_shift_r, g_green_shift_r;
61    static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;
62    
63  /* software backing store */  /* software backing store */
64  static BOOL g_ownbackstore;  static BOOL g_ownbackstore;
# Line 69  static int g_move_y_offset = 0; Line 72  static int g_move_y_offset = 0;
72  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
73  extern int g_dsp_fd;  extern int g_dsp_fd;
74  extern BOOL g_dsp_busy;  extern BOOL g_dsp_busy;
75    extern BOOL g_rdpsnd;
76  #endif  #endif
77    
78  /* MWM decorations */  /* MWM decorations */
# Line 110  BOOL g_owncolmap = False; Line 114  BOOL g_owncolmap = False;
114  static Colormap g_xcolmap;  static Colormap g_xcolmap;
115  static uint32 *g_colmap = NULL;  static uint32 *g_colmap = NULL;
116    
117  #define TRANSLATE(col)          ( g_server_bpp != 8 ? translate_colour(col) : g_owncolmap ? col : translate_colour(g_colmap[col]) )  #define TRANSLATE(col)          ( g_server_bpp != 8 ? translate_colour(col) : g_owncolmap ? col : g_colmap[col] )
118  #define SET_FOREGROUND(col)     XSetForeground(g_display, g_gc, TRANSLATE(col));  #define SET_FOREGROUND(col)     XSetForeground(g_display, g_gc, TRANSLATE(col));
119  #define SET_BACKGROUND(col)     XSetBackground(g_display, g_gc, TRANSLATE(col));  #define SET_BACKGROUND(col)     XSetBackground(g_display, g_gc, TRANSLATE(col));
120    
# Line 195  split_colour24(uint32 colour) Line 199  split_colour24(uint32 colour)
199  }  }
200    
201  static uint32  static uint32
202  make_colour16(PixelColour pc)  make_colour(PixelColour pc)
203  {  {
204          pc.red = (pc.red * 0x1f) / 0xff;          return (((pc.red >> g_red_shift_r) << g_red_shift_l)
205          pc.green = (pc.green * 0x3f) / 0xff;                  | ((pc.green >> g_green_shift_r) << g_green_shift_l)
206          pc.blue = (pc.blue * 0x1f) / 0xff;                  | ((pc.blue >> g_blue_shift_r) << g_blue_shift_l));
         return (pc.red << 11) | (pc.green << 5) | pc.blue;  
 }  
   
 static uint32  
 make_colour24(PixelColour pc)  
 {  
         if (g_xserver_be)  
         {  
                 return pc.red | (pc.green << 8) | (pc.blue << 16);  
         }  
         else  
         {  
                 return (pc.red << 16) | (pc.green << 8) | pc.blue;  
         }  
 }  
   
 static uint32  
 make_colour32(PixelColour pc)  
 {  
         if (g_xserver_be)  
         {  
                 return pc.red | (pc.green << 8) | (pc.blue << 16);  
         }  
         else  
         {  
                 return (pc.red << 16) | (pc.green << 8) | pc.blue;  
         }  
207  }  }
208    
209  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
210  #define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); }  #define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | (x & 0xff00)); }
211  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
212                          x = (x << 16) | (x >> 16); }                          x = (x << 16) | (x >> 16); }
213    
214  static uint32  static uint32
215  translate_colour(uint32 colour)  translate_colour(uint32 colour)
216  {  {
217            PixelColour pc;
218          switch (g_server_bpp)          switch (g_server_bpp)
219          {          {
220                  case 15:                  case 15:
221                          switch (g_bpp)                          pc = split_colour15(colour);
                         {  
                                 case 16:  
                                         colour = make_colour16(split_colour15(colour));  
                                         break;  
                                 case 24:  
                                         colour = make_colour24(split_colour15(colour));  
                                         break;  
                                 case 32:  
                                         colour = make_colour32(split_colour15(colour));  
                                         break;  
                         }  
222                          break;                          break;
223                  case 16:                  case 16:
224                          switch (g_bpp)                          pc = split_colour16(colour);
                         {  
                                 case 16:  
                                         break;  
                                 case 24:  
                                         colour = make_colour24(split_colour16(colour));  
                                         break;  
                                 case 32:  
                                         colour = make_colour32(split_colour16(colour));  
                                         break;  
                         }  
225                          break;                          break;
226                  case 24:                  case 24:
227                          switch (g_bpp)                          pc = split_colour24(colour);
                         {  
                                 case 16:  
                                         colour = make_colour16(split_colour24(colour));  
                                         break;  
                                 case 24:  
                                         break;  
                                 case 32:  
                                         colour = make_colour32(split_colour24(colour));  
                                         break;  
                         }  
228                          break;                          break;
229          }          }
230          return colour;          return make_colour(pc);
231  }  }
232    
233  static void  static void
# Line 291  translate8to8(uint8 * data, uint8 * out, Line 238  translate8to8(uint8 * data, uint8 * out,
238  }  }
239    
240  static void  static void
241  translate8to16(uint8 * data, uint16 * out, uint16 * end)  translate8to16(uint8 * data, uint8 * out, uint8 * end)
242  {  {
243            uint16 value;
244    
245          while (out < end)          while (out < end)
246                  *(out++) = (uint16) g_colmap[*(data++)];          {
247                    value = (uint16) g_colmap[*(data++)];
248    
249                    if (g_xserver_be)
250                    {
251                            *(out++) = value >> 8;
252                            *(out++) = value;
253                    }
254                    else
255                    {
256                            *(out++) = value;
257                            *(out++) = value >> 8;
258                    }
259            }
260  }  }
261    
262  /* little endian - conversion happens when colourmap is built */  /* little endian - conversion happens when colourmap is built */
# Line 306  translate8to24(uint8 * data, uint8 * out Line 268  translate8to24(uint8 * data, uint8 * out
268          while (out < end)          while (out < end)
269          {          {
270                  value = g_colmap[*(data++)];                  value = g_colmap[*(data++)];
271                  *(out++) = value;  
272                  *(out++) = value >> 8;                  if (g_xserver_be)
273                  *(out++) = value >> 16;                  {
274                            *(out++) = value >> 16;
275                            *(out++) = value >> 8;
276                            *(out++) = value;
277                    }
278                    else
279                    {
280                            *(out++) = value;
281                            *(out++) = value >> 8;
282                            *(out++) = value >> 16;
283                    }
284          }          }
285  }  }
286    
287  static void  static void
288  translate8to32(uint8 * data, uint32 * out, uint32 * end)  translate8to32(uint8 * data, uint8 * out, uint8 * end)
289  {  {
290            uint32 value;
291    
292          while (out < end)          while (out < end)
293                  *(out++) = g_colmap[*(data++)];          {
294                    value = g_colmap[*(data++)];
295    
296                    if (g_xserver_be)
297                    {
298                            *(out++) = value >> 24;
299                            *(out++) = value >> 16;
300                            *(out++) = value >> 8;
301                            *(out++) = value;
302                    }
303                    else
304                    {
305                            *(out++) = value;
306                            *(out++) = value >> 8;
307                            *(out++) = value >> 16;
308                            *(out++) = value >> 24;
309                    }
310            }
311  }  }
312    
313  /* todo the remaining translate function might need some big endian check ?? */  /* todo the remaining translate function might need some big endian check ?? */
# Line 333  translate15to16(uint16 * data, uint8 * o Line 324  translate15to16(uint16 * data, uint8 * o
324    
325                  if (g_host_be)                  if (g_host_be)
326                  {                  {
327                          BSWAP16(pixel)                          BSWAP16(pixel);
328                  }                  }
329    
330                  value = make_colour16(split_colour15(pixel));                  value = make_colour(split_colour15(pixel));
331    
332                  if (g_xserver_be)                  if (g_xserver_be)
333                  {                  {
# Line 363  translate15to24(uint16 * data, uint8 * o Line 354  translate15to24(uint16 * data, uint8 * o
354    
355                  if (g_host_be)                  if (g_host_be)
356                  {                  {
357                          BSWAP16(pixel)                          BSWAP16(pixel);
358                  }                  }
359    
360                  value = make_colour24(split_colour15(pixel));                  value = make_colour(split_colour15(pixel));
361                  if (g_xserver_be)                  if (g_xserver_be)
362                  {                  {
363                          *(out++) = value >> 16;                          *(out++) = value >> 16;
# Line 397  translate15to32(uint16 * data, uint8 * o Line 388  translate15to32(uint16 * data, uint8 * o
388                          BSWAP16(pixel);                          BSWAP16(pixel);
389                  }                  }
390    
391                  value = make_colour32(split_colour15(pixel));                  value = make_colour(split_colour15(pixel));
392    
393                  if (g_xserver_be)                  if (g_xserver_be)
394                  {                  {
# Line 417  translate15to32(uint16 * data, uint8 * o Line 408  translate15to32(uint16 * data, uint8 * o
408  }  }
409    
410  static void  static void
411  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate16to16(uint16 * data, uint8 * out, uint8 * end)
412  {  {
413            uint16 pixel;
414          uint16 value;          uint16 value;
415    
416          if (g_xserver_be)          while (out < end)
417          {          {
418                  while (out < end)                  pixel = *(data++);
419    
420                    if (g_host_be)
421                  {                  {
422                          value = *data;                          BSWAP16(pixel);
                         BSWAP16(value);  
                         *out = value;  
                         data++;  
                         out++;  
423                  }                  }
424    
425          }                  value = make_colour(split_colour16(pixel));
426          else  
427          {                  if (g_xserver_be)
428                  while (out < end)                  {
429                            *(out++) = value >> 8;
430                            *(out++) = value;
431                    }
432                    else
433                  {                  {
434                          *out = *data;                          *(out++) = value;
435                          out++;                          *(out++) = value >> 8;
                         data++;  
436                  }                  }
437          }          }
438  }  }
439    
   
440  static void  static void
441  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
442  {  {
# Line 457  translate16to24(uint16 * data, uint8 * o Line 449  translate16to24(uint16 * data, uint8 * o
449    
450                  if (g_host_be)                  if (g_host_be)
451                  {                  {
452                          BSWAP16(pixel)                          BSWAP16(pixel);
453                  }                  }
454    
455                  value = make_colour24(split_colour16(pixel));                  value = make_colour(split_colour16(pixel));
456    
457                  if (g_xserver_be)                  if (g_xserver_be)
458                  {                  {
# Line 489  translate16to32(uint16 * data, uint8 * o Line 481  translate16to32(uint16 * data, uint8 * o
481    
482                  if (g_host_be)                  if (g_host_be)
483                  {                  {
484                          BSWAP16(pixel)                          BSWAP16(pixel);
485                  }                  }
486    
487                  value = make_colour32(split_colour16(pixel));                  value = make_colour(split_colour16(pixel));
488    
489                  if (g_xserver_be)                  if (g_xserver_be)
490                  {                  {
# Line 500  translate16to32(uint16 * data, uint8 * o Line 492  translate16to32(uint16 * data, uint8 * o
492                          *(out++) = value >> 16;                          *(out++) = value >> 16;
493                          *(out++) = value >> 8;                          *(out++) = value >> 8;
494                          *(out++) = value;                          *(out++) = value;
495                  }                  }
496                  else                  else
497                  {                  {
498                          *(out++) = value;                          *(out++) = value;
499                          *(out++) = value >> 8;                          *(out++) = value >> 8;
500                          *(out++) = value >> 16;                          *(out++) = value >> 16;
501                          *(out++) = value >> 24;                          *(out++) = value >> 24;
502                  }                  }
503          }          }
504  }  }
505    
506  static void  static void
# Line 522  translate24to16(uint8 * data, uint8 * ou Line 514  translate24to16(uint8 * data, uint8 * ou
514                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
515                  pixel |= *(data++);                  pixel |= *(data++);
516    
517                  value = (uint16) make_colour16(split_colour24(pixel));                  value = (uint16) make_colour(split_colour24(pixel));
518    
519                  if (g_xserver_be)                  if (g_xserver_be)
520                  {                  {
# Line 540  translate24to16(uint8 * data, uint8 * ou Line 532  translate24to16(uint8 * data, uint8 * ou
532  static void  static void
533  translate24to24(uint8 * data, uint8 * out, uint8 * end)  translate24to24(uint8 * data, uint8 * out, uint8 * end)
534  {  {
535            uint32 pixel;
536            uint32 value;
537    
538          while (out < end)          while (out < end)
539          {          {
540                  *(out++) = (*(data++));                  pixel = *(data++) << 16;
541                    pixel |= *(data++) << 8;
542                    pixel |= *(data++);
543    
544                    value = make_colour(split_colour24(pixel));
545                    
546                    if (g_xserver_be)
547                    {
548                            *(out++) = value >> 16;
549                            *(out++) = value >> 8;
550                            *(out++) = value;
551                    }
552                    else
553                    {
554                            *(out++) = value;
555                            *(out++) = value >> 8;
556                            *(out++) = value >> 16;
557                    }
558          }          }
559  }  }
560    
561  static void  static void
562  translate24to32(uint8 * data, uint8 * out, uint8 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
563  {  {
564            uint32 pixel;
565            uint32 value;
566    
567          while (out < end)          while (out < end)
568          {          {
569                    pixel = *(data++) << 16;
570                    pixel |= *(data++) << 8;
571                    pixel |= *(data++);
572    
573                    value = make_colour(split_colour24(pixel));
574    
575                  if (g_xserver_be)                  if (g_xserver_be)
576                  {                  {
577                          *(out++) = 0x00;                          *(out++) = value >> 24;
578                          *(out++) = *(data++);                          *(out++) = value >> 16;
579                          *(out++) = *(data++);                          *(out++) = value >> 8;
580                          *(out++) = *(data++);                          *(out++) = value;
581                  }                  }
582                  else                  else
583                  {                  {
584                          *(out++) = *(data++);                          *(out++) = value;
585                          *(out++) = *(data++);                          *(out++) = value >> 8;
586                          *(out++) = *(data++);                          *(out++) = value >> 16;
587                          *(out++) = 0x00;                          *(out++) = value >> 24;
588                  }                  }
589          }          }
590  }  }
# Line 601  translate_image(int width, int height, u Line 622  translate_image(int width, int height, u
622                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
623                                          break;                                          break;
624                                  case 16:                                  case 16:
625                                          translate16to16((uint16 *) data, (uint16 *) out,                                          translate16to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
626                                          break;                                          break;
627                          }                          }
628                          break;                          break;
# Line 627  translate_image(int width, int height, u Line 647  translate_image(int width, int height, u
647                                          translate8to8(data, out, end);                                          translate8to8(data, out, end);
648                                          break;                                          break;
649                                  case 16:                                  case 16:
650                                          translate8to16(data, (uint16 *) out, (uint16 *) end);                                          translate8to16(data, out, end);
651                                          break;                                          break;
652                                  case 24:                                  case 24:
653                                          translate8to24(data, out, end);                                          translate8to24(data, out, end);
654                                          break;                                          break;
655                                  case 32:                                  case 32:
656                                          translate8to32(data, (uint32 *) out, (uint32 *) end);                                          translate8to32(data, out, end);
657                                          break;                                          break;
658                          }                          }
659                          break;                          break;
# Line 666  get_key_state(unsigned int state, uint32 Line 686  get_key_state(unsigned int state, uint32
686          return (state & keysymMask) ? True : False;          return (state & keysymMask) ? True : False;
687  }  }
688    
689    static void
690    calculate_shifts(uint32 mask, int *shift_r, int *shift_l)
691    {
692            *shift_l = ffs(mask) - 1;
693            mask >>= *shift_l;
694            *shift_r = 8 - ffs(mask & ~(mask >> 1));
695    }
696    
697  BOOL  BOOL
698  ui_init(void)  ui_init(void)
699  {  {
700            XVisualInfo vi;
701          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
702          uint16 test;          uint16 test;
703          int i;          int i, screen_num;
704    
705          g_display = XOpenDisplay(NULL);          g_display = XOpenDisplay(NULL);
706          if (g_display == NULL)          if (g_display == NULL)
# Line 680  ui_init(void) Line 709  ui_init(void)
709                  return False;                  return False;
710          }          }
711    
712            screen_num = DefaultScreen(g_display);
713          g_x_socket = ConnectionNumber(g_display);          g_x_socket = ConnectionNumber(g_display);
714          g_screen = DefaultScreenOfDisplay(g_display);          g_screen = ScreenOfDisplay(g_display, screen_num);
         g_visual = DefaultVisualOfScreen(g_screen);  
715          g_depth = DefaultDepthOfScreen(g_screen);          g_depth = DefaultDepthOfScreen(g_screen);
716    
717            if (g_server_bpp == 8)
718            {
719                    /* we use a colourmap, so any visual should do */
720                    g_visual = DefaultVisualOfScreen(g_screen);
721            }
722            else
723            {
724                    /* need a truecolour visual */
725                    if (!XMatchVisualInfo(g_display, screen_num, g_depth, TrueColor, &vi))
726                    {
727                            error("The display does not support true colour - high colour support unavailable.\n");
728                            return False;
729                    }
730    
731                    g_visual = vi.visual;
732                    g_owncolmap = False;
733                    calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l);
734                    calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l);
735                    calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);
736            }
737    
738          pfm = XListPixmapFormats(g_display, &i);          pfm = XListPixmapFormats(g_display, &i);
739          if (pfm != NULL)          if (pfm != NULL)
740          {          {
# Line 707  ui_init(void) Line 757  ui_init(void)
757                  return False;                  return False;
758          }          }
759    
760          if (g_owncolmap != True)          if (!g_owncolmap)
761          {          {
762                  g_xcolmap = DefaultColormapOfScreen(g_screen);                  g_xcolmap = DefaultColormapOfScreen(g_screen);
763                  if (g_depth <= 8)                  if (g_depth <= 8)
# Line 723  ui_init(void) Line 773  ui_init(void)
773          g_host_be = !(BOOL) (*(uint8 *) (&test));          g_host_be = !(BOOL) (*(uint8 *) (&test));
774          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
775    
776          if ((g_width == 0) || (g_height == 0))          /*
777             * Determine desktop size
778             */
779            if (g_width < 0)
780            {
781                    /* Percent of screen */
782                    g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
783                    g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
784            }
785            else if (g_width == 0)
786          {          {
787                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
788                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
# Line 740  ui_init(void) Line 799  ui_init(void)
799                          g_height = 600;                          g_height = 600;
800                  }                  }
801          }          }
802            else if (g_fullscreen)
         if (g_fullscreen)  
803          {          {
804                  g_width = WidthOfScreen(g_screen);                  g_width = WidthOfScreen(g_screen);
805                  g_height = HeightOfScreen(g_screen);                  g_height = HeightOfScreen(g_screen);
# Line 770  ui_init(void) Line 828  ui_init(void)
828    
829          xclip_init();          xclip_init();
830    
831          /* todo take this out when high colour is done */          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth));
         printf("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth);  
832    
833          return True;          return True;
834  }  }
# Line 795  ui_deinit(void) Line 852  ui_deinit(void)
852  BOOL  BOOL
853  ui_create_window(void)  ui_create_window(void)
854  {  {
855            uint8 null_pointer_mask[1] = { 0x80 };
856            uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 };
857          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
858          XClassHint *classhints;          XClassHint *classhints;
859          XSizeHints *sizehints;          XSizeHints *sizehints;
# Line 876  ui_create_window(void) Line 935  ui_create_window(void)
935          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);
936          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
937    
938            /* create invisible 1x1 cursor to be used as null cursor */
939            g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);
940    
941          return True;          return True;
942  }  }
943    
944  void  void
945  ui_destroy_window(void)  ui_destroy_window(void)
946  {  {
947            ui_destroy_cursor(g_null_cursor);
948    
949          if (g_IC != NULL)          if (g_IC != NULL)
950                  XDestroyIC(g_IC);                  XDestroyIC(g_IC);
951    
# Line 1203  ui_select(int rdp_socket) Line 1267  ui_select(int rdp_socket)
1267                  {                  {
1268                          FD_SET(g_dsp_fd, &wfds);                          FD_SET(g_dsp_fd, &wfds);
1269                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1270                  }                  }
1271  #endif  #endif
1272    
1273                  switch (select(n, &rfds, &wfds, NULL, NULL))                  switch (select(n, &rfds, &wfds, NULL, NULL))
# Line 1237  ui_create_bitmap(int width, int height, Line 1301  ui_create_bitmap(int width, int height,
1301          XImage *image;          XImage *image;
1302          Pixmap bitmap;          Pixmap bitmap;
1303          uint8 *tdata;          uint8 *tdata;
1304            int bitmap_pad;
1305    
1306            if (g_server_bpp == 8)
1307            {
1308                    bitmap_pad = 8;
1309            }
1310            else
1311            {
1312                    bitmap_pad = g_bpp;
1313    
1314                    if (g_bpp == 24)
1315                            bitmap_pad = 32;
1316            }
1317    
1318          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1319          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);
1320          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1321                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1322    
1323          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);
1324    
# Line 1256  ui_paint_bitmap(int x, int y, int cx, in Line 1333  ui_paint_bitmap(int x, int y, int cx, in
1333  {  {
1334          XImage *image;          XImage *image;
1335          uint8 *tdata;          uint8 *tdata;
1336            int bitmap_pad;
1337    
1338            if (g_server_bpp == 8)
1339            {
1340                    bitmap_pad = 8;
1341            }
1342            else
1343            {
1344                    bitmap_pad = g_bpp;
1345    
1346                    if (g_bpp == 24)
1347                            bitmap_pad = 32;
1348            }
1349    
1350          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1351          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1352                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1353    
1354          if (g_ownbackstore)          if (g_ownbackstore)
1355          {          {
# Line 1397  ui_destroy_cursor(HCURSOR cursor) Line 1488  ui_destroy_cursor(HCURSOR cursor)
1488          XFreeCursor(g_display, (Cursor) cursor);          XFreeCursor(g_display, (Cursor) cursor);
1489  }  }
1490    
1491    void
1492    ui_set_null_cursor(void)
1493    {
1494            ui_set_cursor(g_null_cursor);
1495    }
1496    
1497  #define MAKE_XCOLOR(xc,c) \  #define MAKE_XCOLOR(xc,c) \
1498                  (xc)->red   = ((c)->red   << 8) | (c)->red; \                  (xc)->red   = ((c)->red   << 8) | (c)->red; \
1499                  (xc)->green = ((c)->green << 8) | (c)->green; \                  (xc)->green = ((c)->green << 8) | (c)->green; \
# Line 1478  ui_create_colourmap(COLOURMAP * colours) Line 1575  ui_create_colourmap(COLOURMAP * colours)
1575    
1576                          }                          }
1577    
1578                            map[i] = colour;
                         /* byte swap here to make translate_image faster */  
                         map[i] = translate_colour(colour);  
1579                  }                  }
1580                  return map;                  return map;
1581          }          }

Legend:
Removed from v.498  
changed lines
  Added in v.536

  ViewVC Help
Powered by ViewVC 1.1.26