/[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 499 by astrand, Wed Oct 15 14:01:32 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                    value = make_colour16(split_colour15(pixel));
339    
340                    if (g_xserver_be)
341                    {
342                            *(out++) = value >> 8;
343                            *(out++) = value;
344                    }
345                    else
346                    {
347                            *(out++) = value;
348                            *(out++) = value >> 8;
349                    }
350            }
351  }  }
352    
353  static void  static void
354  translate15to24(uint16 * data, uint8 * out, uint8 * end)  translate15to24(uint16 * data, uint8 * out, uint8 * end)
355  {  {
356          uint32 value;          uint32 value;
357            uint16 pixel;
358    
359          while (out < end)          while (out < end)
360          {          {
361                  value = make_colour24(split_colour15(*(data++)));                  pixel = *(data++);
362                  *(out++) = value;  
363                  *(out++) = value >> 8;                  if (g_host_be)
364                  *(out++) = value >> 16;                  {
365                    BSWAP16(pixel)}
366    
367                    value = make_colour24(split_colour15(pixel));
368                    if (g_xserver_be)
369                    {
370                            *(out++) = value >> 16;
371                            *(out++) = value >> 8;
372                            *(out++) = value;
373                    }
374                    else
375                    {
376                            *(out++) = value;
377                            *(out++) = value >> 8;
378                            *(out++) = value >> 16;
379                    }
380          }          }
381  }  }
382    
383  static void  static void
384  translate15to32(uint16 * data, uint32 * out, uint32 * end)  translate15to32(uint16 * data, uint8 * out, uint8 * end)
385  {  {
386            uint16 pixel;
387            uint32 value;
388    
389          while (out < end)          while (out < end)
390                  *(out++) = make_colour32(split_colour15(*(data++)));          {
391                    pixel = *(data++);
392    
393                    if (g_host_be)
394                    {
395                            BSWAP16(pixel);
396                    }
397    
398                    value = make_colour32(split_colour15(pixel));
399    
400                    if (g_xserver_be)
401                    {
402                            *(out++) = value >> 24;
403                            *(out++) = value >> 16;
404                            *(out++) = value >> 8;
405                            *(out++) = value;
406                    }
407                    else
408                    {
409                            *(out++) = value;
410                            *(out++) = value >> 8;
411                            *(out++) = value >> 16;
412                            *(out++) = value >> 24;
413                    }
414            }
415  }  }
416    
417  static void  static void
418  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate16to16(uint16 * data, uint16 * out, uint16 * end)
419  {  {
420          while (out < end)          uint16 value;
421                  *(out++) = (uint16) (*(data++));  
422            if (g_xserver_be)
423            {
424                    while (out < end)
425                    {
426                            value = *data;
427                            BSWAP16(value);
428                            *out = value;
429                            data++;
430                            out++;
431                    }
432    
433            }
434            else
435            {
436                    while (out < end)
437                    {
438                            *out = *data;
439                            out++;
440                            data++;
441                    }
442            }
443  }  }
444    
445    
# Line 360  static void Line 447  static void
447  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
448  {  {
449          uint32 value;          uint32 value;
450            uint16 pixel;
451    
452          while (out < end)          while (out < end)
453          {          {
454                  value = make_colour24(split_colour16(*(data++)));                  pixel = *(data++);
455                  *(out++) = value;  
456                  *(out++) = value >> 8;                  if (g_host_be)
457                  *(out++) = value >> 16;                  {
458                    BSWAP16(pixel)}
459    
460                    value = make_colour24(split_colour16(pixel));
461    
462                    if (g_xserver_be)
463                    {
464                            *(out++) = value >> 16;
465                            *(out++) = value >> 8;
466                            *(out++) = value;
467                    }
468                    else
469                    {
470                            *(out++) = value;
471                            *(out++) = value >> 8;
472                            *(out++) = value >> 16;
473                    }
474          }          }
475  }  }
476    
477  static void  static void
478  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint8 * out, uint8 * end)
479  {  {
480            uint16 pixel;
481            uint32 value;
482    
483          while (out < end)          while (out < end)
484                  *(out++) = make_colour32(split_colour16(*(data++)));          {
485                    pixel = *(data++);
486    
487                    if (g_host_be)
488                    {
489                    BSWAP16(pixel)}
490    
491                    value = make_colour32(split_colour16(pixel));
492    
493                    if (g_xserver_be)
494                    {
495                            *(out++) = value >> 24;
496                            *(out++) = value >> 16;
497                            *(out++) = value >> 8;
498                            *(out++) = value;
499                    }
500                    else
501                    {
502                            *(out++) = value;
503                            *(out++) = value >> 8;
504                            *(out++) = value >> 16;
505                            *(out++) = value >> 24;
506                    }
507            }
508  }  }
509    
510  static void  static void
511  translate24to16(uint8 * data, uint16 * out, uint16 * end)  translate24to16(uint8 * data, uint8 * out, uint8 * end)
512  {  {
513          uint32 pixel = 0;          uint32 pixel = 0;
514            uint16 value;
515          while (out < end)          while (out < end)
516          {          {
517                  pixel = *(data++) << 16;                  pixel = *(data++) << 16;
518                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
519                  pixel |= *(data++);                  pixel |= *(data++);
520                  *(out++) = (uint16) make_colour16(split_colour24(pixel));  
521                    value = (uint16) make_colour16(split_colour24(pixel));
522    
523                    if (g_xserver_be)
524                    {
525                            *(out++) = value >> 8;
526                            *(out++) = value;
527                    }
528                    else
529                    {
530                            *(out++) = value;
531                            *(out++) = value >> 8;
532                    }
533          }          }
534  }  }
535    
# Line 400  translate24to24(uint8 * data, uint8 * ou Line 543  translate24to24(uint8 * data, uint8 * ou
543  }  }
544    
545  static void  static void
546  translate24to32(uint8 * data, uint32 * out, uint32 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
547  {  {
         uint32 pixel = 0;  
548          while (out < end)          while (out < end)
549          {          {
550                  pixel = *(data++);                  if (g_xserver_be)
551                  pixel |= *(data++) << 8;                  {
552                  pixel |= *(data++) << 16;                          *(out++) = 0x00;
553                  *(out++) = pixel;                          *(out++) = *(data++);
554                            *(out++) = *(data++);
555                            *(out++) = *(data++);
556                    }
557                    else
558                    {
559                            *(out++) = *(data++);
560                            *(out++) = *(data++);
561                            *(out++) = *(data++);
562                            *(out++) = 0x00;
563                    }
564          }          }
565  }  }
566    
# Line 425  translate_image(int width, int height, u Line 577  translate_image(int width, int height, u
577                          switch (g_bpp)                          switch (g_bpp)
578                          {                          {
579                                  case 32:                                  case 32:
580                                          translate24to32(data, (uint32 *) out, (uint32 *) end);                                          translate24to32(data, out, end);
581                                          break;                                          break;
582                                  case 24:                                  case 24:
583                                          translate24to24(data, out, end);                                          translate24to24(data, out, end);
584                                          break;                                          break;
585                                  case 16:                                  case 16:
586                                          translate24to16(data, (uint16 *) out, (uint16 *) end);                                          translate24to16(data, out, end);
587                                          break;                                          break;
588                          }                          }
589                          break;                          break;
# Line 439  translate_image(int width, int height, u Line 591  translate_image(int width, int height, u
591                          switch (g_bpp)                          switch (g_bpp)
592                          {                          {
593                                  case 32:                                  case 32:
594                                          translate16to32((uint16 *) data, (uint32 *) out,                                          translate16to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
595                                          break;                                          break;
596                                  case 24:                                  case 24:
597                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
# Line 455  translate_image(int width, int height, u Line 606  translate_image(int width, int height, u
606                          switch (g_bpp)                          switch (g_bpp)
607                          {                          {
608                                  case 32:                                  case 32:
609                                          translate15to32((uint16 *) data, (uint32 *) out,                                          translate15to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
610                                          break;                                          break;
611                                  case 24:                                  case 24:
612                                          translate15to24((uint16 *) data, out, end);                                          translate15to24((uint16 *) data, out, end);
613                                          break;                                          break;
614                                  case 16:                                  case 16:
615                                          translate15to16((uint16 *) data, (uint16 *) out,                                          translate15to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
616                                          break;                                          break;
617                          }                          }
618                          break;                          break;
# Line 610  ui_init(void) Line 759  ui_init(void)
759    
760          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
761    
762            xkeymap_init();
763    
764          if (g_enable_compose)          if (g_enable_compose)
765                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);
766    
         xkeymap_init();  
767          xclip_init();          xclip_init();
768    
769          /* todo take this out when high colour is done */          /* todo take this out when high colour is done */
# Line 833  xwin_process_events(void) Line 983  xwin_process_events(void)
983                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
984                                          break;                                          break;
985    
986                                  save_remote_modifiers();                                  save_remote_modifiers(tr.scancode);
987                                  ensure_remote_modifiers(ev_time, tr);                                  ensure_remote_modifiers(ev_time, tr);
988                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
989                                  restore_remote_modifiers(ev_time);                                  restore_remote_modifiers(ev_time, tr.scancode);
990    
991                                  break;                                  break;
992    
# Line 1029  int Line 1179  int
1179  ui_select(int rdp_socket)  ui_select(int rdp_socket)
1180  {  {
1181          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;
1182          fd_set rfds;          fd_set rfds, wfds;
   
         FD_ZERO(&rfds);  
1183    
1184          while (True)          while (True)
1185          {          {
# Line 1041  ui_select(int rdp_socket) Line 1189  ui_select(int rdp_socket)
1189                          return 0;                          return 0;
1190    
1191                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
1192                    FD_ZERO(&wfds);
1193                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
1194                  FD_SET(g_x_socket, &rfds);                  FD_SET(g_x_socket, &rfds);
1195    
1196                  switch (select(n, &rfds, NULL, NULL, NULL))  #ifdef WITH_RDPSND
1197                    /* FIXME: there should be an API for registering fds */
1198                    if (g_dsp_busy)
1199                    {
1200                            FD_SET(g_dsp_fd, &wfds);
1201                            n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1202                    }
1203    #endif
1204    
1205                    switch (select(n, &rfds, &wfds, NULL, NULL))
1206                  {                  {
1207                          case -1:                          case -1:
1208                                  error("select: %s\n", strerror(errno));                                  error("select: %s\n", strerror(errno));
# Line 1055  ui_select(int rdp_socket) Line 1213  ui_select(int rdp_socket)
1213    
1214                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
1215                          return 1;                          return 1;
1216    
1217    #ifdef WITH_RDPSND
1218                    if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1219                            wave_out_play();
1220    #endif
1221          }          }
1222  }  }
1223    
# Line 1430  ui_patblt(uint8 opcode, Line 1593  ui_patblt(uint8 opcode,
1593                  case 2: /* Hatch */                  case 2: /* Hatch */
1594                          fill = (Pixmap) ui_create_glyph(8, 8,                          fill = (Pixmap) ui_create_glyph(8, 8,
1595                                                          hatch_patterns + brush->pattern[0] * 8);                                                          hatch_patterns + brush->pattern[0] * 8);
1596                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(fgcolour);
1597                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(bgcolour);
1598                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1599                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1600                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);

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

  ViewVC Help
Powered by ViewVC 1.1.26