54 |
{ |
{ |
55 |
Window wnd; |
Window wnd; |
56 |
unsigned long id; |
unsigned long id; |
57 |
|
XWMHints *hints; |
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; |
unsigned int desktop; |
62 |
struct _seamless_window *next; |
struct _seamless_window *next; |
63 |
} seamless_window; |
} seamless_window; |
294 |
if (sw == win) |
if (sw == win) |
295 |
{ |
{ |
296 |
*prevnext = sw->next; |
*prevnext = sw->next; |
297 |
|
XFree(sw->hints); |
298 |
xfree(sw); |
xfree(sw); |
299 |
return; |
return; |
300 |
} |
} |
3046 |
Window wnd; |
Window wnd; |
3047 |
XSetWindowAttributes attribs; |
XSetWindowAttributes attribs; |
3048 |
XClassHint *classhints; |
XClassHint *classhints; |
3049 |
|
XSizeHints *sizehints; |
3050 |
long input_mask; |
long input_mask; |
3051 |
seamless_window *sw, *sw_parent; |
seamless_window *sw, *sw_parent; |
3052 |
|
|
3058 |
get_window_attribs(&attribs); |
get_window_attribs(&attribs); |
3059 |
attribs.override_redirect = False; |
attribs.override_redirect = False; |
3060 |
|
|
3061 |
/* 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, |
|
3062 |
InputOutput, g_visual, |
InputOutput, g_visual, |
3063 |
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | |
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | |
3064 |
CWBorderPixel, &attribs); |
CWBorderPixel, &attribs); |
3065 |
|
|
3066 |
XStoreName(g_display, wnd, "rdesktop-seamless"); |
XStoreName(g_display, wnd, "SeamlessRDP"); |
3067 |
|
ewmh_set_wm_name(wnd, "SeamlessRDP"); |
3068 |
|
|
3069 |
mwm_hide_decorations(wnd); |
mwm_hide_decorations(wnd); |
3070 |
|
|
3071 |
classhints = XAllocClassHint(); |
classhints = XAllocClassHint(); |
3072 |
if (classhints != NULL) |
if (classhints != NULL) |
3073 |
{ |
{ |
3074 |
classhints->res_name = classhints->res_class = "rdesktop"; |
classhints->res_name = "rdesktop"; |
3075 |
|
classhints->res_class = "SeamlessRDP"; |
3076 |
XSetClassHint(g_display, wnd, classhints); |
XSetClassHint(g_display, wnd, classhints); |
3077 |
XFree(classhints); |
XFree(classhints); |
3078 |
} |
} |
3079 |
|
|
3080 |
|
/* WM_NORMAL_HINTS */ |
3081 |
|
sizehints = XAllocSizeHints(); |
3082 |
|
if (sizehints != NULL) |
3083 |
|
{ |
3084 |
|
sizehints->flags = USPosition; |
3085 |
|
XSetWMNormalHints(g_display, wnd, sizehints); |
3086 |
|
XFree(sizehints); |
3087 |
|
} |
3088 |
|
|
3089 |
|
/* Handle popups without parents through some ewm hints */ |
3090 |
|
if (parent == 0xFFFFFFFF) |
3091 |
|
ewmh_set_window_popup(wnd); |
3092 |
/* Set WM_TRANSIENT_FOR, if necessary */ |
/* Set WM_TRANSIENT_FOR, if necessary */ |
3093 |
if (parent) |
else if (parent != 0x00000000) |
3094 |
{ |
{ |
3095 |
sw_parent = seamless_get_window_by_id(parent); |
sw_parent = seamless_get_window_by_id(parent); |
3096 |
if (sw_parent) |
if (sw_parent) |
3099 |
warning("ui_seamless_create_window: No parent window 0x%lx\n", parent); |
warning("ui_seamless_create_window: No parent window 0x%lx\n", parent); |
3100 |
} |
} |
3101 |
|
|
3102 |
|
|
3103 |
/* FIXME: Support for Input Context:s */ |
/* FIXME: Support for Input Context:s */ |
3104 |
|
|
3105 |
get_input_mask(&input_mask); |
get_input_mask(&input_mask); |
3107 |
|
|
3108 |
XSelectInput(g_display, wnd, input_mask); |
XSelectInput(g_display, wnd, input_mask); |
3109 |
|
|
|
XMapWindow(g_display, wnd); |
|
|
|
|
3110 |
/* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a |
/* handle the WM_DELETE_WINDOW protocol. FIXME: When killing a |
3111 |
seamless window, we could try to close the window on the |
seamless window, we could try to close the window on the |
3112 |
serverside, instead of terminating rdesktop */ |
serverside, instead of terminating rdesktop */ |
3115 |
sw = malloc(sizeof(seamless_window)); |
sw = malloc(sizeof(seamless_window)); |
3116 |
sw->wnd = wnd; |
sw->wnd = wnd; |
3117 |
sw->id = id; |
sw->id = id; |
3118 |
|
sw->hints = XAllocWMHints(); |
3119 |
|
sw->hints->flags = 0; |
3120 |
sw->xoffset = 0; |
sw->xoffset = 0; |
3121 |
sw->yoffset = 0; |
sw->yoffset = 0; |
3122 |
sw->width = 0; |
sw->width = 0; |
3123 |
sw->height = 0; |
sw->height = 0; |
3124 |
|
sw->state = SEAMLESSRDP_NOTYETMAPPED; |
3125 |
|
sw->desktop = 0; |
3126 |
sw->next = g_seamless_windows; |
sw->next = g_seamless_windows; |
3127 |
g_seamless_windows = sw; |
g_seamless_windows = sw; |
3128 |
} |
} |
3174 |
|
|
3175 |
/* 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 |
3176 |
accept restoration */ |
accept restoration */ |
3177 |
if (sw->state != SEAMLESSRDP_NORMAL) |
switch (sw->state) |
3178 |
return; |
{ |
3179 |
|
case SEAMLESSRDP_MINIMIZED: |
3180 |
|
case SEAMLESSRDP_MAXIMIZED: |
3181 |
|
return; |
3182 |
|
} |
3183 |
|
|
3184 |
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
3185 |
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); |
3198 |
return; |
return; |
3199 |
} |
} |
3200 |
|
|
3201 |
|
/* FIXME: Might want to convert the name for non-EWMH WMs */ |
3202 |
XStoreName(g_display, sw->wnd, title); |
XStoreName(g_display, sw->wnd, title); |
3203 |
|
ewmh_set_wm_name(sw->wnd, title); |
3204 |
} |
} |
3205 |
|
|
3206 |
|
|
3216 |
return; |
return; |
3217 |
} |
} |
3218 |
|
|
|
sw->state = state; |
|
|
|
|
3219 |
switch (state) |
switch (state) |
3220 |
{ |
{ |
3221 |
case SEAMLESSRDP_NORMAL: |
case SEAMLESSRDP_NORMAL: |
3222 |
case SEAMLESSRDP_MAXIMIZED: |
case SEAMLESSRDP_MAXIMIZED: |
3223 |
ewmh_change_state(sw->wnd, state); |
ewmh_change_state(sw->wnd, state); |
3224 |
|
XMapWindow(g_display, sw->wnd); |
3225 |
break; |
break; |
3226 |
case SEAMLESSRDP_MINIMIZED: |
case SEAMLESSRDP_MINIMIZED: |
3227 |
/* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN |
/* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN |
3229 |
_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 |
3230 |
such as minimization, rather than an independent state." Besides, |
such as minimization, rather than an independent state." Besides, |
3231 |
XIconifyWindow is easier. */ |
XIconifyWindow is easier. */ |
3232 |
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
if (sw->state == SEAMLESSRDP_NOTYETMAPPED) |
3233 |
|
{ |
3234 |
|
sw->hints->flags |= StateHint; |
3235 |
|
sw->hints->initial_state = IconicState; |
3236 |
|
XSetWMHints(g_display, sw->wnd, sw->hints); |
3237 |
|
XMapWindow(g_display, sw->wnd); |
3238 |
|
} |
3239 |
|
else |
3240 |
|
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
3241 |
break; |
break; |
3242 |
default: |
default: |
3243 |
warning("SeamlessRDP: Invalid state %d\n", state); |
warning("SeamlessRDP: Invalid state %d\n", state); |
3244 |
break; |
break; |
3245 |
} |
} |
3246 |
|
|
3247 |
|
sw->state = state; |
3248 |
} |
} |
3249 |
|
|
3250 |
|
|