/[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 1118 by astrand, Tue Mar 14 13:56:50 2006 UTC revision 1133 by astrand, Wed Mar 15 13:15:51 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          unsigned int state;     /* normal/minimized/maximized */          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 85  static Cursor g_current_cursor; Line 86  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;  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 300  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 1957  xwin_process_events(void) Line 1977  xwin_process_events(void)
1977                                          sw->state = ewmh_get_window_state(sw->wnd);                                          sw->state = ewmh_get_window_state(sw->wnd);
1978                                          seamless_send_state(sw->id, sw->state, 0);                                          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 3016  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, *sw_parent;          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);
3063    
3064          XStoreName(g_display, wnd, "rdesktop-seamless");          XStoreName(g_display, wnd, "SeamlessRDP");
3065    
3066          mwm_hide_decorations(wnd);          mwm_hide_decorations(wnd);
3067    
3068          classhints = XAllocClassHint();          classhints = XAllocClassHint();
3069          if (classhints != NULL)          if (classhints != NULL)
3070          {          {
3071                  classhints->res_name = classhints->res_class = "rdesktop";                  classhints->res_name = "rdesktop";
3072                    classhints->res_class = "SeamlessRDP";
3073                  XSetClassHint(g_display, wnd, classhints);                  XSetClassHint(g_display, wnd, classhints);
3074                  XFree(classhints);                  XFree(classhints);
3075          }          }
3076    
3077            /* WM_NORMAL_HINTS */
3078            sizehints = XAllocSizeHints();
3079            if (sizehints != NULL)
3080            {
3081                    sizehints->flags = USPosition;
3082                    XSetWMNormalHints(g_display, wnd, sizehints);
3083                    XFree(sizehints);
3084            }
3085    
3086          /* Set WM_TRANSIENT_FOR, if necessary */          /* Set WM_TRANSIENT_FOR, if necessary */
3087          if (parent)          if (parent)
3088          {          {
# Line 3060  ui_seamless_create_window(unsigned long Line 3100  ui_seamless_create_window(unsigned long
3100    
3101          XSelectInput(g_display, wnd, input_mask);          XSelectInput(g_display, wnd, input_mask);
3102    
         XMapWindow(g_display, wnd);  
   
3103          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a
3104             seamless window, we could try to close the window on the             seamless window, we could try to close the window on the
3105             serverside, instead of terminating rdesktop */             serverside, instead of terminating rdesktop */
# Line 3074  ui_seamless_create_window(unsigned long Line 3112  ui_seamless_create_window(unsigned long
3112          sw->yoffset = 0;          sw->yoffset = 0;
3113          sw->width = 0;          sw->width = 0;
3114          sw->height = 0;          sw->height = 0;
3115            sw->state = SEAMLESSRDP_NOTYETMAPPED;
3116            sw->desktop = 0;
3117          sw->next = g_seamless_windows;          sw->next = g_seamless_windows;
3118          g_seamless_windows = sw;          g_seamless_windows = sw;
3119  }  }
# Line 3125  ui_seamless_move_window(unsigned long id Line 3165  ui_seamless_move_window(unsigned long id
3165    
3166          /* If we move the window in a maximized state, then KDE won't          /* If we move the window in a maximized state, then KDE won't
3167             accept restoration */             accept restoration */
3168          if (sw->state != SEAMLESSRDP_NORMAL)          switch (sw->state)
3169                  return;          {
3170                    case SEAMLESSRDP_MINIMIZED:
3171                    case SEAMLESSRDP_MAXIMIZED:
3172                            return;
3173            }
3174    
3175          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */
3176          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);
# Line 3161  ui_seamless_setstate(unsigned long id, u Line 3205  ui_seamless_setstate(unsigned long id, u
3205                  return;                  return;
3206          }          }
3207    
3208            if (sw->state == SEAMLESSRDP_NOTYETMAPPED)
3209            {
3210                    XMapWindow(g_display, sw->wnd);
3211            }
3212    
3213          sw->state = state;          sw->state = state;
3214    
3215          switch (state)          switch (state)
# Line 3182  ui_seamless_setstate(unsigned long id, u Line 3231  ui_seamless_setstate(unsigned long id, u
3231                          break;                          break;
3232          }          }
3233  }  }
3234    
3235    
3236    void
3237    ui_seamless_syncbegin(unsigned long flags)
3238    {
3239            /* Destroy all seamless windows */
3240            while (g_seamless_windows)
3241            {
3242                    XDestroyWindow(g_display, g_seamless_windows->wnd);
3243                    seamless_remove_window(g_seamless_windows);
3244            }
3245    }

Legend:
Removed from v.1118  
changed lines
  Added in v.1133

  ViewVC Help
Powered by ViewVC 1.1.26