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

Side by Side Diff: ui/views/mus/screen_mus.cc

Issue 2461513002: Primary display change notifications. (Closed)
Patch Set: Cleanup. 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 // This has to be before any other includes, else default is picked up. 5 // This has to be before any other includes, else default is picked up.
6 // See base/logging for details on this. 6 // See base/logging for details on this.
7 #define NOTIMPLEMENTED_POLICY 5 7 #define NOTIMPLEMENTED_POLICY 5
8 8
9 #include "ui/views/mus/screen_mus.h" 9 #include "ui/views/mus/screen_mus.h"
10 10
(...skipping 16 matching lines...) Expand all
27 result.maximized_insets = input->maximized_client_area_insets; 27 result.maximized_insets = input->maximized_client_area_insets;
28 result.max_title_bar_button_width = input->max_title_bar_button_width; 28 result.max_title_bar_button_width = input->max_title_bar_button_width;
29 return result; 29 return result;
30 } 30 }
31 }; 31 };
32 32
33 } // namespace mojo 33 } // namespace mojo
34 34
35 namespace views { 35 namespace views {
36 36
37 using Type = display::DisplayList::Type;
38
37 ScreenMus::ScreenMus(ScreenMusDelegate* delegate) 39 ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
38 : delegate_(delegate), 40 : delegate_(delegate), display_manager_observer_binding_(this) {}
39 display_manager_observer_binding_(this) {
40 }
41 41
42 ScreenMus::~ScreenMus() {} 42 ScreenMus::~ScreenMus() {}
43 43
44 void ScreenMus::Init(service_manager::Connector* connector) { 44 void ScreenMus::Init(service_manager::Connector* connector) {
45 connector->ConnectToInterface("service:ui", &display_manager_); 45 connector->ConnectToInterface("service:ui", &display_manager_);
46 46
47 display_manager_->AddObserver( 47 display_manager_->AddObserver(
48 display_manager_observer_binding_.CreateInterfacePtrAndBind()); 48 display_manager_observer_binding_.CreateInterfacePtrAndBind());
49 49
50 // We need the set of displays before we can continue. Wait for it. 50 // We need the set of displays before we can continue. Wait for it.
51 // 51 //
52 // TODO(rockot): Do something better here. This should not have to block tasks 52 // TODO(rockot): Do something better here. This should not have to block tasks
53 // from running on the calling thread. http://crbug.com/594852. 53 // from running on the calling thread. http://crbug.com/594852.
54 bool success = display_manager_observer_binding_.WaitForIncomingMethodCall(); 54 bool success = display_manager_observer_binding_.WaitForIncomingMethodCall();
55 55
56 // The WaitForIncomingMethodCall() should have supplied the set of Displays, 56 // The WaitForIncomingMethodCall() should have supplied the set of Displays,
57 // unless mus is going down, in which case encountered_error() is true, or the 57 // unless mus is going down, in which case encountered_error() is true, or the
58 // call to WaitForIncomingMethodCall() failed. 58 // call to WaitForIncomingMethodCall() failed.
59 if (display_list()->displays().empty()) { 59 if (display_list()->displays().empty()) {
60 DCHECK(display_manager_.encountered_error() || !success); 60 DCHECK(display_manager_.encountered_error() || !success);
61 // In this case we install a default display and assume the process is 61 // In this case we install a default display and assume the process is
62 // going to exit shortly so that the real value doesn't matter. 62 // going to exit shortly so that the real value doesn't matter.
63 display_list()->AddDisplay( 63 display_list()->AddDisplay(
64 display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)), 64 display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)), Type::PRIMARY);
65 display::DisplayList::Type::PRIMARY);
66 } 65 }
67 } 66 }
68 67
69 gfx::Point ScreenMus::GetCursorScreenPoint() { 68 gfx::Point ScreenMus::GetCursorScreenPoint() {
70 if (!delegate_) { 69 if (!delegate_) {
71 // TODO(erg): If we need the cursor point in the window manager, we'll need 70 // TODO(erg): If we need the cursor point in the window manager, we'll need
72 // to make |delegate_| required. It only recently changed to be optional. 71 // to make |delegate_| required. It only recently changed to be optional.
73 NOTIMPLEMENTED(); 72 NOTIMPLEMENTED();
74 return gfx::Point(); 73 return gfx::Point();
75 } 74 }
(...skipping 12 matching lines...) Expand all
88 if (ui_window) { 87 if (ui_window) {
89 NativeWidgetMus* nw_mus = NativeWidgetMus::GetForWindow(ui_window); 88 NativeWidgetMus* nw_mus = NativeWidgetMus::GetForWindow(ui_window);
90 if (nw_mus) { 89 if (nw_mus) {
91 aura_window = 90 aura_window =
92 static_cast<internal::NativeWidgetPrivate*>(nw_mus)->GetNativeView(); 91 static_cast<internal::NativeWidgetPrivate*>(nw_mus)->GetNativeView();
93 } 92 }
94 } 93 }
95 return aura_window; 94 return aura_window;
96 } 95 }
97 96
98 void ScreenMus::OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) { 97 void ScreenMus::OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays,
99 // This should only be called once from Init() before any observers have been 98 int64_t primary_display_id,
100 // added. 99 int64_t internal_display_id) {
100 // This should only be called once when ScreenMus is added as an observer.
101 DCHECK(display_list()->displays().empty()); 101 DCHECK(display_list()->displays().empty());
102
102 for (size_t i = 0; i < ws_displays.size(); ++i) { 103 for (size_t i = 0; i < ws_displays.size(); ++i) {
103 const bool is_primary = ws_displays[i]->is_primary; 104 const display::Display& display = ws_displays[i]->display;
104 display_list()->AddDisplay(ws_displays[i]->display, 105 const bool is_primary = display.id() == primary_display_id;
105 is_primary 106 display_list()->AddDisplay(display,
106 ? display::DisplayList::Type::PRIMARY 107 is_primary ? Type::PRIMARY : Type::NOT_PRIMARY);
107 : display::DisplayList::Type::NOT_PRIMARY);
108 if (is_primary) { 108 if (is_primary) {
109 // TODO(sky): Make WindowManagerFrameValues per display. 109 // TODO(sky): Make WindowManagerFrameValues per display.
110 WindowManagerFrameValues frame_values = 110 WindowManagerFrameValues frame_values =
111 ws_displays[i] 111 ws_displays[i]
112 ->frame_decoration_values.To<WindowManagerFrameValues>(); 112 ->frame_decoration_values.To<WindowManagerFrameValues>();
113 WindowManagerFrameValues::SetInstance(frame_values); 113 WindowManagerFrameValues::SetInstance(frame_values);
114 } 114 }
115 } 115 }
116
sky 2016/10/28 17:08:47 DCHECK found primary display?
kylechar 2016/10/28 19:40:37 Done.
117 if (internal_display_id != display::Display::kInvalidDisplayID)
118 display::Display::SetInternalDisplayId(internal_display_id);
119
116 DCHECK(!display_list()->displays().empty()); 120 DCHECK(!display_list()->displays().empty());
117 } 121 }
118 122
119 void ScreenMus::OnDisplaysChanged( 123 void ScreenMus::OnDisplaysChanged(
120 mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) { 124 mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) {
121 for (size_t i = 0; i < ws_displays.size(); ++i) { 125 for (size_t i = 0; i < ws_displays.size(); ++i) {
122 const bool is_primary = ws_displays[i]->is_primary; 126 const display::Display& display = ws_displays[i]->display;
123 ProcessDisplayChanged(ws_displays[i]->display, is_primary); 127 const bool is_primary =
128 display.id() == display_list()->GetPrimaryDisplayIterator()->id();
129 ProcessDisplayChanged(display, is_primary);
124 if (is_primary) { 130 if (is_primary) {
125 WindowManagerFrameValues frame_values = 131 WindowManagerFrameValues frame_values =
126 ws_displays[i] 132 ws_displays[i]
127 ->frame_decoration_values.To<WindowManagerFrameValues>(); 133 ->frame_decoration_values.To<WindowManagerFrameValues>();
128 WindowManagerFrameValues::SetInstance(frame_values); 134 WindowManagerFrameValues::SetInstance(frame_values);
129 if (delegate_) 135 if (delegate_)
130 delegate_->OnWindowManagerFrameValuesChanged(); 136 delegate_->OnWindowManagerFrameValuesChanged();
131 } 137 }
132 } 138 }
133 } 139 }
134 140
135 void ScreenMus::OnDisplayRemoved(int64_t id) { 141 void ScreenMus::OnDisplayRemoved(int64_t display_id) {
136 display_list()->RemoveDisplay(id); 142 display_list()->RemoveDisplay(display_id);
143 }
144
145 void ScreenMus::OnPrimaryDisplayChanged(int64_t primary_display_id) {
146 // TODO(kylechar): DisplayList would need to change to handle having no
147 // primary display.
148 if (primary_display_id == display::Display::kInvalidDisplayID)
149 return;
150
151 ProcessDisplayChanged(*display_list()->FindDisplayById(primary_display_id),
152 true);
137 } 153 }
138 154
139 } // namespace views 155 } // namespace views
OLDNEW
« services/ui/ws/window_manager_state.cc ('K') | « ui/views/mus/screen_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698