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

Side by Side Diff: ui/aura/root_window.cc

Issue 9689027: MonitorManager to manage multiple monitors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: crash fix Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_split.h" 15 #include "base/string_split.h"
16 #include "ui/aura/aura_switches.h" 16 #include "ui/aura/aura_switches.h"
17 #include "ui/aura/client/activation_client.h" 17 #include "ui/aura/client/activation_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/root_window_host.h"
20 #include "ui/aura/root_window_observer.h"
21 #include "ui/aura/event.h" 19 #include "ui/aura/event.h"
22 #include "ui/aura/event_filter.h" 20 #include "ui/aura/event_filter.h"
23 #include "ui/aura/focus_manager.h" 21 #include "ui/aura/focus_manager.h"
24 #include "ui/aura/gestures/gesture_recognizer.h" 22 #include "ui/aura/gestures/gesture_recognizer.h"
23 #include "ui/aura/monitor.h"
24 #include "ui/aura/monitor_manager.h"
25 #include "ui/aura/root_window_host.h"
26 #include "ui/aura/root_window_observer.h"
25 #include "ui/aura/screen_aura.h" 27 #include "ui/aura/screen_aura.h"
26 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
27 #include "ui/aura/window_delegate.h" 29 #include "ui/aura/window_delegate.h"
28 #include "ui/base/hit_test.h" 30 #include "ui/base/hit_test.h"
29 #include "ui/gfx/compositor/compositor.h" 31 #include "ui/gfx/compositor/compositor.h"
30 #include "ui/gfx/compositor/layer.h" 32 #include "ui/gfx/compositor/layer.h"
31 #include "ui/gfx/compositor/layer_animator.h" 33 #include "ui/gfx/compositor/layer_animator.h"
32 34
33 using std::string; 35 using std::string;
34 using std::vector; 36 using std::vector;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // RootWindow, public: 86 // RootWindow, public:
85 87
86 RootWindow::RootWindow() 88 RootWindow::RootWindow()
87 : Window(NULL), 89 : Window(NULL),
88 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), 90 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())),
89 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), 91 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
90 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), 92 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)),
91 mouse_button_flags_(0), 93 mouse_button_flags_(0),
92 last_cursor_(kCursorNull), 94 last_cursor_(kCursorNull),
93 cursor_shown_(true), 95 cursor_shown_(true),
94 ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))),
95 capture_window_(NULL), 96 capture_window_(NULL),
96 mouse_pressed_handler_(NULL), 97 mouse_pressed_handler_(NULL),
97 mouse_moved_handler_(NULL), 98 mouse_moved_handler_(NULL),
98 focused_window_(NULL), 99 focused_window_(NULL),
99 touch_event_handler_(NULL), 100 touch_event_handler_(NULL),
100 gesture_handler_(NULL), 101 gesture_handler_(NULL),
101 ALLOW_THIS_IN_INITIALIZER_LIST( 102 ALLOW_THIS_IN_INITIALIZER_LIST(
102 gesture_recognizer_(GestureRecognizer::Create(this))), 103 gesture_recognizer_(GestureRecognizer::Create(this))),
103 synthesize_mouse_move_(false), 104 synthesize_mouse_move_(false),
104 waiting_on_compositing_end_(false), 105 waiting_on_compositing_end_(false),
105 draw_on_compositing_end_(false) { 106 draw_on_compositing_end_(false) {
106 SetName("RootWindow"); 107 SetName("RootWindow");
107 gfx::Screen::SetInstance(screen_); 108
109 gfx::Screen::SetInstance(new ScreenAura(this));
110
108 last_mouse_location_ = host_->QueryMouseLocation(); 111 last_mouse_location_ = host_->QueryMouseLocation();
109 112
110 ui::Compositor::Initialize(false); 113 ui::Compositor::Initialize(false);
111 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(), 114 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(),
112 host_->GetSize())); 115 host_->GetSize()));
113 DCHECK(compositor_.get()); 116 DCHECK(compositor_.get());
114 compositor_->AddObserver(this); 117 compositor_->AddObserver(this);
115 Init(); 118 Init();
116 } 119 }
117 120
(...skipping 23 matching lines...) Expand all
141 last_mouse_location_ = host_->QueryMouseLocation(); 144 last_mouse_location_ = host_->QueryMouseLocation();
142 synthesize_mouse_move_ = false; 145 synthesize_mouse_move_ = false;
143 } 146 }
144 147
145 gfx::Size RootWindow::GetHostSize() const { 148 gfx::Size RootWindow::GetHostSize() const {
146 gfx::Rect rect(host_->GetSize()); 149 gfx::Rect rect(host_->GetSize());
147 layer()->transform().TransformRect(&rect); 150 layer()->transform().TransformRect(&rect);
148 return rect.size(); 151 return rect.size();
149 } 152 }
150 153
151 void RootWindow::SetScreenWorkAreaInsets(const gfx::Insets& insets) { 154 void RootWindow::SetMonitorWorkAreaInsets(const gfx::Insets& insets) {
152 if (screen_->work_area_insets() == insets) 155 Monitor* monitor = Env::GetInstance()->monitor_manager()->
156 GetMonitorNearestWindow(this);
157 if (monitor->work_area_insets() == insets)
153 return; 158 return;
154 screen_->set_work_area_insets(insets); 159 monitor->set_work_area_insets(insets);
155 FOR_EACH_OBSERVER(RootWindowObserver, observers_, 160 FOR_EACH_OBSERVER(RootWindowObserver, observers_,
156 OnScreenWorkAreaInsetsChanged()); 161 OnMonitorWorkAreaInsetsChanged());
157 } 162 }
158 163
159 void RootWindow::SetCursor(gfx::NativeCursor cursor) { 164 void RootWindow::SetCursor(gfx::NativeCursor cursor) {
160 last_cursor_ = cursor; 165 last_cursor_ = cursor;
161 // A lot of code seems to depend on NULL cursors actually showing an arrow, 166 // A lot of code seems to depend on NULL cursors actually showing an arrow,
162 // so just pass everything along to the host. 167 // so just pass everything along to the host.
163 host_->SetCursor(cursor); 168 host_->SetCursor(cursor);
164 } 169 }
165 170
166 void RootWindow::ShowCursor(bool show) { 171 void RootWindow::ShowCursor(bool show) {
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 bool RootWindow::IsFocusedWindow(const Window* window) const { 786 bool RootWindow::IsFocusedWindow(const Window* window) const {
782 return focused_window_ == window; 787 return focused_window_ == window;
783 } 788 }
784 789
785 void RootWindow::Init() { 790 void RootWindow::Init() {
786 Window::Init(ui::Layer::LAYER_NOT_DRAWN); 791 Window::Init(ui::Layer::LAYER_NOT_DRAWN);
787 SetBounds(gfx::Rect(host_->GetSize())); 792 SetBounds(gfx::Rect(host_->GetSize()));
788 Show(); 793 Show();
789 compositor()->SetRootLayer(layer()); 794 compositor()->SetRootLayer(layer());
790 host_->SetRootWindow(this); 795 host_->SetRootWindow(this);
796 // MonitorManager needs to access the root's bounds, so initialize after
797 // layer is created.
798 aura::Env::GetInstance()->SetMonitorManager(
799 aura::CreateSingleMonitorManager(this));
791 } 800 }
792 801
793 gfx::Rect RootWindow::GetInitialHostWindowBounds() const { 802 gfx::Rect RootWindow::GetInitialHostWindowBounds() const {
794 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, 803 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
795 kDefaultHostWindowWidth, kDefaultHostWindowHeight); 804 kDefaultHostWindowWidth, kDefaultHostWindowHeight);
796 805
797 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 806 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
798 switches::kAuraHostWindowSize); 807 switches::kAuraHostWindowSize);
799 vector<string> parts; 808 vector<string> parts;
800 base::SplitString(size_str, 'x', &parts); 809 base::SplitString(size_str, 'x', &parts);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // is currently broken. See/ crbug.com/107931. 842 // is currently broken. See/ crbug.com/107931.
834 MouseEvent event(ui::ET_MOUSE_MOVED, 843 MouseEvent event(ui::ET_MOUSE_MOVED,
835 orig_mouse_location, 844 orig_mouse_location,
836 orig_mouse_location, 845 orig_mouse_location,
837 ui::EF_IS_SYNTHESIZED); 846 ui::EF_IS_SYNTHESIZED);
838 DispatchMouseEvent(&event); 847 DispatchMouseEvent(&event);
839 #endif 848 #endif
840 } 849 }
841 850
842 } // namespace aura 851 } // namespace aura
OLDNEW
« ui/aura/monitor.h ('K') | « ui/aura/root_window.h ('k') | ui/aura/root_window_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698