summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b0f4afe)
raw | patch | inline | side by side (parent: b0f4afe)
author | joncruz <joncruz@users.sourceforge.net> | |
Wed, 27 Feb 2008 08:48:00 +0000 (08:48 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Wed, 27 Feb 2008 08:48:00 +0000 (08:48 +0000) |
src/desktop-events.cpp | patch | blob | history |
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index a1f4363ea69bb56e9ebb53e22edc8e213ce41461..1351d62f0d5fbd9d1c33f2a8efbfb2b074bd4c51 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
#include "display/canvas-axonomgrid.h"
#include "prefs-utils.h"
#include "helper/action.h"
-#include "verbs.h"
+#include "tools-switch.h"
#include <2geom/point.h>
static void snoop_extended(GdkEvent* event, SPDesktop *desktop);
GdkDevice* dev = reinterpret_cast<GdkDevice*>(curr->data);
if ( dev->name
&& (avoidName != dev->name)
- && switchMap.find(dev->source) == switchMap.end() ) {
+ && (switchMap.find(dev->source) == switchMap.end())
+ && (dev->source != GDK_SOURCE_MOUSE) ) {
switchMap[dev->source] = dev->name;
-// g_message("Adding '%s' as [%s]", dev->name, namefor(dev->source));
+// g_message("Adding '%s' as [%d]", dev->name, dev->source);
// Set the initial tool for the device
switch ( dev->source ) {
- case GDK_SOURCE_MOUSE:
- // Don't do anything for the main mouse.
- break;
case GDK_SOURCE_PEN:
- toolToUse[GDK_SOURCE_PEN] = SP_VERB_CONTEXT_CALLIGRAPHIC;
+ toolToUse[GDK_SOURCE_PEN] = TOOLS_CALLIGRAPHIC;
break;
case GDK_SOURCE_ERASER:
- toolToUse[GDK_SOURCE_ERASER] = SP_VERB_CONTEXT_TWEAK;
+ toolToUse[GDK_SOURCE_ERASER] = TOOLS_TWEAK;
break;
case GDK_SOURCE_CURSOR:
- toolToUse[GDK_SOURCE_CURSOR] = SP_VERB_CONTEXT_SELECT;
+ toolToUse[GDK_SOURCE_CURSOR] = TOOLS_SELECT;
break;
+ default:
+ ; // do not add
}
// } else {
// g_message("Skippn '%s' as [%s]", dev->name, namefor(dev->source));
if ( lastName != name || lastType != source ) {
// 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) ) {
- lastName = name;
- lastType = source;
-
+ if ( (it != switchMap.end()) && (name == it->second) ) {
std::map<GdkInputSource, int>::iterator it2 = toolToUse.find(source);
if (it2 != toolToUse.end() ) {
- Inkscape::Verb* verb = Inkscape::Verb::get(it2->second);
- if ( verb ) {
- SPAction* action = verb->get_action(desktop);
- if ( action ) {
- sp_action_perform(action, 0);
- }
- } else {
- g_warning(" NO VERB FOUND");
+ // 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);
}
-// } else {
-// g_warning(" NO ID FOUND");
+ tools_switch(desktop, it2->second);
}
+ lastName = name;
+ lastType = source;
}
}
}