summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2012-07-24 12:07:06 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2012-07-24 12:07:06 +0000
commit1045ef77f45fcc3da502b1512b4182d1f8391962 (patch)
tree5a671ad780deb9f596bc9b069233df1f9e7943a3
parentFix for 614500 : Select tool crosshair cursor (diff)
downloadinkscape-1045ef77f45fcc3da502b1512b4182d1f8391962.tar.gz
inkscape-1045ef77f45fcc3da502b1512b4182d1f8391962.zip
Don't include keyboards in input-device list. Remove comments about private fields.
Fixed bugs: - https://launchpad.net/bugs/1028088 (bzr r11571)
-rw-r--r--src/device-manager.cpp90
1 files changed, 20 insertions, 70 deletions
diff --git a/src/device-manager.cpp b/src/device-manager.cpp
index fedcb232b..059e1b52d 100644
--- a/src/device-manager.cpp
+++ b/src/device-manager.cpp
@@ -26,9 +26,7 @@ struct GdkDeviceFake {
GdkInputMode mode;
gboolean has_cursor;
gint num_axes;
-// GdkDeviceAxis *axes;
gint num_keys;
-// GdkDeviceKey *keys;
};
@@ -40,7 +38,6 @@ static bool isValidDevice(GdkDevice *device)
{
bool valid = true;
for (size_t i = 0; (i < G_N_ELEMENTS(fakeout)) && valid; i++) {
- // Ideally, we should probably check all fields of the GdkDevice
gboolean name_matches = (g_strcmp0 (gdk_device_get_name (device), fakeout[i].name) == 0);
gboolean source_matches = (gdk_device_get_source (device) == fakeout[i].source);
gboolean mode_matches = (gdk_device_get_mode (device) == fakeout[i].mode);
@@ -344,15 +341,26 @@ DeviceManagerImpl::DeviceManagerImpl() :
for ( GList* curr = devList; curr; curr = g_list_next(curr) ) {
GdkDevice* dev = reinterpret_cast<GdkDevice*>(curr->data);
- if ( dev ) {
+ if (dev) {
+
+#if GTK_CHECK_VERSION(3,0,0)
+ // GTK+ 3 has added keyboards to the list of supported devices.
+ if(gdk_device_get_source(dev) != GDK_SOURCE_KEYBOARD) {
+#endif
+
#if DEBUG_VERBOSE
- g_message("device: name[%s] source[0x%x] mode[0x%x] cursor[%s] axis count[%d] key count[%d]", dev->name, dev->source, dev->mode,
- dev->has_cursor?"Yes":"no", dev->num_axes, dev->num_keys);
+ g_message("device: name[%s] source[0x%x] mode[0x%x] cursor[%s] axis count[%d] key count[%d]", dev->name, dev->source, dev->mode,
+ dev->has_cursor?"Yes":"no", dev->num_axes, dev->num_keys);
+#endif
+
+ InputDeviceImpl* device = new InputDeviceImpl(dev, knownIDs);
+ device->reference();
+ devices.push_back(Glib::RefPtr<InputDeviceImpl>(device));
+
+#if GTK_CHECK_VERSION(3,0,0)
+ }
#endif
- InputDeviceImpl* device = new InputDeviceImpl(dev, knownIDs);
- device->reference();
- devices.push_back(Glib::RefPtr<InputDeviceImpl>(device));
}
}
@@ -631,54 +639,6 @@ DeviceManager& DeviceManager::getManager() {
} // namespace Inkscape
-
-
-
-/* FIXME: Device Axis and Key details are inaccessible in GTK+ 3
- * and are deprecated in GTK+ 2. Perhaps there is a way of specifying
- * this in underlying API?
- *
-GdkDeviceAxis padAxes[] = {{GDK_AXIS_X, 0.0, 0.0},
- {GDK_AXIS_Y, 0.0, 0.0},
- {GDK_AXIS_PRESSURE, 0.0, 1.0},
- {GDK_AXIS_XTILT, -1.0, 1.0},
- {GDK_AXIS_YTILT, -1.0, 1.0},
- {GDK_AXIS_WHEEL, 0.0, 1.0}};
-GdkDeviceKey padKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
- {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}};
-
-GdkDeviceAxis eraserAxes[] = {{GDK_AXIS_X, 0.0, 0.0},
- {GDK_AXIS_Y, 0.0, 0.0},
- {GDK_AXIS_PRESSURE, 0.0, 1.0},
- {GDK_AXIS_XTILT, -1.0, 1.0},
- {GDK_AXIS_YTILT, -1.0, 1.0},
- {GDK_AXIS_WHEEL, 0.0, 1.0}};
-GdkDeviceKey eraserKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
- {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}};
-
-GdkDeviceAxis cursorAxes[] = {{GDK_AXIS_X, 0.0, 0.0},
- {GDK_AXIS_Y, 0.0, 0.0},
- {GDK_AXIS_PRESSURE, 0.0, 1.0},
- {GDK_AXIS_XTILT, -1.0, 1.0},
- {GDK_AXIS_YTILT, -1.0, 1.0},
- {GDK_AXIS_WHEEL, 0.0, 1.0}};
-GdkDeviceKey cursorKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
- {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}};
-
-GdkDeviceAxis stylusAxes[] = {{GDK_AXIS_X, 0.0, 0.0},
- {GDK_AXIS_Y, 0.0, 0.0},
- {GDK_AXIS_PRESSURE, 0.0, 1.0},
- {GDK_AXIS_XTILT, -1.0, 1.0},
- {GDK_AXIS_YTILT, -1.0, 1.0},
- {GDK_AXIS_WHEEL, 0.0, 1.0}};
-GdkDeviceKey stylusKeys[] = {{0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0},
- {0, (GdkModifierType)0}, {0, (GdkModifierType)0}, {0, (GdkModifierType)0}};
-
-
-GdkDeviceAxis coreAxes[] = {{GDK_AXIS_X, 0.0, 0.0},
- {GDK_AXIS_Y, 0.0, 0.0}};
-*/
-
static void createFakeList() {
if ( !fakeList ) {
fakeout[0].name = g_strdup("pad");
@@ -686,38 +646,30 @@ static void createFakeList() {
fakeout[0].mode = GDK_MODE_SCREEN;
fakeout[0].has_cursor = TRUE;
fakeout[0].num_axes = 6;
-// fakeout[0].axes = padAxes;
fakeout[0].num_keys = 8;
-// fakeout[0].keys = padKeys;
fakeout[1].name = g_strdup("eraser");
fakeout[1].source = GDK_SOURCE_ERASER;
fakeout[1].mode = GDK_MODE_SCREEN;
fakeout[1].has_cursor = TRUE;
fakeout[1].num_axes = 6;
-// fakeout[1].axes = eraserAxes;
fakeout[1].num_keys = 7;
-// fakeout[1].keys = eraserKeys;
fakeout[2].name = g_strdup("cursor");
fakeout[2].source = GDK_SOURCE_CURSOR;
fakeout[2].mode = GDK_MODE_SCREEN;
fakeout[2].has_cursor = TRUE;
fakeout[2].num_axes = 6;
-// fakeout[2].axes = cursorAxes;
fakeout[2].num_keys = 7;
-// fakeout[2].keys = cursorKeys;
fakeout[3].name = g_strdup("stylus");
fakeout[3].source = GDK_SOURCE_PEN;
fakeout[3].mode = GDK_MODE_SCREEN;
fakeout[3].has_cursor = TRUE;
fakeout[3].num_axes = 6;
-// fakeout[3].axes = stylusAxes;
fakeout[3].num_keys = 7;
-// fakeout[3].keys = stylusKeys;
-// try to find the first *real* core pointer
+ // try to find the first *real* core pointer
#if GTK_CHECK_VERSION(3,0,0)
GdkDisplay *display = gdk_display_get_default();
GdkDeviceManager *dm = gdk_display_get_device_manager(display);
@@ -726,12 +678,12 @@ static void createFakeList() {
GList* devList = gdk_devices_list();
#endif
+ // Skip past any items in the device list that are not mice
while ( devList && devList->data && (gdk_device_get_source ((GdkDevice*)devList->data) != GDK_SOURCE_MOUSE)) {
devList = g_list_next(devList);
}
+
if ( devList && devList->data ) {
- //fakeout[4] = *((GdkDevice*)devList->data);
- // We should probably copy the axes and keys too
GdkDevice *device = (GdkDevice*)devList->data;
fakeout[4].name = g_strdup(gdk_device_get_name (device));
fakeout[4].source = gdk_device_get_source (device);
@@ -749,9 +701,7 @@ static void createFakeList() {
fakeout[4].mode = GDK_MODE_SCREEN;
fakeout[4].has_cursor = TRUE;
fakeout[4].num_axes = 2;
-// fakeout[4].axes = coreAxes;
fakeout[4].num_keys = 0;
-// fakeout[4].keys = NULL;
}
for ( guint pos = 0; pos < G_N_ELEMENTS(fakeout); pos++) {