/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/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/branches/seamlessrdp-branch/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1143 by ossman_, Thu Mar 16 08:41:53 2006 UTC revision 1154 by ossman_, Fri Mar 17 09:56:20 2006 UTC
# Line 55  typedef struct _seamless_window Line 55  typedef struct _seamless_window
55          Window wnd;          Window wnd;
56          unsigned long id;          unsigned long id;
57          unsigned long parent;          unsigned long parent;
         XWMHints *hints;  
58          int xoffset, yoffset;          int xoffset, yoffset;
59          int width, height;          int width, height;
60          int state;              /* normal/minimized/maximized. */          int state;              /* normal/minimized/maximized. */
# Line 63  typedef struct _seamless_window Line 62  typedef struct _seamless_window
62          struct _seamless_window *next;          struct _seamless_window *next;
63  } seamless_window;  } seamless_window;
64  static seamless_window *g_seamless_windows = NULL;  static seamless_window *g_seamless_windows = NULL;
65    static BOOL g_seamless_started = False; /* Server end is up and running */
66    static BOOL g_seamless_active = False;  /* We are currently in seamless mode */
67  extern BOOL g_seamless_rdp;  extern BOOL g_seamless_rdp;
68    
69  extern uint32 g_embed_wnd;  extern uint32 g_embed_wnd;
# Line 295  seamless_remove_window(seamless_window * Line 296  seamless_remove_window(seamless_window *
296                  if (sw == win)                  if (sw == win)
297                  {                  {
298                          *prevnext = sw->next;                          *prevnext = sw->next;
                         XFree(sw->hints);  
299                          xfree(sw);                          xfree(sw);
300                          return;                          return;
301                  }                  }
# Line 1567  ui_create_window(void) Line 1567  ui_create_window(void)
1567          }          }
1568    
1569          XSelectInput(g_display, g_wnd, input_mask);          XSelectInput(g_display, g_wnd, input_mask);
1570          if (!g_seamless_rdp)  
1571            XMapWindow(g_display, g_wnd);
1572            /* wait for VisibilityNotify */
1573            do
1574          {          {
1575                  XMapWindow(g_display, g_wnd);                  XMaskEvent(g_display, VisibilityChangeMask, &xevent);
                 /* wait for VisibilityNotify */  
                 do  
                 {  
                         XMaskEvent(g_display, VisibilityChangeMask, &xevent);  
                 }  
                 while (xevent.type != VisibilityNotify);  
                 g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;  
1576          }          }
1577            while (xevent.type != VisibilityNotify);
1578            g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;
1579    
1580          g_focused = False;          g_focused = False;
1581          g_mouse_in_wnd = False;          g_mouse_in_wnd = False;
# Line 1641  xwin_toggle_fullscreen(void) Line 1639  xwin_toggle_fullscreen(void)
1639  {  {
1640          Pixmap contents = 0;          Pixmap contents = 0;
1641    
1642          if (g_seamless_rdp)          if (g_seamless_active)
1643                  /* Turn off SeamlessRDP mode */                  /* Turn off SeamlessRDP mode */
1644                  ui_seamless_toggle();                  ui_seamless_toggle();
1645    
# Line 1746  handle_button_event(XEvent xevent, BOOL Line 1744  handle_button_event(XEvent xevent, BOOL
1744          }          }
1745  }  }
1746    
1747    static void
1748    ui_seamless_handle_restack(seamless_window * sw)
1749    {
1750            Status status;
1751            Window root, parent, *children;
1752            unsigned int nchildren, i;
1753            seamless_window *sw_below;
1754    
1755            status = XQueryTree(g_display, RootWindowOfScreen(g_screen),
1756                                &root, &parent, &children, &nchildren);
1757            if (!status || !nchildren)
1758                    return;
1759    
1760            sw_below = NULL;
1761    
1762            i = 0;
1763            while (children[i] != sw->wnd)
1764            {
1765                    i++;
1766                    if (i >= nchildren)
1767                            return;
1768            }
1769    
1770            for (i++; i < nchildren; i++)
1771            {
1772                    sw_below = seamless_get_window_by_wnd(children[i]);
1773                    if (sw_below)
1774                            break;
1775            }
1776    
1777            if (sw_below)
1778                    seamless_send_zchange(sw->id, sw_below->id, 0);
1779            else
1780                    seamless_send_zchange(sw->id, 0, 0);
1781    }
1782    
1783  /* Process events in Xlib queue  /* Process events in Xlib queue
1784     Returns 0 after user quit, 1 otherwise */     Returns 0 after user quit, 1 otherwise */
1785  static int  static int
# Line 1878  xwin_process_events(void) Line 1912  xwin_process_events(void)
1912                                  if (g_grab_keyboard && g_mouse_in_wnd)                                  if (g_grab_keyboard && g_mouse_in_wnd)
1913                                          XGrabKeyboard(g_display, g_wnd, True,                                          XGrabKeyboard(g_display, g_wnd, True,
1914                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
1915    
1916                                    sw = seamless_get_window_by_wnd(xevent.xfocus.window);
1917                                    if (!sw)
1918                                            break;
1919    
1920                                    seamless_send_focus(sw->id, 0);
1921                                  break;                                  break;
1922    
1923                          case FocusOut:                          case FocusOut:
# Line 1990  xwin_process_events(void) Line 2030  xwin_process_events(void)
2030    
2031                                  break;                                  break;
2032                          case MapNotify:                          case MapNotify:
2033                                  if (!g_seamless_rdp)                                  if (!g_seamless_active)
2034                                          rdp_send_client_window_status(1);                                          rdp_send_client_window_status(1);
2035                                  break;                                  break;
2036                          case UnmapNotify:                          case UnmapNotify:
2037                                  if (!g_seamless_rdp)                                  if (!g_seamless_active)
2038                                          rdp_send_client_window_status(0);                                          rdp_send_client_window_status(0);
2039                                  break;                                  break;
2040                            case ConfigureNotify:
2041                                    /* seamless */
2042                                    sw = seamless_get_window_by_wnd(xevent.xconfigure.window);
2043                                    if (!sw)
2044                                            break;
2045    
2046                                    ui_seamless_handle_restack(sw);
2047                  }                  }
2048          }          }
2049          /* Keep going */          /* Keep going */
# Line 3008  ui_end_update(void) Line 3055  ui_end_update(void)
3055  }  }
3056    
3057  void  void
3058    ui_seamless_begin()
3059    {
3060            if (!g_seamless_rdp)
3061                    return;
3062    
3063            if (g_seamless_started)
3064                    return;
3065    
3066            g_seamless_started = True;
3067    
3068            ui_seamless_toggle();
3069    }
3070    
3071    void
3072  ui_seamless_toggle()  ui_seamless_toggle()
3073  {  {
3074          if (g_seamless_rdp)          if (!g_seamless_rdp)
3075                    return;
3076    
3077            if (!g_seamless_started)
3078                    return;
3079    
3080            if (g_seamless_active)
3081          {          {
3082                  /* Deactivate */                  /* Deactivate */
3083                  while (g_seamless_windows)                  while (g_seamless_windows)
# Line 3023  ui_seamless_toggle() Line 3090  ui_seamless_toggle()
3090          else          else
3091          {          {
3092                  /* Activate */                  /* Activate */
                 if (g_win_button_size)  
                 {  
                         error("SeamlessRDP mode cannot be activated when using single application mode\n");  
                         return;  
                 }  
                 if (!g_using_full_workarea)  
                 {  
                         error("SeamlessRDP mode requires a session that covers the whole screen");  
                         return;  
                 }  
   
3093                  XUnmapWindow(g_display, g_wnd);                  XUnmapWindow(g_display, g_wnd);
3094                  seamless_send_sync();                  seamless_send_sync();
3095          }          }
3096    
3097          g_seamless_rdp = !g_seamless_rdp;          g_seamless_active = !g_seamless_active;
3098  }  }
3099    
3100  void  void
# Line 3051  ui_seamless_create_window(unsigned long Line 3107  ui_seamless_create_window(unsigned long
3107          long input_mask;          long input_mask;
3108          seamless_window *sw, *sw_parent;          seamless_window *sw, *sw_parent;
3109    
3110            if (!g_seamless_active)
3111                    return;
3112    
3113          /* Ignore CREATEs for existing windows */          /* Ignore CREATEs for existing windows */
3114          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3115          if (sw)          if (sw)
# Line 3114  ui_seamless_create_window(unsigned long Line 3173  ui_seamless_create_window(unsigned long
3173          sw->wnd = wnd;          sw->wnd = wnd;
3174          sw->id = id;          sw->id = id;
3175          sw->parent = parent;          sw->parent = parent;
         sw->hints = XAllocWMHints();  
         sw->hints->flags = 0;  
3176          sw->xoffset = 0;          sw->xoffset = 0;
3177          sw->yoffset = 0;          sw->yoffset = 0;
3178          sw->width = 0;          sw->width = 0;
# Line 3132  ui_seamless_destroy_window(unsigned long Line 3189  ui_seamless_destroy_window(unsigned long
3189  {  {
3190          seamless_window *sw;          seamless_window *sw;
3191    
3192            if (!g_seamless_active)
3193                    return;
3194    
3195          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3196          if (!sw)          if (!sw)
3197          {          {
# Line 3149  ui_seamless_move_window(unsigned long id Line 3209  ui_seamless_move_window(unsigned long id
3209  {  {
3210          seamless_window *sw;          seamless_window *sw;
3211    
3212            if (!g_seamless_active)
3213                    return;
3214    
3215          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3216          if (!sw)          if (!sw)
3217          {          {
# Line 3184  ui_seamless_move_window(unsigned long id Line 3247  ui_seamless_move_window(unsigned long id
3247          XMoveResizeWindow(g_display, sw->wnd, sw->xoffset, sw->yoffset, sw->width, sw->height);          XMoveResizeWindow(g_display, sw->wnd, sw->xoffset, sw->yoffset, sw->width, sw->height);
3248  }  }
3249    
3250    void
3251    ui_seamless_restack_window(unsigned long id, unsigned long behind, unsigned long flags)
3252    {
3253            seamless_window *sw;
3254    
3255            if (!g_seamless_active)
3256                    return;
3257    
3258            sw = seamless_get_window_by_id(id);
3259            if (!sw)
3260            {
3261                    warning("ui_seamless_restack_window: No information for window 0x%lx\n", id);
3262                    return;
3263            }
3264    
3265            if (behind)
3266            {
3267                    seamless_window *sw_behind;
3268                    Window wnds[2];
3269    
3270                    sw_behind = seamless_get_window_by_id(behind);
3271                    if (!sw_behind)
3272                    {
3273                            warning("ui_seamless_restack_window: No information for window 0x%lx\n",
3274                                    behind);
3275                            return;
3276                    }
3277    
3278                    wnds[1] = sw_behind->wnd;
3279                    wnds[0] = sw->wnd;
3280    
3281                    XRestackWindows(g_display, wnds, 2);
3282            }
3283            else
3284            {
3285                    XRaiseWindow(g_display, sw->wnd);
3286            }
3287    }
3288    
3289  void  void
3290  ui_seamless_settitle(unsigned long id, const char *title, unsigned long flags)  ui_seamless_settitle(unsigned long id, const char *title, unsigned long flags)
3291  {  {
3292          seamless_window *sw;          seamless_window *sw;
3293    
3294            if (!g_seamless_active)
3295                    return;
3296    
3297          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3298          if (!sw)          if (!sw)
3299          {          {
# Line 3208  ui_seamless_setstate(unsigned long id, u Line 3312  ui_seamless_setstate(unsigned long id, u
3312  {  {
3313          seamless_window *sw;          seamless_window *sw;
3314    
3315            if (!g_seamless_active)
3316                    return;
3317    
3318          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3319          if (!sw)          if (!sw)
3320          {          {
# Line 3230  ui_seamless_setstate(unsigned long id, u Line 3337  ui_seamless_setstate(unsigned long id, u
3337                             XIconifyWindow is easier. */                             XIconifyWindow is easier. */
3338                          if (sw->state == SEAMLESSRDP_NOTYETMAPPED)                          if (sw->state == SEAMLESSRDP_NOTYETMAPPED)
3339                          {                          {
3340                                  sw->hints->flags |= StateHint;                                  XWMHints *hints;
3341                                  sw->hints->initial_state = IconicState;                                  hints = XAllocWMHints();
3342                                  XSetWMHints(g_display, sw->wnd, sw->hints);                                  hints->flags = StateHint;
3343                                    hints->initial_state = IconicState;
3344                                    XSetWMHints(g_display, sw->wnd, hints);
3345                                    XFree(hints);
3346                                  XMapWindow(g_display, sw->wnd);                                  XMapWindow(g_display, sw->wnd);
3347                          }                          }
3348                          else                          else
# Line 3254  ui_seamless_setstate(unsigned long id, u Line 3364  ui_seamless_setstate(unsigned long id, u
3364  void  void
3365  ui_seamless_syncbegin(unsigned long flags)  ui_seamless_syncbegin(unsigned long flags)
3366  {  {
3367            if (!g_seamless_active)
3368                    return;
3369    
3370          /* Destroy all seamless windows */          /* Destroy all seamless windows */
3371          while (g_seamless_windows)          while (g_seamless_windows)
3372          {          {

Legend:
Removed from v.1143  
changed lines
  Added in v.1154

  ViewVC Help
Powered by ViewVC 1.1.26