Commit fbf2368a authored by James Cook's avatar James Cook Committed by Commit Bot

aura: Fix initial display id in CreateInitParamsForTopLevel for mus

It was previously defaulting to the primary display, which is wrong.

Bug: none
Change-Id: I827424b0e5a8dbb1725fe2741402c069afeb4fa3
Reviewed-on: https://chromium-review.googlesource.com/1089202
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565055}
parent af8e8219
...@@ -4,12 +4,39 @@ ...@@ -4,12 +4,39 @@
#include "ui/aura/mus/window_tree_host_mus_init_params.h" #include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "services/ui/public/cpp/property_type_converters.h"
#include "services/ui/public/interfaces/window_manager.mojom.h"
#include "ui/aura/mus/window_port_mus.h" #include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/mus/window_tree_client.h" #include "ui/aura/mus/window_tree_client.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
namespace aura { namespace aura {
namespace {
bool GetInitialDisplayId(
const std::map<std::string, std::vector<uint8_t>>& properties,
int64_t* display_id) {
auto it = properties.find(ui::mojom::WindowManager::kDisplayId_InitProperty);
if (it == properties.end())
return false;
*display_id = mojo::ConvertTo<int64_t>(it->second);
return true;
}
bool GetInitialBounds(
const std::map<std::string, std::vector<uint8_t>>& properties,
gfx::Rect* bounds) {
auto it = properties.find(ui::mojom::WindowManager::kBounds_InitProperty);
if (it == properties.end())
return false;
*bounds = mojo::ConvertTo<gfx::Rect>(it->second);
return true;
}
} // namespace
DisplayInitParams::DisplayInitParams() = default; DisplayInitParams::DisplayInitParams() = default;
...@@ -27,8 +54,22 @@ WindowTreeHostMusInitParams CreateInitParamsForTopLevel( ...@@ -27,8 +54,22 @@ WindowTreeHostMusInitParams CreateInitParamsForTopLevel(
std::map<std::string, std::vector<uint8_t>> properties) { std::map<std::string, std::vector<uint8_t>> properties) {
WindowTreeHostMusInitParams params; WindowTreeHostMusInitParams params;
params.window_tree_client = window_tree_client; params.window_tree_client = window_tree_client;
// TODO(jamescook): This seems wrong. Use display id from |properties|?
params.display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); int64_t display_id = display::kInvalidDisplayId;
gfx::Rect bounds_in_screen;
if (GetInitialDisplayId(properties, &display_id)) {
params.display_id = display_id;
} else if (GetInitialBounds(properties, &bounds_in_screen)) {
// Bounds must be in screen coordinates because a top-level can't have an
// aura::Window parent.
params.display_id =
display::Screen::GetScreen()->GetDisplayMatching(bounds_in_screen).id();
} else {
// TODO(jamescook): This should probably be the display for new windows,
// but that information isn't available at this level.
params.display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
}
// Pass |properties| to CreateWindowPortForTopLevel() so that |properties| // Pass |properties| to CreateWindowPortForTopLevel() so that |properties|
// are passed to the server *and* pass |properties| to the WindowTreeHostMus // are passed to the server *and* pass |properties| to the WindowTreeHostMus
// constructor (above) which applies the properties to the Window. Some of the // constructor (above) which applies the properties to the Window. Some of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment