summaryrefslogtreecommitdiff
path: root/gtk/gtkwindow.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2020-12-03 22:50:31 +0100
committerJonas Ådahl <jadahl@gmail.com>2020-12-07 20:37:29 +0100
commit19d2a4ab947f807b68a5d2cda5c68b6bfa0a5d17 (patch)
tree092817abc1236b0e79097709472d21e84a6930f9 /gtk/gtkwindow.c
parent6ee7535af07e14193436876eafed6297916d0ca2 (diff)
downloadgtk+-19d2a4ab947f807b68a5d2cda5c68b6bfa0a5d17.tar.gz
gtk/window: Only fake motion events on windows with pending allocations
This fixes an issue where the focus of the window continuously received fake motion events even when a popover was open, making input events end up behind the popover. It also adds a comment describing why motion events are requested. Note that popovers won't work with this, and it's possible both in the past and now that sporadic missplaced motion events will appear, e.g. when a window changes allocation but a popover is open.
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r--gtk/gtkwindow.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 2ffc166894..07c23b0761 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1894,7 +1894,6 @@ gtk_window_native_layout (GtkNative *native,
GtkWindow *window = GTK_WINDOW (native);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *widget = GTK_WIDGET (native);
- GdkSeat *seat;
if (priv->surface_width != width || priv->surface_height != height)
{
@@ -1903,21 +1902,30 @@ gtk_window_native_layout (GtkNative *native,
priv->surface_height = height;
}
- seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
- if (seat)
+ /* This fake motion event is needed for getting up to date pointer focus
+ * and coordinates when tho pointer didn't move but the layout changed
+ * within the window.
+ */
+ if (gtk_widget_needs_allocate (widget))
{
- GdkDevice *device;
- GtkWidget *focus;
+ GdkSeat *seat;
- device = gdk_seat_get_pointer (seat);
- focus = gtk_window_lookup_pointer_focus_widget (GTK_WINDOW (widget),
- device, NULL);
- if (focus)
+ seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
+ if (seat)
{
- GdkSurface *focus_surface =
- gtk_native_get_surface (gtk_widget_get_native (focus));
+ GdkDevice *device;
+ GtkWidget *focus;
+
+ device = gdk_seat_get_pointer (seat);
+ focus = gtk_window_lookup_pointer_focus_widget (GTK_WINDOW (widget),
+ device, NULL);
+ if (focus)
+ {
+ GdkSurface *focus_surface =
+ gtk_native_get_surface (gtk_widget_get_native (focus));
- gdk_surface_request_motion (focus_surface);
+ gdk_surface_request_motion (focus_surface);
+ }
}
}