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

Unified Diff: chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h

Issue 6975057: Listen to XI_HierarchyChanged events and call setxkbmap when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added workaround for crbug.com/84694 Created 9 years, 7 months 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
Index: chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
diff --git a/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c37ac3769e15a1899e5b2fb16e18d37ba5fa0f6
--- /dev/null
+++ b/chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_XINPUT_HIERARCHY_CHANGED_EVENT_LISTENER_H_
+#define CHROME_BROWSER_CHROMEOS_XINPUT_HIERARCHY_CHANGED_EVENT_LISTENER_H_
+#pragma once
+
+// TODO(yusukes): Remove the #if once the ARM bot (crbug.com/84694) is fixed.
+#if defined(HAVE_XINPUT2)
+
+#include <gdk/gdk.h>
+
+#include "base/memory/singleton.h"
+#include "base/message_loop.h"
+
+typedef union _XEvent XEvent;
+
+namespace chromeos {
+
+// XInputHierarchyChangedEventListener listens for an XI_HierarchyChanged event,
+// which is sent to Chrome when X detects a system or USB keyboard (or mouse),
+// then tells X to change the current XKB keyboard layout. Start by just calling
+// instance() to get it going.
+class XInputHierarchyChangedEventListener : public MessageLoopForUI::Observer {
+ public:
+ static XInputHierarchyChangedEventListener* GetInstance();
+
+ void Stop();
+
+ private:
+ // Defines the delete on exit Singleton traits we like. Best to have this
+ // and const/dest private as recommended for Singletons.
+ friend struct DefaultSingletonTraits<XInputHierarchyChangedEventListener>;
+
+ XInputHierarchyChangedEventListener();
+ virtual ~XInputHierarchyChangedEventListener();
+
+ // When TOUCH_UI is not defined, WillProcessXEvent() will not be called
+ // automatically. We have to call the function manually by adding the Gdk
+ // event filter.
+ static GdkFilterReturn GdkEventFilter(GdkXEvent* gxevent,
+ GdkEvent* gevent,
+ gpointer data);
+
+ // MessageLoopForUI::Observer overrides.
+ virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {}
+ virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {}
+ virtual bool WillProcessXEvent(XEvent* xevent)
+#if defined(TOUCH_UI)
+ OVERRIDE
+#endif
+ ;
+
+ bool stopped_;
+ int xiopcode_;
+
+ DISALLOW_COPY_AND_ASSIGN(XInputHierarchyChangedEventListener);
+};
+
+} // namespace chromeos
+
+#endif
+#endif // CHROME_BROWSER_CHROMEOS_XINPUT_HIERARCHY_CHANGED_EVENT_LISTENER_H_
« no previous file with comments | « chrome/browser/chromeos/input_method/xkeyboard.cc ('k') | chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698