summaryrefslogtreecommitdiffstats
path: root/ui/views/focus
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 18:31:52 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-02 18:31:52 +0000
commitcc2c4eb51c6fc7c688151df5fc28e28d031cf3e3 (patch)
treecf110bb3cfe4fb2f19dfca7fd3c5d808cee2c8d9 /ui/views/focus
parent832c698f26e0d26a05a699720b5ed214b7463c74 (diff)
downloadchromium_src-cc2c4eb51c6fc7c688151df5fc28e28d031cf3e3.zip
chromium_src-cc2c4eb51c6fc7c688151df5fc28e28d031cf3e3.tar.gz
chromium_src-cc2c4eb51c6fc7c688151df5fc28e28d031cf3e3.tar.bz2
Begin to integrate Focus Manager. Add Windows accelerator handler implementation (commented out now due to lack of focus manager). Add some utilities to NativeWidget for obtaining NativeWidget from a NativeView.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6286035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/focus')
-rw-r--r--ui/views/focus/accelerator_handler.h71
-rw-r--r--ui/views/focus/accelerator_handler_win.cc60
2 files changed, 131 insertions, 0 deletions
diff --git a/ui/views/focus/accelerator_handler.h b/ui/views/focus/accelerator_handler.h
new file mode 100644
index 0000000..3f129ba
--- /dev/null
+++ b/ui/views/focus/accelerator_handler.h
@@ -0,0 +1,71 @@
+// 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 UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
+#define UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
+#pragma once
+
+#include "build/build_config.h"
+
+#if defined(OS_LINUX)
+#include <gdk/gdk.h>
+#endif
+
+#include <set>
+#include <vector>
+
+#include "base/message_loop.h"
+
+namespace ui {
+
+#if defined(TOUCH_UI)
+// Dispatch an XEvent to the RootView. Return true if the event was dispatched
+// and handled, false otherwise.
+bool DispatchXEvent(XEvent* xevent);
+
+#if defined(HAVE_XINPUT2)
+// Keep a list of touch devices so that it is possible to determine if a pointer
+// event is a touch-event or a mouse-event.
+void SetTouchDeviceList(std::vector<unsigned int>& devices);
+#endif // HAVE_XINPUT2
+#endif // TOUCH_UI
+
+////////////////////////////////////////////////////////////////////////////////
+// AcceleratorHandler class
+//
+// An object that pre-screens all UI messages for potential accelerators.
+// Registered accelerators are processed regardless of focus within a given
+// Widget or Window.
+//
+// This processing is done at the Dispatcher level rather than on the Widget
+// because of the global nature of this processing, and the fact that not all
+// controls within a window need to be Widgets - some are native controls from
+// the underlying toolkit wrapped by NativeViewHost.
+//
+class AcceleratorHandler : public MessageLoopForUI::Dispatcher {
+ public:
+ AcceleratorHandler();
+ // Dispatcher method. This returns true if an accelerator was processed by the
+ // focus manager
+#if defined(OS_WIN)
+ virtual bool Dispatch(const MSG& msg);
+#else
+ virtual bool Dispatch(GdkEvent* event);
+#if defined(TOUCH_UI)
+ virtual MessagePumpGlibXDispatcher::DispatchStatus Dispatch(XEvent* xev);
+#endif
+#endif
+
+ private:
+#if defined(OS_WIN)
+ // The keys currently pressed and consumed by the FocusManager.
+ std::set<WPARAM> pressed_keys_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(AcceleratorHandler);
+};
+
+} // namespace ui
+
+#endif // UI_VIEWS_FOCUS_ACCELERATOR_HANDLER_H_
diff --git a/ui/views/focus/accelerator_handler_win.cc b/ui/views/focus/accelerator_handler_win.cc
new file mode 100644
index 0000000..02bd097
--- /dev/null
+++ b/ui/views/focus/accelerator_handler_win.cc
@@ -0,0 +1,60 @@
+// 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.
+
+#include "ui/views/focus/accelerator_handler.h"
+
+#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/base/keycodes/keyboard_code_conversion_win.h"
+#include "ui/views/events/event.h"
+//#include "ui/views/focus/focus_manager.h"
+
+namespace ui {
+
+AcceleratorHandler::AcceleratorHandler() {
+}
+
+bool AcceleratorHandler::Dispatch(const MSG& msg) {
+ bool process_message = true;
+
+ if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) {
+ /*
+ FocusManager* focus_manager =
+ FocusManager::GetFocusManagerForNativeView(msg.hwnd);
+ if (focus_manager) {
+ switch (msg.message) {
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN: {
+ process_message = focus_manager->OnKeyEvent(KeyEvent(msg));
+ if (!process_message) {
+ // Record that this key is pressed so we can remember not to
+ // translate and dispatch the associated WM_KEYUP.
+ pressed_keys_.insert(msg.wParam);
+ }
+ break;
+ }
+ case WM_KEYUP:
+ case WM_SYSKEYUP: {
+ std::set<WPARAM>::iterator iter = pressed_keys_.find(msg.wParam);
+ if (iter != pressed_keys_.end()) {
+ // Don't translate/dispatch the KEYUP since we have eaten the
+ // associated KEYDOWN.
+ pressed_keys_.erase(iter);
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ */
+ }
+
+ if (process_message) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return true;
+}
+
+} // namespace ui