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 */ |
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; |
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: |
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 |
{ |
{ |
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 |
|
|
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; |
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) |
3045 |
XSetWindowAttributes attribs; |
XSetWindowAttributes attribs; |
3046 |
XClassHint *classhints; |
XClassHint *classhints; |
3047 |
long input_mask; |
long input_mask; |
3048 |
seamless_window *sw; |
seamless_window *sw, *sw_parent; |
3049 |
|
|
3050 |
get_window_attribs(&attribs); |
/* Ignore CREATEs for existing windows */ |
3051 |
|
sw = seamless_get_window_by_id(id); |
3052 |
|
if (sw) |
3053 |
|
return; |
3054 |
|
|
3055 |
|
get_window_attribs(&attribs); |
3056 |
attribs.override_redirect = False; |
attribs.override_redirect = False; |
3057 |
|
|
3058 |
/* FIXME: Do not assume that -1, -1 is outside screen Consider |
/* FIXME: Do not assume that -1, -1 is outside screen Consider |
3075 |
XFree(classhints); |
XFree(classhints); |
3076 |
} |
} |
3077 |
|
|
3078 |
|
/* Set WM_TRANSIENT_FOR, if necessary */ |
3079 |
|
if (parent) |
3080 |
|
{ |
3081 |
|
sw_parent = seamless_get_window_by_id(parent); |
3082 |
|
if (sw_parent) |
3083 |
|
XSetTransientForHint(g_display, wnd, sw_parent->wnd); |
3084 |
|
else |
3085 |
|
warning("ui_seamless_create_window: No parent window 0x%lx\n", parent); |
3086 |
|
} |
3087 |
|
|
3088 |
/* FIXME: Support for Input Context:s */ |
/* FIXME: Support for Input Context:s */ |
3089 |
|
|
3090 |
get_input_mask(&input_mask); |
get_input_mask(&input_mask); |
3091 |
|
input_mask |= PropertyChangeMask; |
3092 |
|
|
3093 |
XSelectInput(g_display, wnd, input_mask); |
XSelectInput(g_display, wnd, input_mask); |
3094 |
|
|
3115 |
ui_seamless_destroy_window(unsigned long id, unsigned long flags) |
ui_seamless_destroy_window(unsigned long id, unsigned long flags) |
3116 |
{ |
{ |
3117 |
seamless_window *sw; |
seamless_window *sw; |
|
sw = seamless_get_window_by_id(id); |
|
3118 |
|
|
3119 |
|
sw = seamless_get_window_by_id(id); |
3120 |
if (!sw) |
if (!sw) |
3121 |
{ |
{ |
3122 |
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); |
3134 |
seamless_window *sw; |
seamless_window *sw; |
3135 |
|
|
3136 |
sw = seamless_get_window_by_id(id); |
sw = seamless_get_window_by_id(id); |
|
|
|
3137 |
if (!sw) |
if (!sw) |
3138 |
{ |
{ |
3139 |
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); |
3155 |
sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset); |
sw->width = MIN(MIN(width, width + x), g_width - sw->xoffset); |
3156 |
sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset); |
sw->height = MIN(MIN(height, height + y), g_height - sw->yoffset); |
3157 |
|
|
3158 |
|
/* If we move the window in a maximized state, then KDE won't |
3159 |
|
accept restoration */ |
3160 |
|
if (sw->state != SEAMLESSRDP_NORMAL) |
3161 |
|
return; |
3162 |
|
|
3163 |
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
/* FIXME: Perhaps use ewmh_net_moveresize_window instead */ |
3164 |
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); |
3165 |
} |
} |
3171 |
seamless_window *sw; |
seamless_window *sw; |
3172 |
|
|
3173 |
sw = seamless_get_window_by_id(id); |
sw = seamless_get_window_by_id(id); |
3174 |
|
if (!sw) |
3175 |
|
{ |
3176 |
|
warning("ui_seamless_settitle: No information for window 0x%lx\n", id); |
3177 |
|
return; |
3178 |
|
} |
3179 |
|
|
3180 |
XStoreName(g_display, sw->wnd, title); |
XStoreName(g_display, sw->wnd, title); |
3181 |
} |
} |
3187 |
seamless_window *sw; |
seamless_window *sw; |
3188 |
|
|
3189 |
sw = seamless_get_window_by_id(id); |
sw = seamless_get_window_by_id(id); |
3190 |
|
if (!sw) |
3191 |
|
{ |
3192 |
|
warning("ui_seamless_setstate: No information for window 0x%lx\n", id); |
3193 |
|
return; |
3194 |
|
} |
3195 |
|
|
3196 |
|
sw->state = state; |
3197 |
|
|
3198 |
switch (state) |
switch (state) |
3199 |
{ |
{ |
3200 |
case SEAMLESSRDP_NORMAL: |
case SEAMLESSRDP_NORMAL: |
3201 |
case SEAMLESSRDP_MAXIMIZED: |
case SEAMLESSRDP_MAXIMIZED: |
3202 |
/* FIXME */ |
ewmh_change_state(sw->wnd, state); |
3203 |
break; |
break; |
3204 |
case SEAMLESSRDP_MINIMIZED: |
case SEAMLESSRDP_MINIMIZED: |
3205 |
|
/* EWMH says: "if an Application asks to toggle _NET_WM_STATE_HIDDEN |
3206 |
|
the Window Manager should probably just ignore the request, since |
3207 |
|
_NET_WM_STATE_HIDDEN is a function of some other aspect of the window |
3208 |
|
such as minimization, rather than an independent state." Besides, |
3209 |
|
XIconifyWindow is easier. */ |
3210 |
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
XIconifyWindow(g_display, sw->wnd, DefaultScreen(g_display)); |
3211 |
break; |
break; |
3212 |
default: |
default: |
3214 |
break; |
break; |
3215 |
} |
} |
3216 |
} |
} |
3217 |
|
|
3218 |
|
|
3219 |
|
void |
3220 |
|
ui_seamless_syncbegin(unsigned long flags) |
3221 |
|
{ |
3222 |
|
/* Destroy all seamless windows */ |
3223 |
|
while (g_seamless_windows) |
3224 |
|
{ |
3225 |
|
XDestroyWindow(g_display, g_seamless_windows->wnd); |
3226 |
|
seamless_remove_window(g_seamless_windows); |
3227 |
|
} |
3228 |
|
} |