summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2013-05-09 15:23:33 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2013-05-11 21:18:31 +0200
commit8cbd5d745c221f788878c9c713f3b46a25828d3f (patch)
tree876cd02343c09f3dcff6731b47af86b4c4355c59
parent51d57cecde47b0b4f074654931ddaf4e0d1bef90 (diff)
widget: release keys when the grab is taken elsewhere
gtk may propagate some press event up to the Spice display widget, but a widget may take focus and grab the release event, so the guest will keep seeing the key pressed. Releasing the keys when the grab is taken solves two menu-related bugs: https://bugzilla.redhat.com/show_bug.cgi?id=820829 https://bugzilla.redhat.com/show_bug.cgi?id=924577
-rw-r--r--gtk/spice-widget.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index b882106..b938e87 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -137,6 +137,7 @@ static void channel_destroy(SpiceSession *s, SpiceChannel *channel, gpointer dat
static void sync_keyboard_lock_modifiers(SpiceDisplay *display);
static void cursor_invalidate(SpiceDisplay *display);
static void update_area(SpiceDisplay *display, gint x, gint y, gint width, gint height);
+static void release_keys(SpiceDisplay *display);
/* ---------------------------------------------------------------- */
@@ -533,6 +534,14 @@ static void drag_data_received_callback(SpiceDisplay *self,
gtk_drag_finish(drag_context, TRUE, FALSE, time);
}
+static void grab_notify(SpiceDisplay *display, gboolean was_grabbed)
+{
+ SPICE_DEBUG("grab notify %d", was_grabbed);
+
+ if (was_grabbed == FALSE)
+ release_keys(display);
+}
+
static void spice_display_init(SpiceDisplay *display)
{
GtkWidget *widget = GTK_WIDGET(display);
@@ -542,9 +551,12 @@ static void spice_display_init(SpiceDisplay *display)
d = display->priv = SPICE_DISPLAY_GET_PRIVATE(display);
g_signal_connect(display, "grab-broken-event", G_CALLBACK(grab_broken), NULL);
+ g_signal_connect(display, "grab-notify", G_CALLBACK(grab_notify), NULL);
+
gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, &targets, 1, GDK_ACTION_COPY);
g_signal_connect(display, "drag-data-received",
G_CALLBACK(drag_data_received_callback), NULL);
+
gtk_widget_add_events(widget,
GDK_STRUCTURE_MASK |
GDK_POINTER_MOTION_MASK |