summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-11-23 07:40:19 +0100
committerinfirit <[email protected]>2014-11-23 07:45:53 +0100
commit91ae83fa5dce263b568909cbe143fa4f833057c8 (patch)
tree963eede4e9e5e0aac2e8c90dd3f7a91ecd8106b1
parentb75dcdb46cce1e2dc864e361902b293f7103a5e3 (diff)
downloadmate-panel-91ae83fa5dce263b568909cbe143fa4f833057c8.tar.bz2
mate-panel-91ae83fa5dce263b568909cbe143fa4f833057c8.tar.xz
Gtk3: Port gdk_keyboard_grab to gdk_device
Based on gnome-panel commits: menu: 434e491bc4a280037638fb828529856276de3512 toplevel: e0bf14009416f19484bd0431a85744db7d907eb9 force-quit: 2760d89026ea5cf5bf25a4b8ceaf9f6dd2651043
-rw-r--r--mate-panel/menu.c13
-rw-r--r--mate-panel/panel-force-quit.c21
-rw-r--r--mate-panel/panel-toplevel.c16
3 files changed, 43 insertions, 7 deletions
diff --git a/mate-panel/menu.c b/mate-panel/menu.c
index f92dbeaa..c9e0bcf6 100644
--- a/mate-panel/menu.c
+++ b/mate-panel/menu.c
@@ -690,6 +690,7 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context)
gboolean status;
GdkDisplay *display;
GdkDevice *pointer;
+ GdkDevice *keyboard;
GdkDeviceManager *device_manager;
#endif
GdkWindow *window = gtk_widget_get_window (xgrab_shell);
@@ -698,10 +699,12 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context)
#if GTK_CHECK_VERSION (3, 0, 0)
display = gdk_window_get_display (window);
device_manager = gdk_display_get_device_manager (display);
+ keyboard = gdk_device_get_associated_device (pointer);
pointer = gdk_device_manager_get_client_pointer (device_manager);
/* FIXMEgpoo: Not sure if report to GDK_OWNERSHIP_WINDOW
- or GDK_OWNERSHIP_APPLICATION */
+ or GDK_OWNERSHIP_APPLICATION Idem for the
+ keyboard below */
status = gdk_device_grab (pointer, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_BUTTON_PRESS_MASK
@@ -712,17 +715,23 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context)
cursor, GDK_CURRENT_TIME);
if (!status)
+ {
+ if (gdk_device_grab (keyboard, window,
+ GDK_OWNERSHIP_WINDOW, TRUE,
+ GDK_KEY_PRESS | GDK_KEY_RELEASE,
+ NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
+ {
#else
if ((gdk_pointer_grab (window, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK,
NULL, cursor, GDK_CURRENT_TIME) == 0))
-#endif
{
if (gdk_keyboard_grab (window, TRUE,
GDK_CURRENT_TIME) == 0)
{
+#endif
/* FIXME fix for GTK3 */
#if !GTK_CHECK_VERSION (3, 0, 0)
GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE;
diff --git a/mate-panel/panel-force-quit.c b/mate-panel/panel-force-quit.c
index bc3e6dda..9b3afaa0 100644
--- a/mate-panel/panel-force-quit.c
+++ b/mate-panel/panel-force-quit.c
@@ -104,6 +104,7 @@ remove_popup (GtkWidget *popup)
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDevice *pointer;
+ GdkDevice *keyboard;
GdkDeviceManager *device_manager;
#endif
@@ -117,12 +118,14 @@ remove_popup (GtkWidget *popup)
display = gdk_window_get_display (root);
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
+ gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
#else
gdk_pointer_ungrab (GDK_CURRENT_TIME);
-#endif
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+#endif
}
static gboolean
@@ -309,6 +312,7 @@ panel_force_quit (GdkScreen *screen,
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDevice *pointer;
+ GdkDevice *keyboard;
GdkDeviceManager *device_manager;
#endif
@@ -323,6 +327,7 @@ panel_force_quit (GdkScreen *screen,
display = gdk_window_get_display (root);
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
status = gdk_device_grab (pointer, root,
GDK_OWNERSHIP_NONE, FALSE,
@@ -330,12 +335,22 @@ panel_force_quit (GdkScreen *screen,
cross, time);
g_object_unref (cross);
+
+ status = gdk_device_grab (keyboard, root,
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_KEY_PRESS | GDK_KEY_RELEASE,
+ NULL, time);
+
+ if (status != GDK_GRAB_SUCCESS) {
+ g_warning ("Pointer grab failed\n");
+ remove_popup (popup);
+ return;
+ }
#else
status = gdk_pointer_grab (root, FALSE, GDK_BUTTON_PRESS_MASK,
NULL, cross, time);
gdk_cursor_unref (cross);
-#endif
if (status != GDK_GRAB_SUCCESS) {
g_warning ("Pointer grab failed\n");
@@ -349,6 +364,6 @@ panel_force_quit (GdkScreen *screen,
remove_popup (popup);
return;
}
-
+#endif
gdk_flush ();
}
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index 1e0ab359..4232e56b 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -444,6 +444,7 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDevice *pointer;
+ GdkDevice *keyboard;
GdkDeviceManager *device_manager;
#endif
@@ -503,6 +504,7 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp
display = gdk_window_get_display (window);
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
gdk_device_grab (pointer, window,
GDK_OWNERSHIP_NONE, FALSE,
@@ -510,17 +512,24 @@ static void panel_toplevel_begin_grab_op(PanelToplevel* toplevel, PanelGrabOpTyp
cursor, time_);
g_object_unref (cursor);
+
+ if (grab_keyboard)
+ gdk_device_grab (keyboard, window,
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_KEY_PRESS | GDK_KEY_RELEASE,
+ NULL, time_);
+}
#else
gdk_pointer_grab (window, FALSE,
GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL, cursor, time_);
gdk_cursor_unref (cursor);
-#endif
if (grab_keyboard)
gdk_keyboard_grab (window, FALSE, time_);
}
+#endif
static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
{
@@ -528,6 +537,7 @@ static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
GdkDevice *pointer;
+ GdkDevice *keyboard;
GdkDeviceManager *device_manager;
#endif
@@ -544,12 +554,14 @@ static void panel_toplevel_end_grab_op (PanelToplevel* toplevel, guint32 time_)
display = gtk_widget_get_display (widget);
device_manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
gdk_device_ungrab (pointer, time_);
+ gdk_device_ungrab (keyboard, time_);
#else
gdk_pointer_ungrab (time_);
-#endif
gdk_keyboard_ungrab (time_);
+#endif
}
static void panel_toplevel_cancel_grab_op(PanelToplevel* toplevel, guint32 time_)