Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: ui/base/x/x11_util.cc

Issue 8793002: aura-x11: Add support for xmodmap'ed pointer buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/x/x11_util.h ('K') | « ui/base/x/x11_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/x/x11_util.cc
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index fed7764d7b2b3058f2bad0e780076b3d4614a8f4..690a9c770f26545d32e2c93712126c3d6d3693ac 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -18,6 +18,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/memory/singleton.h"
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
@@ -138,6 +139,36 @@ class XCursorCache {
DISALLOW_COPY_AND_ASSIGN(XCursorCache);
};
+// A singleton object that remembers remappings of mouse buttons.
+class XButtonMap {
+ public:
+ static XButtonMap* GetInstance() {
+ return Singleton<XButtonMap>::get();
+ }
+
+ void UpdateMapping() {
+ count_ = XGetPointerMapping(ui::GetXDisplay(), map_, arraysize(map_));
+ }
+
+ int GetMappedButton(int button) {
+ return button > 0 && button <= count_ ? map_[button - 1] : button;
+ }
+
+ private:
+ friend struct DefaultSingletonTraits<XButtonMap>;
+
+ XButtonMap() {
+ UpdateMapping();
+ }
+
+ ~XButtonMap() {}
+
+ unsigned char map_[256];
+ int count_;
+
+ DISALLOW_COPY_AND_ASSIGN(XButtonMap);
+};
+
} // namespace
bool XDisplayExists() {
@@ -833,6 +864,14 @@ bool IsX11WindowFullScreen(XID window) {
#endif
}
+int GetMappedButton(int button) {
+ return XButtonMap::GetInstance()->GetMappedButton(button);
+}
+
+void UpdateButtonMap() {
+ XButtonMap::GetInstance()->UpdateMapping();
+}
+
// ----------------------------------------------------------------------------
// These functions are declared in x11_util_internal.h because they require
// XLib.h to be included, and it conflicts with many other headers.
« ui/base/x/x11_util.h ('K') | « ui/base/x/x11_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698