| OLD | NEW |
| 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" | 19 #include "ui/aura/root_window_host.h" |
| 20 #include "ui/aura/root_window_observer.h" | 20 #include "ui/aura/root_window_observer.h" |
| 21 #include "ui/aura/event.h" | 21 #include "ui/aura/event.h" |
| 22 #include "ui/aura/event_filter.h" | 22 #include "ui/aura/event_filter.h" |
| 23 #include "ui/aura/focus_manager.h" | 23 #include "ui/aura/focus_manager.h" |
| 24 #include "ui/aura/gestures/gesture_recognizer.h" | 24 #include "ui/aura/gestures/gesture_recognizer.h" |
| 25 #include "ui/aura/screen_aura.h" | |
| 26 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 27 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 28 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
| 29 #include "ui/gfx/compositor/compositor.h" | 28 #include "ui/gfx/compositor/compositor.h" |
| 30 #include "ui/gfx/compositor/layer.h" | 29 #include "ui/gfx/compositor/layer.h" |
| 31 #include "ui/gfx/compositor/layer_animator.h" | 30 #include "ui/gfx/compositor/layer_animator.h" |
| 32 | 31 |
| 33 using std::string; | 32 using std::string; |
| 34 using std::vector; | 33 using std::vector; |
| 35 | 34 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // RootWindow, public: | 83 // RootWindow, public: |
| 85 | 84 |
| 86 RootWindow::RootWindow() | 85 RootWindow::RootWindow() |
| 87 : Window(NULL), | 86 : Window(NULL), |
| 88 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), | 87 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 88 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
| 90 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), | 89 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), |
| 91 mouse_button_flags_(0), | 90 mouse_button_flags_(0), |
| 92 last_cursor_(kCursorNull), | 91 last_cursor_(kCursorNull), |
| 93 cursor_shown_(true), | 92 cursor_shown_(true), |
| 94 ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))), | |
| 95 capture_window_(NULL), | 93 capture_window_(NULL), |
| 96 mouse_pressed_handler_(NULL), | 94 mouse_pressed_handler_(NULL), |
| 97 mouse_moved_handler_(NULL), | 95 mouse_moved_handler_(NULL), |
| 98 focused_window_(NULL), | 96 focused_window_(NULL), |
| 99 touch_event_handler_(NULL), | 97 touch_event_handler_(NULL), |
| 100 gesture_handler_(NULL), | 98 gesture_handler_(NULL), |
| 101 ALLOW_THIS_IN_INITIALIZER_LIST( | 99 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 102 gesture_recognizer_(GestureRecognizer::Create(this))), | 100 gesture_recognizer_(GestureRecognizer::Create(this))), |
| 103 synthesize_mouse_move_(false), | 101 synthesize_mouse_move_(false), |
| 104 waiting_on_compositing_end_(false), | 102 waiting_on_compositing_end_(false), |
| 105 draw_on_compositing_end_(false), | 103 draw_on_compositing_end_(false), |
| 106 defer_draw_scheduling_(false), | 104 defer_draw_scheduling_(false), |
| 107 mouse_move_hold_count_(0), | 105 mouse_move_hold_count_(0), |
| 108 should_hold_mouse_moves_(false), | 106 should_hold_mouse_moves_(false), |
| 109 release_mouse_moves_after_draw_(false) { | 107 release_mouse_moves_after_draw_(false) { |
| 110 SetName("RootWindow"); | 108 SetName("RootWindow"); |
| 111 gfx::Screen::SetInstance(screen_); | |
| 112 last_mouse_location_ = host_->QueryMouseLocation(); | 109 last_mouse_location_ = host_->QueryMouseLocation(); |
| 113 | 110 |
| 114 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( | 111 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 115 switches::kAuraDisableHoldMouseMoves); | 112 switches::kAuraDisableHoldMouseMoves); |
| 116 | 113 |
| 117 ui::Compositor::Initialize(false); | 114 ui::Compositor::Initialize(false); |
| 118 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(), | 115 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(), |
| 119 host_->GetSize())); | 116 host_->GetSize())); |
| 120 DCHECK(compositor_.get()); | 117 DCHECK(compositor_.get()); |
| 121 compositor_->AddObserver(this); | 118 compositor_->AddObserver(this); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 148 last_mouse_location_ = host_->QueryMouseLocation(); | 145 last_mouse_location_ = host_->QueryMouseLocation(); |
| 149 synthesize_mouse_move_ = false; | 146 synthesize_mouse_move_ = false; |
| 150 } | 147 } |
| 151 | 148 |
| 152 gfx::Size RootWindow::GetHostSize() const { | 149 gfx::Size RootWindow::GetHostSize() const { |
| 153 gfx::Rect rect(host_->GetSize()); | 150 gfx::Rect rect(host_->GetSize()); |
| 154 layer()->transform().TransformRect(&rect); | 151 layer()->transform().TransformRect(&rect); |
| 155 return rect.size(); | 152 return rect.size(); |
| 156 } | 153 } |
| 157 | 154 |
| 158 void RootWindow::SetScreenWorkAreaInsets(const gfx::Insets& insets) { | |
| 159 if (screen_->work_area_insets() == insets) | |
| 160 return; | |
| 161 screen_->set_work_area_insets(insets); | |
| 162 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | |
| 163 OnScreenWorkAreaInsetsChanged()); | |
| 164 } | |
| 165 | |
| 166 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 155 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
| 167 last_cursor_ = cursor; | 156 last_cursor_ = cursor; |
| 168 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 157 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
| 169 // so just pass everything along to the host. | 158 // so just pass everything along to the host. |
| 170 host_->SetCursor(cursor); | 159 host_->SetCursor(cursor); |
| 171 } | 160 } |
| 172 | 161 |
| 173 void RootWindow::ShowCursor(bool show) { | 162 void RootWindow::ShowCursor(bool show) { |
| 174 cursor_shown_ = show; | 163 cursor_shown_ = show; |
| 175 host_->ShowCursor(show); | 164 host_->ShowCursor(show); |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 // is currently broken. See/ crbug.com/107931. | 885 // is currently broken. See/ crbug.com/107931. |
| 897 MouseEvent event(ui::ET_MOUSE_MOVED, | 886 MouseEvent event(ui::ET_MOUSE_MOVED, |
| 898 orig_mouse_location, | 887 orig_mouse_location, |
| 899 orig_mouse_location, | 888 orig_mouse_location, |
| 900 ui::EF_IS_SYNTHESIZED); | 889 ui::EF_IS_SYNTHESIZED); |
| 901 DispatchMouseEvent(&event); | 890 DispatchMouseEvent(&event); |
| 902 #endif | 891 #endif |
| 903 } | 892 } |
| 904 | 893 |
| 905 } // namespace aura | 894 } // namespace aura |
| OLD | NEW |