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,
}
else
{
gint i, screens, width, height;
gint width, height;
GList *toplevels, *list;
Window pointer_window, root, child;
int rootx = -1, rooty = -1;
......@@ -459,59 +459,52 @@ gdk_x11_device_core_window_at_position (GdkDevice *device,
/* FIXME: untrusted clients case not multidevice-safe */
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);
toplevels = gdk_screen_get_toplevel_windows (screen);
for (list = toplevels; list != NULL; list = g_list_next (list))
window = GDK_WINDOW (list->data);
xwindow = GDK_WINDOW_XID (window);
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);
xwindow = GDK_WINDOW_XID (window);
gdk_x11_display_error_trap_push (display);
/* 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);
if (gdk_x11_display_error_trap_pop (display))
continue;
if (child != None)
XDestroyWindow (xdisplay, w);
if (child == w)
{
pointer_window = child;
pointer_window = xwindow;
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;
}
......
......@@ -512,27 +512,53 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
}
else
{
gint i, screens, width, height;
gint width, height;
GList *toplevels, *list;
Window pointer_window, root, child;
/* FIXME: untrusted clients case not multidevice-safe */
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);
toplevels = gdk_screen_get_toplevel_windows (screen);
for (list = toplevels; list != NULL; list = g_list_next (list))
window = GDK_WINDOW (list->data);
xwindow = GDK_WINDOW_XID (window);
/* 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);
xwindow = GDK_WINDOW_XID (window);
/* A childless toplevel, or below another window? */
XSetWindowAttributes attributes;
Window w;
/* Free previous button mask, if any */
g_free (button_state.mask);
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,
device_xi2->device_id,
xwindow,
......@@ -542,42 +568,12 @@ gdk_x11_device_xi2_window_at_position (GdkDevice *device,
&button_state,
&mod_state,
&group_state);
if (gdk_x11_display_error_trap_pop (display))
continue;
if (child != None)
XDestroyWindow (xdisplay, w);
if (child == w)
{
pointer_window = child;
pointer_window = xwindow;
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);
......
......@@ -478,27 +478,21 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
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);
for (i = 0; i < n; i++)
if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window)
{
screen = gdk_display_get_screen (display, i);
x11_screen = GDK_X11_SCREEN (screen);
if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window)
{
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");
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 */
_gdk_x11_screen_window_manager_changed (screen);
/* careful, reentrancy */
_gdk_x11_screen_window_manager_changed (screen);
return_val = FALSE;
goto done;
}
return_val = FALSE;
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