[gnome-control-center/gnome-3-24] wacom: Make calibrator use GDK for button events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-24] wacom: Make calibrator use GDK for button events
- Date: Fri, 30 Jun 2017 19:29:10 +0000 (UTC)
commit 9aad254c27cf0599b0f206fa812fbcd4bae92fb1
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 16 18:11:54 2017 +0200
wacom: Make calibrator use GDK for button events
This way we can cut down the last step in the mapping across
GUdevDevice->GsdDevice->GdkDevice->ClutterInputDevice.
https://bugzilla.gnome.org/show_bug.cgi?id=782040
panels/wacom/calibrator/calibrator-gui.c | 47 ++++++++++++-----------------
panels/wacom/calibrator/calibrator-gui.h | 2 +-
panels/wacom/calibrator/main.c | 2 +-
panels/wacom/cc-wacom-page.c | 2 +-
4 files changed, 23 insertions(+), 30 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator-gui.c b/panels/wacom/calibrator/calibrator-gui.c
index 7d52263..c4e145e 100644
--- a/panels/wacom/calibrator/calibrator-gui.c
+++ b/panels/wacom/calibrator/calibrator-gui.c
@@ -41,7 +41,7 @@ struct CalibArea
XYinfo axis;
gboolean swap;
gboolean success;
- int device_id;
+ GdkDevice *device;
double X[4], Y[4];
int display_width, display_height;
@@ -310,35 +310,29 @@ hide_error_message (CalibArea *area)
}
static gboolean
-on_button_press_event(ClutterActor *actor,
- ClutterButtonEvent *event,
- CalibArea *area)
+on_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ CalibArea *area)
{
gint num_clicks;
gboolean success;
+ GdkDevice *source;
if (area->success)
return FALSE;
- if (event->click_count > 1)
+ if (event->type != GDK_BUTTON_PRESS ||
+ event->button != GDK_BUTTON_PRIMARY)
return FALSE;
- /* Check matching device ID if a device ID was provided */
- if (area->device_id > -1)
+ source = gdk_event_get_source_device ((GdkEvent *) event);
+
+ /* Check matching device if a device was provided */
+ if (area->device && area->device != source)
{
- ClutterInputDevice *device;
-
- device = clutter_event_get_source_device ((ClutterEvent *) event);
- if (device != NULL && clutter_input_device_get_device_id (device) != area->device_id) {
- char *name;
-
- g_object_get (G_OBJECT (device), "name", &name, NULL);
- g_debug ("Ignoring input from device %s (%d)",
- name,
- clutter_input_device_get_device_id (device));
- g_free (name);
- return FALSE;
- }
+ g_debug ("Ignoring input from device %s",
+ gdk_device_get_name (source));
+ return FALSE;
}
/* Handle click */
@@ -661,11 +655,6 @@ set_up_stage (CalibArea *calib_area, ClutterActor *stage)
"completed",
G_CALLBACK (on_timeout),
calib_area);
-
- g_signal_connect (stage,
- "button-press-event",
- G_CALLBACK (on_button_press_event),
- calib_area);
}
/**
@@ -677,7 +666,7 @@ set_up_stage (CalibArea *calib_area, ClutterActor *stage)
CalibArea *
calib_area_new (GdkScreen *screen,
int monitor,
- int device_id,
+ GdkDevice *device,
FinishCallback callback,
gpointer user_data,
XYinfo *old_axis,
@@ -706,7 +695,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->device = device;
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;
@@ -760,6 +749,10 @@ calib_area_new (GdkScreen *screen,
"window-state-event",
G_CALLBACK (on_fullscreen),
calib_area);
+ g_signal_connect (calib_area->window,
+ "button-press-event",
+ G_CALLBACK (on_button_press_event),
+ calib_area);
gtk_window_fullscreen_on_monitor (GTK_WINDOW (calib_area->window), screen, monitor);
diff --git a/panels/wacom/calibrator/calibrator-gui.h b/panels/wacom/calibrator/calibrator-gui.h
index d65eb8b..787a5b0 100644
--- a/panels/wacom/calibrator/calibrator-gui.h
+++ b/panels/wacom/calibrator/calibrator-gui.h
@@ -40,7 +40,7 @@ typedef void (*FinishCallback) (CalibArea *area, gpointer user_data);
CalibArea * calib_area_new (GdkScreen *screen,
int monitor,
- int device_id,
+ GdkDevice *device,
FinishCallback callback,
gpointer user_data,
XYinfo *old_axis,
diff --git a/panels/wacom/calibrator/main.c b/panels/wacom/calibrator/main.c
index 52816cf..281ea1e 100644
--- a/panels/wacom/calibrator/main.c
+++ b/panels/wacom/calibrator/main.c
@@ -406,7 +406,7 @@ int main(int argc, char** argv)
calib_area = calib_area_new (NULL,
0, /* monitor */
- -1, /* -1 to ignore device ID */
+ NULL, /* NULL to accept input from any device */
calibration_finished_cb,
NULL,
&calibrator->old_axis,
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index dda1a97..53bb835 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -224,7 +224,7 @@ run_calibration (CcWacomPage *page,
priv->area = calib_area_new (NULL,
monitor,
- -1, /* FIXME: Pass GdkDevice/ClutterInputDevice */
+ NULL, /* FIXME: Pass GdkDevice/ClutterInputDevice */
finish_calibration,
page,
&old_axis,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]