[virt-tools-list] [PATCH] timed-revealer: listen to the "grab-notify" signal

Fabiano Fidêncio fidencio at redhat.com
Wed Jun 29 13:36:07 UTC 2016


The "grab-notify" signal lets us know when our widget becomes
shadowed by a Gtk+ grab on another widget, or when it becomes unshadowed
due to a grab being removed.

That's exactly the case we face when dealing with "usb-redirection" and
"close" items of the fullscreen toolbar. And, currently, when these
widgets get closed the timed-revealer stays there forever. From now on
let's take advantage of the "grab-notify" signal and schedule a timeout
for the revealer when these widgets' windows get closed.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 src/virt-viewer-timed-revealer.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/virt-viewer-timed-revealer.c b/src/virt-viewer-timed-revealer.c
index 7892436..3c48ab5 100644
--- a/src/virt-viewer-timed-revealer.c
+++ b/src/virt-viewer-timed-revealer.c
@@ -74,6 +74,15 @@ virt_viewer_timed_revealer_schedule_unreveal_timeout(VirtViewerTimedRevealer *se
                                      self);
 }
 
+static void
+virt_viewer_timed_revealer_grab_notify(VirtViewerTimedRevealer *self,
+                                       gboolean was_grabbed,
+                                       gpointer user_data G_GNUC_UNUSED)
+{
+    if (was_grabbed)
+        virt_viewer_timed_revealer_schedule_unreveal_timeout(self, 1000);
+}
+
 static gboolean
 virt_viewer_timed_revealer_enter_leave_notify(VirtViewerTimedRevealer *self,
                                               GdkEventCrossing *event,
@@ -174,6 +183,10 @@ virt_viewer_timed_revealer_new(GtkWidget *toolbar)
     gtk_widget_show_all(GTK_WIDGET(self));
 
     g_signal_connect(self,
+                     "grab-notify",
+                     G_CALLBACK(virt_viewer_timed_revealer_grab_notify),
+                     NULL);
+    g_signal_connect(self,
                      "enter-notify-event",
                      G_CALLBACK(virt_viewer_timed_revealer_enter_leave_notify),
                      NULL);
-- 
2.7.4




More information about the virt-tools-list mailing list