summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2015-09-30 01:20:27 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2015-09-30 01:20:27 +0200
commita78f60dea00ea87c66259b511ce254ce0a767fa9 (patch)
treea7237dd225c89971e47da1ab10e32917c4efd049 /unity-shared
parent3b436979171d0adf7b67eb021532729b49cb5fe4 (diff)
GnomeKeyGrabber: return always the same action ID for a keybinding
Fixes LP: #1459571 (bzr r4008.7.7)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/GnomeKeyGrabber.cpp10
-rw-r--r--unity-shared/GnomeKeyGrabberImpl.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/unity-shared/GnomeKeyGrabber.cpp b/unity-shared/GnomeKeyGrabber.cpp
index b7e138532..8c39f01ff 100644
--- a/unity-shared/GnomeKeyGrabber.cpp
+++ b/unity-shared/GnomeKeyGrabber.cpp
@@ -85,7 +85,7 @@ uint32_t GnomeGrabber::Impl::NextActionID()
return ++current_action_id_;
}
-bool GnomeGrabber::Impl::AddAction(CompAction const& action, uint32_t action_id)
+bool GnomeGrabber::Impl::AddAction(CompAction const& action, uint32_t& action_id)
{
LOG_DEBUG(logger) << "AddAction (\"" << action.keyToString() << "\") = " << action_id;
@@ -95,10 +95,12 @@ bool GnomeGrabber::Impl::AddAction(CompAction const& action, uint32_t action_id)
return false;
}
- if (std::find(actions_.begin(), actions_.end(), action) != actions_.end())
+ auto it = std::find(actions_.begin(), actions_.end(), action);
+ if (it != actions_.end())
{
- LOG_ERROR(logger) << "Key binding \"" << action.keyToString() << "\" is already grabbed";
- return false;
+ action_id = actions_ids_[it - actions_.begin()];
+ LOG_DEBUG(logger) << "Key binding \"" << action.keyToString() << "\" is already grabbed, reusing id " << action_id;
+ return true;
}
if (screen_->addAction(const_cast<CompAction*>(&action)))
diff --git a/unity-shared/GnomeKeyGrabberImpl.h b/unity-shared/GnomeKeyGrabberImpl.h
index 82aedbee2..6631adb1c 100644
--- a/unity-shared/GnomeKeyGrabberImpl.h
+++ b/unity-shared/GnomeKeyGrabberImpl.h
@@ -39,7 +39,7 @@ struct GnomeGrabber::Impl
uint32_t NextActionID();
- bool AddAction(CompAction const& action, uint32_t action_id);
+ bool AddAction(CompAction const& action, uint32_t& action_id);
uint32_t AddAction(CompAction const& action);
bool RemoveAction(CompAction const& action);