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

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

Issue 8194004: change the way windows are parented when their parent is set to NULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/aura.gyp ('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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef UI_AURA_DESKTOP_H_ 5 #ifndef UI_AURA_DESKTOP_H_
6 #define UI_AURA_DESKTOP_H_ 6 #define UI_AURA_DESKTOP_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "ui/aura/aura_export.h" 13 #include "ui/aura/aura_export.h"
14 #include "ui/aura/cursor.h" 14 #include "ui/aura/cursor.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/base/events.h" 16 #include "ui/base/events.h"
17 #include "ui/gfx/compositor/compositor.h" 17 #include "ui/gfx/compositor/compositor.h"
18 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Size; 21 class Size;
22 } 22 }
23 23
24 namespace aura { 24 namespace aura {
25 25
26 class DesktopDelegate;
26 class DesktopHost; 27 class DesktopHost;
27 class MouseEvent; 28 class MouseEvent;
28 29
29 // Desktop is responsible for hosting a set of windows. 30 // Desktop is responsible for hosting a set of windows.
30 class AURA_EXPORT Desktop : public ui::CompositorDelegate { 31 class AURA_EXPORT Desktop : public ui::CompositorDelegate {
31 public: 32 public:
32 Desktop(); 33 Desktop();
33 ~Desktop(); 34 ~Desktop();
34 35
36 DesktopDelegate* delegate() { return delegate_; }
37 void set_delegate(DesktopDelegate* delegate) {
38 delegate_ = delegate;
39 }
40
35 // Initializes the desktop. 41 // Initializes the desktop.
36 void Init(); 42 void Init();
37 43
38 // Initializes |default_parent()| for testing.
39 void CreateDefaultParentForTesting();
40
41 // Shows the desktop host. 44 // Shows the desktop host.
42 void Show(); 45 void Show();
43 46
44 // Sets the size of the desktop. 47 // Sets the size of the desktop.
45 void SetSize(const gfx::Size& size); 48 void SetSize(const gfx::Size& size);
46 gfx::Size GetSize() const; 49 gfx::Size GetSize() const;
47 50
48 // Shows the specified cursor. 51 // Shows the specified cursor.
49 void SetCursor(gfx::NativeCursor cursor); 52 void SetCursor(gfx::NativeCursor cursor);
50 53
(...skipping 10 matching lines...) Expand all
61 bool OnKeyEvent(const KeyEvent& event); 64 bool OnKeyEvent(const KeyEvent& event);
62 65
63 // Called when the host changes size. 66 // Called when the host changes size.
64 void OnHostResized(const gfx::Size& size); 67 void OnHostResized(const gfx::Size& size);
65 68
66 // Compositor we're drawing to. 69 // Compositor we're drawing to.
67 ui::Compositor* compositor() { return compositor_.get(); } 70 ui::Compositor* compositor() { return compositor_.get(); }
68 71
69 Window* window() { return window_.get(); } 72 Window* window() { return window_.get(); }
70 73
71 // The window where windows created without an explicitly specified parent are
72 // parented.
73 Window* default_parent() { return default_parent_; }
74 void set_default_parent(Window* default_parent) {
75 default_parent_ = default_parent;
76 }
77
78 static void set_compositor_factory_for_testing(ui::Compositor*(*factory)()) { 74 static void set_compositor_factory_for_testing(ui::Compositor*(*factory)()) {
79 compositor_factory_ = factory; 75 compositor_factory_ = factory;
80 } 76 }
81 static ui::Compositor* (*compositor_factory())() { 77 static ui::Compositor* (*compositor_factory())() {
82 return compositor_factory_; 78 return compositor_factory_;
83 } 79 }
84 80
85 // Sets the active window to |window| and the focused window to |to_focus|. 81 // Sets the active window to |window| and the focused window to |to_focus|.
86 // If |to_focus| is NULL, |window| is focused. 82 // If |to_focus| is NULL, |window| is focused.
87 void SetActiveWindow(Window* window, Window* to_focus); 83 void SetActiveWindow(Window* window, Window* to_focus);
88 Window* active_window() { return active_window_; } 84 Window* active_window() { return active_window_; }
89 85
90 // Activates the topmost window. Does nothing if the topmost window is already 86 // Activates the topmost window. Does nothing if the topmost window is already
91 // active. 87 // active.
92 void ActivateTopmostWindow(); 88 void ActivateTopmostWindow();
93 89
94 // Invoked from RootWindow when |window| is being destroyed. 90 // Invoked from RootWindow when |window| is being destroyed.
95 void WindowDestroying(Window* window); 91 void WindowDestroying(Window* window);
96 92
97 // Returns the desktop's dispatcher. The result should only be passed to 93 // Returns the desktop's dispatcher. The result should only be passed to
98 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(), 94 // MessageLoopForUI::Run() or MessageLoopForUI::RunAllPendingWithDispatcher(),
99 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it. 95 // or used to dispatch an event by |Dispatch(const NativeEvent&)| on it.
100 // It must never be stored. 96 // It must never be stored.
101 MessageLoop::Dispatcher* GetDispatcher(); 97 MessageLoop::Dispatcher* GetDispatcher();
102 98
103 static Desktop* GetInstance(); 99 static Desktop* GetInstance();
104 100
105 private: 101 private:
106 // Returns the topmost window to activate. This ignores |ignore|.
107 Window* GetTopmostWindowToActivate(Window* ignore);
108
109 // Overridden from ui::CompositorDelegate 102 // Overridden from ui::CompositorDelegate
110 virtual void ScheduleDraw(); 103 virtual void ScheduleDraw();
111 104
105 DesktopDelegate* delegate_;
106
112 scoped_refptr<ui::Compositor> compositor_; 107 scoped_refptr<ui::Compositor> compositor_;
113 108
114 scoped_ptr<internal::RootWindow> window_; 109 scoped_ptr<internal::RootWindow> window_;
115 110
116 Window* default_parent_;
117
118 scoped_ptr<DesktopHost> host_; 111 scoped_ptr<DesktopHost> host_;
119 112
120 static Desktop* instance_; 113 static Desktop* instance_;
121 114
122 // Used to schedule painting. 115 // Used to schedule painting.
123 ScopedRunnableMethodFactory<Desktop> schedule_paint_; 116 ScopedRunnableMethodFactory<Desktop> schedule_paint_;
124 117
125 // Factory used to create Compositors. Settable by tests. 118 // Factory used to create Compositors. Settable by tests.
126 static ui::Compositor*(*compositor_factory_)(); 119 static ui::Compositor*(*compositor_factory_)();
127 120
128 Window* active_window_; 121 Window* active_window_;
129 122
130 // Are we in the process of being destroyed? Used to avoid processing during 123 // Are we in the process of being destroyed? Used to avoid processing during
131 // destruction. 124 // destruction.
132 bool in_destructor_; 125 bool in_destructor_;
133 126
134 DISALLOW_COPY_AND_ASSIGN(Desktop); 127 DISALLOW_COPY_AND_ASSIGN(Desktop);
135 }; 128 };
136 129
137 } // namespace aura 130 } // namespace aura
138 131
139 #endif // UI_AURA_DESKTOP_H_ 132 #endif // UI_AURA_DESKTOP_H_
OLDNEW
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698