[gnome-screenshot] screenshot: don't use deprecated GDK api
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screenshot] screenshot: don't use deprecated GDK api
- Date: Tue, 25 Oct 2011 14:02:26 +0000 (UTC)
commit 29e5f8c853ef75f5092a6e754ae4c2a44ac99fca
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Oct 25 09:51:33 2011 -0400
screenshot: don't use deprecated GDK api
Use GdkDevice and GdkDeviceManager instead of the deprecated pointer GDK
API.
src/screenshot-area-selection.c | 37 ++++++++++++++++++++++++++-----------
src/screenshot-utils.c | 17 ++++++++++++++---
2 files changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/src/screenshot-area-selection.c b/src/screenshot-area-selection.c
index e4eba7a..c9f5acc 100644
--- a/src/screenshot-area-selection.c
+++ b/src/screenshot-area-selection.c
@@ -218,9 +218,12 @@ emit_select_callback_in_idle (gpointer user_data)
void
screenshot_select_area_async (SelectAreaCallback callback)
{
- GdkCursor *cursor;
+ GdkCursor *cursor;
select_area_filter_data data;
CallbackData *cb_data;
+ GdkDeviceManager *manager;
+ GdkDevice *pointer, *keyboard;
+ GdkGrabStatus res;
data.rect.x = 0;
data.rect.y = 0;
@@ -238,27 +241,39 @@ screenshot_select_area_async (SelectAreaCallback callback)
g_signal_connect (data.window, "motion-notify-event", G_CALLBACK (select_area_motion_notify), &data);
cursor = gdk_cursor_new (GDK_CROSSHAIR);
-
- if (gdk_pointer_grab (gtk_widget_get_window (data.window), FALSE,
- GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,
- NULL, cursor,
- GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ pointer = gdk_device_manager_get_client_pointer (manager);
+ keyboard = gdk_device_get_associated_device (pointer);
+
+ res = gdk_device_grab (pointer, gtk_widget_get_window (data.window),
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK,
+ cursor, GDK_CURRENT_TIME);
+
+ if (res != GDK_GRAB_SUCCESS)
{
g_object_unref (cursor);
goto out;
}
- if (gdk_keyboard_grab (gtk_widget_get_window (data.window), FALSE, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
+ res = gdk_device_grab (keyboard, gtk_widget_get_window (data.window),
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK,
+ NULL, GDK_CURRENT_TIME);
+ if (res != GDK_GRAB_SUCCESS)
{
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_cursor_unref (cursor);
+ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
+ g_object_unref (cursor);
goto out;
}
gtk_main ();
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
+ gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
gtk_widget_destroy (data.window);
g_object_unref (cursor);
diff --git a/src/screenshot-utils.c b/src/screenshot-utils.c
index 854be46..523e19e 100644
--- a/src/screenshot-utils.c
+++ b/src/screenshot-utils.c
@@ -119,14 +119,18 @@ GdkWindow *
screenshot_find_current_window ()
{
GdkWindow *current_window;
+ GdkDeviceManager *manager;
+ GdkDevice *device;
current_window = screenshot_find_active_window ();
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ device = gdk_device_manager_get_client_pointer (manager);
/* If there's no active window, we fall back to returning the
* window that the cursor is in.
*/
if (!current_window)
- current_window = gdk_window_at_pointer (NULL, NULL);
+ current_window = gdk_device_get_window_at_position (device, NULL, NULL);
if (current_window)
{
@@ -507,13 +511,20 @@ screenshot_get_pixbuf_fallback (GdkWindow *window,
if (cursor_pixbuf != NULL)
{
+ GdkDeviceManager *manager;
+ GdkDevice *device;
GdkRectangle rect;
gint cx, cy, xhot, yhot;
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ device = gdk_device_manager_get_client_pointer (manager);
+
if (wm_window != NULL)
- gdk_window_get_pointer (wm_window, &cx, &cy, NULL);
+ gdk_window_get_device_position (wm_window, device,
+ &cx, &cy, NULL);
else
- gdk_window_get_pointer (window, &cx, &cy, NULL);
+ gdk_window_get_device_position (window, device,
+ &cx, &cy, NULL);
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"), "%d", &xhot);
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "y_hot"), "%d", &yhot);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]