/[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 456 by astrand, Sun Aug 31 20:01:12 2003 UTC revision 528 by matthewc, Wed Oct 29 08:37:20 2003 UTC
# Line 34  extern BOOL g_hide_decorations; Line 34  extern BOOL g_hide_decorations;
34  extern char g_title[];  extern char g_title[];
35  extern int g_server_bpp;  extern int g_server_bpp;
36  extern int g_win_button_size;  extern int g_win_button_size;
 BOOL g_enable_compose = False;  
 BOOL g_focused;  
 BOOL g_mouse_in_wnd;  
37    
38  Display *g_display;  Display *g_display;
39  Time g_last_gesturetime;  Time g_last_gesturetime;
40  static int g_x_socket;  static int g_x_socket;
41  static Screen *g_screen;  static Screen *g_screen;
42  Window g_wnd;  Window g_wnd;
43    BOOL g_enable_compose = False;
44  static GC g_gc;  static GC g_gc;
45  static Visual *g_visual;  static Visual *g_visual;
46  static int g_depth;  static int g_depth;
# Line 51  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;
55    static BOOL g_mouse_in_wnd;
56    
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 66  static BOOL g_moving_wnd; Line 69  static BOOL g_moving_wnd;
69  static int g_move_x_offset = 0;  static int g_move_x_offset = 0;
70  static int g_move_y_offset = 0;  static int g_move_y_offset = 0;
71    
72    #ifdef WITH_RDPSND
73    extern int g_dsp_fd;
74    extern BOOL g_dsp_busy;
75    extern BOOL g_rdpsnd;
76    #endif
77    
78  /* MWM decorations */  /* MWM decorations */
79  #define MWM_HINTS_DECORATIONS   (1L << 1)  #define MWM_HINTS_DECORATIONS   (1L << 1)
80  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
# Line 105  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 190  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)
 {  
         pc.red = (pc.red * 0x1f) / 0xff;  
         pc.green = (pc.green * 0x3f) / 0xff;  
         pc.blue = (pc.blue * 0x1f) / 0xff;  
         return (pc.red << 11) | (pc.green << 5) | pc.blue;  
 }  
   
 static uint32  
 make_colour24(PixelColour pc)  
203  {  {
204          return (pc.red << 16) | (pc.green << 8) | pc.blue;          return (((pc.red >> g_red_shift_r) << g_red_shift_l)
205  }                  | ((pc.green >> g_green_shift_r) << g_green_shift_l)
206                    | ((pc.blue >> g_blue_shift_r) << g_blue_shift_l));
 static uint32  
 make_colour32(PixelColour pc)  
 {  
         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)); }
# Line 218  make_colour32(PixelColour pc) Line 214  make_colour32(PixelColour pc)
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;  
                         }  
                         break;  
                 case 24:  
                         switch (g_bpp)  
                         {  
                                 case 16:  
                                         colour = make_colour16(split_colour24(colour));  
                                         break;  
                                 case 24:  
                                         break;  
                                 case 32:  
                                         colour = make_colour32(split_colour24(colour));  
                                         break;  
                         }  
225                          break;                          break;
         }  
         switch (g_bpp)  
         {  
                 case 16:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP16(colour);  
                         break;  
   
226                  case 24:                  case 24:
227                          if (g_xserver_be)                          pc = split_colour24(colour);
                                 BSWAP24(colour);  
                         break;  
   
                 case 32:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP32(colour);  
228                          break;                          break;
229          }          }
230            return make_colour(pc);
         return colour;  
231  }  }
232    
233  static void  static void
# Line 290  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 305  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 ?? */
314    
315  static void  static void
316  translate15to16(uint16 * data, uint16 * out, uint16 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
317  {  {
318            uint16 pixel;
319            uint16 value;
320    
321          while (out < end)          while (out < end)
322                  *(out++) = (uint16) make_colour16(split_colour15(*(data++)));          {
323                    pixel = *(data++);
324    
325                    if (g_host_be)
326                    {
327                            BSWAP16(pixel);
328                    }
329    
330                    value = make_colour(split_colour15(pixel));
331    
332                    if (g_xserver_be)
333                    {
334                            *(out++) = value >> 8;
335                            *(out++) = value;
336                    }
337                    else
338                    {
339                            *(out++) = value;
340                            *(out++) = value >> 8;
341                    }
342            }
343  }  }
344    
345  static void  static void
346  translate15to24(uint16 * data, uint8 * out, uint8 * end)  translate15to24(uint16 * data, uint8 * out, uint8 * end)
347  {  {
348          uint32 value;          uint32 value;
349            uint16 pixel;
350    
351          while (out < end)          while (out < end)
352          {          {
353                  value = make_colour24(split_colour15(*(data++)));                  pixel = *(data++);
354                  *(out++) = value;  
355                  *(out++) = value >> 8;                  if (g_host_be)
356                  *(out++) = value >> 16;                  {
357                            BSWAP16(pixel);
358                    }
359    
360                    value = make_colour(split_colour15(pixel));
361                    if (g_xserver_be)
362                    {
363                            *(out++) = value >> 16;
364                            *(out++) = value >> 8;
365                            *(out++) = value;
366                    }
367                    else
368                    {
369                            *(out++) = value;
370                            *(out++) = value >> 8;
371                            *(out++) = value >> 16;
372                    }
373          }          }
374  }  }
375    
376  static void  static void
377  translate15to32(uint16 * data, uint32 * out, uint32 * end)  translate15to32(uint16 * data, uint8 * out, uint8 * end)
378  {  {
379            uint16 pixel;
380            uint32 value;
381    
382          while (out < end)          while (out < end)
383                  *(out++) = make_colour32(split_colour15(*(data++)));          {
384                    pixel = *(data++);
385    
386                    if (g_host_be)
387                    {
388                            BSWAP16(pixel);
389                    }
390    
391                    value = make_colour(split_colour15(pixel));
392    
393                    if (g_xserver_be)
394                    {
395                            *(out++) = value >> 24;
396                            *(out++) = value >> 16;
397                            *(out++) = value >> 8;
398                            *(out++) = value;
399                    }
400                    else
401                    {
402                            *(out++) = value;
403                            *(out++) = value >> 8;
404                            *(out++) = value >> 16;
405                            *(out++) = value >> 24;
406                    }
407            }
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;
415    
416          while (out < end)          while (out < end)
417                  *(out++) = (uint16) (*(data++));          {
418  }                  pixel = *(data++);
419    
420                    if (g_host_be)
421                    {
422                            BSWAP16(pixel);
423                    }
424    
425                    value = make_colour(split_colour16(pixel));
426    
427                    if (g_xserver_be)
428                    {
429                            *(out++) = value >> 8;
430                            *(out++) = value;
431                    }
432                    else
433                    {
434                            *(out++) = value;
435                            *(out++) = value >> 8;
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  {  {
443          uint32 value;          uint32 value;
444            uint16 pixel;
445    
446          while (out < end)          while (out < end)
447          {          {
448                  value = make_colour24(split_colour16(*(data++)));                  pixel = *(data++);
449                  *(out++) = value;  
450                  *(out++) = value >> 8;                  if (g_host_be)
451                  *(out++) = value >> 16;                  {
452                            BSWAP16(pixel);
453                    }
454    
455                    value = make_colour(split_colour16(pixel));
456    
457                    if (g_xserver_be)
458                    {
459                            *(out++) = value >> 16;
460                            *(out++) = value >> 8;
461                            *(out++) = value;
462                    }
463                    else
464                    {
465                            *(out++) = value;
466                            *(out++) = value >> 8;
467                            *(out++) = value >> 16;
468                    }
469          }          }
470  }  }
471    
472  static void  static void
473  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint8 * out, uint8 * end)
474  {  {
475            uint16 pixel;
476            uint32 value;
477    
478          while (out < end)          while (out < end)
479                  *(out++) = make_colour32(split_colour16(*(data++)));          {
480                    pixel = *(data++);
481    
482                    if (g_host_be)
483                    {
484                    BSWAP16(pixel)}
485    
486                    value = make_colour(split_colour16(pixel));
487    
488                    if (g_xserver_be)
489                    {
490                            *(out++) = value >> 24;
491                            *(out++) = value >> 16;
492                            *(out++) = value >> 8;
493                            *(out++) = value;
494                    }
495                    else
496                    {
497                            *(out++) = value;
498                            *(out++) = value >> 8;
499                            *(out++) = value >> 16;
500                            *(out++) = value >> 24;
501                    }
502            }
503  }  }
504    
505  static void  static void
506  translate24to16(uint8 * data, uint16 * out, uint16 * end)  translate24to16(uint8 * data, uint8 * out, uint8 * end)
507  {  {
508          uint32 pixel = 0;          uint32 pixel = 0;
509            uint16 value;
510          while (out < end)          while (out < end)
511          {          {
512                  pixel = *(data++) << 16;                  pixel = *(data++) << 16;
513                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
514                  pixel |= *(data++);                  pixel |= *(data++);
515                  *(out++) = (uint16) make_colour16(split_colour24(pixel));  
516                    value = (uint16) make_colour(split_colour24(pixel));
517    
518                    if (g_xserver_be)
519                    {
520                            *(out++) = value >> 8;
521                            *(out++) = value;
522                    }
523                    else
524                    {
525                            *(out++) = value;
526                            *(out++) = value >> 8;
527                    }
528          }          }
529  }  }
530    
# Line 400  translate24to24(uint8 * data, uint8 * ou Line 538  translate24to24(uint8 * data, uint8 * ou
538  }  }
539    
540  static void  static void
541  translate24to32(uint8 * data, uint32 * out, uint32 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
542  {  {
         uint32 pixel = 0;  
543          while (out < end)          while (out < end)
544          {          {
545                  pixel = *(data++);                  if (g_xserver_be)
546                  pixel |= *(data++) << 8;                  {
547                  pixel |= *(data++) << 16;                          *(out++) = 0x00;
548                  *(out++) = pixel;                          *(out++) = *(data++);
549                            *(out++) = *(data++);
550                            *(out++) = *(data++);
551                    }
552                    else
553                    {
554                            *(out++) = *(data++);
555                            *(out++) = *(data++);
556                            *(out++) = *(data++);
557                            *(out++) = 0x00;
558                    }
559          }          }
560  }  }
561    
# Line 425  translate_image(int width, int height, u Line 572  translate_image(int width, int height, u
572                          switch (g_bpp)                          switch (g_bpp)
573                          {                          {
574                                  case 32:                                  case 32:
575                                          translate24to32(data, (uint32 *) out, (uint32 *) end);                                          translate24to32(data, out, end);
576                                          break;                                          break;
577                                  case 24:                                  case 24:
578                                          translate24to24(data, out, end);                                          translate24to24(data, out, end);
579                                          break;                                          break;
580                                  case 16:                                  case 16:
581                                          translate24to16(data, (uint16 *) out, (uint16 *) end);                                          translate24to16(data, out, end);
582                                          break;                                          break;
583                          }                          }
584                          break;                          break;
# Line 439  translate_image(int width, int height, u Line 586  translate_image(int width, int height, u
586                          switch (g_bpp)                          switch (g_bpp)
587                          {                          {
588                                  case 32:                                  case 32:
589                                          translate16to32((uint16 *) data, (uint32 *) out,                                          translate16to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
590                                          break;                                          break;
591                                  case 24:                                  case 24:
592                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
593                                          break;                                          break;
594                                  case 16:                                  case 16:
595                                          translate16to16((uint16 *) data, (uint16 *) out,                                          translate16to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
596                                          break;                                          break;
597                          }                          }
598                          break;                          break;
# Line 455  translate_image(int width, int height, u Line 600  translate_image(int width, int height, u
600                          switch (g_bpp)                          switch (g_bpp)
601                          {                          {
602                                  case 32:                                  case 32:
603                                          translate15to32((uint16 *) data, (uint32 *) out,                                          translate15to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
604                                          break;                                          break;
605                                  case 24:                                  case 24:
606                                          translate15to24((uint16 *) data, out, end);                                          translate15to24((uint16 *) data, out, end);
607                                          break;                                          break;
608                                  case 16:                                  case 16:
609                                          translate15to16((uint16 *) data, (uint16 *) out,                                          translate15to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
610                                          break;                                          break;
611                          }                          }
612                          break;                          break;
# Line 474  translate_image(int width, int height, u Line 617  translate_image(int width, int height, u
617                                          translate8to8(data, out, end);                                          translate8to8(data, out, end);
618                                          break;                                          break;
619                                  case 16:                                  case 16:
620                                          translate8to16(data, (uint16 *) out, (uint16 *) end);                                          translate8to16(data, out, end);
621                                          break;                                          break;
622                                  case 24:                                  case 24:
623                                          translate8to24(data, out, end);                                          translate8to24(data, out, end);
624                                          break;                                          break;
625                                  case 32:                                  case 32:
626                                          translate8to32(data, (uint32 *) out, (uint32 *) end);                                          translate8to32(data, out, end);
627                                          break;                                          break;
628                          }                          }
629                          break;                          break;
# Line 513  get_key_state(unsigned int state, uint32 Line 656  get_key_state(unsigned int state, uint32
656          return (state & keysymMask) ? True : False;          return (state & keysymMask) ? True : False;
657  }  }
658    
659    static void
660    calculate_shifts(uint32 mask, int *shift_r, int *shift_l)
661    {
662            *shift_l = ffs(mask) - 1;
663            mask >>= *shift_l;
664            *shift_r = 8 - ffs(mask & ~(mask >> 1));
665    }
666    
667  BOOL  BOOL
668  ui_init(void)  ui_init(void)
669  {  {
670            XVisualInfo vi;
671          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
672          uint16 test;          uint16 test;
673          int i;          int i, screen_num;
674    
675          g_display = XOpenDisplay(NULL);          g_display = XOpenDisplay(NULL);
676          if (g_display == NULL)          if (g_display == NULL)
# Line 527  ui_init(void) Line 679  ui_init(void)
679                  return False;                  return False;
680          }          }
681    
682            screen_num = DefaultScreen(g_display);
683          g_x_socket = ConnectionNumber(g_display);          g_x_socket = ConnectionNumber(g_display);
684          g_screen = DefaultScreenOfDisplay(g_display);          g_screen = ScreenOfDisplay(g_display, screen_num);
         g_visual = DefaultVisualOfScreen(g_screen);  
685          g_depth = DefaultDepthOfScreen(g_screen);          g_depth = DefaultDepthOfScreen(g_screen);
686    
687            if (g_server_bpp == 8)
688            {
689                    /* we use a colourmap, so any visual should do */
690                    g_visual = DefaultVisualOfScreen(g_screen);
691            }
692            else
693            {
694                    /* need a truecolour visual */
695                    if (!XMatchVisualInfo(g_display, screen_num, g_depth, TrueColor, &vi))
696                    {
697                            error("The display does not support true colour - high colour support unavailable.\n");
698                            return False;
699                    }
700    
701                    g_visual = vi.visual;
702                    g_owncolmap = False;
703                    calculate_shifts(vi.red_mask,   &g_red_shift_r,   &g_red_shift_l);
704                    calculate_shifts(vi.blue_mask,  &g_blue_shift_r,  &g_blue_shift_l);
705                    calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);
706            }
707    
708          pfm = XListPixmapFormats(g_display, &i);          pfm = XListPixmapFormats(g_display, &i);
709          if (pfm != NULL)          if (pfm != NULL)
710          {          {
# Line 554  ui_init(void) Line 727  ui_init(void)
727                  return False;                  return False;
728          }          }
729    
730          if (g_owncolmap != True)          if (!g_owncolmap)
731          {          {
732                  g_xcolmap = DefaultColormapOfScreen(g_screen);                  g_xcolmap = DefaultColormapOfScreen(g_screen);
733                  if (g_depth <= 8)                  if (g_depth <= 8)
# Line 570  ui_init(void) Line 743  ui_init(void)
743          g_host_be = !(BOOL) (*(uint8 *) (&test));          g_host_be = !(BOOL) (*(uint8 *) (&test));
744          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
745    
746          if ((g_width == 0) || (g_height == 0))          /*
747             * Determine desktop size
748             */
749            if (g_width < 0)
750            {
751                    /* Percent of screen */
752                    g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
753                    g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
754            }
755            else if (g_width == 0)
756          {          {
757                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
758                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
# Line 587  ui_init(void) Line 769  ui_init(void)
769                          g_height = 600;                          g_height = 600;
770                  }                  }
771          }          }
772            else if (g_fullscreen)
         if (g_fullscreen)  
773          {          {
774                  g_width = WidthOfScreen(g_screen);                  g_width = WidthOfScreen(g_screen);
775                  g_height = HeightOfScreen(g_screen);                  g_height = HeightOfScreen(g_screen);
# Line 610  ui_init(void) Line 791  ui_init(void)
791    
792          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
793    
794            xkeymap_init();
795    
796          if (g_enable_compose)          if (g_enable_compose)
797                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);
798    
         xkeymap_init();  
799          xclip_init();          xclip_init();
800    
801          /* 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);  
802    
803          return True;          return True;
804  }  }
# Line 638  ui_deinit(void) Line 819  ui_deinit(void)
819          g_display = NULL;          g_display = NULL;
820  }  }
821    
822    #define NULL_POINTER_MASK       "\x80"
823    #define NULL_POINTER_DATA       "\x0\x0\x0"
824            
825  BOOL  BOOL
826  ui_create_window(void)  ui_create_window(void)
827  {  {
# Line 722  ui_create_window(void) Line 906  ui_create_window(void)
906          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);
907          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
908    
909            /* create invisible 1x1 cursor to be used as null cursor */
910            g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA);
911    
912          return True;          return True;
913  }  }
914    
915  void  void
916  ui_destroy_window(void)  ui_destroy_window(void)
917  {  {
918            ui_destroy_cursor(g_null_cursor);
919            
920          if (g_IC != NULL)          if (g_IC != NULL)
921                  XDestroyIC(g_IC);                  XDestroyIC(g_IC);
922    
# Line 833  xwin_process_events(void) Line 1022  xwin_process_events(void)
1022                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
1023                                          break;                                          break;
1024    
1025                                  save_remote_modifiers();                                  save_remote_modifiers(tr.scancode);
1026                                  ensure_remote_modifiers(ev_time, tr);                                  ensure_remote_modifiers(ev_time, tr);
1027                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
1028                                  restore_remote_modifiers();                                  restore_remote_modifiers(ev_time, tr.scancode);
1029    
1030                                  break;                                  break;
1031    
# Line 1029  int Line 1218  int
1218  ui_select(int rdp_socket)  ui_select(int rdp_socket)
1219  {  {
1220          int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1;          int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1;
1221          fd_set rfds;          fd_set rfds, wfds;
   
         FD_ZERO(&rfds);  
1222    
1223          while (True)          while (True)
1224          {          {
# Line 1041  ui_select(int rdp_socket) Line 1228  ui_select(int rdp_socket)
1228                          return 0;                          return 0;
1229    
1230                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
1231                    FD_ZERO(&wfds);
1232                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
1233                  FD_SET(g_x_socket, &rfds);                  FD_SET(g_x_socket, &rfds);
1234    
1235                  switch (select(n, &rfds, NULL, NULL, NULL))  #ifdef WITH_RDPSND
1236                    /* FIXME: there should be an API for registering fds */
1237                    if (g_dsp_busy)
1238                    {
1239                            FD_SET(g_dsp_fd, &wfds);
1240                            n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1241                    }
1242    #endif
1243    
1244                    switch (select(n, &rfds, &wfds, NULL, NULL))
1245                  {                  {
1246                          case -1:                          case -1:
1247                                  error("select: %s\n", strerror(errno));                                  error("select: %s\n", strerror(errno));
# Line 1055  ui_select(int rdp_socket) Line 1252  ui_select(int rdp_socket)
1252    
1253                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
1254                          return 1;                          return 1;
1255    
1256    #ifdef WITH_RDPSND
1257                    if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1258                            wave_out_play();
1259    #endif
1260          }          }
1261  }  }
1262    
# Line 1070  ui_create_bitmap(int width, int height, Line 1272  ui_create_bitmap(int width, int height,
1272          XImage *image;          XImage *image;
1273          Pixmap bitmap;          Pixmap bitmap;
1274          uint8 *tdata;          uint8 *tdata;
1275            int bitmap_pad;
1276    
1277            if (g_server_bpp == 8)
1278            {
1279                    bitmap_pad = 8;
1280            }
1281            else
1282            {
1283                    bitmap_pad = g_bpp;
1284    
1285                    if (g_bpp == 24)
1286                            bitmap_pad = 32;
1287            }
1288    
1289          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1290          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);
1291          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1292                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1293    
1294          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);
1295    
# Line 1089  ui_paint_bitmap(int x, int y, int cx, in Line 1304  ui_paint_bitmap(int x, int y, int cx, in
1304  {  {
1305          XImage *image;          XImage *image;
1306          uint8 *tdata;          uint8 *tdata;
1307            int bitmap_pad;
1308    
1309            if (g_server_bpp == 8)
1310            {
1311                    bitmap_pad = 8;
1312            }
1313            else
1314            {
1315                    bitmap_pad = g_bpp;
1316    
1317                    if (g_bpp == 24)
1318                            bitmap_pad = 32;
1319            }
1320    
1321          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1322          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1323                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1324    
1325          if (g_ownbackstore)          if (g_ownbackstore)
1326          {          {
# Line 1230  ui_destroy_cursor(HCURSOR cursor) Line 1459  ui_destroy_cursor(HCURSOR cursor)
1459          XFreeCursor(g_display, (Cursor) cursor);          XFreeCursor(g_display, (Cursor) cursor);
1460  }  }
1461    
1462    void
1463    ui_set_null_cursor(void)
1464    {
1465            ui_set_cursor(g_null_cursor);
1466    }
1467    
1468  #define MAKE_XCOLOR(xc,c) \  #define MAKE_XCOLOR(xc,c) \
1469                  (xc)->red   = ((c)->red   << 8) | (c)->red; \                  (xc)->red   = ((c)->red   << 8) | (c)->red; \
1470                  (xc)->green = ((c)->green << 8) | (c)->green; \                  (xc)->green = ((c)->green << 8) | (c)->green; \
# Line 1311  ui_create_colourmap(COLOURMAP * colours) Line 1546  ui_create_colourmap(COLOURMAP * colours)
1546    
1547                          }                          }
1548    
1549                            map[i] = colour;
                         /* byte swap here to make translate_image faster */  
                         map[i] = translate_colour(colour);  
1550                  }                  }
1551                  return map;                  return map;
1552          }          }
# Line 1430  ui_patblt(uint8 opcode, Line 1663  ui_patblt(uint8 opcode,
1663                  case 2: /* Hatch */                  case 2: /* Hatch */
1664                          fill = (Pixmap) ui_create_glyph(8, 8,                          fill = (Pixmap) ui_create_glyph(8, 8,
1665                                                          hatch_patterns + brush->pattern[0] * 8);                                                          hatch_patterns + brush->pattern[0] * 8);
1666                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(fgcolour);
1667                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(bgcolour);
1668                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1669                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1670                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);

Legend:
Removed from v.456  
changed lines
  Added in v.528

  ViewVC Help
Powered by ViewVC 1.1.26