[PATCH]: Make virt-viewer ungrab the mouse and keyboard on un-focus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All,
     I ran into an unfortunate situation today with virt-viewer.  I was working
inside a virt-viewer window with the mouse and keyboard grabbed.  In the
meantime, a long running job that I had started earlier finished up, and fired
up another virt-viewer window (to a different guest).  Unfortunately, however,
my window manager decided to place that new virt-viewer window on top of the one
I was currently working in.  Once that happened, I couldn't give input to either
window, so I couldn't ungrab the old window or kill the new window.

The attached patch prevents this situation by doing a forced ungrab when we get
a focus-out-event from GTK.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
diff -r e2ee322e3d1a src/main.c
--- a/src/main.c	Tue Apr 08 15:17:24 2008 -0400
+++ b/src/main.c	Fri Apr 18 21:12:02 2008 -0400
@@ -127,6 +127,12 @@ static void viewer_ungrab(GtkWidget *vnc
 	for (i = 0 ; i < LAST_MENU; i++) {
 		gtk_label_set_text_with_mnemonic(GTK_LABEL(menuItems[i].label), menuItems[i].ungrabbed_text);
 	}
+}
+
+static void focus_out_event(GtkWidget *window, void *dummy G_GNUC_UNUSED, GtkWidget *vnc)
+{
+	vnc_display_force_grab(VNC_DISPLAY(vnc), 0);
+	viewer_ungrab(vnc, window);
 }
 
 static void viewer_shutdown(GtkWidget *src G_GNUC_UNUSED, void *dummy G_GNUC_UNUSED, GtkWidget *vnc)
@@ -550,6 +556,8 @@ static GtkWidget *viewer_build_window(Vn
 			   GTK_SIGNAL_FUNC(viewer_initialized), window);
 	gtk_signal_connect(GTK_OBJECT(vnc), "vnc-disconnected",
 			   GTK_SIGNAL_FUNC(viewer_disconnected), NULL);
+	gtk_signal_connect(GTK_OBJECT(window), "focus-out-event",
+			   GTK_SIGNAL_FUNC(focus_out_event), vnc);
 
 	g_signal_connect(GTK_OBJECT(vnc), "vnc-auth-credential",
 			 GTK_SIGNAL_FUNC(viewer_credential), NULL);
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux