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

Unified Diff: ash/ui_controls_ash.cc

Issue 10545058: Add UIControlsAsh that works with multiple root windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 8 years, 6 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
« no previous file with comments | « ash/shell_factory.h ('k') | ash/wm/window_properties.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/ui_controls_ash.cc
diff --git a/ash/ui_controls_ash.cc b/ash/ui_controls_ash.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6069c612b179ba60f51dc00b83f1a7f603c7b0b9
--- /dev/null
+++ b/ash/ui_controls_ash.cc
@@ -0,0 +1,131 @@
+// Copyright (c) 2012 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 "ash/shell.h"
+#include "ash/shell_factory.h"
+#include "ash/wm/window_properties.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/ui_controls_aura.h"
+#include "ui/gfx/screen.h"
+#include "ui/ui_controls/ui_controls_aura.h"
+
+namespace ash {
+namespace internal {
+namespace {
+
+// Returns the UIControls object for RootWindow.
+// kUIControlsKey is owned property and UIControls object
+// will be deleted when the root window is deleted.
+ui_controls::UIControlsAura* GetUIControlsForRootWindow(
+ aura::RootWindow* root_window) {
+ ui_controls::UIControlsAura* native_ui_control =
+ root_window->GetProperty(kUIControlsKey);
+ if (!native_ui_control) {
+ native_ui_control = aura::CreateUIControlsAura(root_window);
+ // Pass the ownership to the |root_window|.
+ root_window->SetProperty(kUIControlsKey, native_ui_control);
+ }
+ return native_ui_control;
+}
+
+// Returns the UIControls object for the RootWindow at the |point| in
+// absolute screen coordinates. NULL if there is no RootWindow under the
+// |point|.
+ui_controls::UIControlsAura* GetUIControlsAt(const gfx::Point& point) {
+ aura::RootWindow* root = Shell::GetRootWindowAt(point);
+ return root ? GetUIControlsForRootWindow(root) : NULL;
+}
+
+} // namespace
+
+class UIControlsAsh : public ui_controls::UIControlsAura {
+ public:
+ UIControlsAsh() {
+ }
+ virtual ~UIControlsAsh() {
+ }
+
+ // ui_controls::UIControslAura overrides:
+ virtual bool SendKeyPress(gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command) OVERRIDE {
+ return SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, command, base::Closure());
+ }
+
+ virtual bool SendKeyPressNotifyWhenDone(
+ gfx::NativeWindow window,
+ ui::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ const base::Closure& closure) OVERRIDE {
+ aura::RootWindow* root =
+ window ? window->GetRootWindow() : Shell::GetActiveRootWindow();
+ ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(root);
+ return ui_controls && ui_controls->SendKeyPressNotifyWhenDone(
+ window, key, control, shift, alt, command, closure);
+ }
+
+ virtual bool SendMouseMove(long x, long y) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls =
+ GetUIControlsAt(gfx::Point(x, y));
+ return ui_controls && ui_controls->SendMouseMove(x, y);
+ }
+
+ virtual bool SendMouseMoveNotifyWhenDone(
+ long x,
+ long y,
+ const base::Closure& closure) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls =
+ GetUIControlsAt(gfx::Point(x, y));
+ return ui_controls &&
+ ui_controls->SendMouseMoveNotifyWhenDone(x, y, closure);
+ }
+
+ virtual bool SendMouseEvents(ui_controls::MouseButton type,
+ int state) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls =
+ GetUIControlsAt(gfx::Screen::GetCursorScreenPoint());
+ return ui_controls && ui_controls->SendMouseEvents(type, state);
+ }
+
+ virtual bool SendMouseEventsNotifyWhenDone(
+ ui_controls::MouseButton type,
+ int state,
+ const base::Closure& closure) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls =
+ GetUIControlsAt(gfx::Screen::GetCursorScreenPoint());
+ return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone(
+ type, state, closure);
+ }
+
+ virtual bool SendMouseClick(ui_controls::MouseButton type) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls =
+ GetUIControlsAt(gfx::Screen::GetCursorScreenPoint());
+ return ui_controls && ui_controls->SendMouseClick(type);
+ }
+
+ virtual void RunClosureAfterAllPendingUIEvents(
+ const base::Closure& closure) OVERRIDE {
+ ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(
+ Shell::GetActiveRootWindow());
+ if (ui_controls)
+ ui_controls->RunClosureAfterAllPendingUIEvents(closure);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UIControlsAsh);
+};
+
+ui_controls::UIControlsAura* CreateUIControls() {
+ return new UIControlsAsh();
+}
+
+} // namespace internal
+} // namespace ash
« no previous file with comments | « ash/shell_factory.h ('k') | ash/wm/window_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698