| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.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 "ui/aura/aura_switches.h" | 14 #include "ui/aura/aura_switches.h" |
| 15 #include "ui/aura/client/activation_client.h" | 15 #include "ui/aura/client/activation_client.h" |
| 16 #include "ui/aura/client/event_client.h" | 16 #include "ui/aura/client/event_client.h" |
| 17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 18 #include "ui/aura/event.h" | 18 #include "ui/aura/event.h" |
| 19 #include "ui/aura/event_filter.h" | 19 #include "ui/aura/event_filter.h" |
| 20 #include "ui/aura/focus_manager.h" | 20 #include "ui/aura/focus_manager.h" |
| 21 #include "ui/aura/monitor_manager.h" |
| 21 #include "ui/aura/root_window_host.h" | 22 #include "ui/aura/root_window_host.h" |
| 22 #include "ui/aura/root_window_observer.h" | 23 #include "ui/aura/root_window_observer.h" |
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_delegate.h" | 25 #include "ui/aura/window_delegate.h" |
| 25 #include "ui/base/gestures/gesture_recognizer.h" | 26 #include "ui/base/gestures/gesture_recognizer.h" |
| 26 #include "ui/base/gestures/gesture_types.h" | 27 #include "ui/base/gestures/gesture_types.h" |
| 27 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 28 #include "ui/gfx/compositor/compositor.h" | 29 #include "ui/gfx/compositor/compositor.h" |
| 30 #include "ui/gfx/compositor/dip_util.h" |
| 29 #include "ui/gfx/compositor/layer.h" | 31 #include "ui/gfx/compositor/layer.h" |
| 30 #include "ui/gfx/compositor/layer_animator.h" | 32 #include "ui/gfx/compositor/layer_animator.h" |
| 33 #include "ui/gfx/monitor.h" |
| 34 #include "ui/gfx/screen.h" |
| 31 | 35 |
| 32 using std::vector; | 36 using std::vector; |
| 33 | 37 |
| 34 namespace aura { | 38 namespace aura { |
| 35 | 39 |
| 36 namespace { | 40 namespace { |
| 37 | 41 |
| 38 // Returns true if |target| has a non-client (frame) component at |location|, | 42 // Returns true if |target| has a non-client (frame) component at |location|, |
| 39 // in window coordinates. | 43 // in window coordinates. |
| 40 bool IsNonClientLocation(Window* target, const gfx::Point& location) { | 44 bool IsNonClientLocation(Window* target, const gfx::Point& location) { |
| 41 if (!target->delegate()) | 45 if (!target->delegate()) |
| 42 return false; | 46 return false; |
| 43 int hit_test_code = target->delegate()->GetNonClientComponent(location); | 47 int hit_test_code = target->delegate()->GetNonClientComponent(location); |
| 44 return hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE; | 48 return hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE; |
| 45 } | 49 } |
| 46 | 50 |
| 47 typedef std::vector<EventFilter*> EventFilters; | 51 typedef std::vector<EventFilter*> EventFilters; |
| 48 | 52 |
| 49 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { | 53 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { |
| 50 while (target) { | 54 while (target) { |
| 51 if (target->event_filter()) | 55 if (target->event_filter()) |
| 52 filters->push_back(target->event_filter()); | 56 filters->push_back(target->event_filter()); |
| 53 target = target->parent(); | 57 target = target->parent(); |
| 54 } | 58 } |
| 55 } | 59 } |
| 56 | 60 |
| 61 float GetDeviceScaleFactorFromMonitor(const aura::Window* window) { |
| 62 MonitorManager* monitor_manager = Env::GetInstance()->monitor_manager(); |
| 63 return monitor_manager->GetMonitorNearestWindow(window).device_scale_factor(); |
| 64 } |
| 65 |
| 57 const int kCompositorLockTimeoutMs = 67; | 66 const int kCompositorLockTimeoutMs = 67; |
| 58 | 67 |
| 59 } // namespace | 68 } // namespace |
| 60 | 69 |
| 61 CompositorLock::CompositorLock(RootWindow* root_window) | 70 CompositorLock::CompositorLock(RootWindow* root_window) |
| 62 : root_window_(root_window) { | 71 : root_window_(root_window) { |
| 63 MessageLoop::current()->PostDelayedTask( | 72 MessageLoop::current()->PostDelayedTask( |
| 64 FROM_HERE, | 73 FROM_HERE, |
| 65 base::Bind(&CompositorLock::CancelLock, AsWeakPtr()), | 74 base::Bind(&CompositorLock::CancelLock, AsWeakPtr()), |
| 66 kCompositorLockTimeoutMs); | 75 kCompositorLockTimeoutMs); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 defer_draw_scheduling_(false), | 112 defer_draw_scheduling_(false), |
| 104 mouse_move_hold_count_(0), | 113 mouse_move_hold_count_(0), |
| 105 should_hold_mouse_moves_(false), | 114 should_hold_mouse_moves_(false), |
| 106 compositor_lock_(NULL), | 115 compositor_lock_(NULL), |
| 107 draw_on_compositor_unlock_(false), | 116 draw_on_compositor_unlock_(false), |
| 108 draw_trace_count_(0) { | 117 draw_trace_count_(0) { |
| 109 SetName("RootWindow"); | 118 SetName("RootWindow"); |
| 110 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( | 119 should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kAuraDisableHoldMouseMoves); | 120 switches::kAuraDisableHoldMouseMoves); |
| 112 | 121 |
| 113 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget(), | 122 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); |
| 114 host_->GetBounds().size())); | |
| 115 DCHECK(compositor_.get()); | 123 DCHECK(compositor_.get()); |
| 116 compositor_->AddObserver(this); | 124 compositor_->AddObserver(this); |
| 117 } | 125 } |
| 118 | 126 |
| 119 RootWindow::~RootWindow() { | 127 RootWindow::~RootWindow() { |
| 120 if (compositor_lock_) { | 128 if (compositor_lock_) { |
| 121 // No need to schedule a draw, we're going away. | 129 // No need to schedule a draw, we're going away. |
| 122 draw_on_compositor_unlock_ = false; | 130 draw_on_compositor_unlock_ = false; |
| 123 compositor_lock_->CancelLock(); | 131 compositor_lock_->CancelLock(); |
| 124 DCHECK(!compositor_lock_); | 132 DCHECK(!compositor_lock_); |
| 125 } | 133 } |
| 126 compositor_->RemoveObserver(this); | 134 compositor_->RemoveObserver(this); |
| 127 // Make sure to destroy the compositor before terminating so that state is | 135 // Make sure to destroy the compositor before terminating so that state is |
| 128 // cleared and we don't hit asserts. | 136 // cleared and we don't hit asserts. |
| 129 compositor_.reset(); | 137 compositor_.reset(); |
| 130 | 138 |
| 131 // Tear down in reverse. Frees any references held by the host. | 139 // Tear down in reverse. Frees any references held by the host. |
| 132 host_.reset(NULL); | 140 host_.reset(NULL); |
| 133 | 141 |
| 134 // An observer may have been added by an animation on the RootWindow. | 142 // An observer may have been added by an animation on the RootWindow. |
| 135 layer()->GetAnimator()->RemoveObserver(this); | 143 layer()->GetAnimator()->RemoveObserver(this); |
| 136 } | 144 } |
| 137 | 145 |
| 138 void RootWindow::Init() { | 146 void RootWindow::Init() { |
| 147 compositor()->WidgetScaleOrSizeChanged( |
| 148 GetDeviceScaleFactorFromMonitor(this), host_->GetBounds().size()); |
| 139 Window::Init(ui::LAYER_NOT_DRAWN); | 149 Window::Init(ui::LAYER_NOT_DRAWN); |
| 140 last_mouse_location_ = ConvertPointToDIP(this, host_->QueryMouseLocation()); | 150 last_mouse_location_ = |
| 141 SetBounds(ConvertRectToDIP(this, gfx::Rect(host_->GetBounds().size()))); | 151 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); |
| 152 compositor()->SetRootLayer(layer()); |
| 153 SetBounds( |
| 154 ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size()))); |
| 142 Show(); | 155 Show(); |
| 143 compositor()->SetRootLayer(layer()); | |
| 144 host_->SetRootWindow(this); | 156 host_->SetRootWindow(this); |
| 145 } | 157 } |
| 146 | 158 |
| 147 void RootWindow::ShowRootWindow() { | 159 void RootWindow::ShowRootWindow() { |
| 148 host_->Show(); | 160 host_->Show(); |
| 149 } | 161 } |
| 150 | 162 |
| 151 void RootWindow::SetHostSize(const gfx::Size& size) { | 163 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { |
| 152 DispatchHeldMouseMove(); | 164 DispatchHeldMouseMove(); |
| 153 gfx::Rect bounds = host_->GetBounds(); | 165 gfx::Rect bounds = host_->GetBounds(); |
| 154 bounds.set_size(size); | 166 bounds.set_size(size_in_pixel); |
| 155 host_->SetBounds(bounds); | 167 host_->SetBounds(bounds); |
| 156 // Requery the location to constrain it within the new root window size. | 168 // Requery the location to constrain it within the new root window size. |
| 157 last_mouse_location_ = ConvertPointToDIP(this, host_->QueryMouseLocation()); | 169 last_mouse_location_ = |
| 170 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); |
| 158 synthesize_mouse_move_ = false; | 171 synthesize_mouse_move_ = false; |
| 159 } | 172 } |
| 160 | 173 |
| 161 gfx::Size RootWindow::GetHostSize() const { | 174 gfx::Size RootWindow::GetHostSize() const { |
| 162 return host_->GetBounds().size(); | 175 return host_->GetBounds().size(); |
| 163 } | 176 } |
| 164 | 177 |
| 165 void RootWindow::SetHostBounds(const gfx::Rect& bounds) { | 178 void RootWindow::SetHostBounds(const gfx::Rect& bounds_in_pixel) { |
| 166 DispatchHeldMouseMove(); | 179 DispatchHeldMouseMove(); |
| 167 host_->SetBounds(bounds); | 180 host_->SetBounds(bounds_in_pixel); |
| 168 // Requery the location to constrain it within the new root window size. | 181 // Requery the location to constrain it within the new root window size. |
| 169 last_mouse_location_ = ConvertPointToDIP(this, host_->QueryMouseLocation()); | 182 last_mouse_location_ = |
| 183 ui::ConvertPointToDIP(layer(), host_->QueryMouseLocation()); |
| 170 synthesize_mouse_move_ = false; | 184 synthesize_mouse_move_ = false; |
| 171 } | 185 } |
| 172 | 186 |
| 173 gfx::Point RootWindow::GetHostOrigin() const { | 187 gfx::Point RootWindow::GetHostOrigin() const { |
| 174 return host_->GetBounds().origin(); | 188 return host_->GetBounds().origin(); |
| 175 } | 189 } |
| 176 | 190 |
| 177 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 191 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
| 178 last_cursor_ = cursor; | 192 last_cursor_ = cursor; |
| 179 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 193 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
| 180 // so just pass everything along to the host. | 194 // so just pass everything along to the host. |
| 181 host_->SetCursor(cursor); | 195 host_->SetCursor(cursor); |
| 182 } | 196 } |
| 183 | 197 |
| 184 void RootWindow::ShowCursor(bool show) { | 198 void RootWindow::ShowCursor(bool show) { |
| 185 cursor_shown_ = show; | 199 cursor_shown_ = show; |
| 186 host_->ShowCursor(show); | 200 host_->ShowCursor(show); |
| 187 } | 201 } |
| 188 | 202 |
| 189 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 203 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
| 190 host_->MoveCursorTo(ConvertPointToPixel(this, location_in_dip)); | 204 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); |
| 191 } | 205 } |
| 192 | 206 |
| 193 bool RootWindow::ConfineCursorToWindow() { | 207 bool RootWindow::ConfineCursorToWindow() { |
| 194 // We would like to be able to confine the cursor to that window. However, | 208 // We would like to be able to confine the cursor to that window. However, |
| 195 // currently, we do not have such functionality in X. So we just confine | 209 // currently, we do not have such functionality in X. So we just confine |
| 196 // to the root window. This is ok because this option is currently only | 210 // to the root window. This is ok because this option is currently only |
| 197 // being used in fullscreen mode, so root_window bounds = window bounds. | 211 // being used in fullscreen mode, so root_window bounds = window bounds. |
| 198 return host_->ConfineCursorToRootWindow(); | 212 return host_->ConfineCursorToRootWindow(); |
| 199 } | 213 } |
| 200 | 214 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 client::EventClient* client = client::GetEventClient(GetRootWindow()); | 256 client::EventClient* client = client::GetEventClient(GetRootWindow()); |
| 243 if (client && !client->CanProcessEventsWithinSubtree(focused_window_)) { | 257 if (client && !client->CanProcessEventsWithinSubtree(focused_window_)) { |
| 244 SetFocusedWindow(NULL, NULL); | 258 SetFocusedWindow(NULL, NULL); |
| 245 return false; | 259 return false; |
| 246 } | 260 } |
| 247 return ProcessKeyEvent(focused_window_, &translated_event); | 261 return ProcessKeyEvent(focused_window_, &translated_event); |
| 248 } | 262 } |
| 249 | 263 |
| 250 bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { | 264 bool RootWindow::DispatchScrollEvent(ScrollEvent* event) { |
| 251 DispatchHeldMouseMove(); | 265 DispatchHeldMouseMove(); |
| 252 #if defined(ENABLE_DIP) | 266 if (ui::IsDIPEnabled()) { |
| 253 float scale = GetMonitorScaleFactor(this); | 267 float scale = ui::GetDeviceScaleFactor(layer()); |
| 254 ui::Transform transform; | 268 ui::Transform transform = layer()->transform(); |
| 255 transform.SetScale(scale, scale); | 269 transform.ConcatScale(scale, scale); |
| 256 transform.ConcatTransform(layer()->transform()); | 270 event->UpdateForRootTransform(transform); |
| 257 event->UpdateForRootTransform(transform); | 271 } else { |
| 258 #else | 272 event->UpdateForRootTransform(layer()->transform()); |
| 259 event->UpdateForRootTransform(layer()->transform()); | 273 } |
| 260 #endif | |
| 261 | 274 |
| 262 last_mouse_location_ = event->location(); | 275 last_mouse_location_ = event->location(); |
| 263 synthesize_mouse_move_ = false; | 276 synthesize_mouse_move_ = false; |
| 264 | 277 |
| 265 Window* target = | 278 Window* target = |
| 266 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; | 279 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; |
| 267 if (!target) | 280 if (!target) |
| 268 target = GetEventHandlerForPoint(event->location()); | 281 target = GetEventHandlerForPoint(event->location()); |
| 269 | 282 |
| 270 if (target && target->delegate()) { | 283 if (target && target->delegate()) { |
| 271 int flags = event->flags(); | 284 int flags = event->flags(); |
| 272 gfx::Point location_in_window = event->location(); | 285 gfx::Point location_in_window = event->location(); |
| 273 Window::ConvertPointToWindow(this, target, &location_in_window); | 286 Window::ConvertPointToWindow(this, target, &location_in_window); |
| 274 if (IsNonClientLocation(target, location_in_window)) | 287 if (IsNonClientLocation(target, location_in_window)) |
| 275 flags |= ui::EF_IS_NON_CLIENT; | 288 flags |= ui::EF_IS_NON_CLIENT; |
| 276 ScrollEvent translated_event(*event, this, target, event->type(), flags); | 289 ScrollEvent translated_event(*event, this, target, event->type(), flags); |
| 277 return ProcessMouseEvent(target, &translated_event); | 290 return ProcessMouseEvent(target, &translated_event); |
| 278 } | 291 } |
| 279 return false; | 292 return false; |
| 280 } | 293 } |
| 281 | 294 |
| 282 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | 295 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { |
| 283 DispatchHeldMouseMove(); | 296 DispatchHeldMouseMove(); |
| 284 #if defined(ENABLE_DIP) | 297 if (ui::IsDIPEnabled()) { |
| 285 float scale = GetMonitorScaleFactor(this); | 298 float scale = ui::GetDeviceScaleFactor(layer()); |
| 286 ui::Transform transform; | 299 ui::Transform transform = layer()->transform(); |
| 287 transform.SetScale(scale, scale); | 300 transform.ConcatScale(scale, scale); |
| 288 transform.ConcatTransform(layer()->transform()); | 301 event->UpdateForRootTransform(transform); |
| 289 event->UpdateForRootTransform(transform); | 302 } else { |
| 290 #else | 303 event->UpdateForRootTransform(layer()->transform()); |
| 291 event->UpdateForRootTransform(layer()->transform()); | 304 } |
| 292 #endif | |
| 293 bool handled = false; | 305 bool handled = false; |
| 294 | 306 |
| 295 GestureConsumer* consumer = gesture_recognizer_->GetTouchLockedTarget(event); | 307 GestureConsumer* consumer = gesture_recognizer_->GetTouchLockedTarget(event); |
| 296 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | 308 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
| 297 | 309 |
| 298 if (!consumer || !consumer->ignores_events()) { | 310 if (!consumer || !consumer->ignores_events()) { |
| 299 Window* target = static_cast<Window*>(consumer); | 311 Window* target = static_cast<Window*>(consumer); |
| 300 | 312 |
| 301 if (!target && HasCapture(capture_window_, ui::CW_LOCK_TOUCH)) | 313 if (!target && HasCapture(capture_window_, ui::CW_LOCK_TOUCH)) |
| 302 target = capture_window_; | 314 target = capture_window_; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 365 |
| 354 if (target) { | 366 if (target) { |
| 355 GestureEvent translated_event(*event, this, target); | 367 GestureEvent translated_event(*event, this, target); |
| 356 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); | 368 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); |
| 357 return status != ui::GESTURE_STATUS_UNKNOWN; | 369 return status != ui::GESTURE_STATUS_UNKNOWN; |
| 358 } | 370 } |
| 359 | 371 |
| 360 return false; | 372 return false; |
| 361 } | 373 } |
| 362 | 374 |
| 363 void RootWindow::OnHostResized(const gfx::Size& size) { | 375 void RootWindow::OnHostResized(const gfx::Size& size_in_pixel) { |
| 364 DispatchHeldMouseMove(); | 376 DispatchHeldMouseMove(); |
| 365 // The compositor should have the same size as the native root window host. | 377 // The compositor should have the same size as the native root window host. |
| 366 compositor_->WidgetSizeChanged(size); | 378 // Get the latest scale from monitor because it might have been changed. |
| 367 gfx::Size old(ConvertSizeToDIP(this, bounds().size())); | 379 compositor_->WidgetScaleOrSizeChanged( |
| 380 GetDeviceScaleFactorFromMonitor(this), size_in_pixel); |
| 381 gfx::Size old(bounds().size()); |
| 368 // The layer, and all the observers should be notified of the | 382 // The layer, and all the observers should be notified of the |
| 369 // transformed size of the root window. | 383 // transformed size of the root window. |
| 370 gfx::Rect bounds(ConvertSizeToDIP(this, size)); | 384 gfx::Rect bounds(ui::ConvertSizeToDIP(layer(), size_in_pixel)); |
| 371 layer()->transform().TransformRect(&bounds); | 385 layer()->transform().TransformRect(&bounds); |
| 372 SetBounds(gfx::Rect(bounds.size())); | 386 SetBounds(bounds); |
| 373 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 387 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 374 OnRootWindowResized(this, old)); | 388 OnRootWindowResized(this, old)); |
| 375 } | 389 } |
| 376 | 390 |
| 377 void RootWindow::OnWindowDestroying(Window* window) { | 391 void RootWindow::OnWindowDestroying(Window* window) { |
| 378 OnWindowHidden(window, true); | 392 OnWindowHidden(window, true); |
| 379 | 393 |
| 380 if (window->IsVisible() && | 394 if (window->IsVisible() && |
| 381 window->ContainsPointInRoot(last_mouse_location_)) { | 395 window->ContainsPointInRoot(last_mouse_location_)) { |
| 382 PostMouseMoveEventAfterWindowChange(); | 396 PostMouseMoveEventAfterWindowChange(); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 901 |
| 888 bool RootWindow::IsFocusedWindow(const Window* window) const { | 902 bool RootWindow::IsFocusedWindow(const Window* window) const { |
| 889 return focused_window_ == window; | 903 return focused_window_ == window; |
| 890 } | 904 } |
| 891 | 905 |
| 892 bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) { | 906 bool RootWindow::DispatchMouseEventImpl(MouseEvent* event) { |
| 893 static const int kMouseButtonFlagMask = | 907 static const int kMouseButtonFlagMask = |
| 894 ui::EF_LEFT_MOUSE_BUTTON | | 908 ui::EF_LEFT_MOUSE_BUTTON | |
| 895 ui::EF_MIDDLE_MOUSE_BUTTON | | 909 ui::EF_MIDDLE_MOUSE_BUTTON | |
| 896 ui::EF_RIGHT_MOUSE_BUTTON; | 910 ui::EF_RIGHT_MOUSE_BUTTON; |
| 897 #if defined(ENABLE_DIP) | 911 if (ui::IsDIPEnabled()) { |
| 898 float scale = GetMonitorScaleFactor(this); | 912 float scale = ui::GetDeviceScaleFactor(layer()); |
| 899 ui::Transform transform; | 913 ui::Transform transform = layer()->transform(); |
| 900 transform.SetScale(scale, scale); | 914 transform.ConcatScale(scale, scale); |
| 901 transform.ConcatTransform(layer()->transform()); | 915 event->UpdateForRootTransform(transform); |
| 902 event->UpdateForRootTransform(transform); | 916 } else { |
| 903 #else | 917 event->UpdateForRootTransform(layer()->transform()); |
| 904 event->UpdateForRootTransform(layer()->transform()); | 918 } |
| 905 #endif | |
| 906 | 919 |
| 907 last_mouse_location_ = event->location(); | 920 last_mouse_location_ = event->location(); |
| 908 synthesize_mouse_move_ = false; | 921 synthesize_mouse_move_ = false; |
| 909 | 922 |
| 910 Window* target = mouse_pressed_handler_; | 923 Window* target = mouse_pressed_handler_; |
| 911 if (!target && HasCapture(capture_window_, ui::CW_LOCK_MOUSE)) | 924 if (!target && HasCapture(capture_window_, ui::CW_LOCK_MOUSE)) |
| 912 target = capture_window_; | 925 target = capture_window_; |
| 913 if (!target) | 926 if (!target) |
| 914 target = GetEventHandlerForPoint(event->location()); | 927 target = GetEventHandlerForPoint(event->location()); |
| 915 switch (event->type()) { | 928 switch (event->type()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 event_factory_.GetWeakPtr())); | 975 event_factory_.GetWeakPtr())); |
| 963 } | 976 } |
| 964 | 977 |
| 965 void RootWindow::SynthesizeMouseMoveEvent() { | 978 void RootWindow::SynthesizeMouseMoveEvent() { |
| 966 if (!synthesize_mouse_move_) | 979 if (!synthesize_mouse_move_) |
| 967 return; | 980 return; |
| 968 synthesize_mouse_move_ = false; | 981 synthesize_mouse_move_ = false; |
| 969 #if !defined(OS_WIN) | 982 #if !defined(OS_WIN) |
| 970 // Temporarily disabled for windows. See crbug.com/112222. | 983 // Temporarily disabled for windows. See crbug.com/112222. |
| 971 gfx::Point orig_mouse_location = last_mouse_location_; | 984 gfx::Point orig_mouse_location = last_mouse_location_; |
| 972 orig_mouse_location = ConvertPointToPixel(this, orig_mouse_location); | |
| 973 layer()->transform().TransformPoint(orig_mouse_location); | 985 layer()->transform().TransformPoint(orig_mouse_location); |
| 974 orig_mouse_location = ConvertPointToDIP(this,orig_mouse_location); | |
| 975 | 986 |
| 976 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | 987 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's |
| 977 // currently broken. See/ crbug.com/107931. | 988 // currently broken. See/ crbug.com/107931. |
| 978 MouseEvent event(ui::ET_MOUSE_MOVED, | 989 MouseEvent event(ui::ET_MOUSE_MOVED, |
| 979 orig_mouse_location, | 990 orig_mouse_location, |
| 980 orig_mouse_location, | 991 orig_mouse_location, |
| 981 ui::EF_IS_SYNTHESIZED); | 992 ui::EF_IS_SYNTHESIZED); |
| 982 DispatchMouseEvent(&event); | 993 DispatchMouseEvent(&event); |
| 983 #endif | 994 #endif |
| 984 } | 995 } |
| 985 | 996 |
| 986 void RootWindow::UnlockCompositor() { | 997 void RootWindow::UnlockCompositor() { |
| 987 DCHECK(compositor_lock_); | 998 DCHECK(compositor_lock_); |
| 988 compositor_lock_ = NULL; | 999 compositor_lock_ = NULL; |
| 989 if (draw_on_compositor_unlock_) { | 1000 if (draw_on_compositor_unlock_) { |
| 990 draw_on_compositor_unlock_ = false; | 1001 draw_on_compositor_unlock_ = false; |
| 991 ScheduleDraw(); | 1002 ScheduleDraw(); |
| 992 } | 1003 } |
| 993 } | 1004 } |
| 994 | 1005 |
| 995 } // namespace aura | 1006 } // namespace aura |
| OLD | NEW |