/[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 1144 by ossman_, Thu Mar 16 10:14:18 2006 UTC
# Line 54  typedef struct _seamless_window Line 54  typedef struct _seamless_window
54  {  {
55          Window wnd;          Window wnd;
56          unsigned long id;          unsigned long id;
57            unsigned long parent;
58          int xoffset, yoffset;          int xoffset, yoffset;
59          int width, height;          int width, height;
60          unsigned int state;     /* normal/minimized/maximized */          int state;              /* normal/minimized/maximized. */
61            unsigned int desktop;
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;
# Line 85  static Cursor g_current_cursor; Line 87  static Cursor g_current_cursor;
87  static HCURSOR g_null_cursor = NULL;  static HCURSOR g_null_cursor = NULL;
88  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
89  extern Atom g_net_wm_state_atom;  extern Atom g_net_wm_state_atom;
90    extern Atom g_net_wm_desktop_atom;
91  static BOOL g_focused;  static BOOL g_focused;
92  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
93  /* Indicates that:  /* Indicates that:
# Line 300  seamless_remove_window(seamless_window * Line 303  seamless_remove_window(seamless_window *
303  }  }
304    
305    
306    /* Move all windows except wnd to new desktop */
307    static void
308    seamless_all_to_desktop(Window wnd, unsigned int desktop)
309    {
310            seamless_window *sw;
311            for (sw = g_seamless_windows; sw; sw = sw->next)
312            {
313                    if (sw->wnd == wnd)
314                            continue;
315                    if (sw->desktop != desktop)
316                    {
317                            ewmh_move_to_desktop(sw->wnd, desktop);
318                            sw->desktop = desktop;
319                    }
320            }
321    }
322    
323    
324  static void  static void
325  mwm_hide_decorations(Window wnd)  mwm_hide_decorations(Window wnd)
326  {  {
# Line 1957  xwin_process_events(void) Line 1978  xwin_process_events(void)
1978                                          sw->state = ewmh_get_window_state(sw->wnd);                                          sw->state = ewmh_get_window_state(sw->wnd);
1979                                          seamless_send_state(sw->id, sw->state, 0);                                          seamless_send_state(sw->id, sw->state, 0);
1980                                  }                                  }
1981    
1982                                    if ((xevent.xproperty.atom == g_net_wm_desktop_atom)
1983                                        && (xevent.xproperty.state == PropertyNewValue))
1984                                    {
1985                                            sw->desktop = ewmh_get_window_desktop(sw->wnd);
1986                                            seamless_all_to_desktop(sw->wnd, sw->desktop);
1987                                    }
1988    
1989                                  break;                                  break;
1990                          case MapNotify:                          case MapNotify:
1991                                  if (!g_seamless_rdp)                                  if (!g_seamless_rdp)
# Line 3016  ui_seamless_create_window(unsigned long Line 3045  ui_seamless_create_window(unsigned long
3045          Window wnd;          Window wnd;
3046          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
3047          XClassHint *classhints;          XClassHint *classhints;
3048            XSizeHints *sizehints;
3049          long input_mask;          long input_mask;
3050          seamless_window *sw, *sw_parent;          seamless_window *sw, *sw_parent;
3051    
3052          get_window_attribs(&attribs);          /* Ignore CREATEs for existing windows */
3053            sw = seamless_get_window_by_id(id);
3054            if (sw)
3055                    return;
3056    
3057            get_window_attribs(&attribs);
3058          attribs.override_redirect = False;          attribs.override_redirect = False;
3059    
3060          /* 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,  
3061                              InputOutput, g_visual,                              InputOutput, g_visual,
3062                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
3063                              CWBorderPixel, &attribs);                              CWBorderPixel, &attribs);
3064    
3065          XStoreName(g_display, wnd, "rdesktop-seamless");          XStoreName(g_display, wnd, "SeamlessRDP");
3066            ewmh_set_wm_name(wnd, "SeamlessRDP");
3067    
3068          mwm_hide_decorations(wnd);          mwm_hide_decorations(wnd);
3069    
3070          classhints = XAllocClassHint();          classhints = XAllocClassHint();
3071          if (classhints != NULL)          if (classhints != NULL)
3072          {          {
3073                  classhints->res_name = classhints->res_class = "rdesktop";                  classhints->res_name = "rdesktop";
3074                    classhints->res_class = "SeamlessRDP";
3075                  XSetClassHint(g_display, wnd, classhints);                  XSetClassHint(g_display, wnd, classhints);
3076                  XFree(classhints);                  XFree(classhints);
3077          }          }
3078    
3079            /* WM_NORMAL_HINTS */
3080            sizehints = XAllocSizeHints();
3081            if (sizehints != NULL)
3082            {
3083                    sizehints->flags = USPosition;
3084                    XSetWMNormalHints(g_display, wnd, sizehints);
3085                    XFree(sizehints);
3086            }
3087    
3088          /* Set WM_TRANSIENT_FOR, if necessary */          /* Set WM_TRANSIENT_FOR, if necessary */
3089          if (parent)          if ((parent != 0x00000000) && (parent != 0xFFFFFFFF))
3090          {          {
3091                  sw_parent = seamless_get_window_by_id(parent);                  sw_parent = seamless_get_window_by_id(parent);
3092                  if (sw_parent)                  if (sw_parent)
# Line 3053  ui_seamless_create_window(unsigned long Line 3095  ui_seamless_create_window(unsigned long
3095                          warning("ui_seamless_create_window: No parent window 0x%lx\n", parent);                          warning("ui_seamless_create_window: No parent window 0x%lx\n", parent);
3096          }          }
3097    
3098    
3099          /* FIXME: Support for Input Context:s */          /* FIXME: Support for Input Context:s */
3100    
3101          get_input_mask(&input_mask);          get_input_mask(&input_mask);
# Line 3060  ui_seamless_create_window(unsigned long Line 3103  ui_seamless_create_window(unsigned long
3103    
3104          XSelectInput(g_display, wnd, input_mask);          XSelectInput(g_display, wnd, input_mask);
3105    
         XMapWindow(g_display, wnd);  
   
3106          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a
3107             seamless window, we could try to close the window on the             seamless window, we could try to close the window on the
3108             serverside, instead of terminating rdesktop */             serverside, instead of terminating rdesktop */
# Line 3070  ui_seamless_create_window(unsigned long Line 3111  ui_seamless_create_window(unsigned long
3111          sw = malloc(sizeof(seamless_window));          sw = malloc(sizeof(seamless_window));
3112          sw->wnd = wnd;          sw->wnd = wnd;
3113          sw->id = id;          sw->id = id;
3114            sw->parent = parent;
3115          sw->xoffset = 0;          sw->xoffset = 0;
3116          sw->yoffset = 0;          sw->yoffset = 0;
3117          sw->width = 0;          sw->width = 0;
3118          sw->height = 0;          sw->height = 0;
3119            sw->state = SEAMLESSRDP_NOTYETMAPPED;
3120            sw->desktop = 0;
3121          sw->next = g_seamless_windows;          sw->next = g_seamless_windows;
3122          g_seamless_windows = sw;          g_seamless_windows = sw;
3123  }  }
# Line 3125  ui_seamless_move_window(unsigned long id Line 3169  ui_seamless_move_window(unsigned long id
3169    
3170          /* 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
3171             accept restoration */             accept restoration */
3172          if (sw->state != SEAMLESSRDP_NORMAL)          switch (sw->state)
3173                  return;          {
3174                    case SEAMLESSRDP_MINIMIZED:
3175                    case SEAMLESSRDP_MAXIMIZED:
3176                            return;
3177            }
3178    
3179          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */
3180          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 3145  ui_seamless_settitle(unsigned long id, c Line 3193  ui_seamless_settitle(unsigned long id, c
3193                  return;                  return;
3194          }          }
3195    
3196            /* FIXME: Might want to convert the name for non-EWMH WMs */
3197          XStoreName(g_display, sw->wnd, title);          XStoreName(g_display, sw->wnd, title);
3198            ewmh_set_wm_name(sw->wnd, title);
3199  }  }
3200    
3201    
# Line 3161  ui_seamless_setstate(unsigned long id, u Line 3211  ui_seamless_setstate(unsigned long id, u
3211                  return;                  return;
3212          }          }
3213    
         sw->state = state;  
   
3214          switch (state)          switch (state)
3215          {          {
3216                  case SEAMLESSRDP_NORMAL:                  case SEAMLESSRDP_NORMAL:
3217                  case SEAMLESSRDP_MAXIMIZED:                  case SEAMLESSRDP_MAXIMIZED:
3218                          ewmh_change_state(sw->wnd, state);                          ewmh_change_state(sw->wnd, state);
3219                            XMapWindow(g_display, sw->wnd);
3220                          break;                          break;
3221                  case SEAMLESSRDP_MINIMIZED:                  case SEAMLESSRDP_MINIMIZED:
3222                          /* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN                          /* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN
# Line 3175  ui_seamless_setstate(unsigned long id, u Line 3224  ui_seamless_setstate(unsigned long id, u
3224                             _NET_WM_STATE_HIDDEN is a function of some other aspect of the window                             _NET_WM_STATE_HIDDEN is a function of some other aspect of the window
3225                             such as minimization, rather than an independent state." Besides,                             such as minimization, rather than an independent state." Besides,
3226                             XIconifyWindow is easier. */                             XIconifyWindow is easier. */
3227                          XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));                          if (sw->state == SEAMLESSRDP_NOTYETMAPPED)
3228                            {
3229                                    XWMHints *hints;
3230                                    hints = XAllocWMHints();
3231                                    hints->flags = StateHint;
3232                                    hints->initial_state = IconicState;
3233                                    XSetWMHints(g_display, sw->wnd, hints);
3234                                    XFree(hints);
3235                                    XMapWindow(g_display, sw->wnd);
3236                            }
3237                            else
3238                                    XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));
3239                          break;                          break;
3240                  default:                  default:
3241                          warning("SeamlessRDP: Invalid state %d\n", state);                          warning("SeamlessRDP: Invalid state %d\n", state);
3242                          break;                          break;
3243          }          }
3244    
3245            /* Handle popups without parents through some ewm hints */
3246            if ((sw->state == SEAMLESSRDP_NOTYETMAPPED) && (sw->parent == 0xFFFFFFFF))
3247                    ewmh_set_window_popup(sw->wnd);
3248    
3249            sw->state = state;
3250    }
3251    
3252    
3253    void
3254    ui_seamless_syncbegin(unsigned long flags)
3255    {
3256            /* Destroy all seamless windows */
3257            while (g_seamless_windows)
3258            {
3259                    XDestroyWindow(g_display, g_seamless_windows->wnd);
3260                    seamless_remove_window(g_seamless_windows);
3261            }
3262  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26