[gnome-control-center] wacom: Do calibration for the selected tool only
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Do calibration for the selected tool only
- Date: Thu, 19 Jul 2012 15:39:52 +0000 (UTC)
commit 06554439b7243aa3625d52ad8fe41ed621d3ac3c
Author: Olivier Fourdan <ofourdan redhat com>
Date: Wed Jul 18 14:23:29 2012 +0200
wacom: Do calibration for the selected tool only
As different tools may have different resolutions (e.g.
touch vs. stylus on tablets which support both).
https://bugzilla.gnome.org/show_bug.cgi?id=680114
panels/wacom/calibrator/gui_gtk.c | 13 +++++++++++++
panels/wacom/calibrator/gui_gtk.h | 1 +
panels/wacom/calibrator/main.c | 3 ++-
panels/wacom/cc-wacom-page.c | 14 +++++++++++++-
4 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/panels/wacom/calibrator/gui_gtk.c b/panels/wacom/calibrator/gui_gtk.c
index 6521ac8..82b60d5 100644
--- a/panels/wacom/calibrator/gui_gtk.c
+++ b/panels/wacom/calibrator/gui_gtk.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <cairo.h>
@@ -39,6 +40,7 @@ struct CalibArea
XYinfo axis;
gboolean swap;
gboolean success;
+ int device_id;
double X[4], Y[4];
int display_width, display_height;
@@ -349,6 +351,15 @@ on_button_press_event(GtkWidget *widget,
if (area->success)
return FALSE;
+ /* Check matching device ID if a device ID was provided */
+ if (area->device_id > -1) {
+ GdkDevice *device;
+
+ device = gdk_event_get_source_device ((GdkEvent *) event);
+ if (device != NULL && gdk_x11_device_get_id (device) != area->device_id)
+ return FALSE;
+ }
+
/* Handle click */
area->time_elapsed = 0;
success = add_click(&area->calibrator, (int)event->x_root, (int)event->y_root);
@@ -438,6 +449,7 @@ on_timer_signal(CalibArea *area)
CalibArea *
calib_area_new (GdkScreen *screen,
int monitor,
+ int device_id,
FinishCallback callback,
gpointer user_data,
XYinfo *old_axis,
@@ -462,6 +474,7 @@ calib_area_new (GdkScreen *screen,
calib_area = g_new0 (CalibArea, 1);
calib_area->callback = callback;
calib_area->user_data = user_data;
+ calib_area->device_id = device_id;
calib_area->calibrator.old_axis.x_min = old_axis->x_min;
calib_area->calibrator.old_axis.x_max = old_axis->x_max;
calib_area->calibrator.old_axis.y_min = old_axis->y_min;
diff --git a/panels/wacom/calibrator/gui_gtk.h b/panels/wacom/calibrator/gui_gtk.h
index d6ea56c..d3d12fc 100644
--- a/panels/wacom/calibrator/gui_gtk.h
+++ b/panels/wacom/calibrator/gui_gtk.h
@@ -40,6 +40,7 @@ typedef void (*FinishCallback) (CalibArea *area, gpointer user_data);
CalibArea * calib_area_new (GdkScreen *screen,
int monitor,
+ int device_id,
FinishCallback callback,
gpointer user_data,
XYinfo *old_axis,
diff --git a/panels/wacom/calibrator/main.c b/panels/wacom/calibrator/main.c
index 06cd634..2368a10 100644
--- a/panels/wacom/calibrator/main.c
+++ b/panels/wacom/calibrator/main.c
@@ -400,7 +400,8 @@ int main(int argc, char** argv)
gtk_init(&argc, &argv);
calib_area = calib_area_new (NULL,
- 0,
+ 0, /* monitor */
+ -1, /* -1 to ignore device ID */
calibration_finished_cb,
NULL,
&calibrator->old_axis,
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 5513196..ae84e1c 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -179,7 +179,10 @@ run_calibration (CcWacomPage *page,
gint *cal,
gint monitor)
{
- XYinfo old_axis;
+ XYinfo old_axis;
+ GdkDevice *gdk_device;
+ CcWacomPagePrivate *priv;
+ int device_id;
g_assert (page->priv->area == NULL);
@@ -188,8 +191,17 @@ run_calibration (CcWacomPage *page,
old_axis.x_max = cal[2];
old_axis.y_max = cal[3];
+ priv = page->priv;
+ g_object_get (priv->stylus, "gdk-device", &gdk_device, NULL);
+
+ if (gdk_device != NULL)
+ g_object_get (gdk_device, "device-id", &device_id, NULL);
+ else
+ device_id = -1;
+
page->priv->area = calib_area_new (NULL,
monitor,
+ device_id,
finish_calibration,
page,
&old_axis,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]