/[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 644 by jsorg71, Thu Mar 25 22:58:45 2004 UTC revision 753 by stargo, Mon Aug 23 11:13:50 2004 UTC
# Line 43  Time g_last_gesturetime; Line 43  Time g_last_gesturetime;
43  static int g_x_socket;  static int g_x_socket;
44  static Screen *g_screen;  static Screen *g_screen;
45  Window g_wnd;  Window g_wnd;
46  uint32 g_embed_wnd;  extern uint32 g_embed_wnd;
47  BOOL g_enable_compose = False;  BOOL g_enable_compose = False;
48    BOOL g_Unobscured;              /* used for screenblt */
49  static GC g_gc = NULL;  static GC g_gc = NULL;
50    static GC g_create_bitmap_gc = NULL;
51    static GC g_create_glyph_gc = NULL;
52  static Visual *g_visual;  static Visual *g_visual;
53  static int g_depth;  static int g_depth;
54  static int g_bpp;  static int g_bpp;
# Line 57  static HCURSOR g_null_cursor = NULL; Line 60  static HCURSOR g_null_cursor = NULL;
60  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
61  static BOOL g_focused;  static BOOL g_focused;
62  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
63  static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */  static BOOL g_arch_match = False;       /* set to True if RGB XServer and little endian */
64    
65  /* endianness */  /* endianness */
66  static BOOL g_host_be;  static BOOL g_host_be;
# Line 66  static int g_red_shift_r, g_blue_shift_r Line 69  static int g_red_shift_r, g_blue_shift_r
69  static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;  static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;
70    
71  /* software backing store */  /* software backing store */
72  BOOL g_ownbackstore = True;     /* We can't rely on external BackingStore */  extern BOOL g_ownbackstore;
73  static Pixmap g_backstore = 0;  static Pixmap g_backstore = 0;
74    
75  /* Moving in single app mode */  /* Moving in single app mode */
# Line 115  PixelColour; Line 118  PixelColour;
118  }  }
119    
120  /* colour maps */  /* colour maps */
121  BOOL g_owncolmap = False;  extern BOOL g_owncolmap;
122  static Colormap g_xcolmap;  static Colormap g_xcolmap;
123  static uint32 *g_colmap = NULL;  static uint32 *g_colmap = NULL;
124    
# Line 171  static PixelColour Line 174  static PixelColour
174  split_colour15(uint32 colour)  split_colour15(uint32 colour)
175  {  {
176          PixelColour rv;          PixelColour rv;
177          rv.red = (colour & 0x7c00) >> 7;          rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7);
178          rv.green = (colour & 0x03e0) >> 2;          rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7);
179          rv.blue = (colour & 0x001f) << 3;          rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
180          return rv;          return rv;
181  }  }
182    
# Line 181  static PixelColour Line 184  static PixelColour
184  split_colour16(uint32 colour)  split_colour16(uint32 colour)
185  {  {
186          PixelColour rv;          PixelColour rv;
187          rv.red = (colour & 0xf800) >> 8;          rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7);
188          rv.green = (colour & 0x07e0) >> 3;          rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3);
189          rv.blue = (colour & 0x001f) << 3;          rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
190          return rv;          return rv;
191  }  }
192    
# Line 229  translate_colour(uint32 colour) Line 232  translate_colour(uint32 colour)
232          return make_colour(pc);          return make_colour(pc);
233  }  }
234    
235    /* indent is confused by UNROLL8 */
236    /* *INDENT-OFF* */
237    
238    /* repeat and unroll, similar to bitmap.c */
239    /* potentialy any of the following translate */
240    /* functions can use repeat but just doing */
241    /* the most common ones */
242    
243    #define UNROLL8(stm) { stm stm stm stm stm stm stm stm }
244    /* 2 byte output repeat */
245    #define REPEAT2(stm) \
246    { \
247            while (out <= end - 8 * 2) \
248                    UNROLL8(stm) \
249            while (out < end) \
250                    { stm } \
251    }
252    /* 4 byte output repeat */
253    #define REPEAT4(stm) \
254    { \
255            while (out <= end - 8 * 4) \
256                    UNROLL8(stm) \
257            while (out < end) \
258                    { stm } \
259    }
260    
261  static void  static void
262  translate8to8(uint8 * data, uint8 * out, uint8 * end)  translate8to8(uint8 * data, uint8 * out, uint8 * end)
263  {  {
# Line 241  translate8to16(uint8 * data, uint8 * out Line 270  translate8to16(uint8 * data, uint8 * out
270  {  {
271          uint16 value;          uint16 value;
272    
273          if (g_xserver_be)          if (g_arch_match)
274            {
275                    REPEAT2
276                    (
277                            *((uint16 *) out) = g_colmap[*(data++)];
278                            out += 2;
279                    )
280            }
281            else if (g_xserver_be)
282          {          {
283                  while (out < end)                  while (out < end)
284                  {                  {
# Line 294  translate8to32(uint8 * data, uint8 * out Line 331  translate8to32(uint8 * data, uint8 * out
331  {  {
332          uint32 value;          uint32 value;
333    
334          if (g_xserver_be)          if (g_arch_match)
335            {
336                    REPEAT4
337                    (
338                            *((uint32 *) out) = g_colmap[*(data++)];
339                            out += 4;
340                    )
341            }
342            else if (g_xserver_be)
343          {          {
344                  while (out < end)                  while (out < end)
345                  {                  {
# Line 318  translate8to32(uint8 * data, uint8 * out Line 363  translate8to32(uint8 * data, uint8 * out
363          }          }
364  }  }
365    
366    /* *INDENT-ON* */
367    
368  static void  static void
369  translate15to16(uint16 * data, uint8 * out, uint8 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
370  {  {
# Line 605  translate_image(int width, int height, u Line 652  translate_image(int width, int height, u
652          /* if server and xserver bpp match, */          /* if server and xserver bpp match, */
653          /* and arch(endian) matches, no need to translate */          /* and arch(endian) matches, no need to translate */
654          /* just return data */          /* just return data */
655          if (g_depth > 8)          if (g_arch_match)
656                  if (g_arch_match)          {
657                          if (g_depth == g_server_bpp)                  if (g_depth == 15 && g_server_bpp == 15)
658                                  return data;                          return data;
659                    if (g_depth == 16 && g_server_bpp == 16)
660                            return data;
661            }
662    
663          size = width * height * (g_bpp / 8);          size = width * height * (g_bpp / 8);
664          out = (uint8 *) xmalloc(size);          out = (uint8 *) xmalloc(size);
# Line 921  ui_create_window(void) Line 971  ui_create_window(void)
971          if (g_gc == NULL)          if (g_gc == NULL)
972                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);                  g_gc = XCreateGC(g_display, g_wnd, 0, NULL);
973    
974            if (g_create_bitmap_gc == NULL)
975                    g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL);
976    
977          if ((g_ownbackstore) && (g_backstore == 0))          if ((g_ownbackstore) && (g_backstore == 0))
978          {          {
979                  g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);                  g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
# Line 953  ui_create_window(void) Line 1006  ui_create_window(void)
1006                  XFree(sizehints);                  XFree(sizehints);
1007          }          }
1008    
1009          if ( g_embed_wnd )          if (g_embed_wnd)
1010          {          {
1011                  XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0);                  XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0);
1012          }          }
1013    
1014          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
1015                  VisibilityChangeMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
# Line 989  ui_create_window(void) Line 1042  ui_create_window(void)
1042                  XMaskEvent(g_display, VisibilityChangeMask, &xevent);                  XMaskEvent(g_display, VisibilityChangeMask, &xevent);
1043          }          }
1044          while (xevent.type != VisibilityNotify);          while (xevent.type != VisibilityNotify);
1045            g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;
1046    
1047          g_focused = False;          g_focused = False;
1048          g_mouse_in_wnd = False;          g_mouse_in_wnd = False;
# Line 1006  ui_create_window(void) Line 1060  ui_create_window(void)
1060  }  }
1061    
1062  void  void
1063    ui_resize_window()
1064    {
1065            XSizeHints *sizehints;
1066            Pixmap bs;
1067    
1068            sizehints = XAllocSizeHints();
1069            if (sizehints)
1070            {
1071                    sizehints->flags = PMinSize | PMaxSize;
1072                    sizehints->min_width = sizehints->max_width = g_width;
1073                    sizehints->min_height = sizehints->max_height = g_height;
1074                    XSetWMNormalHints(g_display, g_wnd, sizehints);
1075                    XFree(sizehints);
1076            }
1077    
1078            if (!(g_fullscreen || g_embed_wnd))
1079            {
1080                    XResizeWindow(g_display, g_wnd, g_width, g_height);
1081            }
1082    
1083            /* create new backstore pixmap */
1084            if (g_backstore != 0)
1085            {
1086                    bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
1087                    XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
1088                    XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height);
1089                    XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0);
1090                    XFreePixmap(g_display, g_backstore);
1091                    g_backstore = bs;
1092            }
1093    }
1094    
1095    void
1096  ui_destroy_window(void)  ui_destroy_window(void)
1097  {  {
1098          if (g_IC != NULL)          if (g_IC != NULL)
# Line 1066  xwin_process_events(void) Line 1153  xwin_process_events(void)
1153    
1154                  switch (xevent.type)                  switch (xevent.type)
1155                  {                  {
1156                            case VisibilityNotify:
1157                                    g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;
1158                                    break;
1159                          case ClientMessage:                          case ClientMessage:
1160                                  /* the window manager told us to quit */                                  /* the window manager told us to quit */
1161                                  if ((xevent.xclient.message_type == g_protocol_atom)                                  if ((xevent.xclient.message_type == g_protocol_atom)
# Line 1355  ui_select(int rdp_socket) Line 1445  ui_select(int rdp_socket)
1445    
1446                  rdpdr_check_fds(&rfds, &wfds, (BOOL) False);                  rdpdr_check_fds(&rfds, &wfds, (BOOL) False);
1447    
                 if (FD_ISSET(rdp_socket, &rfds))  
                         return 1;  
   
1448  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
1449                  if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))                  if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1450                          wave_out_play();                          wave_out_play();
1451  #endif  #endif
1452    
1453                    if (FD_ISSET(rdp_socket, &rfds))
1454                            return 1;
1455          }          }
1456  }  }
1457    
# Line 1396  ui_create_bitmap(int width, int height, Line 1486  ui_create_bitmap(int width, int height,
1486          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1487                               (char *) tdata, width, height, bitmap_pad, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1488    
1489          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_create_bitmap_gc, image, 0, 0, 0, 0, width, height);
1490    
1491          XFree(image);          XFree(image);
1492          if (tdata != data)          if (tdata != data)
# Line 1454  ui_create_glyph(int width, int height, u Line 1544  ui_create_glyph(int width, int height, u
1544          XImage *image;          XImage *image;
1545          Pixmap bitmap;          Pixmap bitmap;
1546          int scanline;          int scanline;
         GC gc;  
1547    
1548          scanline = (width + 7) / 8;          scanline = (width + 7) / 8;
1549    
1550          bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1);          bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1);
1551          gc = XCreateGC(g_display, bitmap, 0, NULL);          if (g_create_glyph_gc == 0)
1552                    g_create_glyph_gc = XCreateGC(g_display, bitmap, 0, NULL);
1553    
1554          image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data,          image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data,
1555                               width, height, 8, scanline);                               width, height, 8, scanline);
# Line 1467  ui_create_glyph(int width, int height, u Line 1557  ui_create_glyph(int width, int height, u
1557          image->bitmap_bit_order = MSBFirst;          image->bitmap_bit_order = MSBFirst;
1558          XInitImage(image);          XInitImage(image);
1559    
1560          XPutImage(g_display, bitmap, gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height);
1561    
1562          XFree(image);          XFree(image);
         XFreeGC(g_display, gc);  
1563          return (HGLYPH) bitmap;          return (HGLYPH) bitmap;
1564  }  }
1565    
# Line 1762  ui_patblt(uint8 opcode, Line 1851  ui_patblt(uint8 opcode,
1851          {          {
1852                  case 0: /* Solid */                  case 0: /* Solid */
1853                          SET_FOREGROUND(fgcolour);                          SET_FOREGROUND(fgcolour);
1854                          FILL_RECTANGLE(x, y, cx, cy);                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
1855                          break;                          break;
1856    
1857                  case 2: /* Hatch */                  case 2: /* Hatch */
# Line 1773  ui_patblt(uint8 opcode, Line 1862  ui_patblt(uint8 opcode,
1862                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1863                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1864                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
1865                          FILL_RECTANGLE(x, y, cx, cy);                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
1866                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
1867                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
1868                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((HGLYPH) fill);
# Line 1783  ui_patblt(uint8 opcode, Line 1872  ui_patblt(uint8 opcode,
1872                          for (i = 0; i != 8; i++)                          for (i = 0; i != 8; i++)
1873                                  ipattern[7 - i] = brush->pattern[i];                                  ipattern[7 - i] = brush->pattern[i];
1874                          fill = (Pixmap) ui_create_glyph(8, 8, ipattern);                          fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
   
1875                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(bgcolour);
1876                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(fgcolour);
1877                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1878                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1879                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
1880                            FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
                         FILL_RECTANGLE(x, y, cx, cy);  
   
1881                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
1882                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
1883                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((HGLYPH) fill);
# Line 1802  ui_patblt(uint8 opcode, Line 1888  ui_patblt(uint8 opcode,
1888          }          }
1889    
1890          RESET_FUNCTION(opcode);          RESET_FUNCTION(opcode);
1891    
1892            if (g_ownbackstore)
1893                    XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y);
1894  }  }
1895    
1896  void  void
# Line 1812  ui_screenblt(uint8 opcode, Line 1901  ui_screenblt(uint8 opcode,
1901          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
1902          if (g_ownbackstore)          if (g_ownbackstore)
1903          {          {
1904                  XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);                  if (g_Unobscured)
1905                  XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x, y);                  {
1906                            XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
1907                            XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x,
1908                                      y);
1909                    }
1910                    else
1911                    {
1912                            XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
1913                            XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x,
1914                                      y);
1915                    }
1916          }          }
1917          else          else
1918          {          {
# Line 2088  ui_desktop_restore(uint32 offset, int x, Line 2187  ui_desktop_restore(uint32 offset, int x,
2187    
2188          XFree(image);          XFree(image);
2189  }  }
2190    
2191    /* these do nothing here but are used in uiports */
2192    void
2193    ui_begin_update(void)
2194    {
2195    }
2196    
2197    void
2198    ui_end_update(void)
2199    {
2200    }

Legend:
Removed from v.644  
changed lines
  Added in v.753

  ViewVC Help
Powered by ViewVC 1.1.26