[gnome-settings-daemon] wacom: implement switch monitor function
- From: Olivier Fourdan <ofourdan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] wacom: implement switch monitor function
- Date: Tue, 21 Aug 2012 15:29:09 +0000 (UTC)
commit 8a9e82d147a25b20e6ea9a6302f48dfebdf58bcb
Author: Olivier Fourdan <ofourdan redhat com>
Date: Tue Aug 21 14:25:18 2012 +0200
wacom: implement switch monitor function
as described in g-c-c bug 668908
https://bugzilla.gnome.org/show_bug.cgi?id=668908
data/gsd-enums.h | 3 ++-
plugins/wacom/gsd-wacom-device.c | 12 ++++++------
plugins/wacom/gsd-wacom-device.h | 3 +++
plugins/wacom/gsd-wacom-manager.c | 35 ++++++++++++++++++++++++++++++++++-
4 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/data/gsd-enums.h b/data/gsd-enums.h
index c9e1a1b..528622c 100644
--- a/data/gsd-enums.h
+++ b/data/gsd-enums.h
@@ -93,7 +93,8 @@ typedef enum
typedef enum
{
GSD_WACOM_ACTION_TYPE_NONE,
- GSD_WACOM_ACTION_TYPE_CUSTOM
+ GSD_WACOM_ACTION_TYPE_CUSTOM,
+ GSD_WACOM_ACTION_TYPE_SWITCH_MONITOR
} GsdWacomActionType;
typedef enum
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index fad3e63..0761c07 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -756,7 +756,7 @@ gsd_wacom_device_set_display (GsdWacomDevice *device,
return;
}
- if (monitor >= 0)
+ if (monitor > GSD_WACOM_SET_ALL_MONITORS)
output = find_output_by_monitor (rr_screen, gdk_screen_get_default (), monitor);
set_display_by_output (device, output);
@@ -823,25 +823,25 @@ gsd_wacom_device_get_display_monitor (GsdWacomDevice *device)
GnomeRRCrtc *crtc;
gint area[4];
- g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), -1);
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), GSD_WACOM_SET_ALL_MONITORS);
rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
if (rr_screen == NULL) {
g_warning ("Failed to create GnomeRRScreen: %s", error->message);
g_error_free (error);
- return -1;
+ return GSD_WACOM_SET_ALL_MONITORS;
}
rr_output = find_output (rr_screen, device);
if (rr_output == NULL) {
g_object_unref (rr_screen);
- return -1;
+ return GSD_WACOM_SET_ALL_MONITORS;
}
if (!is_on (rr_output)) {
g_warning ("Output is not active.");
g_object_unref (rr_screen);
- return -1;
+ return GSD_WACOM_SET_ALL_MONITORS;
}
crtc = gnome_rr_output_get_crtc (rr_output);
@@ -855,7 +855,7 @@ gsd_wacom_device_get_display_monitor (GsdWacomDevice *device)
if (area[2] <= 0 || area[3] <= 0) {
g_warning ("Output has non-positive area.");
- return -1;
+ return GSD_WACOM_SET_ALL_MONITORS;
}
g_debug ("Area: %d,%d %dx%d", area[0], area[1], area[2], area[3]);
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 59c4b27..8604ee4 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -122,6 +122,9 @@ typedef enum {
WACOM_TYPE_ALL = WACOM_TYPE_STYLUS | WACOM_TYPE_ERASER | WACOM_TYPE_CURSOR | WACOM_TYPE_PAD | WACOM_TYPE_TOUCH
} GsdWacomDeviceType;
+/* We use -1 for entire screen when setting/getting monitor value */
+#define GSD_WACOM_SET_ALL_MONITORS -1
+
GType gsd_wacom_device_get_type (void);
void gsd_wacom_device_set_display (GsdWacomDevice *device,
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index 17854cf..d178afb 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -375,7 +375,7 @@ set_keep_aspect (GsdWacomDevice *device,
guint i;
gint *area;
- gint monitor = -1;
+ gint monitor = GSD_WACOM_SET_ALL_MONITORS;
GsdWacomRotation rotation;
GSettings *settings;
@@ -1054,6 +1054,32 @@ generate_key (GsdWacomTabletButton *wbutton,
g_free (str);
}
+static void
+switch_monitor (GsdWacomDevice *device)
+{
+ gint current_monitor, n_monitors;
+
+ /* We dont; do that for screen tablets, sorry... */
+ if (gsd_wacom_device_is_screen_tablet (device))
+ return;
+
+ n_monitors = gdk_screen_get_n_monitors (gdk_screen_get_default ());
+
+ /* There's no point in switching if there just one monitor */
+ if (n_monitors < 2)
+ return;
+
+ current_monitor = gsd_wacom_device_get_display_monitor (device);
+
+ /* Select next monitor */
+ current_monitor++;
+
+ if (current_monitor >= n_monitors)
+ current_monitor = GSD_WACOM_SET_ALL_MONITORS;
+
+ gsd_wacom_device_set_display (device, current_monitor);
+}
+
static GdkFilterReturn
filter_button_events (XEvent *xevent,
GdkEvent *event,
@@ -1122,6 +1148,13 @@ filter_button_events (XEvent *xevent,
if (g_settings_get_enum (wbutton->settings, KEY_ACTION_TYPE) == GSD_WACOM_ACTION_TYPE_NONE)
return GDK_FILTER_REMOVE;
+ /* Switch monitor */
+ if (g_settings_get_enum (wbutton->settings, KEY_ACTION_TYPE) == GSD_WACOM_ACTION_TYPE_SWITCH_MONITOR) {
+ if (xiev->evtype == XI_ButtonRelease)
+ switch_monitor (device);
+ return GDK_FILTER_REMOVE;
+ }
+
/* Send a key combination out */
generate_key (wbutton, xev->group.effective, xev->display, dir, xiev->evtype == XI_ButtonPress ? True : False);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]