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

Unified Diff: ui/views/mus/screen_mus.cc

Issue 2461513002: Primary display change notifications. (Closed)
Patch Set: More fixes. Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/mus/screen_mus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/screen_mus.cc
diff --git a/ui/views/mus/screen_mus.cc b/ui/views/mus/screen_mus.cc
index 265bfbb2bbbfa8da322d297e5b44af9c1cc0b620..a841211a61c4a60fee03954acff6a63a43030eb0 100644
--- a/ui/views/mus/screen_mus.cc
+++ b/ui/views/mus/screen_mus.cc
@@ -34,10 +34,10 @@ struct TypeConverter<views::WindowManagerFrameValues,
namespace views {
+using Type = display::DisplayList::Type;
+
ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
- : delegate_(delegate),
- display_manager_observer_binding_(this) {
-}
+ : delegate_(delegate), display_manager_observer_binding_(this) {}
ScreenMus::~ScreenMus() {}
@@ -61,8 +61,7 @@ void ScreenMus::Init(service_manager::Connector* connector) {
// In this case we install a default display and assume the process is
// going to exit shortly so that the real value doesn't matter.
display_list()->AddDisplay(
- display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)),
- display::DisplayList::Type::PRIMARY);
+ display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)), Type::PRIMARY);
}
}
@@ -95,16 +94,17 @@ gfx::NativeWindow ScreenMus::GetWindowAtScreenPoint(const gfx::Point& point) {
return aura_window;
}
-void ScreenMus::OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) {
- // This should only be called once from Init() before any observers have been
- // added.
+void ScreenMus::OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays,
+ int64_t primary_display_id,
+ int64_t internal_display_id) {
+ // This should only be called once when ScreenMus is added as an observer.
DCHECK(display_list()->displays().empty());
+
for (size_t i = 0; i < ws_displays.size(); ++i) {
- const bool is_primary = ws_displays[i]->is_primary;
- display_list()->AddDisplay(ws_displays[i]->display,
- is_primary
- ? display::DisplayList::Type::PRIMARY
- : display::DisplayList::Type::NOT_PRIMARY);
+ const display::Display& display = ws_displays[i]->display;
+ const bool is_primary = display.id() == primary_display_id;
+ display_list()->AddDisplay(display,
+ is_primary ? Type::PRIMARY : Type::NOT_PRIMARY);
if (is_primary) {
// TODO(sky): Make WindowManagerFrameValues per display.
WindowManagerFrameValues frame_values =
@@ -113,14 +113,23 @@ void ScreenMus::OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) {
WindowManagerFrameValues::SetInstance(frame_values);
}
}
+
+ DCHECK(display_list()->GetPrimaryDisplayIterator() !=
+ display_list()->displays().end());
+
+ if (internal_display_id != display::Display::kInvalidDisplayID)
+ display::Display::SetInternalDisplayId(internal_display_id);
+
DCHECK(!display_list()->displays().empty());
}
void ScreenMus::OnDisplaysChanged(
mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) {
for (size_t i = 0; i < ws_displays.size(); ++i) {
- const bool is_primary = ws_displays[i]->is_primary;
- ProcessDisplayChanged(ws_displays[i]->display, is_primary);
+ const display::Display& display = ws_displays[i]->display;
+ const bool is_primary =
+ display.id() == display_list()->GetPrimaryDisplayIterator()->id();
+ ProcessDisplayChanged(display, is_primary);
if (is_primary) {
WindowManagerFrameValues frame_values =
ws_displays[i]
@@ -132,8 +141,18 @@ void ScreenMus::OnDisplaysChanged(
}
}
-void ScreenMus::OnDisplayRemoved(int64_t id) {
- display_list()->RemoveDisplay(id);
+void ScreenMus::OnDisplayRemoved(int64_t display_id) {
+ display_list()->RemoveDisplay(display_id);
+}
+
+void ScreenMus::OnPrimaryDisplayChanged(int64_t primary_display_id) {
+ // TODO(kylechar): DisplayList would need to change to handle having no
+ // primary display.
+ if (primary_display_id == display::Display::kInvalidDisplayID)
+ return;
+
+ ProcessDisplayChanged(*display_list()->FindDisplayById(primary_display_id),
+ true);
}
} // namespace views
« no previous file with comments | « ui/views/mus/screen_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698