Commit f8b017fa authored by Benjamin Otte's avatar Benjamin Otte

x11: Simplify code for single-screen case

parent b3158686
...@@ -450,7 +450,7 @@ gdk_x11_device_core_window_at_position (GdkDevice *device, ...@@ -450,7 +450,7 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
} }
else else
{ {
gint i, screens, width, height; gint width, height;
GList *toplevels, *list; GList *toplevels, *list;
Window pointer_window, root, child; Window pointer_window, root, child;
int rootx = -1, rooty = -1; int rootx = -1, rooty = -1;
...@@ -459,59 +459,52 @@ gdk_x11_device_core_window_at_position (GdkDevice *device, ...@@ -459,59 +459,52 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
/* FIXME: untrusted clients case not multidevice-safe */ /* FIXME: untrusted clients case not multidevice-safe */
pointer_window = None; pointer_window = None;
screens = gdk_display_get_n_screens (display); screen = gdk_display_get_screen (display, 0);
toplevels = gdk_screen_get_toplevel_windows (screen);
for (i = 0; i < screens; ++i) for (list = toplevels; list != NULL; list = g_list_next (list))
{ {
screen = gdk_display_get_screen (display, i); window = GDK_WINDOW (list->data);
toplevels = gdk_screen_get_toplevel_windows (screen); xwindow = GDK_WINDOW_XID (window);
for (list = toplevels; list != NULL; list = g_list_next (list)) gdk_x11_display_error_trap_push (display);
XQueryPointer (xdisplay, xwindow,
&root, &child,
&rootx, &rooty,
&winx, &winy,
&xmask);
if (gdk_x11_display_error_trap_pop (display))
continue;
if (child != None)
{
pointer_window = child;
break;
}
gdk_window_get_geometry (window, NULL, NULL, &width, &height);
if (winx >= 0 && winy >= 0 && winx < width && winy < height)
{ {
window = GDK_WINDOW (list->data); /* A childless toplevel, or below another window? */
xwindow = GDK_WINDOW_XID (window); XSetWindowAttributes attributes;
gdk_x11_display_error_trap_push (display); Window w;
w = XCreateWindow (xdisplay, xwindow, winx, winy, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent,
0, &attributes);
XMapWindow (xdisplay, w);
XQueryPointer (xdisplay, xwindow, XQueryPointer (xdisplay, xwindow,
&root, &child, &root, &child,
&rootx, &rooty, &rootx, &rooty,
&winx, &winy, &winx, &winy,
&xmask); &xmask);
if (gdk_x11_display_error_trap_pop (display)) XDestroyWindow (xdisplay, w);
continue; if (child == w)
if (child != None)
{ {
pointer_window = child; pointer_window = xwindow;
break; break;
} }
gdk_window_get_geometry (window, NULL, NULL, &width, &height);
if (winx >= 0 && winy >= 0 && winx < width && winy < height)
{
/* A childless toplevel, or below another window? */
XSetWindowAttributes attributes;
Window w;
w = XCreateWindow (xdisplay, xwindow, winx, winy, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent,
0, &attributes);
XMapWindow (xdisplay, w);
XQueryPointer (xdisplay, xwindow,
&root, &child,
&rootx, &rooty,
&winx, &winy,
&xmask);
XDestroyWindow (xdisplay, w);
if (child == w)
{
pointer_window = xwindow;
break;
}
}
} }
g_list_free (toplevels);
if (pointer_window != None)
break;
} }
g_list_free (toplevels);
xwindow = pointer_window; xwindow = pointer_window;
} }
......
...@@ -512,27 +512,53 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device, ...@@ -512,27 +512,53 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
} }
else else
{ {
gint i, screens, width, height; gint width, height;
GList *toplevels, *list; GList *toplevels, *list;
Window pointer_window, root, child; Window pointer_window, root, child;
/* FIXME: untrusted clients case not multidevice-safe */ /* FIXME: untrusted clients case not multidevice-safe */
pointer_window = None; pointer_window = None;
screens = gdk_display_get_n_screens (display);
for (i = 0; i < screens; ++i) screen = gdk_display_get_screen (display, 0);
toplevels = gdk_screen_get_toplevel_windows (screen);
for (list = toplevels; list != NULL; list = g_list_next (list))
{ {
screen = gdk_display_get_screen (display, i); window = GDK_WINDOW (list->data);
toplevels = gdk_screen_get_toplevel_windows (screen); xwindow = GDK_WINDOW_XID (window);
for (list = toplevels; list != NULL; list = g_list_next (list))
/* Free previous button mask, if any */
g_free (button_state.mask);
gdk_x11_display_error_trap_push (display);
XIQueryPointer (xdisplay,
device_xi2->device_id,
xwindow,
&root, &child,
&xroot_x, &xroot_y,
&xwin_x, &xwin_y,
&button_state,
&mod_state,
&group_state);
if (gdk_x11_display_error_trap_pop (display))
continue;
if (child != None)
{
pointer_window = child;
break;
}
gdk_window_get_geometry (window, NULL, NULL, &width, &height);
if (xwin_x >= 0 && xwin_y >= 0 && xwin_x < width && xwin_y < height)
{ {
window = GDK_WINDOW (list->data); /* A childless toplevel, or below another window? */
xwindow = GDK_WINDOW_XID (window); XSetWindowAttributes attributes;
Window w;
/* Free previous button mask, if any */ free (button_state.mask);
g_free (button_state.mask);
gdk_x11_display_error_trap_push (display); w = XCreateWindow (xdisplay, xwindow, (int)xwin_x, (int)xwin_y, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent,
0, &attributes);
XMapWindow (xdisplay, w);
XIQueryPointer (xdisplay, XIQueryPointer (xdisplay,
device_xi2->device_id, device_xi2->device_id,
xwindow, xwindow,
...@@ -542,42 +568,12 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device, ...@@ -542,42 +568,12 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
&button_state, &button_state,
&mod_state, &mod_state,
&group_state); &group_state);
if (gdk_x11_display_error_trap_pop (display)) XDestroyWindow (xdisplay, w);
continue; if (child == w)
if (child != None)
{ {
pointer_window = child; pointer_window = xwindow;
break; break;
} }
gdk_window_get_geometry (window, NULL, NULL, &width, &height);
if (xwin_x >= 0 && xwin_y >= 0 && xwin_x < width && xwin_y < height)
{
/* A childless toplevel, or below another window? */
XSetWindowAttributes attributes;
Window w;
free (button_state.mask);
w = XCreateWindow (xdisplay, xwindow, (int)xwin_x, (int)xwin_y, 1, 1, 0,
CopyFromParent, InputOnly, CopyFromParent,
0, &attributes);
XMapWindow (xdisplay, w);
XIQueryPointer (xdisplay,
device_xi2->device_id,
xwindow,
&root, &child,
&xroot_x, &xroot_y,
&xwin_x, &xwin_y,
&button_state,
&mod_state,
&group_state);
XDestroyWindow (xdisplay, w);
if (child == w)
{
pointer_window = xwindow;
break;
}
}
} }
g_list_free (toplevels); g_list_free (toplevels);
......
...@@ -478,27 +478,21 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, ...@@ -478,27 +478,21 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
if (xevent->type == DestroyNotify && !is_substructure) if (xevent->type == DestroyNotify && !is_substructure)
{ {
int i, n; screen = GDK_X11_DISPLAY (display)->screen;
x11_screen = GDK_X11_SCREEN (screen);
n = gdk_display_get_n_screens (display); if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window)
for (i = 0; i < n; i++)
{ {
screen = gdk_display_get_screen (display, i); x11_screen->wmspec_check_window = None;
x11_screen = GDK_X11_SCREEN (screen); x11_screen->last_wmspec_check_time = 0;
g_free (x11_screen->window_manager_name);
if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window) x11_screen->window_manager_name = g_strdup ("unknown");
{
x11_screen->wmspec_check_window = None;
x11_screen->last_wmspec_check_time = 0;
g_free (x11_screen->window_manager_name);
x11_screen->window_manager_name = g_strdup ("unknown");
/* careful, reentrancy */ /* careful, reentrancy */
_gdk_x11_screen_window_manager_changed (screen); _gdk_x11_screen_window_manager_changed (screen);
return_val = FALSE; return_val = FALSE;
goto done; goto done;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment