diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2020-05-19 17:48:28 +0100 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2020-05-19 17:48:28 +0100 |
commit | c12131ef30e745909a02bab6b3878465411fdbb0 (patch) | |
tree | e2b7c0625a377d5a9128a0e7a8f64ed530633340 | |
parent | bbda3aa71a50abec11b69dfd7a3ef73a5c8052d7 (diff) |
fix handling of enter/leave events in full screen revealer
The current code is using a single event handler for leave/enter and
looking at the mouse coordinates to decide whether it entered or left
the widget. This logic is completely broken when the window is
mimimized, because the mouse coordinates of the leave event are still
within the window boundary.
Switch to just have a separate handler for enter/leave events and stop
looking at mouse coordinates entirely.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | src/virt-viewer-timed-revealer.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/virt-viewer-timed-revealer.c b/src/virt-viewer-timed-revealer.c index acc55fc..4ee053d 100644 --- a/src/virt-viewer-timed-revealer.c +++ b/src/virt-viewer-timed-revealer.c @@ -81,38 +81,39 @@ virt_viewer_timed_revealer_grab_notify(VirtViewerTimedRevealer *self, } static gboolean -virt_viewer_timed_revealer_enter_leave_notify(VirtViewerTimedRevealer *self, - GdkEventCrossing *event, - gpointer user_data G_GNUC_UNUSED) +virt_viewer_timed_revealer_enter_notify(VirtViewerTimedRevealer *self, + GdkEventCrossing *event G_GNUC_UNUSED, + gpointer user_data G_GNUC_UNUSED) { VirtViewerTimedRevealerPrivate *priv = self->priv; - GdkDevice *device; - GtkAllocation allocation; - gint x, y; - gboolean entered; if (!priv->fullscreen) return FALSE; - device = gdk_event_get_device((GdkEvent *)event); + virt_viewer_timed_revealer_unregister_timeout(self); + if (!gtk_revealer_get_reveal_child(GTK_REVEALER(priv->revealer))) { + gtk_revealer_set_reveal_child(GTK_REVEALER(priv->revealer), TRUE); + } + + return FALSE; +} - gdk_window_get_device_position(event->window, device, &x, &y, 0); - gtk_widget_get_allocation(GTK_WIDGET(self), &allocation); +static gboolean +virt_viewer_timed_revealer_leave_notify(VirtViewerTimedRevealer *self, + GdkEventCrossing *event G_GNUC_UNUSED, + gpointer user_data G_GNUC_UNUSED) +{ + VirtViewerTimedRevealerPrivate *priv = self->priv; - entered = !!(x >= 0 && y >= 0 && x < allocation.width && y < allocation.height); + if (!priv->fullscreen) + return FALSE; /* * Pointer exited the toolbar, and toolbar is revealed. Schedule * a timeout to close it, if one isn't already scheduled. */ - if (!entered && gtk_revealer_get_reveal_child(GTK_REVEALER(priv->revealer))) { + if (gtk_revealer_get_reveal_child(GTK_REVEALER(priv->revealer))) { virt_viewer_timed_revealer_schedule_unreveal_timeout(self, 1000); - return FALSE; - } - - virt_viewer_timed_revealer_unregister_timeout(self); - if (entered && !gtk_revealer_get_reveal_child(GTK_REVEALER(priv->revealer))) { - gtk_revealer_set_reveal_child(GTK_REVEALER(priv->revealer), TRUE); } return FALSE; @@ -183,11 +184,11 @@ virt_viewer_timed_revealer_new(GtkWidget *toolbar) NULL); g_signal_connect(self, "enter-notify-event", - G_CALLBACK(virt_viewer_timed_revealer_enter_leave_notify), + G_CALLBACK(virt_viewer_timed_revealer_enter_notify), NULL); g_signal_connect(self, "leave-notify-event", - G_CALLBACK(virt_viewer_timed_revealer_enter_leave_notify), + G_CALLBACK(virt_viewer_timed_revealer_leave_notify), NULL); return self; |