/[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 1098 by astrand, Fri Mar 10 12:44:32 2006 UTC revision 1132 by astrand, Wed Mar 15 12:58:50 2006 UTC
# Line 56  typedef struct _seamless_window Line 56  typedef struct _seamless_window
56          unsigned long id;          unsigned long id;
57          int xoffset, yoffset;          int xoffset, yoffset;
58          int width, height;          int width, height;
59            int state;              /* normal/minimized/maximized. */
60            unsigned int desktop;
61          struct _seamless_window *next;          struct _seamless_window *next;
62  } seamless_window;  } seamless_window;
63  static seamless_window *g_seamless_windows = NULL;  static seamless_window *g_seamless_windows = NULL;
# Line 83  static XModifierKeymap *g_mod_map; Line 85  static XModifierKeymap *g_mod_map;
85  static Cursor g_current_cursor;  static Cursor g_current_cursor;
86  static HCURSOR g_null_cursor = NULL;  static HCURSOR g_null_cursor = NULL;
87  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
88    extern Atom g_net_wm_state_atom;
89    extern Atom g_net_wm_desktop_atom;
90  static BOOL g_focused;  static BOOL g_focused;
91  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
92  /* Indicates that:  /* Indicates that:
# Line 298  seamless_remove_window(seamless_window * Line 302  seamless_remove_window(seamless_window *
302  }  }
303    
304    
305    /* Move all windows except wnd to new desktop */
306    static void
307    seamless_all_to_desktop(Window wnd, unsigned int desktop)
308    {
309            seamless_window *sw;
310            for (sw = g_seamless_windows; sw; sw = sw->next)
311            {
312                    if (sw->wnd == wnd)
313                            continue;
314                    if (sw->desktop != desktop)
315                    {
316                            ewmh_move_to_desktop(sw->wnd, desktop);
317                            sw->desktop = desktop;
318                    }
319            }
320    }
321    
322    
323  static void  static void
324  mwm_hide_decorations(Window wnd)  mwm_hide_decorations(Window wnd)
325  {  {
# Line 1396  ui_init(void) Line 1418  ui_init(void)
1418                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);
1419    
1420          xclip_init();          xclip_init();
1421            ewmh_init();
1422          if (g_seamless_rdp)          if (g_seamless_rdp)
1423                  seamless_init();                  seamless_init();
1424    
# Line 1903  xwin_process_events(void) Line 1926  xwin_process_events(void)
1926                                                            xevent.xexpose.width,                                                            xevent.xexpose.width,
1927                                                            xevent.xexpose.height, xevent.xexpose.x,                                                            xevent.xexpose.height, xevent.xexpose.x,
1928                                                            xevent.xexpose.y);                                                            xevent.xexpose.y);
1929                                            else
1930                                            {
1931                                                    error("Expose for unknown window 0x%lx\n",
1932                                                          xevent.xexpose.window);
1933                                            }
1934                                  }                                  }
1935    
1936                                  break;                                  break;
# Line 1933  xwin_process_events(void) Line 1961  xwin_process_events(void)
1961                                  break;                                  break;
1962                          case PropertyNotify:                          case PropertyNotify:
1963                                  xclip_handle_PropertyNotify(&xevent.xproperty);                                  xclip_handle_PropertyNotify(&xevent.xproperty);
1964                                    if (xevent.xproperty.window == g_wnd)
1965                                            break;
1966                                    if (xevent.xproperty.window == DefaultRootWindow(g_display))
1967                                            break;
1968    
1969                                    /* seamless */
1970                                    sw = seamless_get_window_by_wnd(xevent.xproperty.window);
1971                                    if (!sw)
1972                                            break;
1973    
1974                                    if ((xevent.xproperty.atom == g_net_wm_state_atom)
1975                                        && (xevent.xproperty.state == PropertyNewValue))
1976                                    {
1977                                            sw->state = ewmh_get_window_state(sw->wnd);
1978                                            seamless_send_state(sw->id, sw->state, 0);
1979                                    }
1980    
1981                                    if ((xevent.xproperty.atom == g_net_wm_desktop_atom)
1982                                        && (xevent.xproperty.state == PropertyNewValue))
1983                                    {
1984                                            sw->desktop = ewmh_get_window_desktop(sw->wnd);
1985                                            seamless_all_to_desktop(sw->wnd, sw->desktop);
1986                                    }
1987    
1988                                  break;                                  break;
1989                          case MapNotify:                          case MapNotify:
1990                                  if (!g_seamless_rdp)                                  if (!g_seamless_rdp)
# Line 2992  ui_seamless_create_window(unsigned long Line 3044  ui_seamless_create_window(unsigned long
3044          Window wnd;          Window wnd;
3045          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
3046          XClassHint *classhints;          XClassHint *classhints;
3047            XSizeHints *sizehints;
3048          long input_mask;          long input_mask;
3049          seamless_window *sw;          seamless_window *sw, *sw_parent;
3050    
3051          get_window_attribs(&attribs);          /* Ignore CREATEs for existing windows */
3052            sw = seamless_get_window_by_id(id);
3053            if (sw)
3054                    return;
3055    
3056            get_window_attribs(&attribs);
3057          attribs.override_redirect = False;          attribs.override_redirect = False;
3058    
3059          /* FIXME: Do not assume that -1, -1 is outside screen Consider          wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, g_depth,
            wait with showing the window until STATE and others have  
            been recieved. */  
         wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), -1, -1, 1, 1, 0, 0,  
3060                              InputOutput, g_visual,                              InputOutput, g_visual,
3061                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
3062                              CWBorderPixel, &attribs);                              CWBorderPixel, &attribs);
# Line 3019  ui_seamless_create_window(unsigned long Line 3073  ui_seamless_create_window(unsigned long
3073                  XFree(classhints);                  XFree(classhints);
3074          }          }
3075    
3076            /* WM_NORMAL_HINTS */
3077            sizehints = XAllocSizeHints();
3078            if (sizehints != NULL)
3079            {
3080                    sizehints->flags = USPosition;
3081                    XSetWMNormalHints(g_display, wnd, sizehints);
3082                    XFree(sizehints);
3083            }
3084    
3085            /* Set WM_TRANSIENT_FOR, if necessary */
3086            if (parent)
3087            {
3088                    sw_parent = seamless_get_window_by_id(parent);
3089                    if (sw_parent)
3090                            XSetTransientForHint(g_display, wnd, sw_parent->wnd);
3091                    else
3092                            warning("ui_seamless_create_window: No parent window 0x%lx\n", parent);
3093            }
3094    
3095          /* FIXME: Support for Input Context:s */          /* FIXME: Support for Input Context:s */
3096    
3097          get_input_mask(&input_mask);          get_input_mask(&input_mask);
3098            input_mask |= PropertyChangeMask;
3099    
3100          XSelectInput(g_display, wnd, input_mask);          XSelectInput(g_display, wnd, input_mask);
3101    
         XMapWindow(g_display, wnd);  
   
3102          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a
3103             seamless window, we could try to close the window on the             seamless window, we could try to close the window on the
3104             serverside, instead of terminating rdesktop */             serverside, instead of terminating rdesktop */
# Line 3039  ui_seamless_create_window(unsigned long Line 3111  ui_seamless_create_window(unsigned long
3111          sw->yoffset = 0;          sw->yoffset = 0;
3112          sw->width = 0;          sw->width = 0;
3113          sw->height = 0;          sw->height = 0;
3114            sw->state = SEAMLESSRDP_NOTYETMAPPED;
3115            sw->desktop = 0;
3116          sw->next = g_seamless_windows;          sw->next = g_seamless_windows;
3117          g_seamless_windows = sw;          g_seamless_windows = sw;
3118  }  }
# Line 3048  void Line 3122  void
3122  ui_seamless_destroy_window(unsigned long id, unsigned long flags)  ui_seamless_destroy_window(unsigned long id, unsigned long flags)
3123  {  {
3124          seamless_window *sw;          seamless_window *sw;
         sw = seamless_get_window_by_id(id);  
3125    
3126            sw = seamless_get_window_by_id(id);
3127          if (!sw)          if (!sw)
3128          {          {
3129                  warning("ui_seamless_destroy_window: No information for window 0x%lx\n", id);                  warning("ui_seamless_destroy_window: No information for window 0x%lx\n", id);
# Line 3067  ui_seamless_move_window(unsigned long id Line 3141  ui_seamless_move_window(unsigned long id
3141          seamless_window *sw;          seamless_window *sw;
3142    
3143          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
   
3144          if (!sw)          if (!sw)
3145          {          {
3146                  warning("ui_seamless_move_window: No information for window 0x%lx\n", id);                  warning("ui_seamless_move_window: No information for window 0x%lx\n", id);
# Line 3089  ui_seamless_move_window(unsigned long id Line 3162  ui_seamless_move_window(unsigned long id
3162          sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset);          sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset);
3163          sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset);          sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset);
3164    
3165            /* If we move the window in a maximized state, then KDE won't
3166               accept restoration */
3167            switch (sw->state)
3168            {
3169                    case SEAMLESSRDP_MINIMIZED:
3170                    case SEAMLESSRDP_MAXIMIZED:
3171                            return;
3172            }
3173    
3174          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */
3175          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);
3176  }  }
# Line 3100  ui_seamless_settitle(unsigned long id, c Line 3182  ui_seamless_settitle(unsigned long id, c
3182          seamless_window *sw;          seamless_window *sw;
3183    
3184          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3185            if (!sw)
3186            {
3187                    warning("ui_seamless_settitle: No information for window 0x%lx\n", id);
3188                    return;
3189            }
3190    
3191          XStoreName(g_display, sw->wnd, title);          XStoreName(g_display, sw->wnd, title);
3192  }  }
# Line 3111  ui_seamless_setstate(unsigned long id, u Line 3198  ui_seamless_setstate(unsigned long id, u
3198          seamless_window *sw;          seamless_window *sw;
3199    
3200          sw = seamless_get_window_by_id(id);          sw = seamless_get_window_by_id(id);
3201            if (!sw)
3202            {
3203                    warning("ui_seamless_setstate: No information for window 0x%lx\n", id);
3204                    return;
3205            }
3206    
3207            if (sw->state == SEAMLESSRDP_NOTYETMAPPED)
3208            {
3209                    XMapWindow(g_display, sw->wnd);
3210            }
3211    
3212            sw->state = state;
3213    
3214          switch (state)          switch (state)
3215          {          {
3216                  case SEAMLESSRDP_NORMAL:                  case SEAMLESSRDP_NORMAL:
3217                  case SEAMLESSRDP_MAXIMIZED:                  case SEAMLESSRDP_MAXIMIZED:
3218                          /* FIXME */                          ewmh_change_state(sw->wnd, state);
3219                          break;                          break;
3220                  case SEAMLESSRDP_MINIMIZED:                  case SEAMLESSRDP_MINIMIZED:
3221                            /* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN
3222                               the Window Manager should probably just ignore the request, since
3223                               _NET_WM_STATE_HIDDEN is a function of some other aspect of the window
3224                               such as minimization, rather than an independent state." Besides,
3225                               XIconifyWindow is easier. */
3226                          XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));                          XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));
3227                          break;                          break;
3228                  default:                  default:
# Line 3126  ui_seamless_setstate(unsigned long id, u Line 3230  ui_seamless_setstate(unsigned long id, u
3230                          break;                          break;
3231          }          }
3232  }  }
3233    
3234    
3235    void
3236    ui_seamless_syncbegin(unsigned long flags)
3237    {
3238            /* Destroy all seamless windows */
3239            while (g_seamless_windows)
3240            {
3241                    XDestroyWindow(g_display, g_seamless_windows->wnd);
3242                    seamless_remove_window(g_seamless_windows);
3243            }
3244    }

Legend:
Removed from v.1098  
changed lines
  Added in v.1132

  ViewVC Help
Powered by ViewVC 1.1.26