/[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 461 by astrand, Tue Sep 2 09:40:07 2003 UTC revision 483 by jsorg71, Sat Oct 11 19:12:10 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 52  static XIC g_IC; Line 50  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 Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
53    static BOOL g_focused;
54    static BOOL g_mouse_in_wnd;
55    
56  /* endianness */  /* endianness */
57  static BOOL g_host_be;  static BOOL g_host_be;
# Line 66  static BOOL g_moving_wnd; Line 66  static BOOL g_moving_wnd;
66  static int g_move_x_offset = 0;  static int g_move_x_offset = 0;
67  static int g_move_y_offset = 0;  static int g_move_y_offset = 0;
68    
69    #ifdef WITH_RDPSND
70    extern int g_dsp_fd;
71    extern BOOL g_dsp_busy;
72    #endif
73    
74  /* MWM decorations */  /* MWM decorations */
75  #define MWM_HINTS_DECORATIONS   (1L << 1)  #define MWM_HINTS_DECORATIONS   (1L << 1)
76  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
# Line 201  make_colour16(PixelColour pc) Line 206  make_colour16(PixelColour pc)
206  static uint32  static uint32
207  make_colour24(PixelColour pc)  make_colour24(PixelColour pc)
208  {  {
209          return (pc.red << 16) | (pc.green << 8) | pc.blue;          if (g_xserver_be)
210            {
211                    return pc.red | (pc.green << 8) | (pc.blue << 16);
212            }
213            else
214            {
215                    return (pc.red << 16) | (pc.green << 8) | pc.blue;
216            }
217  }  }
218    
219  static uint32  static uint32
220  make_colour32(PixelColour pc)  make_colour32(PixelColour pc)
221  {  {
222          return (pc.red << 16) | (pc.green << 8) | pc.blue;          if (g_xserver_be)
223            {
224                    return pc.red | (pc.green << 8) | (pc.blue << 16);
225            }
226            else
227            {
228                    return (pc.red << 16) | (pc.green << 8) | pc.blue;
229            }
230  }  }
231    
232  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
# Line 261  translate_colour(uint32 colour) Line 280  translate_colour(uint32 colour)
280                          }                          }
281                          break;                          break;
282          }          }
         switch (g_bpp)  
         {  
                 case 16:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP16(colour);  
                         break;  
   
                 case 24:  
                         if (g_xserver_be)  
                                 BSWAP24(colour);  
                         break;  
   
                 case 32:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP32(colour);  
                         break;  
         }  
   
283          return colour;          return colour;
284  }  }
285    
# Line 321  translate8to32(uint8 * data, uint32 * ou Line 322  translate8to32(uint8 * data, uint32 * ou
322  /* todo the remaining translate function might need some big endian check ?? */  /* todo the remaining translate function might need some big endian check ?? */
323    
324  static void  static void
325  translate15to16(uint16 * data, uint16 * out, uint16 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
326  {  {
327            uint16 pixel;
328            uint16 value;
329    
330          while (out < end)          while (out < end)
331                  *(out++) = (uint16) make_colour16(split_colour15(*(data++)));          {
332                    pixel = *(data++);
333    
334                    if (g_host_be)
335                    {
336                            BSWAP16(pixel)
337                    }
338    
339                    value = make_colour16(split_colour15(pixel));
340    
341                    if (g_xserver_be)
342                    {
343                            *(out++) = value >> 8;
344                            *(out++) = value;
345                    }
346                    else
347                    {
348                            *(out++) = value;
349                            *(out++) = value >> 8;
350                    }
351            }
352  }  }
353    
354  static void  static void
355  translate15to24(uint16 * data, uint8 * out, uint8 * end)  translate15to24(uint16 * data, uint8 * out, uint8 * end)
356  {  {
357          uint32 value;          uint32 value;
358            uint16 pixel;
359    
360          while (out < end)          while (out < end)
361          {          {
362                  value = make_colour24(split_colour15(*(data++)));                  pixel = *(data++);
363                  *(out++) = value;  
364                  *(out++) = value >> 8;                  if (g_host_be)
365                  *(out++) = value >> 16;                  {
366                            BSWAP16(pixel)
367                    }
368    
369                    value = make_colour24(split_colour15(pixel));
370                    if (g_xserver_be)
371                    {
372                            *(out++) = value >> 16;
373                            *(out++) = value >> 8;
374                            *(out++) = value;
375                    }
376                    else
377                    {
378                            *(out++) = value;
379                            *(out++) = value >> 8;
380                            *(out++) = value >> 16;
381                    }
382          }          }
383  }  }
384    
385  static void  static void
386  translate15to32(uint16 * data, uint32 * out, uint32 * end)  translate15to32(uint16 * data, uint8 * out, uint8 * end)
387  {  {
388            uint16 pixel;
389            uint32 value;
390    
391          while (out < end)          while (out < end)
392                  *(out++) = make_colour32(split_colour15(*(data++)));          {
393                    pixel = *(data++);
394    
395                    if (g_host_be)
396                    {
397                            BSWAP16(pixel);
398                    }
399    
400                    value = make_colour32(split_colour15(pixel));
401    
402                    if (g_xserver_be)
403                    {
404                            *(out++) = value >> 24;
405                            *(out++) = value >> 16;
406                            *(out++) = value >> 8;
407                            *(out++) = value;
408                    }
409                    else
410                    {
411                            *(out++) = value;
412                            *(out++) = value >> 8;
413                            *(out++) = value >> 16;
414                            *(out++) = value >> 24;
415                    }
416            }
417  }  }
418    
419  static void  static void
420  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate16to16(uint16 * data, uint16 * out, uint16 * end)
421  {  {
422          while (out < end)          uint16 value;
423                  *(out++) = (uint16) (*(data++));  
424            if (g_xserver_be)
425            {
426                    while (out < end)
427                    {
428                            value = *data;
429                            BSWAP16(value);
430                            *out = value;
431                            data++;
432                            out++;
433                    }
434    
435            }
436            else
437            {
438                    while (out < end)
439                    {
440                            *out = *data;
441                            out++;
442                            data++;
443                    }
444            }
445  }  }
446    
447    
# Line 360  static void Line 449  static void
449  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
450  {  {
451          uint32 value;          uint32 value;
452            uint16 pixel;
453    
454          while (out < end)          while (out < end)
455          {          {
456                  value = make_colour24(split_colour16(*(data++)));                  pixel = *(data++);
457                  *(out++) = value;  
458                  *(out++) = value >> 8;                  if (g_host_be)
459                  *(out++) = value >> 16;                  {
460                            BSWAP16(pixel)
461                    }
462    
463                    value = make_colour24(split_colour16(pixel));
464    
465                    if (g_xserver_be)
466                    {
467                            *(out++) = value >> 16;
468                            *(out++) = value >> 8;
469                            *(out++) = value;
470                    }
471                    else
472                    {
473                            *(out++) = value;
474                            *(out++) = value >> 8;
475                            *(out++) = value >> 16;
476                    }
477          }          }
478  }  }
479    
480  static void  static void
481  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint8 * out, uint8 * end)
482  {  {
483            uint16 pixel;
484            uint32 value;
485    
486          while (out < end)          while (out < end)
487                  *(out++) = make_colour32(split_colour16(*(data++)));          {
488                    pixel = *(data++);
489    
490                    if (g_host_be)
491                    {
492                            BSWAP16(pixel)
493                    }
494    
495                    value = make_colour32(split_colour16(pixel));
496    
497                    if (g_xserver_be)
498                    {
499                            *(out++) = value >> 24;
500                            *(out++) = value >> 16;
501                            *(out++) = value >> 8;
502                            *(out++) = value;
503                    }
504                    else
505                    {
506                            *(out++) = value;
507                            *(out++) = value >> 8;
508                            *(out++) = value >> 16;
509                            *(out++) = value >> 24;
510                    }
511            }
512  }  }
513    
514  static void  static void
515  translate24to16(uint8 * data, uint16 * out, uint16 * end)  translate24to16(uint8 * data, uint8 * out, uint8 * end)
516  {  {
517          uint32 pixel = 0;          uint32 pixel = 0;
518            uint16 value;
519          while (out < end)          while (out < end)
520          {          {
521                  pixel = *(data++) << 16;                  pixel = *(data++) << 16;
522                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
523                  pixel |= *(data++);                  pixel |= *(data++);
524                  *(out++) = (uint16) make_colour16(split_colour24(pixel));  
525                    value = (uint16) make_colour16(split_colour24(pixel));
526    
527                    if (g_xserver_be)
528                    {
529                            *(out++) = value >> 8;
530                            *(out++) = value;
531                    }
532                    else
533                    {
534                            *(out++) = value;
535                            *(out++) = value >> 8;
536                    }
537          }          }
538  }  }
539    
# Line 400  translate24to24(uint8 * data, uint8 * ou Line 547  translate24to24(uint8 * data, uint8 * ou
547  }  }
548    
549  static void  static void
550  translate24to32(uint8 * data, uint32 * out, uint32 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
551  {  {
         uint32 pixel = 0;  
552          while (out < end)          while (out < end)
553          {          {
554                  pixel = *(data++);                  if (g_xserver_be)
555                  pixel |= *(data++) << 8;                  {
556                  pixel |= *(data++) << 16;                          *(out++) = 0x00;
557                  *(out++) = pixel;                          *(out++) = *(data++);
558                            *(out++) = *(data++);
559                            *(out++) = *(data++);
560                    }
561                    else
562                    {
563                            *(out++) = *(data++);
564                            *(out++) = *(data++);
565                            *(out++) = *(data++);
566                            *(out++) = 0x00;
567                    }
568          }          }
569  }  }
570    
# Line 425  translate_image(int width, int height, u Line 581  translate_image(int width, int height, u
581                          switch (g_bpp)                          switch (g_bpp)
582                          {                          {
583                                  case 32:                                  case 32:
584                                          translate24to32(data, (uint32 *) out, (uint32 *) end);                                          translate24to32(data, out, end);
585                                          break;                                          break;
586                                  case 24:                                  case 24:
587                                          translate24to24(data, out, end);                                          translate24to24(data, out, end);
588                                          break;                                          break;
589                                  case 16:                                  case 16:
590                                          translate24to16(data, (uint16 *) out, (uint16 *) end);                                          translate24to16(data, out, end);
591                                          break;                                          break;
592                          }                          }
593                          break;                          break;
# Line 439  translate_image(int width, int height, u Line 595  translate_image(int width, int height, u
595                          switch (g_bpp)                          switch (g_bpp)
596                          {                          {
597                                  case 32:                                  case 32:
598                                          translate16to32((uint16 *) data, (uint32 *) out,                                          translate16to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
599                                          break;                                          break;
600                                  case 24:                                  case 24:
601                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
# Line 455  translate_image(int width, int height, u Line 610  translate_image(int width, int height, u
610                          switch (g_bpp)                          switch (g_bpp)
611                          {                          {
612                                  case 32:                                  case 32:
613                                          translate15to32((uint16 *) data, (uint32 *) out,                                          translate15to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
614                                          break;                                          break;
615                                  case 24:                                  case 24:
616                                          translate15to24((uint16 *) data, out, end);                                          translate15to24((uint16 *) data, out, end);
617                                          break;                                          break;
618                                  case 16:                                  case 16:
619                                          translate15to16((uint16 *) data, (uint16 *) out,                                          translate15to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
620                                          break;                                          break;
621                          }                          }
622                          break;                          break;
# Line 833  xwin_process_events(void) Line 986  xwin_process_events(void)
986                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
987                                          break;                                          break;
988    
989                                  save_remote_modifiers();                                  save_remote_modifiers(tr.scancode);
990                                  ensure_remote_modifiers(ev_time, tr);                                  ensure_remote_modifiers(ev_time, tr);
991                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
992                                  restore_remote_modifiers(ev_time);                                  restore_remote_modifiers(ev_time, tr.scancode);
993    
994                                  break;                                  break;
995    
# Line 1029  int Line 1182  int
1182  ui_select(int rdp_socket)  ui_select(int rdp_socket)
1183  {  {
1184          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;
1185          fd_set rfds;          fd_set rfds, wfds;
   
         FD_ZERO(&rfds);  
1186    
1187          while (True)          while (True)
1188          {          {
# Line 1041  ui_select(int rdp_socket) Line 1192  ui_select(int rdp_socket)
1192                          return 0;                          return 0;
1193    
1194                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
1195                    FD_ZERO(&wfds);
1196                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
1197                  FD_SET(g_x_socket, &rfds);                  FD_SET(g_x_socket, &rfds);
1198    
1199                  switch (select(n, &rfds, NULL, NULL, NULL))  #ifdef WITH_RDPSND
1200                    /* FIXME: there should be an API for registering fds */
1201                    if (g_dsp_busy)
1202                    {
1203                            FD_SET(g_dsp_fd, &wfds);
1204                            n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1205                    }
1206    #endif
1207    
1208                    switch (select(n, &rfds, &wfds, NULL, NULL))
1209                  {                  {
1210                          case -1:                          case -1:
1211                                  error("select: %s\n", strerror(errno));                                  error("select: %s\n", strerror(errno));
# Line 1055  ui_select(int rdp_socket) Line 1216  ui_select(int rdp_socket)
1216    
1217                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
1218                          return 1;                          return 1;
1219    
1220    #ifdef WITH_RDPSND
1221                    if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1222                            wave_out_play();
1223    #endif
1224          }          }
1225  }  }
1226    

Legend:
Removed from v.461  
changed lines
  Added in v.483

  ViewVC Help
Powered by ViewVC 1.1.26