summaryrefslogtreecommitdiffstats
path: root/src/desktop-events.cpp
diff options
context:
space:
mode:
authorNiko Kiirala <niko@kiirala.com>2009-01-11 21:49:58 +0000
committerkiirala <kiirala@users.sourceforge.net>2009-01-11 21:49:58 +0000
commitc74bdf2508cce7073e051143e0444e5707578827 (patch)
tree7afcf74ad85e487556d09f77efc518cf4392ca00 /src/desktop-events.cpp
parenta much improved Tango icon set from jEsuSdA (diff)
downloadinkscape-c74bdf2508cce7073e051143e0444e5707578827.tar.gz
inkscape-c74bdf2508cce7073e051143e0444e5707578827.zip
Switching tools based on tablet device now handles many devices of same type
(bzr r7118)
Diffstat (limited to 'src/desktop-events.cpp')
-rw-r--r--src/desktop-events.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 4258d1980..e2c3ba40e 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -303,8 +303,8 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
return ret;
}
-static std::map<GdkInputSource, std::string> switchMap;
-static std::map<GdkInputSource, int> toolToUse;
+//static std::map<GdkInputSource, std::string> switchMap;
+static std::map<std::string, int> toolToUse;
static std::string lastName;
static GdkInputSource lastType = GDK_SOURCE_MOUSE;
@@ -317,27 +317,25 @@ static void init_extended()
GdkDevice* dev = reinterpret_cast<GdkDevice*>(curr->data);
if ( dev->name
&& (avoidName != dev->name)
- && (switchMap.find(dev->source) == switchMap.end())
&& (dev->source != GDK_SOURCE_MOUSE) ) {
- switchMap[dev->source] = dev->name;
// g_message("Adding '%s' as [%d]", dev->name, dev->source);
// Set the initial tool for the device
switch ( dev->source ) {
case GDK_SOURCE_PEN:
- toolToUse[GDK_SOURCE_PEN] = TOOLS_CALLIGRAPHIC;
+ toolToUse[dev->name] = TOOLS_CALLIGRAPHIC;
break;
case GDK_SOURCE_ERASER:
- toolToUse[GDK_SOURCE_ERASER] = TOOLS_ERASER;
+ toolToUse[dev->name] = TOOLS_ERASER;
break;
case GDK_SOURCE_CURSOR:
- toolToUse[GDK_SOURCE_CURSOR] = TOOLS_SELECT;
+ toolToUse[dev->name] = TOOLS_SELECT;
break;
default:
; // do not add
}
-// } else {
-// g_message("Skippn '%s' as [%s]", dev->name, namefor(dev->source));
+// } else if (dev->name) {
+// g_message("Skippn '%s' as [%s]", dev->name, dev->source);
}
}
}
@@ -399,22 +397,23 @@ void snoop_extended(GdkEvent* event, SPDesktop *desktop)
}
if (!name.empty()) {
- if ( lastName != name || lastType != source ) {
+ if ( lastType != source || lastName != name ) {
// The device switched. See if it is one we 'count'
- std::map<GdkInputSource, std::string>::iterator it = switchMap.find(source);
- if ( (it != switchMap.end()) && (name == it->second) ) {
- std::map<GdkInputSource, int>::iterator it2 = toolToUse.find(source);
- if (it2 != toolToUse.end() ) {
- // Save the tool currently selected for next time the input device shows up.
- if ( (switchMap.find(lastType) != switchMap.end())
- && (lastName == switchMap.find(lastType)->second)) {
- toolToUse[lastType] = tools_active(desktop);
- }
- tools_switch(desktop, it2->second);
- }
- lastName = name;
- lastType = source;
+ //g_message("Changed device %s -> %s", lastName.c_str(), name.c_str());
+ std::map<std::string, int>::iterator it = toolToUse.find(lastName);
+ if (it != toolToUse.end()) {
+ // Save the tool currently selected for next time the input
+ // device shows up.
+ it->second = tools_active(desktop);
}
+
+ it = toolToUse.find(name);
+ if (it != toolToUse.end() ) {
+ tools_switch(desktop, it->second);
+ }
+
+ lastName = name;
+ lastType = source;
}
}
}