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

Side by Side Diff: ui/aura/desktop.h

Issue 8771015: Rename Desktop->RootWindow. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/aura/desktop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_AURA_DESKTOP_H_
6 #define UI_AURA_DESKTOP_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h"
13 #include "base/task.h"
14 #include "ui/aura/aura_export.h"
15 #include "ui/aura/cursor.h"
16 #include "ui/aura/focus_manager.h"
17 #include "ui/aura/window.h"
18 #include "ui/base/events.h"
19 #include "ui/gfx/compositor/compositor.h"
20 #include "ui/gfx/compositor/layer_animation_observer.h"
21 #include "ui/gfx/native_widget_types.h"
22 #include "ui/gfx/point.h"
23
24 namespace gfx {
25 class Size;
26 }
27
28 namespace ui {
29 class LayerAnimationSequence;
30 class Transform;
31 }
32
33 namespace aura {
34
35 class DesktopHost;
36 class DesktopObserver;
37 class KeyEvent;
38 class MouseEvent;
39 class ScreenAura;
40 class StackingClient;
41 class TouchEvent;
42
43 // Desktop is responsible for hosting a set of windows.
44 class AURA_EXPORT Desktop : public ui::CompositorDelegate,
45 public Window,
46 public internal::FocusManager,
47 public ui::LayerAnimationObserver {
48 public:
49 static Desktop* GetInstance();
50 static void DeleteInstance();
51
52 static void set_use_fullscreen_host_window(bool use_fullscreen) {
53 use_fullscreen_host_window_ = use_fullscreen;
54 }
55
56 ui::Compositor* compositor() { return compositor_.get(); }
57 gfx::Point last_mouse_location() const { return last_mouse_location_; }
58 gfx::NativeCursor last_cursor() const { return last_cursor_; }
59 StackingClient* stacking_client() { return stacking_client_.get(); }
60 Window* active_window() { return active_window_; }
61 Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
62 Window* capture_window() { return capture_window_; }
63 ScreenAura* screen() { return screen_; }
64
65 void SetStackingClient(StackingClient* stacking_client);
66
67 // Shows the desktop host.
68 void ShowDesktop();
69
70 // Sets the size of the desktop.
71 void SetHostSize(const gfx::Size& size);
72 gfx::Size GetHostSize() const;
73
74 // Shows the specified cursor.
75 void SetCursor(gfx::NativeCursor cursor);
76
77 // Shows the desktop host and runs an event loop for it.
78 void Run();
79
80 // Draws the necessary set of windows.
81 void Draw();
82
83 // Handles a mouse event. Returns true if handled.
84 bool DispatchMouseEvent(MouseEvent* event);
85
86 // Handles a key event. Returns true if handled.
87 bool DispatchKeyEvent(KeyEvent* event);
88
89 // Handles a touch event. Returns true if handled.
90 bool DispatchTouchEvent(TouchEvent* event);
91
92 // Called when the host changes size.
93 void OnHostResized(const gfx::Size& size);
94
95 // Called when the native screen's resolution changes.
96 void OnNativeScreenResized(const gfx::Size& size);
97
98 // Sets the active window to |window| and the focused window to |to_focus|.
99 // If |to_focus| is NULL, |window| is focused. Does nothing if |window| is
100 // NULL.
101 void SetActiveWindow(Window* window, Window* to_focus);
102
103 // Activates the topmost window. Does nothing if the topmost window is already
104 // active.
105 void ActivateTopmostWindow();
106
107 // Deactivates |window| and activates the topmost window. Does nothing if
108 // |window| is not a topmost window, or there are no other suitable windows to
109 // activate.
110 void Deactivate(Window* window);
111
112 // Invoked when |window| is initialized.
113 void WindowInitialized(Window* window);
114
115 // Invoked when |window| is being destroyed.
116 void WindowDestroying(Window* window);
117
118 // Returns the desktop's dispatcher. The result should only be passed to
119 // MessageLoopForUI::RunWithDispatcher() or
120 // MessageLoopForUI::RunAllPendingWithDispatcher(), or used to dispatch
121 // an event by |Dispatch(const NativeEvent&)| on it. It must never be stored.
122 MessageLoop::Dispatcher* GetDispatcher();
123
124 // Add/remove observer.
125 void AddObserver(DesktopObserver* observer);
126 void RemoveObserver(DesktopObserver* observer);
127
128 // Are any mouse buttons currently down?
129 bool IsMouseButtonDown() const;
130
131 // Posts |native_event| to the platform's event queue.
132 void PostNativeEvent(const base::NativeEvent& native_event);
133
134 // Converts |point| from the desktop's coordinate system to native screen's.
135 void ConvertPointToNativeScreen(gfx::Point* point) const;
136
137 // Capture -------------------------------------------------------------------
138
139 // Sets capture to the specified window.
140 void SetCapture(Window* window);
141
142 // If |window| has mouse capture, the current capture window is set to NULL.
143 void ReleaseCapture(Window* window);
144
145 // Overridden from Window:
146 virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
147
148 #if !defined(NDEBUG)
149 // Toggles the host's full screen state.
150 void ToggleFullScreen();
151 #endif
152
153 // Overridden from ui::CompositorDelegate:
154 virtual void ScheduleDraw();
155
156 private:
157 Desktop();
158 virtual ~Desktop();
159
160 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|,
161 // sending exited and entered events as its value changes.
162 void HandleMouseMoved(const MouseEvent& event, Window* target);
163
164 bool ProcessMouseEvent(Window* target, MouseEvent* event);
165 bool ProcessKeyEvent(Window* target, KeyEvent* event);
166 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event);
167
168 // Overridden from Window:
169 virtual bool CanFocus() const OVERRIDE;
170 virtual internal::FocusManager* GetFocusManager() OVERRIDE;
171 virtual Desktop* GetDesktop() OVERRIDE;
172 virtual void WindowDetachedFromDesktop(Window* window) OVERRIDE;
173
174 // Overridden from ui::LayerAnimationObserver:
175 virtual void OnLayerAnimationEnded(
176 const ui::LayerAnimationSequence* animation) OVERRIDE;
177 virtual void OnLayerAnimationScheduled(
178 const ui::LayerAnimationSequence* animation) OVERRIDE;
179 virtual void OnLayerAnimationAborted(
180 const ui::LayerAnimationSequence* animation) OVERRIDE;
181
182 // Overridden from FocusManager:
183 virtual void SetFocusedWindow(Window* window) OVERRIDE;
184 virtual Window* GetFocusedWindow() OVERRIDE;
185 virtual bool IsFocusedWindow(const Window* window) const OVERRIDE;
186
187 // Initializes the desktop.
188 void Init();
189
190 // Parses the switch describing the initial size for the host window and
191 // returns bounds for the window.
192 gfx::Rect GetInitialHostWindowBounds() const;
193
194 scoped_refptr<ui::Compositor> compositor_;
195
196 scoped_ptr<DesktopHost> host_;
197
198 scoped_ptr<StackingClient> stacking_client_;
199
200 static Desktop* instance_;
201
202 // If set before the Desktop is created, the host window will cover the entire
203 // screen. Note that this can still be overridden via the
204 // switches::kAuraHostWindowSize flag.
205 static bool use_fullscreen_host_window_;
206
207 // Used to schedule painting.
208 base::WeakPtrFactory<Desktop> schedule_paint_factory_;
209
210 Window* active_window_;
211
212 // Last location seen in a mouse event.
213 gfx::Point last_mouse_location_;
214
215 // ui::EventFlags containing the current state of the mouse buttons.
216 int mouse_button_flags_;
217
218 // Last cursor set. Used for testing.
219 gfx::NativeCursor last_cursor_;
220
221 // Are we in the process of being destroyed? Used to avoid processing during
222 // destruction.
223 bool in_destructor_;
224
225 ObserverList<DesktopObserver> observers_;
226
227 ScreenAura* screen_;
228
229 // The capture window. When not-null, this window receives all the mouse and
230 // touch events.
231 Window* capture_window_;
232
233 Window* mouse_pressed_handler_;
234 Window* mouse_moved_handler_;
235 Window* focused_window_;
236 Window* touch_event_handler_;
237
238 DISALLOW_COPY_AND_ASSIGN(Desktop);
239 };
240
241 } // namespace aura
242
243 #endif // UI_AURA_DESKTOP_H_
OLDNEW
« no previous file with comments | « ui/aura/demo/demo_main.cc ('k') | ui/aura/desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698