summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-10-24 14:21:04 +0200
committerinfirit <[email protected]>2014-10-24 15:40:43 +0200
commite10d87f85996697b6623723640802dafc0c03174 (patch)
tree758ef9dd3867c2113ec2592bce5c7030010ae6fe
parent897be1b007ea4789a88716d5889e5b9f8c88fbf7 (diff)
downloadmarco-e10d87f85996697b6623723640802dafc0c03174.tar.bz2
marco-e10d87f85996697b6623723640802dafc0c03174.tar.xz
Replace in GTK3 deprecated Gdk api
Taken from metacity commit: 238e83a98cf014c9b1082d21541e63f102d441d6 From: Alberts Muktupāvels <[email protected]>
-rw-r--r--src/tools/marco-mag.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tools/marco-mag.c b/src/tools/marco-mag.c
index 0e90d95e..157c9846 100644
--- a/src/tools/marco-mag.c
+++ b/src/tools/marco-mag.c
@@ -158,9 +158,17 @@ grab_area_at_mouse (GtkWidget *invisible,
static void
shutdown_grab (void)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDeviceManager *manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ GdkDevice *device = gdk_device_manager_get_client_pointer (manager);
+
+ gdk_device_ungrab (device, gtk_get_current_event_time ());
+ gdk_device_ungrab (gdk_device_get_associated_device (device), gtk_get_current_event_time ());
+#else
gdk_keyboard_ungrab (gtk_get_current_event_time ());
gdk_pointer_ungrab (gtk_get_current_event_time ());
gtk_grab_remove (grab_widget);
+#endif
}
static void
@@ -236,6 +244,11 @@ mouse_press (GtkWidget *invisible,
static void
begin_area_grab (void)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkWindow *window;
+ GdkDeviceManager *manager;
+ GdkDevice *device;
+#endif
if (grab_widget == NULL)
{
grab_widget = gtk_invisible_new ();
@@ -246,6 +259,37 @@ begin_area_grab (void)
gtk_widget_show (grab_widget);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window = gtk_widget_get_window (grab_widget);
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ device = gdk_device_manager_get_client_pointer (manager);
+
+ if (gdk_device_grab (device,
+ window,
+ GDK_OWNERSHIP_NONE,
+ FALSE,
+ GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
+ NULL,
+ gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
+
+ {
+ g_warning ("Failed to grab pointer to do eyedropper");
+ return;
+ }
+
+ if (gdk_device_grab (gdk_device_get_associated_device (device),
+ window,
+ GDK_OWNERSHIP_NONE,
+ FALSE,
+ GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
+ NULL,
+ gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
+ {
+ gdk_device_ungrab (device, gtk_get_current_event_time ());
+ g_warning ("Failed to grab keyboard to do eyedropper");
+ return;
+ }
+#else
if (gdk_keyboard_grab (gtk_widget_get_window (grab_widget),
FALSE,
gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
@@ -265,6 +309,7 @@ begin_area_grab (void)
g_warning ("Failed to grab pointer to do eyedropper");
return;
}
+#endif
gtk_grab_add (grab_widget);