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

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

Issue 2446893005: Adds a porting layer so aura can be made to work with mus (Closed)
Patch Set: better Created 4 years, 1 month 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
« no previous file with comments | « ui/aura/window_port_local.h ('k') | ui/aura/window_property.h » ('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 2016 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 #include "ui/aura/window_port_local.h"
6
7 #include "ui/aura/client/cursor_client.h"
8 #include "ui/aura/env.h"
9 #include "ui/aura/window.h"
10 #include "ui/aura/window_delegate.h"
11 #include "ui/display/display.h"
12 #include "ui/display/screen.h"
13
14 namespace aura {
15 namespace {
16
17 class ScopedCursorHider {
18 public:
19 explicit ScopedCursorHider(Window* window)
20 : window_(window), hid_cursor_(false) {
21 if (!window_->IsRootWindow())
22 return;
23 const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains(
24 Env::GetInstance()->last_mouse_location());
25 client::CursorClient* cursor_client = client::GetCursorClient(window_);
26 if (cursor_is_in_bounds && cursor_client &&
27 cursor_client->IsCursorVisible()) {
28 cursor_client->HideCursor();
29 hid_cursor_ = true;
30 }
31 }
32 ~ScopedCursorHider() {
33 if (!window_->IsRootWindow())
34 return;
35
36 // Update the device scale factor of the cursor client only when the last
37 // mouse location is on this root window.
38 if (hid_cursor_) {
39 client::CursorClient* cursor_client = client::GetCursorClient(window_);
40 if (cursor_client) {
41 const display::Display& display =
42 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
43 cursor_client->SetDisplay(display);
44 cursor_client->ShowCursor();
45 }
46 }
47 }
48
49 private:
50 Window* window_;
51 bool hid_cursor_;
52
53 DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider);
54 };
55
56 } // namespace
57
58 WindowPortLocal::WindowPortLocal(Window* window) : window_(window) {}
59
60 WindowPortLocal::~WindowPortLocal() {}
61
62 std::unique_ptr<WindowPortInitData> WindowPortLocal::OnPreInit(Window* window) {
63 return nullptr;
64 }
65
66 void WindowPortLocal::OnPostInit(
67 std::unique_ptr<WindowPortInitData> init_data) {}
68
69 void WindowPortLocal::OnDeviceScaleFactorChanged(float device_scale_factor) {
70 ScopedCursorHider hider(window_);
71 if (window_->delegate())
72 window_->delegate()->OnDeviceScaleFactorChanged(device_scale_factor);
73 }
74
75 void WindowPortLocal::OnWillAddChild(Window* child) {}
76
77 void WindowPortLocal::OnWillRemoveChild(Window* child) {}
78
79 void WindowPortLocal::OnWillMoveChild(size_t current_index, size_t dest_index) {
80 }
81
82 void WindowPortLocal::OnVisibilityChanged(bool visible) {}
83
84 void WindowPortLocal::OnDidChangeBounds(const gfx::Rect& old_bounds,
85 const gfx::Rect& new_bounds) {}
86
87 std::unique_ptr<WindowPortPropertyData> WindowPortLocal::OnWillChangeProperty(
88 const void* key) {
89 return nullptr;
90 }
91
92 void WindowPortLocal::OnPropertyChanged(
93 const void* key,
94 std::unique_ptr<WindowPortPropertyData> data) {}
95
96 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window_port_local.h ('k') | ui/aura/window_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698