/[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 1122 by astrand, Wed Mar 15 08:35:13 2006 UTC revision 1143 by ossman_, Thu Mar 16 08:41:53 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            XWMHints *hints;
59          int xoffset, yoffset;          int xoffset, yoffset;
60          int width, height;          int width, height;
61          unsigned int state;     /* normal/minimized/maximized */          int state;              /* normal/minimized/maximized. */
62          unsigned int desktop;          unsigned int desktop;
63          struct _seamless_window *next;          struct _seamless_window *next;
64  } seamless_window;  } seamless_window;
# Line 293  seamless_remove_window(seamless_window * Line 295  seamless_remove_window(seamless_window *
295                  if (sw == win)                  if (sw == win)
296                  {                  {
297                          *prevnext = sw->next;                          *prevnext = sw->next;
298                            XFree(sw->hints);
299                          xfree(sw);                          xfree(sw);
300                          return;                          return;
301                  }                  }
# Line 3044  ui_seamless_create_window(unsigned long Line 3047  ui_seamless_create_window(unsigned long
3047          Window wnd;          Window wnd;
3048          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
3049          XClassHint *classhints;          XClassHint *classhints;
3050            XSizeHints *sizehints;
3051          long input_mask;          long input_mask;
3052          seamless_window *sw, *sw_parent;          seamless_window *sw, *sw_parent;
3053    
# Line 3055  ui_seamless_create_window(unsigned long Line 3059  ui_seamless_create_window(unsigned long
3059          get_window_attribs(&attribs);          get_window_attribs(&attribs);
3060          attribs.override_redirect = False;          attribs.override_redirect = False;
3061    
3062          /* 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,  
3063                              InputOutput, g_visual,                              InputOutput, g_visual,
3064                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |                              CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
3065                              CWBorderPixel, &attribs);                              CWBorderPixel, &attribs);
3066    
3067          XStoreName(g_display, wnd, "rdesktop-seamless");          XStoreName(g_display, wnd, "SeamlessRDP");
3068            ewmh_set_wm_name(wnd, "SeamlessRDP");
3069    
3070          mwm_hide_decorations(wnd);          mwm_hide_decorations(wnd);
3071    
3072          classhints = XAllocClassHint();          classhints = XAllocClassHint();
3073          if (classhints != NULL)          if (classhints != NULL)
3074          {          {
3075                  classhints->res_name = classhints->res_class = "rdesktop";                  classhints->res_name = "rdesktop";
3076                    classhints->res_class = "SeamlessRDP";
3077                  XSetClassHint(g_display, wnd, classhints);                  XSetClassHint(g_display, wnd, classhints);
3078                  XFree(classhints);                  XFree(classhints);
3079          }          }
3080    
3081            /* WM_NORMAL_HINTS */
3082            sizehints = XAllocSizeHints();
3083            if (sizehints != NULL)
3084            {
3085                    sizehints->flags = USPosition;
3086                    XSetWMNormalHints(g_display, wnd, sizehints);
3087                    XFree(sizehints);
3088            }
3089    
3090          /* Set WM_TRANSIENT_FOR, if necessary */          /* Set WM_TRANSIENT_FOR, if necessary */
3091          if (parent)          if ((parent != 0x00000000) && (parent != 0xFFFFFFFF))
3092          {          {
3093                  sw_parent = seamless_get_window_by_id(parent);                  sw_parent = seamless_get_window_by_id(parent);
3094                  if (sw_parent)                  if (sw_parent)
# Line 3085  ui_seamless_create_window(unsigned long Line 3097  ui_seamless_create_window(unsigned long
3097                          warning("ui_seamless_create_window: No parent window 0x%lx\n", parent);                          warning("ui_seamless_create_window: No parent window 0x%lx\n", parent);
3098          }          }
3099    
3100    
3101          /* FIXME: Support for Input Context:s */          /* FIXME: Support for Input Context:s */
3102    
3103          get_input_mask(&input_mask);          get_input_mask(&input_mask);
# Line 3092  ui_seamless_create_window(unsigned long Line 3105  ui_seamless_create_window(unsigned long
3105    
3106          XSelectInput(g_display, wnd, input_mask);          XSelectInput(g_display, wnd, input_mask);
3107    
         XMapWindow(g_display, wnd);  
   
3108          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a          /* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a
3109             seamless window, we could try to close the window on the             seamless window, we could try to close the window on the
3110             serverside, instead of terminating rdesktop */             serverside, instead of terminating rdesktop */
# Line 3102  ui_seamless_create_window(unsigned long Line 3113  ui_seamless_create_window(unsigned long
3113          sw = malloc(sizeof(seamless_window));          sw = malloc(sizeof(seamless_window));
3114          sw->wnd = wnd;          sw->wnd = wnd;
3115          sw->id = id;          sw->id = id;
3116            sw->parent = parent;
3117            sw->hints = XAllocWMHints();
3118            sw->hints->flags = 0;
3119          sw->xoffset = 0;          sw->xoffset = 0;
3120          sw->yoffset = 0;          sw->yoffset = 0;
3121          sw->width = 0;          sw->width = 0;
3122          sw->height = 0;          sw->height = 0;
3123            sw->state = SEAMLESSRDP_NOTYETMAPPED;
3124            sw->desktop = 0;
3125          sw->next = g_seamless_windows;          sw->next = g_seamless_windows;
3126          g_seamless_windows = sw;          g_seamless_windows = sw;
3127  }  }
# Line 3157  ui_seamless_move_window(unsigned long id Line 3173  ui_seamless_move_window(unsigned long id
3173    
3174          /* 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
3175             accept restoration */             accept restoration */
3176          if (sw->state != SEAMLESSRDP_NORMAL)          switch (sw->state)
3177                  return;          {
3178                    case SEAMLESSRDP_MINIMIZED:
3179                    case SEAMLESSRDP_MAXIMIZED:
3180                            return;
3181            }
3182    
3183          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */          /* FIXME: Perhaps use ewmh_net_moveresize_window instead */
3184          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 3177  ui_seamless_settitle(unsigned long id, c Line 3197  ui_seamless_settitle(unsigned long id, c
3197                  return;                  return;
3198          }          }
3199    
3200            /* FIXME: Might want to convert the name for non-EWMH WMs */
3201          XStoreName(g_display, sw->wnd, title);          XStoreName(g_display, sw->wnd, title);
3202            ewmh_set_wm_name(sw->wnd, title);
3203  }  }
3204    
3205    
# Line 3193  ui_seamless_setstate(unsigned long id, u Line 3215  ui_seamless_setstate(unsigned long id, u
3215                  return;                  return;
3216          }          }
3217    
         sw->state = state;  
   
3218          switch (state)          switch (state)
3219          {          {
3220                  case SEAMLESSRDP_NORMAL:                  case SEAMLESSRDP_NORMAL:
3221                  case SEAMLESSRDP_MAXIMIZED:                  case SEAMLESSRDP_MAXIMIZED:
3222                          ewmh_change_state(sw->wnd, state);                          ewmh_change_state(sw->wnd, state);
3223                            XMapWindow(g_display, sw->wnd);
3224                          break;                          break;
3225                  case SEAMLESSRDP_MINIMIZED:                  case SEAMLESSRDP_MINIMIZED:
3226                          /* 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 3207  ui_seamless_setstate(unsigned long id, u Line 3228  ui_seamless_setstate(unsigned long id, u
3228                             _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
3229                             such as minimization, rather than an independent state." Besides,                             such as minimization, rather than an independent state." Besides,
3230                             XIconifyWindow is easier. */                             XIconifyWindow is easier. */
3231                          XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));                          if (sw->state == SEAMLESSRDP_NOTYETMAPPED)
3232                            {
3233                                    sw->hints->flags |= StateHint;
3234                                    sw->hints->initial_state = IconicState;
3235                                    XSetWMHints(g_display, sw->wnd, sw->hints);
3236                                    XMapWindow(g_display, sw->wnd);
3237                            }
3238                            else
3239                                    XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display));
3240                          break;                          break;
3241                  default:                  default:
3242                          warning("SeamlessRDP: Invalid state %d\n", state);                          warning("SeamlessRDP: Invalid state %d\n", state);
3243                          break;                          break;
3244          }          }
3245    
3246            /* Handle popups without parents through some ewm hints */
3247            if ((sw->state == SEAMLESSRDP_NOTYETMAPPED) && (sw->parent == 0xFFFFFFFF))
3248                    ewmh_set_window_popup(sw->wnd);
3249    
3250            sw->state = state;
3251    }
3252    
3253    
3254    void
3255    ui_seamless_syncbegin(unsigned long flags)
3256    {
3257            /* Destroy all seamless windows */
3258            while (g_seamless_windows)
3259            {
3260                    XDestroyWindow(g_display, g_seamless_windows->wnd);
3261                    seamless_remove_window(g_seamless_windows);
3262            }
3263  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26