OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/ws/server_window.h" | 5 #include "services/ui/ws/server_window.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "services/ui/common/transient_window_utils.h" | 12 #include "services/ui/common/transient_window_utils.h" |
13 #include "services/ui/public/interfaces/window_manager.mojom.h" | 13 #include "services/ui/public/interfaces/window_manager.mojom.h" |
14 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 14 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
15 #include "services/ui/ws/server_window_delegate.h" | 15 #include "services/ui/ws/server_window_delegate.h" |
16 #include "services/ui/ws/server_window_observer.h" | 16 #include "services/ui/ws/server_window_observer.h" |
| 17 #include "ui/base/cursor/cursor.h" |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 namespace ws { | 20 namespace ws { |
20 | 21 |
21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) | 22 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) |
22 : ServerWindow(delegate, id, Properties()) {} | 23 : ServerWindow(delegate, id, Properties()) {} |
23 | 24 |
24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, | 25 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
25 const WindowId& id, | 26 const WindowId& id, |
26 const Properties& properties) | 27 const Properties& properties) |
27 : delegate_(delegate), | 28 : delegate_(delegate), |
28 id_(id), | 29 id_(id), |
29 frame_sink_id_(WindowIdToTransportId(id), 0), | 30 frame_sink_id_(WindowIdToTransportId(id), 0), |
30 parent_(nullptr), | 31 parent_(nullptr), |
31 stacking_target_(nullptr), | 32 stacking_target_(nullptr), |
32 transient_parent_(nullptr), | 33 transient_parent_(nullptr), |
33 modal_type_(MODAL_TYPE_NONE), | 34 modal_type_(MODAL_TYPE_NONE), |
34 visible_(false), | 35 visible_(false), |
35 // Default to kPointer as kNull doesn't change the cursor, it leaves | 36 // Default to kPointer as kNull doesn't change the cursor, it leaves |
36 // the last non-null cursor. | 37 // the last non-null cursor. |
37 cursor_id_(mojom::CursorType::kPointer), | 38 cursor_(ui::CursorType::kPointer), |
38 non_client_cursor_id_(mojom::CursorType::kPointer), | 39 non_client_cursor_(ui::CursorType::kPointer), |
39 opacity_(1), | 40 opacity_(1), |
40 can_focus_(true), | 41 can_focus_(true), |
41 properties_(properties), | 42 properties_(properties), |
42 // Don't notify newly added observers during notification. This causes | 43 // Don't notify newly added observers during notification. This causes |
43 // problems for code that adds an observer as part of an observer | 44 // problems for code that adds an observer as part of an observer |
44 // notification (such as ServerWindowDrawTracker). | 45 // notification (such as ServerWindowDrawTracker). |
45 observers_( | 46 observers_( |
46 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { | 47 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { |
47 DCHECK(delegate); // Must provide a delegate. | 48 DCHECK(delegate); // Must provide a delegate. |
48 } | 49 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 293 |
293 void ServerWindow::SetOpacity(float value) { | 294 void ServerWindow::SetOpacity(float value) { |
294 if (value == opacity_) | 295 if (value == opacity_) |
295 return; | 296 return; |
296 float old_opacity = opacity_; | 297 float old_opacity = opacity_; |
297 opacity_ = value; | 298 opacity_ = value; |
298 for (auto& observer : observers_) | 299 for (auto& observer : observers_) |
299 observer.OnWindowOpacityChanged(this, old_opacity, opacity_); | 300 observer.OnWindowOpacityChanged(this, old_opacity, opacity_); |
300 } | 301 } |
301 | 302 |
302 void ServerWindow::SetPredefinedCursor(ui::mojom::CursorType value) { | 303 void ServerWindow::SetCursor(ui::CursorData value) { |
303 if (value == cursor_id_) | 304 if (cursor_.IsSameAs(value)) |
304 return; | 305 return; |
305 cursor_id_ = value; | 306 cursor_ = std::move(value); |
306 for (auto& observer : observers_) | 307 for (auto& observer : observers_) |
307 observer.OnWindowPredefinedCursorChanged(this, value); | 308 observer.OnWindowCursorChanged(this, cursor_); |
308 } | 309 } |
309 | 310 |
310 void ServerWindow::SetNonClientCursor(ui::mojom::CursorType value) { | 311 void ServerWindow::SetNonClientCursor(ui::CursorData value) { |
311 if (value == non_client_cursor_id_) | 312 if (non_client_cursor_.IsSameAs(value)) |
312 return; | 313 return; |
313 non_client_cursor_id_ = value; | 314 non_client_cursor_ = std::move(value); |
314 for (auto& observer : observers_) | 315 for (auto& observer : observers_) |
315 observer.OnWindowNonClientCursorChanged(this, value); | 316 observer.OnWindowNonClientCursorChanged(this, non_client_cursor_); |
316 } | 317 } |
317 | 318 |
318 void ServerWindow::SetTransform(const gfx::Transform& transform) { | 319 void ServerWindow::SetTransform(const gfx::Transform& transform) { |
319 if (transform_ == transform) | 320 if (transform_ == transform) |
320 return; | 321 return; |
321 | 322 |
322 transform_ = transform; | 323 transform_ = transform; |
323 } | 324 } |
324 | 325 |
325 void ServerWindow::SetProperty(const std::string& name, | 326 void ServerWindow::SetProperty(const std::string& name, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 window->OnStackingChanged(); | 472 window->OnStackingChanged(); |
472 } | 473 } |
473 | 474 |
474 // static | 475 // static |
475 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 476 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
476 return &window->stacking_target_; | 477 return &window->stacking_target_; |
477 } | 478 } |
478 | 479 |
479 } // namespace ws | 480 } // namespace ws |
480 } // namespace ui | 481 } // namespace ui |
OLD | NEW |