[mousetweaks] Fix deprecation warnings.
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Fix deprecation warnings.
- Date: Sun, 19 Feb 2012 08:27:25 +0000 (UTC)
commit 97d17edd13517a3038acd763d1ad1e45f2eecdc9
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Sun Feb 19 03:39:55 2012 +0100
Fix deprecation warnings.
src/mt-common.c | 29 ++++++++++++++++++++++++-----
src/mt-common.h | 20 +++++++++++---------
src/mt-main.c | 47 ++++++++++++++++++++++++++++++++++-------------
3 files changed, 69 insertions(+), 27 deletions(-)
---
diff --git a/src/mt-common.c b/src/mt-common.c
index 355ed68..1084a85 100644
--- a/src/mt-common.c
+++ b/src/mt-common.c
@@ -47,11 +47,26 @@ mt_common_xtrap_pop (void)
}
}
+GdkDevice *
+mt_common_get_client_pointer (void)
+{
+ GdkDisplay *gdk_dpy;
+ GdkDeviceManager *manager;
+
+ gdk_dpy = gdk_display_get_default ();
+ manager = gdk_display_get_device_manager (gdk_dpy);
+
+ if (manager)
+ return gdk_device_manager_get_client_pointer (manager);
+
+ return NULL;
+}
+
GdkScreen *
mt_common_get_screen (void)
{
GdkDisplay *gdk_dpy;
- GdkScreen *screen;
+ GdkScreen *screen = NULL;
gint n_screens;
gdk_dpy = gdk_display_get_default ();
@@ -59,12 +74,16 @@ mt_common_get_screen (void)
if (n_screens > 1)
{
- gdk_display_get_pointer (gdk_dpy, &screen, NULL, NULL, NULL);
+ GdkDevice *cp;
+
+ cp = mt_common_get_client_pointer ();
+ if (cp)
+ gdk_device_get_position (cp, &screen, NULL, NULL);
}
- else
- {
+
+ if (!screen)
screen = gdk_screen_get_default ();
- }
+
return screen;
}
diff --git a/src/mt-common.h b/src/mt-common.h
index e3a3165..36bf2c8 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -83,19 +83,21 @@ typedef enum /*< skip >*/
MT_MESSAGE_TYPE_WARNING,
} MtMessageType;
-Display * mt_common_get_xdisplay (void);
+Display * mt_common_get_xdisplay (void);
-void mt_common_xtrap_push (void);
-void mt_common_xtrap_pop (void);
+void mt_common_xtrap_push (void);
+void mt_common_xtrap_pop (void);
-GdkScreen * mt_common_get_screen (void);
+GdkDevice * mt_common_get_client_pointer (void);
-void mt_common_show_help (GdkScreen *screen,
- guint32 timestamp);
+GdkScreen * mt_common_get_screen (void);
-void mt_common_show_dialog (const gchar *primary,
- const gchar *secondary,
- MtMessageType type);
+void mt_common_show_help (GdkScreen *screen,
+ guint32 timestamp);
+
+void mt_common_show_dialog (const gchar *primary,
+ const gchar *secondary,
+ MtMessageType type);
G_END_DECLS
diff --git a/src/mt-main.c b/src/mt-main.c
index a8b4fbe..8685398 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -83,7 +83,11 @@ typedef struct _MtData
static void
mt_main_generate_motion_event (GdkScreen *screen, gint x, gint y)
{
- gdk_display_warp_pointer (gdk_display_get_default (), screen, x, y);
+ GdkDevice *cp;
+
+ cp = mt_common_get_client_pointer ();
+ if (cp)
+ gdk_device_warp (cp, screen, x, y);
}
static void
@@ -138,7 +142,7 @@ mt_main_set_cursor (MtData *mt, GdkCursorType type)
screen = gdk_display_get_screen (gdk_dpy, i);
gdk_window_set_cursor (gdk_screen_get_root_window (screen), cursor);
}
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static void
@@ -234,12 +238,17 @@ mt_main_analyze_gesture (MtData *mt)
{
MtSettings *ms;
GDesktopMouseDwellDirection direction;
+ GdkDevice *cp;
gint x, y;
if (mt_service_get_click_type (mt->service) == MT_DWELL_CLICK_TYPE_DRAG)
return TRUE;
- gdk_display_get_pointer (gdk_display_get_default (), NULL, &x, &y, NULL);
+ cp = mt_common_get_client_pointer ();
+ if (!cp)
+ return FALSE;
+
+ gdk_device_get_position (cp, NULL, &x, &y);
if (below_threshold (mt, x, y))
return FALSE;
@@ -274,18 +283,24 @@ mt_main_analyze_gesture (MtData *mt)
static void
dwell_start_gesture (MtData *mt)
{
+ GdkDevice *cp;
GdkCursor *cursor;
GdkWindow *root;
if (mt->override_cursor)
{
- cursor = gdk_cursor_new (GDK_CROSS);
- root = gdk_screen_get_root_window (mt_common_get_screen ());
- gdk_pointer_grab (root, FALSE,
- GDK_POINTER_MOTION_MASK,
- NULL, cursor,
- gtk_get_current_event_time ());
- gdk_cursor_unref (cursor);
+ cp = mt_common_get_client_pointer ();
+ if (cp)
+ {
+ cursor = gdk_cursor_new (GDK_CROSS);
+ root = gdk_screen_get_root_window (mt_common_get_screen ());
+ gdk_device_grab (cp, root,
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_POINTER_MOTION_MASK,
+ cursor,
+ gtk_get_current_event_time ());
+ g_object_unref (cursor);
+ }
}
else
{
@@ -299,10 +314,18 @@ dwell_start_gesture (MtData *mt)
static void
dwell_stop_gesture (MtData *mt)
{
+ GdkDevice *cp;
+
if (mt->override_cursor)
- gdk_pointer_ungrab (gtk_get_current_event_time ());
+ {
+ cp = mt_common_get_client_pointer ();
+ if (cp)
+ gdk_device_ungrab (cp, gtk_get_current_event_time ());
+ }
else
+ {
mt_main_set_cursor (mt, GDK_LEFT_PTR);
+ }
mt->dwell_gesture_started = FALSE;
mt_timer_stop (mt->dwell_timer);
@@ -663,8 +686,6 @@ mt_main (int argc, char **argv, MtCliArgs cli_args)
return;
}
- gdk_disable_multidevice ();
-
gtk_init (&argc, &argv);
sigh = mt_sig_handler_get_default ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]