/[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 1214 by ossman_, Tue Mar 28 13:56:08 2006 UTC revision 1413 by ossman_, Mon Jun 18 12:00:34 2007 UTC
# Line 1  Line 1 
1  /* -*- c-basic-offset: 8 -*-  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X Window System     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2005     Copyright (C) Matthew Chapman 1999-2007
5       Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
6    
7     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 20  Line 21 
21    
22  #include <X11/Xlib.h>  #include <X11/Xlib.h>
23  #include <X11/Xutil.h>  #include <X11/Xutil.h>
24    #include <X11/Xproto.h>
25  #include <unistd.h>  #include <unistd.h>
26  #include <sys/time.h>  #include <sys/time.h>
27  #include <time.h>  #include <time.h>
# Line 28  Line 30 
30  #include "rdesktop.h"  #include "rdesktop.h"
31  #include "xproto.h"  #include "xproto.h"
32    
 /* We can't include Xproto.h because of conflicting defines for BOOL */  
 #define X_ConfigureWindow              12  
   
33  extern int g_width;  extern int g_width;
34  extern int g_height;  extern int g_height;
35  extern int g_xpos;  extern int g_xpos;
36  extern int g_ypos;  extern int g_ypos;
37  extern int g_pos;  extern int g_pos;
38  extern BOOL g_sendmotion;  extern RD_BOOL g_sendmotion;
39  extern BOOL g_fullscreen;  extern RD_BOOL g_fullscreen;
40  extern BOOL g_grab_keyboard;  extern RD_BOOL g_grab_keyboard;
41  extern BOOL g_hide_decorations;  extern RD_BOOL g_hide_decorations;
42  extern char g_title[];  extern char g_title[];
43  /* Color depth of the RDP session.  /* Color depth of the RDP session.
44     As of RDP 5.1, it may be 8, 15, 16 or 24. */     As of RDP 5.1, it may be 8, 15, 16 or 24. */
# Line 71  typedef struct _seamless_window Line 70  typedef struct _seamless_window
70          unsigned int desktop;          unsigned int desktop;
71          struct timeval *position_timer;          struct timeval *position_timer;
72    
73          BOOL outstanding_position;          RD_BOOL outstanding_position;
74          unsigned int outpos_serial;          unsigned int outpos_serial;
75          int outpos_xoffset, outpos_yoffset;          int outpos_xoffset, outpos_yoffset;
76          int outpos_width, outpos_height;          int outpos_width, outpos_height;
77    
78            unsigned int icon_size;
79            unsigned int icon_offset;
80            char icon_buffer[32 * 32 * 4];
81    
82          struct _seamless_window *next;          struct _seamless_window *next;
83  } seamless_window;  } seamless_window;
84  static seamless_window *g_seamless_windows = NULL;  static seamless_window *g_seamless_windows = NULL;
85  static unsigned long g_seamless_focused = 0;  static unsigned long g_seamless_focused = 0;
86  static BOOL g_seamless_started = False; /* Server end is up and running */  static RD_BOOL g_seamless_started = False;      /* Server end is up and running */
87  static BOOL g_seamless_active = False;  /* We are currently in seamless mode */  static RD_BOOL g_seamless_active = False;       /* We are currently in seamless mode */
88  static BOOL g_seamless_hidden = False;  /* Desktop is hidden on server */  static RD_BOOL g_seamless_hidden = False;       /* Desktop is hidden on server */
89  extern BOOL g_seamless_rdp;  extern RD_BOOL g_seamless_rdp;
90    
91  extern uint32 g_embed_wnd;  extern uint32 g_embed_wnd;
92  BOOL g_enable_compose = False;  RD_BOOL g_enable_compose = False;
93  BOOL g_Unobscured;              /* used for screenblt */  RD_BOOL g_Unobscured;           /* used for screenblt */
94  static GC g_gc = NULL;  static GC g_gc = NULL;
95  static GC g_create_bitmap_gc = NULL;  static GC g_create_bitmap_gc = NULL;
96  static GC g_create_glyph_gc = NULL;  static GC g_create_glyph_gc = NULL;
# Line 104  static int g_bpp; Line 107  static int g_bpp;
107  static XIM g_IM;  static XIM g_IM;
108  static XIC g_IC;  static XIC g_IC;
109  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
110    /* Maps logical (xmodmap -pp) pointing device buttons (0-based) back
111       to physical (1-based) indices. */
112    static unsigned char g_pointer_log_to_phys_map[16];
113  static Cursor g_current_cursor;  static Cursor g_current_cursor;
114  static HCURSOR g_null_cursor = NULL;  static RD_HCURSOR g_null_cursor = NULL;
115  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
116  extern Atom g_net_wm_state_atom;  extern Atom g_net_wm_state_atom;
117  extern Atom g_net_wm_desktop_atom;  extern Atom g_net_wm_desktop_atom;
118  static BOOL g_focused;  static RD_BOOL g_focused;
119  static BOOL g_mouse_in_wnd;  static RD_BOOL g_mouse_in_wnd;
120  /* Indicates that:  /* Indicates that:
121     1) visual has 15, 16 or 24 depth and the same color channel masks     1) visual has 15, 16 or 24 depth and the same color channel masks
122        as its RDP equivalent (implies X server is LE),        as its RDP equivalent (implies X server is LE),
123     2) host is LE     2) host is LE
124     This will trigger an optimization whose real value is questionable.     This will trigger an optimization whose real value is questionable.
125  */  */
126  static BOOL g_compatible_arch;  static RD_BOOL g_compatible_arch;
127  /* Indicates whether RDP's bitmaps and our XImages have the same  /* Indicates whether RDP's bitmaps and our XImages have the same
128     binary format. If so, we can avoid an expensive translation.     binary format. If so, we can avoid an expensive translation.
129     Note that this can be true when g_compatible_arch is false,     Note that this can be true when g_compatible_arch is false,
# Line 128  static BOOL g_compatible_arch; Line 134  static BOOL g_compatible_arch;
134     ('host' is the machine running rdesktop; the host simply memcpy's     ('host' is the machine running rdesktop; the host simply memcpy's
135      so its endianess doesn't matter)      so its endianess doesn't matter)
136   */   */
137  static BOOL g_no_translate_image = False;  static RD_BOOL g_no_translate_image = False;
138    
139  /* endianness */  /* endianness */
140  static BOOL g_host_be;  static RD_BOOL g_host_be;
141  static BOOL g_xserver_be;  static RD_BOOL g_xserver_be;
142  static int g_red_shift_r, g_blue_shift_r, g_green_shift_r;  static int g_red_shift_r, g_blue_shift_r, g_green_shift_r;
143  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;
144    
145  /* software backing store */  /* software backing store */
146  extern BOOL g_ownbackstore;  extern RD_BOOL g_ownbackstore;
147  static Pixmap g_backstore = 0;  static Pixmap g_backstore = 0;
148    
149  /* Moving in single app mode */  /* Moving in single app mode */
150  static BOOL g_moving_wnd;  static RD_BOOL g_moving_wnd;
151  static int g_move_x_offset = 0;  static int g_move_x_offset = 0;
152  static int g_move_y_offset = 0;  static int g_move_y_offset = 0;
153  static BOOL g_using_full_workarea = False;  static RD_BOOL g_using_full_workarea = False;
154    
155  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
156  extern int g_dsp_fd;  extern RD_BOOL g_rdpsnd;
 extern BOOL g_dsp_busy;  
 extern BOOL g_rdpsnd;  
157  #endif  #endif
158    
159  /* MWM decorations */  /* MWM decorations */
# Line 242  seamless_XDrawLines(Drawable d, XPoint * Line 246  seamless_XDrawLines(Drawable d, XPoint *
246                          break; \                          break; \
247                  case 1: /* Filled */ \                  case 1: /* Filled */ \
248                          XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \                          XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \
249                          ON_ALL_SEAMLESS_WINDOWS(XCopyArea, (g_display, g_ownbackstore ? g_backstore : g_wnd, sw->wnd, g_gc, \                          ON_ALL_SEAMLESS_WINDOWS(XFillArc, (g_display, sw->wnd, g_gc, x-sw->xoffset, y-sw->yoffset, cx, cy, 0, 360*64)); \
                                                             x, y, cx, cy, x-sw->xoffset, y-sw->yoffset)); \  
250                          if (g_ownbackstore) \                          if (g_ownbackstore) \
251                                  XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \                                  XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \
252                          break; \                          break; \
# Line 251  seamless_XDrawLines(Drawable d, XPoint * Line 254  seamless_XDrawLines(Drawable d, XPoint *
254  }  }
255    
256  /* colour maps */  /* colour maps */
257  extern BOOL g_owncolmap;  extern RD_BOOL g_owncolmap;
258  static Colormap g_xcolmap;  static Colormap g_xcolmap;
259  static uint32 *g_colmap = NULL;  static uint32 *g_colmap = NULL;
260    
# Line 475  sw_handle_restack(seamless_window * sw) Line 478  sw_handle_restack(seamless_window * sw)
478    
479    
480  static seamless_group *  static seamless_group *
481  sw_find_group(unsigned long id, BOOL dont_create)  sw_find_group(unsigned long id, RD_BOOL dont_create)
482  {  {
483          seamless_window *sw;          seamless_window *sw;
484          seamless_group *sg;          seamless_group *sg;
# Line 1265  translate_image(int width, int height, u Line 1268  translate_image(int width, int height, u
1268          return out;          return out;
1269  }  }
1270    
1271  BOOL  static void
1272    xwin_refresh_pointer_map(void)
1273    {
1274            unsigned char phys_to_log_map[sizeof(g_pointer_log_to_phys_map)];
1275            int i, pointer_buttons;
1276    
1277            pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map));
1278            for (i = 0; i < pointer_buttons; ++i)
1279            {
1280                    /* This might produce multiple logical buttons mapping
1281                       to a single physical one, but hey, that's
1282                       life... */
1283                    g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1;
1284            }
1285    }
1286    
1287    RD_BOOL
1288  get_key_state(unsigned int state, uint32 keysym)  get_key_state(unsigned int state, uint32 keysym)
1289  {  {
1290          int modifierpos, key, keysymMask = 0;          int modifierpos, key, keysymMask = 0;
# Line 1313  calculate_mask_weight(uint32 mask) Line 1332  calculate_mask_weight(uint32 mask)
1332          return weight;          return weight;
1333  }  }
1334    
1335  static BOOL  static RD_BOOL
1336  select_visual()  select_visual(int screen_num)
1337  {  {
1338          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
1339          int pixmap_formats_count, visuals_count;          int pixmap_formats_count, visuals_count;
# Line 1325  select_visual() Line 1344  select_visual()
1344    
1345          red_weight = blue_weight = green_weight = 0;          red_weight = blue_weight = green_weight = 0;
1346    
1347            if (g_server_depth == -1)
1348            {
1349                    g_server_depth = DisplayPlanes(g_display, DefaultScreen(g_display));
1350            }
1351    
1352          pfm = XListPixmapFormats(g_display, &pixmap_formats_count);          pfm = XListPixmapFormats(g_display, &pixmap_formats_count);
1353          if (pfm == NULL)          if (pfm == NULL)
1354          {          {
# Line 1335  select_visual() Line 1359  select_visual()
1359    
1360          /* Search for best TrueColor visual */          /* Search for best TrueColor visual */
1361          template.class = TrueColor;          template.class = TrueColor;
1362          vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count);          template.screen = screen_num;
1363            vmatches =
1364                    XGetVisualInfo(g_display, VisualClassMask | VisualScreenMask, &template,
1365                                   &visuals_count);
1366          g_visual = NULL;          g_visual = NULL;
1367          g_no_translate_image = False;          g_no_translate_image = False;
1368          g_compatible_arch = False;          g_compatible_arch = False;
# Line 1344  select_visual() Line 1371  select_visual()
1371                  for (i = 0; i < visuals_count; ++i)                  for (i = 0; i < visuals_count; ++i)
1372                  {                  {
1373                          XVisualInfo *visual_info = &vmatches[i];                          XVisualInfo *visual_info = &vmatches[i];
1374                            RD_BOOL can_translate_to_bpp = False;
1375                            int j;
1376    
1377                          /* Try to find a no-translation visual that'll                          /* Try to find a no-translation visual that'll
1378                             allow us to use RDP bitmaps directly as ZPixmaps. */                             allow us to use RDP bitmaps directly as ZPixmaps. */
# Line 1387  select_visual() Line 1416  select_visual()
1416    
1417                          /* Only care for visuals, for whose BPPs (not depths!)                          /* Only care for visuals, for whose BPPs (not depths!)
1418                             we have a translateXtoY function. */                             we have a translateXtoY function. */
                         BOOL can_translate_to_bpp = False;  
                         int j;  
1419                          for (j = 0; j < pixmap_formats_count; ++j)                          for (j = 0; j < pixmap_formats_count; ++j)
1420                          {                          {
1421                                  if (pfm[j].depth == visual_info->depth)                                  if (pfm[j].depth == visual_info->depth)
# Line 1516  error_handler(Display * dpy, XErrorEvent Line 1543  error_handler(Display * dpy, XErrorEvent
1543          return g_old_error_handler(dpy, eev);          return g_old_error_handler(dpy, eev);
1544  }  }
1545    
1546  BOOL  RD_BOOL
1547  ui_init(void)  ui_init(void)
1548  {  {
1549          int screen_num;          int screen_num;
# Line 1530  ui_init(void) Line 1557  ui_init(void)
1557    
1558          {          {
1559                  uint16 endianess_test = 1;                  uint16 endianess_test = 1;
1560                  g_host_be = !(BOOL) (*(uint8 *) (&endianess_test));                  g_host_be = !(RD_BOOL) (*(uint8 *) (&endianess_test));
1561          }          }
1562    
1563          g_old_error_handler = XSetErrorHandler(error_handler);          g_old_error_handler = XSetErrorHandler(error_handler);
# Line 1540  ui_init(void) Line 1567  ui_init(void)
1567          g_screen = ScreenOfDisplay(g_display, screen_num);          g_screen = ScreenOfDisplay(g_display, screen_num);
1568          g_depth = DefaultDepthOfScreen(g_screen);          g_depth = DefaultDepthOfScreen(g_screen);
1569    
1570          if (!select_visual())          if (!select_visual(screen_num))
1571                  return False;                  return False;
1572    
1573          if (g_no_translate_image)          if (g_no_translate_image)
# Line 1611  ui_init(void) Line 1638  ui_init(void)
1638          g_width = (g_width + 3) & ~3;          g_width = (g_width + 3) & ~3;
1639    
1640          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
1641            xwin_refresh_pointer_map();
1642    
1643          xkeymap_init();          xkeymap_init();
1644    
# Line 1682  get_input_mask(long *input_mask) Line 1710  get_input_mask(long *input_mask)
1710                  *input_mask |= LeaveWindowMask;                  *input_mask |= LeaveWindowMask;
1711  }  }
1712    
1713  BOOL  RD_BOOL
1714  ui_create_window(void)  ui_create_window(void)
1715  {  {
1716          uint8 null_pointer_mask[1] = { 0x80 };          uint8 null_pointer_mask[1] = { 0x80 };
# Line 1730  ui_create_window(void) Line 1758  ui_create_window(void)
1758          }          }
1759    
1760          XStoreName(g_display, g_wnd, g_title);          XStoreName(g_display, g_wnd, g_title);
1761            ewmh_set_wm_name(g_wnd, g_title);
1762    
1763          if (g_hide_decorations)          if (g_hide_decorations)
1764                  mwm_hide_decorations(g_wnd);                  mwm_hide_decorations(g_wnd);
# Line 1869  xwin_toggle_fullscreen(void) Line 1898  xwin_toggle_fullscreen(void)
1898  }  }
1899    
1900  static void  static void
1901  handle_button_event(XEvent xevent, BOOL down)  handle_button_event(XEvent xevent, RD_BOOL down)
1902  {  {
1903          uint16 button, flags = 0;          uint16 button, flags = 0;
1904          g_last_gesturetime = xevent.xbutton.time;          g_last_gesturetime = xevent.xbutton.time;
1905            /* Reverse the pointer button mapping, e.g. in the case of
1906               "left-handed mouse mode"; the RDP session expects to
1907               receive physical buttons (true in mstsc as well) and
1908               logical button behavior depends on the remote desktop's own
1909               mouse settings */
1910            xevent.xbutton.button = g_pointer_log_to_phys_map[xevent.xbutton.button - 1];
1911          button = xkeymap_translate_button(xevent.xbutton.button);          button = xkeymap_translate_button(xevent.xbutton.button);
1912          if (button == 0)          if (button == 0)
1913                  return;                  return;
# Line 2160  xwin_process_events(void) Line 2195  xwin_process_events(void)
2195                                          XFreeModifiermap(g_mod_map);                                          XFreeModifiermap(g_mod_map);
2196                                          g_mod_map = XGetModifierMapping(g_display);                                          g_mod_map = XGetModifierMapping(g_display);
2197                                  }                                  }
2198    
2199                                    if (xevent.xmapping.request == MappingPointer)
2200                                    {
2201                                            xwin_refresh_pointer_map();
2202                                    }
2203    
2204                                  break;                                  break;
2205    
2206                                  /* clipboard stuff */                                  /* clipboard stuff */
# Line 2243  ui_select(int rdp_socket) Line 2284  ui_select(int rdp_socket)
2284          int n;          int n;
2285          fd_set rfds, wfds;          fd_set rfds, wfds;
2286          struct timeval tv;          struct timeval tv;
2287          BOOL s_timeout = False;          RD_BOOL s_timeout = False;
2288    
2289          while (True)          while (True)
2290          {          {
# Line 2261  ui_select(int rdp_socket) Line 2302  ui_select(int rdp_socket)
2302                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
2303                  FD_SET(g_x_socket, &rfds);                  FD_SET(g_x_socket, &rfds);
2304    
 #ifdef WITH_RDPSND  
                 /* FIXME: there should be an API for registering fds */  
                 if (g_dsp_busy)  
                 {  
                         FD_SET(g_dsp_fd, &wfds);  
                         n = (g_dsp_fd > n) ? g_dsp_fd : n;  
                 }  
 #endif  
2305                  /* default timeout */                  /* default timeout */
2306                  tv.tv_sec = 60;                  tv.tv_sec = 60;
2307                  tv.tv_usec = 0;                  tv.tv_usec = 0;
2308    
2309    #ifdef WITH_RDPSND
2310                    rdpsnd_add_fds(&n, &rfds, &wfds, &tv);
2311    #endif
2312    
2313                  /* add redirection handles */                  /* add redirection handles */
2314                  rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);                  rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);
2315                  seamless_select_timeout(&tv);                  seamless_select_timeout(&tv);
# Line 2285  ui_select(int rdp_socket) Line 2322  ui_select(int rdp_socket)
2322                                  error("select: %s\n", strerror(errno));                                  error("select: %s\n", strerror(errno));
2323    
2324                          case 0:                          case 0:
2325    #ifdef WITH_RDPSND
2326                                    rdpsnd_check_fds(&rfds, &wfds);
2327    #endif
2328    
2329                                  /* Abort serial read calls */                                  /* Abort serial read calls */
2330                                  if (s_timeout)                                  if (s_timeout)
2331                                          rdpdr_check_fds(&rfds, &wfds, (BOOL) True);                                          rdpdr_check_fds(&rfds, &wfds, (RD_BOOL) True);
2332                                  continue;                                  continue;
2333                  }                  }
2334    
2335                  rdpdr_check_fds(&rfds, &wfds, (BOOL) False);  #ifdef WITH_RDPSND
2336                    rdpsnd_check_fds(&rfds, &wfds);
2337    #endif
2338    
2339                    rdpdr_check_fds(&rfds, &wfds, (RD_BOOL) False);
2340    
2341                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
2342                          return 1;                          return 1;
2343    
 #ifdef WITH_RDPSND  
                 if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))  
                         wave_out_play();  
 #endif  
2344          }          }
2345  }  }
2346    
# Line 2309  ui_move_pointer(int x, int y) Line 2350  ui_move_pointer(int x, int y)
2350          XWarpPointer(g_display, g_wnd, g_wnd, 0, 0, 0, 0, x, y);          XWarpPointer(g_display, g_wnd, g_wnd, 0, 0, 0, 0, x, y);
2351  }  }
2352    
2353  HBITMAP  RD_HBITMAP
2354  ui_create_bitmap(int width, int height, uint8 * data)  ui_create_bitmap(int width, int height, uint8 * data)
2355  {  {
2356          XImage *image;          XImage *image;
# Line 2339  ui_create_bitmap(int width, int height, Line 2380  ui_create_bitmap(int width, int height,
2380          XFree(image);          XFree(image);
2381          if (tdata != data)          if (tdata != data)
2382                  xfree(tdata);                  xfree(tdata);
2383          return (HBITMAP) bitmap;          return (RD_HBITMAP) bitmap;
2384  }  }
2385    
2386  void  void
# Line 2387  ui_paint_bitmap(int x, int y, int cx, in Line 2428  ui_paint_bitmap(int x, int y, int cx, in
2428  }  }
2429    
2430  void  void
2431  ui_destroy_bitmap(HBITMAP bmp)  ui_destroy_bitmap(RD_HBITMAP bmp)
2432  {  {
2433          XFreePixmap(g_display, (Pixmap) bmp);          XFreePixmap(g_display, (Pixmap) bmp);
2434  }  }
2435    
2436  HGLYPH  RD_HGLYPH
2437  ui_create_glyph(int width, int height, uint8 * data)  ui_create_glyph(int width, int height, uint8 * data)
2438  {  {
2439          XImage *image;          XImage *image;
# Line 2414  ui_create_glyph(int width, int height, u Line 2455  ui_create_glyph(int width, int height, u
2455          XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height);
2456    
2457          XFree(image);          XFree(image);
2458          return (HGLYPH) bitmap;          return (RD_HGLYPH) bitmap;
2459  }  }
2460    
2461  void  void
2462  ui_destroy_glyph(HGLYPH glyph)  ui_destroy_glyph(RD_HGLYPH glyph)
2463  {  {
2464          XFreePixmap(g_display, (Pixmap) glyph);          XFreePixmap(g_display, (Pixmap) glyph);
2465  }  }
2466    
2467  HCURSOR  RD_HCURSOR
2468  ui_create_cursor(unsigned int x, unsigned int y, int width, int height,  ui_create_cursor(unsigned int x, unsigned int y, int width, int height,
2469                   uint8 * andmask, uint8 * xormask)                   uint8 * andmask, uint8 * xormask)
2470  {  {
2471          HGLYPH maskglyph, cursorglyph;          RD_HGLYPH maskglyph, cursorglyph;
2472          XColor bg, fg;          XColor bg, fg;
2473          Cursor xcursor;          Cursor xcursor;
2474          uint8 *cursor, *pcursor;          uint8 *cursor, *pcursor;
# Line 2491  ui_create_cursor(unsigned int x, unsigne Line 2532  ui_create_cursor(unsigned int x, unsigne
2532          ui_destroy_glyph(cursorglyph);          ui_destroy_glyph(cursorglyph);
2533          xfree(mask);          xfree(mask);
2534          xfree(cursor);          xfree(cursor);
2535          return (HCURSOR) xcursor;          return (RD_HCURSOR) xcursor;
2536  }  }
2537    
2538  void  void
2539  ui_set_cursor(HCURSOR cursor)  ui_set_cursor(RD_HCURSOR cursor)
2540  {  {
2541          g_current_cursor = (Cursor) cursor;          g_current_cursor = (Cursor) cursor;
2542          XDefineCursor(g_display, g_wnd, g_current_cursor);          XDefineCursor(g_display, g_wnd, g_current_cursor);
# Line 2503  ui_set_cursor(HCURSOR cursor) Line 2544  ui_set_cursor(HCURSOR cursor)
2544  }  }
2545    
2546  void  void
2547  ui_destroy_cursor(HCURSOR cursor)  ui_destroy_cursor(RD_HCURSOR cursor)
2548  {  {
2549          XFreeCursor(g_display, (Cursor) cursor);          XFreeCursor(g_display, (Cursor) cursor);
2550  }  }
# Line 2521  ui_set_null_cursor(void) Line 2562  ui_set_null_cursor(void)
2562                  (xc)->flags = DoRed | DoGreen | DoBlue;                  (xc)->flags = DoRed | DoGreen | DoBlue;
2563    
2564    
2565  HCOLOURMAP  RD_HCOLOURMAP
2566  ui_create_colourmap(COLOURMAP * colours)  ui_create_colourmap(COLOURMAP * colours)
2567  {  {
2568          COLOURENTRY *entry;          COLOURENTRY *entry;
# Line 2617  ui_create_colourmap(COLOURMAP * colours) Line 2658  ui_create_colourmap(COLOURMAP * colours)
2658                  XStoreColors(g_display, map, xcolours, ncolours);                  XStoreColors(g_display, map, xcolours, ncolours);
2659    
2660                  xfree(xcolours);                  xfree(xcolours);
2661                  return (HCOLOURMAP) map;                  return (RD_HCOLOURMAP) map;
2662          }          }
2663  }  }
2664    
2665  void  void
2666  ui_destroy_colourmap(HCOLOURMAP map)  ui_destroy_colourmap(RD_HCOLOURMAP map)
2667  {  {
2668          if (!g_owncolmap)          if (!g_owncolmap)
2669                  xfree(map);                  xfree(map);
# Line 2631  ui_destroy_colourmap(HCOLOURMAP map) Line 2672  ui_destroy_colourmap(HCOLOURMAP map)
2672  }  }
2673    
2674  void  void
2675  ui_set_colourmap(HCOLOURMAP map)  ui_set_colourmap(RD_HCOLOURMAP map)
2676  {  {
2677          if (!g_owncolmap)          if (!g_owncolmap)
2678          {          {
# Line 2719  ui_patblt(uint8 opcode, Line 2760  ui_patblt(uint8 opcode,
2760                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
2761                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
2762                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
2763                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
2764                          break;                          break;
2765    
2766                  case 3: /* Pattern */                  case 3: /* Pattern */
# Line 2734  ui_patblt(uint8 opcode, Line 2775  ui_patblt(uint8 opcode,
2775                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
2776                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
2777                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
2778                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
2779                          break;                          break;
2780    
2781                  default:                  default:
# Line 2777  ui_screenblt(uint8 opcode, Line 2818  ui_screenblt(uint8 opcode,
2818  void  void
2819  ui_memblt(uint8 opcode,  ui_memblt(uint8 opcode,
2820            /* dest */ int x, int y, int cx, int cy,            /* dest */ int x, int y, int cx, int cy,
2821            /* src */ HBITMAP src, int srcx, int srcy)            /* src */ RD_HBITMAP src, int srcx, int srcy)
2822  {  {
2823          SET_FUNCTION(opcode);          SET_FUNCTION(opcode);
2824          XCopyArea(g_display, (Pixmap) src, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);          XCopyArea(g_display, (Pixmap) src, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
# Line 2792  ui_memblt(uint8 opcode, Line 2833  ui_memblt(uint8 opcode,
2833  void  void
2834  ui_triblt(uint8 opcode,  ui_triblt(uint8 opcode,
2835            /* dest */ int x, int y, int cx, int cy,            /* dest */ int x, int y, int cx, int cy,
2836            /* src */ HBITMAP src, int srcx, int srcy,            /* src */ RD_HBITMAP src, int srcx, int srcy,
2837            /* brush */ BRUSH * brush, int bgcolour, int fgcolour)            /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
2838  {  {
2839          /* This is potentially difficult to do in general. Until someone          /* This is potentially difficult to do in general. Until someone
# Line 2850  ui_rect( Line 2891  ui_rect(
2891  void  void
2892  ui_polygon(uint8 opcode,  ui_polygon(uint8 opcode,
2893             /* mode */ uint8 fillmode,             /* mode */ uint8 fillmode,
2894             /* dest */ POINT * point, int npoints,             /* dest */ RD_POINT * point, int npoints,
2895             /* brush */ BRUSH * brush, int bgcolour, int fgcolour)             /* brush */ BRUSH * brush, int bgcolour, int fgcolour)
2896  {  {
2897          uint8 style, i, ipattern[8];          uint8 style, i, ipattern[8];
# Line 2893  ui_polygon(uint8 opcode, Line 2934  ui_polygon(uint8 opcode,
2934                          FILL_POLYGON((XPoint *) point, npoints);                          FILL_POLYGON((XPoint *) point, npoints);
2935                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
2936                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
2937                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
2938                          break;                          break;
2939    
2940                  case 3: /* Pattern */                  case 3: /* Pattern */
# Line 2908  ui_polygon(uint8 opcode, Line 2949  ui_polygon(uint8 opcode,
2949                          FILL_POLYGON((XPoint *) point, npoints);                          FILL_POLYGON((XPoint *) point, npoints);
2950                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
2951                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
2952                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
2953                          break;                          break;
2954    
2955                  default:                  default:
# Line 2920  ui_polygon(uint8 opcode, Line 2961  ui_polygon(uint8 opcode,
2961    
2962  void  void
2963  ui_polyline(uint8 opcode,  ui_polyline(uint8 opcode,
2964              /* dest */ POINT * points, int npoints,              /* dest */ RD_POINT * points, int npoints,
2965              /* pen */ PEN * pen)              /* pen */ PEN * pen)
2966  {  {
2967          /* TODO: set join style */          /* TODO: set join style */
# Line 2971  ui_ellipse(uint8 opcode, Line 3012  ui_ellipse(uint8 opcode,
3012                          DRAW_ELLIPSE(x, y, cx, cy, fillmode);                          DRAW_ELLIPSE(x, y, cx, cy, fillmode);
3013                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
3014                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
3015                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
3016                          break;                          break;
3017    
3018                  case 3: /* Pattern */                  case 3: /* Pattern */
# Line 2986  ui_ellipse(uint8 opcode, Line 3027  ui_ellipse(uint8 opcode,
3027                          DRAW_ELLIPSE(x, y, cx, cy, fillmode);                          DRAW_ELLIPSE(x, y, cx, cy, fillmode);
3028                          XSetFillStyle(g_display, g_gc, FillSolid);                          XSetFillStyle(g_display, g_gc, FillSolid);
3029                          XSetTSOrigin(g_display, g_gc, 0, 0);                          XSetTSOrigin(g_display, g_gc, 0, 0);
3030                          ui_destroy_glyph((HGLYPH) fill);                          ui_destroy_glyph((RD_HGLYPH) fill);
3031                          break;                          break;
3032    
3033                  default:                  default:
# Line 3000  ui_ellipse(uint8 opcode, Line 3041  ui_ellipse(uint8 opcode,
3041  void  void
3042  ui_draw_glyph(int mixmode,  ui_draw_glyph(int mixmode,
3043                /* dest */ int x, int y, int cx, int cy,                /* dest */ int x, int y, int cx, int cy,
3044                /* src */ HGLYPH glyph, int srcx, int srcy,                /* src */ RD_HGLYPH glyph, int srcx, int srcy,
3045                int bgcolour, int fgcolour)                int bgcolour, int fgcolour)
3046  {  {
3047          SET_FOREGROUND(fgcolour);          SET_FOREGROUND(fgcolour);
# Line 3185  ui_desktop_save(uint32 offset, int x, in Line 3226  ui_desktop_save(uint32 offset, int x, in
3226          if (g_ownbackstore)          if (g_ownbackstore)
3227          {          {
3228                  image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap);                  image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap);
3229                    exit_if_null(image);
3230          }          }
3231          else          else
3232          {          {
3233                  pix = XCreatePixmap(g_display, g_wnd, cx, cy, g_depth);                  pix = XCreatePixmap(g_display, g_wnd, cx, cy, g_depth);
3234                  XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0);                  XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0);
3235                  image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);                  image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);
3236                    exit_if_null(image);
3237                  XFreePixmap(g_display, pix);                  XFreePixmap(g_display, pix);
3238          }          }
3239    
# Line 3212  ui_desktop_restore(uint32 offset, int x, Line 3255  ui_desktop_restore(uint32 offset, int x,
3255                  return;                  return;
3256    
3257          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
3258                               (char *) data, cx, cy, BitmapPad(g_display), cx * g_bpp / 8);                               (char *) data, cx, cy, g_bpp, 0);
3259    
3260          if (g_ownbackstore)          if (g_ownbackstore)
3261          {          {
# Line 3246  ui_end_update(void) Line 3289  ui_end_update(void)
3289    
3290    
3291  void  void
3292  ui_seamless_begin(BOOL hidden)  ui_seamless_begin(RD_BOOL hidden)
3293  {  {
3294          if (!g_seamless_rdp)          if (!g_seamless_rdp)
3295                  return;                  return;
# Line 3414  ui_seamless_create_window(unsigned long Line 3457  ui_seamless_create_window(unsigned long
3457          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, wnd, &g_kill_atom, 1);
3458    
3459          sw = xmalloc(sizeof(seamless_window));          sw = xmalloc(sizeof(seamless_window));
3460    
3461            memset(sw, 0, sizeof(seamless_window));
3462    
3463          sw->wnd = wnd;          sw->wnd = wnd;
3464          sw->id = id;          sw->id = id;
         sw->behind = 0;  
3465          sw->group = sw_find_group(group, False);          sw->group = sw_find_group(group, False);
3466          sw->group->refcnt++;          sw->group->refcnt++;
         sw->xoffset = 0;  
         sw->yoffset = 0;  
         sw->width = 0;  
         sw->height = 0;  
3467          sw->state = SEAMLESSRDP_NOTYETMAPPED;          sw->state = SEAMLESSRDP_NOTYETMAPPED;
3468          sw->desktop = 0;          sw->desktop = 0;
3469          sw->position_timer = xmalloc(sizeof(struct timeval));          sw->position_timer = xmalloc(sizeof(struct timeval));
# Line 3468  ui_seamless_destroy_window(unsigned long Line 3509  ui_seamless_destroy_window(unsigned long
3509  }  }
3510    
3511    
3512    void
3513    ui_seamless_destroy_group(unsigned long id, unsigned long flags)
3514    {
3515            seamless_window *sw, *sw_next;
3516    
3517            if (!g_seamless_active)
3518                    return;
3519    
3520            for (sw = g_seamless_windows; sw; sw = sw_next)
3521            {
3522                    sw_next = sw->next;
3523    
3524                    if (sw->group->id == id)
3525                    {
3526                            XDestroyWindow(g_display, sw->wnd);
3527                            sw_remove_window(sw);
3528                    }
3529            }
3530    }
3531    
3532    
3533    void
3534    ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk,
3535                        const char *data, int chunk_len)
3536    {
3537            seamless_window *sw;
3538    
3539            if (!g_seamless_active)
3540                    return;
3541    
3542            sw = sw_get_window_by_id(id);
3543            if (!sw)
3544            {
3545                    warning("ui_seamless_seticon: No information for window 0x%lx\n", id);
3546                    return;
3547            }
3548    
3549            if (chunk == 0)
3550            {
3551                    if (sw->icon_size)
3552                            warning("ui_seamless_seticon: New icon started before previous completed\n");
3553    
3554                    if (strcmp(format, "RGBA") != 0)
3555                    {
3556                            warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format);
3557                            return;
3558                    }
3559    
3560                    sw->icon_size = width * height * 4;
3561                    if (sw->icon_size > 32 * 32 * 4)
3562                    {
3563                            warning("ui_seamless_seticon: Icon too large (%d bytes)\n", sw->icon_size);
3564                            sw->icon_size = 0;
3565                            return;
3566                    }
3567    
3568                    sw->icon_offset = 0;
3569            }
3570            else
3571            {
3572                    if (!sw->icon_size)
3573                            return;
3574            }
3575    
3576            if (chunk_len > (sw->icon_size - sw->icon_offset))
3577            {
3578                    warning("ui_seamless_seticon: Too large chunk received (%d bytes > %d bytes)\n",
3579                            chunk_len, sw->icon_size - sw->icon_offset);
3580                    sw->icon_size = 0;
3581                    return;
3582            }
3583    
3584            memcpy(sw->icon_buffer + sw->icon_offset, data, chunk_len);
3585            sw->icon_offset += chunk_len;
3586    
3587            if (sw->icon_offset == sw->icon_size)
3588            {
3589                    ewmh_set_icon(sw->wnd, width, height, sw->icon_buffer);
3590                    sw->icon_size = 0;
3591            }
3592    }
3593    
3594    
3595    void
3596    ui_seamless_delicon(unsigned long id, const char *format, int width, int height)
3597    {
3598            seamless_window *sw;
3599    
3600            if (!g_seamless_active)
3601                    return;
3602    
3603            sw = sw_get_window_by_id(id);
3604            if (!sw)
3605            {
3606                    warning("ui_seamless_seticon: No information for window 0x%lx\n", id);
3607                    return;
3608            }
3609    
3610            if (strcmp(format, "RGBA") != 0)
3611            {
3612                    warning("ui_seamless_seticon: Uknown icon format \"%s\"\n", format);
3613                    return;
3614            }
3615    
3616            ewmh_del_icon(sw->wnd, width, height);
3617    }
3618    
3619    
3620  void  void
3621  ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags)  ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags)
3622  {  {

Legend:
Removed from v.1214  
changed lines
  Added in v.1413

  ViewVC Help
Powered by ViewVC 1.1.26