[gimp/gtk3-port: 169/170] app: some device hackery for carlos to see
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 169/170] app: some device hackery for carlos to see
- Date: Mon, 20 Dec 2010 22:34:30 +0000 (UTC)
commit 9fe51ca1d2014753c176f853c48aa32933979f2e
Author: Michael Natterer <mitch gimp org>
Date: Mon Dec 20 23:18:59 2010 +0100
app: some device hackery for carlos to see
app/widgets/gimpdeviceinfo-coords.c | 46 ++++++++++++++++++++++++++++-------
app/widgets/gimpdevices.c | 42 +++++++++++--------------------
2 files changed, 52 insertions(+), 36 deletions(-)
---
diff --git a/app/widgets/gimpdeviceinfo-coords.c b/app/widgets/gimpdeviceinfo-coords.c
index 3861b21..fefbc2c 100644
--- a/app/widgets/gimpdeviceinfo-coords.c
+++ b/app/widgets/gimpdeviceinfo-coords.c
@@ -86,16 +86,20 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
GdkWindow *window,
GimpCoords *coords)
{
- gdouble axes[GDK_AXIS_LAST];
+ GdkDevice *device = info->device;
+ gdouble axes[GDK_AXIS_LAST];
+
+ if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE)
+ device = gdk_device_get_associated_device (device);
*coords = default_coords;
- gdk_device_get_state (info->device, window, axes, NULL);
+ gdk_device_get_state (device, window, axes, NULL);
- gdk_device_get_axis (info->device, axes, GDK_AXIS_X, &coords->x);
- gdk_device_get_axis (info->device, axes, GDK_AXIS_Y, &coords->y);
+ gdk_device_get_axis (device, axes, GDK_AXIS_X, &coords->x);
+ gdk_device_get_axis (device, axes, GDK_AXIS_Y, &coords->y);
- if (gdk_device_get_axis (info->device,
+ if (gdk_device_get_axis (device,
axes, GDK_AXIS_PRESSURE, &coords->pressure))
{
coords->pressure = gimp_device_info_map_axis (info,
@@ -103,7 +107,7 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
coords->pressure);
}
- if (gdk_device_get_axis (info->device,
+ if (gdk_device_get_axis (device,
axes, GDK_AXIS_XTILT, &coords->xtilt))
{
coords->xtilt = gimp_device_info_map_axis (info,
@@ -111,7 +115,7 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
coords->xtilt);
}
- if (gdk_device_get_axis (info->device,
+ if (gdk_device_get_axis (device,
axes, GDK_AXIS_YTILT, &coords->ytilt))
{
coords->ytilt = gimp_device_info_map_axis (info,
@@ -119,7 +123,7 @@ gimp_device_info_get_device_coords (GimpDeviceInfo *info,
coords->ytilt);
}
- if (gdk_device_get_axis (info->device,
+ if (gdk_device_get_axis (device,
axes, GDK_AXIS_WHEEL, &coords->wheel))
{
coords->wheel = gimp_device_info_map_axis (info,
@@ -191,5 +195,29 @@ gimp_device_info_get_device_state (GimpDeviceInfo *info,
GdkWindow *window,
GdkModifierType *state)
{
- gdk_device_get_state (info->device, window, NULL, state);
+ GdkDevice *device = info->device;
+
+ switch (gdk_device_get_device_type (device))
+ {
+ case GDK_DEVICE_TYPE_SLAVE:
+ device = gdk_device_get_associated_device (device);
+ break;
+
+ case GDK_DEVICE_TYPE_FLOATING:
+ {
+ GdkDisplay *display = gdk_device_get_display (device);
+ GdkDeviceManager *manager = gdk_display_get_device_manager (display);
+
+ device = gdk_device_manager_get_client_pointer (manager);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+ device = gdk_device_get_associated_device (device);
+
+ gdk_device_get_state (device, window, NULL, state);
}
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 526f443..c0fff83 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -354,36 +354,24 @@ gimp_devices_check_change (Gimp *gimp,
g_return_val_if_fail (manager != NULL, FALSE);
- switch (event->type)
- {
- case GDK_MOTION_NOTIFY:
- device = ((GdkEventMotion *) event)->device;
- break;
-
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- device = ((GdkEventButton *) event)->device;
- break;
-
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- device = ((GdkEventProximity *) event)->device;
- break;
-
- case GDK_SCROLL:
- device = ((GdkEventScroll *) event)->device;
- break;
-
- default:
- device = manager->current_device->device;
- break;
- }
+ device = gdk_event_get_source_device (event);
+
+ if (! device)
+ device = manager->current_device->device;
device_info = gimp_device_info_get_by_device (device);
- if (device_info != manager->current_device)
+ if (! device_info)
+ {
+ device = gdk_event_get_device (event);
+
+ if (! device)
+ device = manager->current_device->device;
+
+ device_info = gimp_device_info_get_by_device (device);
+ }
+
+ if (device_info && device_info != manager->current_device)
{
gimp_devices_select_device (manager, device_info);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]