[mousetweaks] Make mt_main_current_screen reuseable
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Make mt_main_current_screen reuseable
- Date: Mon, 11 Oct 2010 11:26:31 +0000 (UTC)
commit 9ef5576f081708100cee80658c0e338db8af0320
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Mon Oct 11 13:25:39 2010 +0200
Make mt_main_current_screen reuseable
src/mt-common.c | 21 +++++++++++++++++++++
src/mt-common.h | 2 ++
src/mt-ctw.c | 23 ++++-------------------
src/mt-main.c | 29 +++++++++--------------------
src/mt-main.h | 1 -
5 files changed, 36 insertions(+), 40 deletions(-)
---
diff --git a/src/mt-common.c b/src/mt-common.c
index d8cd642..3d498e8 100644
--- a/src/mt-common.c
+++ b/src/mt-common.c
@@ -43,6 +43,27 @@ mt_common_xtrap_pop (void)
}
}
+GdkScreen *
+mt_common_get_screen (void)
+{
+ GdkDisplay *gdk_dpy;
+ GdkScreen *screen;
+ gint n_screens;
+
+ gdk_dpy = gdk_display_get_default ();
+ n_screens = gdk_display_get_n_screens (gdk_dpy);
+
+ if (n_screens > 1)
+ {
+ gdk_display_get_pointer (gdk_dpy, &screen, NULL, NULL, NULL);
+ }
+ else
+ {
+ screen = gdk_screen_get_default ();
+ }
+ return screen;
+}
+
void
mt_common_show_help (GdkScreen *screen, guint32 timestamp)
{
diff --git a/src/mt-common.h b/src/mt-common.h
index fd2d956..b3b844f 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -88,6 +88,8 @@ Display * mt_common_get_xdisplay (void);
void mt_common_xtrap_push (void);
void mt_common_xtrap_pop (void);
+GdkScreen * mt_common_get_screen (void);
+
void mt_common_show_help (GdkScreen *screen,
guint32 timestamp);
diff --git a/src/mt-ctw.c b/src/mt-ctw.c
index 82b607c..99bdcc2 100644
--- a/src/mt-ctw.c
+++ b/src/mt-ctw.c
@@ -48,25 +48,10 @@ mt_ctw_set_clicktype (MtData *mt, guint clicktype)
void
mt_ctw_update_visibility (MtData *mt)
{
- GtkWidget *ctw;
- GdkScreen *screen;
-
- ctw = mt_ctw_get_window (mt);
-
- if (mt->dwell_enabled && mt->dwell_show_ctw)
- {
- if (mt->n_screens > 1)
- {
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, NULL, NULL, NULL);
- gtk_window_set_screen (GTK_WINDOW (ctw), screen);
- }
- gtk_widget_show (ctw);
- }
- else
- {
- gtk_widget_hide (ctw);
- }
+ g_object_set (mt_ctw_get_window (mt),
+ "visible", mt->dwell_enabled && mt->dwell_show_ctw,
+ "screen", mt_common_get_screen (),
+ NULL);
}
void
diff --git a/src/mt-main.c b/src/mt-main.c
index e14c777..54b6d2d 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -61,20 +61,6 @@ typedef struct _MtCliArgs
gboolean login;
} MtCliArgs;
-static GdkScreen *
-mt_main_current_screen (MtData *mt)
-{
- GdkScreen *screen;
-
- if (mt->n_screens > 1)
- gdk_display_get_pointer (gdk_display_get_default (),
- &screen, NULL, NULL, NULL);
- else
- screen = gdk_screen_get_default ();
-
- return screen;
-}
-
static void
mt_main_generate_motion_event (GdkScreen *screen, gint x, gint y)
{
@@ -119,14 +105,18 @@ mt_main_generate_button_event (MtData *mt,
static void
mt_main_set_cursor (MtData *mt, GdkCursorType type)
{
+ GdkDisplay *gdk_dpy;
GdkScreen *screen;
GdkCursor *cursor;
- gint i;
+ gint n_screens, i;
+
+ gdk_dpy = gdk_display_get_default ();
+ n_screens = gdk_display_get_n_screens (gdk_dpy);
cursor = gdk_cursor_new (type);
- for (i = 0; i < mt->n_screens; ++i)
+ for (i = 0; i < n_screens; ++i)
{
- screen = gdk_display_get_screen (gdk_display_get_default (), i);
+ screen = gdk_display_get_screen (gdk_dpy, i);
gdk_window_set_cursor (gdk_screen_get_root_window (screen), cursor);
}
gdk_cursor_unref (cursor);
@@ -150,7 +140,7 @@ mt_main_do_dwell_click (MtData *mt)
if (mt->dwell_mode == DWELL_MODE_GESTURE && !mt->dwell_drag_started)
{
- mt_main_generate_motion_event (mt_main_current_screen (mt),
+ mt_main_generate_motion_event (mt_common_get_screen (),
mt->pointer_x,
mt->pointer_y);
}
@@ -263,7 +253,7 @@ dwell_start_gesture (MtData *mt)
if (mt->override_cursor)
{
cursor = gdk_cursor_new (GDK_CROSS);
- root = gdk_screen_get_root_window (mt_main_current_screen (mt));
+ root = gdk_screen_get_root_window (mt_common_get_screen ());
gdk_pointer_grab (root, FALSE,
GDK_POINTER_MOTION_MASK,
NULL, cursor,
@@ -694,7 +684,6 @@ mt_data_init (void)
G_CALLBACK (mt_main_timer_tick), mt);
mt->service = mt_service_get_default ();
- mt->n_screens = gdk_display_get_n_screens (gdk_display_get_default ());
return mt;
}
diff --git a/src/mt-main.h b/src/mt-main.h
index ae2dd14..023f5f3 100644
--- a/src/mt-main.h
+++ b/src/mt-main.h
@@ -37,7 +37,6 @@ struct _MtData
MtTimer *ssc_timer;
MtTimer *dwell_timer;
MtCursor *cursor;
- gint n_screens;
gint direction;
gint pointer_x;
gint pointer_y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]