OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/shell/browser/shell_desktop_controller.h" | 5 #include "extensions/shell/browser/shell_desktop_controller.h" |
6 | 6 |
7 #include "apps/shell/browser/shell_app_window_controller.h" | |
8 #include "apps/shell/common/switches.h" | |
9 #include "base/command_line.h" | 7 #include "base/command_line.h" |
10 #include "content/public/browser/context_factory.h" | 8 #include "content/public/browser/context_factory.h" |
| 9 #include "extensions/shell/browser/shell_app_window_controller.h" |
| 10 #include "extensions/shell/common/switches.h" |
11 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
12 #include "ui/aura/client/default_capture_client.h" | 12 #include "ui/aura/client/default_capture_client.h" |
13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
14 #include "ui/aura/layout_manager.h" | 14 #include "ui/aura/layout_manager.h" |
15 #include "ui/aura/test/test_screen.h" | 15 #include "ui/aura/test/test_screen.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
18 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
19 #include "ui/base/cursor/cursor.h" | 19 #include "ui/base/cursor/cursor.h" |
20 #include "ui/base/cursor/image_cursors.h" | 20 #include "ui/base/cursor/image_cursors.h" |
21 #include "ui/base/ime/input_method_initializer.h" | 21 #include "ui/base/ime/input_method_initializer.h" |
22 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
24 #include "ui/wm/core/base_focus_rules.h" | 24 #include "ui/wm/core/base_focus_rules.h" |
25 #include "ui/wm/core/compound_event_filter.h" | 25 #include "ui/wm/core/compound_event_filter.h" |
26 #include "ui/wm/core/cursor_manager.h" | 26 #include "ui/wm/core/cursor_manager.h" |
27 #include "ui/wm/core/focus_controller.h" | 27 #include "ui/wm/core/focus_controller.h" |
28 #include "ui/wm/core/input_method_event_filter.h" | 28 #include "ui/wm/core/input_method_event_filter.h" |
29 #include "ui/wm/core/native_cursor_manager.h" | 29 #include "ui/wm/core/native_cursor_manager.h" |
30 #include "ui/wm/core/native_cursor_manager_delegate.h" | 30 #include "ui/wm/core/native_cursor_manager_delegate.h" |
31 #include "ui/wm/core/user_activity_detector.h" | 31 #include "ui/wm/core/user_activity_detector.h" |
32 | 32 |
33 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
34 #include "ui/chromeos/user_activity_power_manager_notifier.h" | 34 #include "ui/chromeos/user_activity_power_manager_notifier.h" |
35 #include "ui/display/types/chromeos/display_mode.h" | 35 #include "ui/display/types/chromeos/display_mode.h" |
36 #include "ui/display/types/chromeos/display_snapshot.h" | 36 #include "ui/display/types/chromeos/display_snapshot.h" |
37 #endif | 37 #endif |
38 | 38 |
39 namespace apps { | 39 namespace extensions { |
40 namespace { | 40 namespace { |
41 | 41 |
42 // A simple layout manager that makes each new window fill its parent. | 42 // A simple layout manager that makes each new window fill its parent. |
43 class FillLayout : public aura::LayoutManager { | 43 class FillLayout : public aura::LayoutManager { |
44 public: | 44 public: |
45 FillLayout() {} | 45 FillLayout() {} |
46 virtual ~FillLayout() {} | 46 virtual ~FillLayout() {} |
47 | 47 |
48 private: | 48 private: |
49 // aura::LayoutManager: | 49 // aura::LayoutManager: |
(...skipping 21 matching lines...) Expand all Loading... |
71 } | 71 } |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(FillLayout); | 73 DISALLOW_COPY_AND_ASSIGN(FillLayout); |
74 }; | 74 }; |
75 | 75 |
76 // A class that bridges the gap between CursorManager and Aura. It borrows | 76 // A class that bridges the gap between CursorManager and Aura. It borrows |
77 // heavily from AshNativeCursorManager. | 77 // heavily from AshNativeCursorManager. |
78 class ShellNativeCursorManager : public wm::NativeCursorManager { | 78 class ShellNativeCursorManager : public wm::NativeCursorManager { |
79 public: | 79 public: |
80 explicit ShellNativeCursorManager(aura::WindowTreeHost* host) | 80 explicit ShellNativeCursorManager(aura::WindowTreeHost* host) |
81 : host_(host), | 81 : host_(host), image_cursors_(new ui::ImageCursors) {} |
82 image_cursors_(new ui::ImageCursors) {} | |
83 virtual ~ShellNativeCursorManager() {} | 82 virtual ~ShellNativeCursorManager() {} |
84 | 83 |
85 // wm::NativeCursorManager overrides. | 84 // wm::NativeCursorManager overrides. |
86 virtual void SetDisplay( | 85 virtual void SetDisplay(const gfx::Display& display, |
87 const gfx::Display& display, | 86 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
88 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | |
89 if (image_cursors_->SetDisplay(display, display.device_scale_factor())) | 87 if (image_cursors_->SetDisplay(display, display.device_scale_factor())) |
90 SetCursor(delegate->GetCursor(), delegate); | 88 SetCursor(delegate->GetCursor(), delegate); |
91 } | 89 } |
92 | 90 |
93 virtual void SetCursor( | 91 virtual void SetCursor(gfx::NativeCursor cursor, |
94 gfx::NativeCursor cursor, | 92 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
95 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | |
96 image_cursors_->SetPlatformCursor(&cursor); | 93 image_cursors_->SetPlatformCursor(&cursor); |
97 cursor.set_device_scale_factor(image_cursors_->GetScale()); | 94 cursor.set_device_scale_factor(image_cursors_->GetScale()); |
98 delegate->CommitCursor(cursor); | 95 delegate->CommitCursor(cursor); |
99 | 96 |
100 if (delegate->IsCursorVisible()) | 97 if (delegate->IsCursorVisible()) |
101 ApplyCursor(cursor); | 98 ApplyCursor(cursor); |
102 } | 99 } |
103 | 100 |
104 virtual void SetVisibility( | 101 virtual void SetVisibility( |
105 bool visible, | 102 bool visible, |
(...skipping 20 matching lines...) Expand all Loading... |
126 | 123 |
127 virtual void SetMouseEventsEnabled( | 124 virtual void SetMouseEventsEnabled( |
128 bool enabled, | 125 bool enabled, |
129 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 126 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { |
130 delegate->CommitMouseEventsEnabled(enabled); | 127 delegate->CommitMouseEventsEnabled(enabled); |
131 SetVisibility(delegate->IsCursorVisible(), delegate); | 128 SetVisibility(delegate->IsCursorVisible(), delegate); |
132 } | 129 } |
133 | 130 |
134 private: | 131 private: |
135 // Sets |cursor| as the active cursor within Aura. | 132 // Sets |cursor| as the active cursor within Aura. |
136 void ApplyCursor(gfx::NativeCursor cursor) { | 133 void ApplyCursor(gfx::NativeCursor cursor) { host_->SetCursor(cursor); } |
137 host_->SetCursor(cursor); | |
138 } | |
139 | 134 |
140 aura::WindowTreeHost* host_; // Not owned. | 135 aura::WindowTreeHost* host_; // Not owned. |
141 | 136 |
142 scoped_ptr<ui::ImageCursors> image_cursors_; | 137 scoped_ptr<ui::ImageCursors> image_cursors_; |
143 | 138 |
144 DISALLOW_COPY_AND_ASSIGN(ShellNativeCursorManager); | 139 DISALLOW_COPY_AND_ASSIGN(ShellNativeCursorManager); |
145 }; | 140 }; |
146 | 141 |
147 class AppsFocusRules : public wm::BaseFocusRules { | 142 class AppsFocusRules : public wm::BaseFocusRules { |
148 public: | 143 public: |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 display_configurator_->cached_displays(); | 326 display_configurator_->cached_displays(); |
332 if (displays.empty()) | 327 if (displays.empty()) |
333 return gfx::Size(); | 328 return gfx::Size(); |
334 const ui::DisplayMode* mode = displays[0].display->current_mode(); | 329 const ui::DisplayMode* mode = displays[0].display->current_mode(); |
335 return mode ? mode->size() : gfx::Size(); | 330 return mode ? mode->size() : gfx::Size(); |
336 #else | 331 #else |
337 return gfx::Size(); | 332 return gfx::Size(); |
338 #endif | 333 #endif |
339 } | 334 } |
340 | 335 |
341 } // namespace apps | 336 } // namespace extensions |
OLD | NEW |