summaryrefslogtreecommitdiff
path: root/chromium/ui/aura/mus
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-24 11:30:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-30 12:56:19 +0000
commit6036726eb981b6c4b42047513b9d3f4ac865daac (patch)
tree673593e70678e7789766d1f732eb51f613a2703b /chromium/ui/aura/mus
parent466052c4e7c052268fd931888cd58961da94c586 (diff)
downloadqtwebengine-chromium-6036726eb981b6c4b42047513b9d3f4ac865daac.tar.gz
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/aura/mus')
-rw-r--r--chromium/ui/aura/mus/DEPS6
-rw-r--r--chromium/ui/aura/mus/capture_synchronizer.cc10
-rw-r--r--chromium/ui/aura/mus/capture_synchronizer.h6
-rw-r--r--chromium/ui/aura/mus/capture_synchronizer_delegate.h2
-rw-r--r--chromium/ui/aura/mus/drag_drop_controller_host.h2
-rw-r--r--chromium/ui/aura/mus/drag_drop_controller_mus.cc26
-rw-r--r--chromium/ui/aura/mus/drag_drop_controller_mus.h18
-rw-r--r--chromium/ui/aura/mus/drag_drop_controller_mus_unittest.cc21
-rw-r--r--chromium/ui/aura/mus/embed_root.cc4
-rw-r--r--chromium/ui/aura/mus/embed_root.h4
-rw-r--r--chromium/ui/aura/mus/focus_synchronizer.cc24
-rw-r--r--chromium/ui/aura/mus/focus_synchronizer.h22
-rw-r--r--chromium/ui/aura/mus/focus_synchronizer_delegate.h2
-rw-r--r--chromium/ui/aura/mus/in_flight_change.cc48
-rw-r--r--chromium/ui/aura/mus/in_flight_change.h5
-rw-r--r--chromium/ui/aura/mus/input_method_mus.cc21
-rw-r--r--chromium/ui/aura/mus/input_method_mus.h13
-rw-r--r--chromium/ui/aura/mus/input_method_mus_delegate.h2
-rw-r--r--chromium/ui/aura/mus/input_method_mus_unittest.cc27
-rw-r--r--chromium/ui/aura/mus/mus_context_factory.cc7
-rw-r--r--chromium/ui/aura/mus/mus_context_factory.h12
-rw-r--r--chromium/ui/aura/mus/mus_mouse_location_updater.cc17
-rw-r--r--chromium/ui/aura/mus/mus_types.h28
-rw-r--r--chromium/ui/aura/mus/platform_event_source_mus_ozone.cc26
-rw-r--r--chromium/ui/aura/mus/platform_event_source_mus_ozone.h35
-rw-r--r--chromium/ui/aura/mus/property_converter.cc67
-rw-r--r--chromium/ui/aura/mus/property_converter_unittest.cc2
-rw-r--r--chromium/ui/aura/mus/property_utils.cc40
-rw-r--r--chromium/ui/aura/mus/property_utils.h6
-rw-r--r--chromium/ui/aura/mus/system_input_injector_mus.cc14
-rw-r--r--chromium/ui/aura/mus/system_input_injector_mus.h4
-rw-r--r--chromium/ui/aura/mus/system_input_injector_mus_unittest.cc82
-rw-r--r--chromium/ui/aura/mus/text_input_client_impl.cc6
-rw-r--r--chromium/ui/aura/mus/text_input_client_impl.h10
-rw-r--r--chromium/ui/aura/mus/topmost_window_tracker.cc41
-rw-r--r--chromium/ui/aura/mus/topmost_window_tracker.h52
-rw-r--r--chromium/ui/aura/mus/user_activity_forwarder.cc4
-rw-r--r--chromium/ui/aura/mus/user_activity_forwarder.h12
-rw-r--r--chromium/ui/aura/mus/user_activity_forwarder_unittest.cc26
-rw-r--r--chromium/ui/aura/mus/window_manager_delegate.cc23
-rw-r--r--chromium/ui/aura/mus/window_manager_delegate.h286
-rw-r--r--chromium/ui/aura/mus/window_mus.h12
-rw-r--r--chromium/ui/aura/mus/window_port_mus.cc45
-rw-r--r--chromium/ui/aura/mus/window_port_mus.h36
-rw-r--r--chromium/ui/aura/mus/window_port_mus_unittest.cc1
-rw-r--r--chromium/ui/aura/mus/window_tree_client.cc1374
-rw-r--r--chromium/ui/aura/mus/window_tree_client.h419
-rw-r--r--chromium/ui/aura/mus/window_tree_client_delegate.h13
-rw-r--r--chromium/ui/aura/mus/window_tree_client_unittest.cc886
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus.cc68
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus.h21
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus_delegate.h13
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus_init_params.cc17
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus_init_params.h30
54 files changed, 1044 insertions, 2954 deletions
diff --git a/chromium/ui/aura/mus/DEPS b/chromium/ui/aura/mus/DEPS
index 9e4ff45ffa6..1b310c00168 100644
--- a/chromium/ui/aura/mus/DEPS
+++ b/chromium/ui/aura/mus/DEPS
@@ -12,9 +12,9 @@ include_rules = [
"+gpu/ipc/client/gpu_channel_host.h",
"+mojo/public/cpp/system/buffer.h",
"+mojo/public/cpp/system/platform_handle.h",
- "+services/ui/common/accelerator_util.h",
- "+services/ui/common/task_runner_test_base.h",
- "+services/ui/public",
+ "+services/ws/common/accelerator_util.h",
+ "+services/ws/common/task_runner_test_base.h",
+ "+services/ws/public",
"+ui/gl/gl_bindings.h",
]
diff --git a/chromium/ui/aura/mus/capture_synchronizer.cc b/chromium/ui/aura/mus/capture_synchronizer.cc
index 48b74f961d4..f1bd68ee8ff 100644
--- a/chromium/ui/aura/mus/capture_synchronizer.cc
+++ b/chromium/ui/aura/mus/capture_synchronizer.cc
@@ -5,7 +5,7 @@
#include "ui/aura/mus/capture_synchronizer.h"
#include "base/auto_reset.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/mus/capture_synchronizer_delegate.h"
#include "ui/aura/mus/window_mus.h"
@@ -14,7 +14,7 @@
namespace aura {
CaptureSynchronizer::CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree)
+ ws::mojom::WindowTree* window_tree)
: delegate_(delegate), window_tree_(window_tree) {}
CaptureSynchronizer::~CaptureSynchronizer() {}
@@ -44,7 +44,11 @@ void CaptureSynchronizer::AttachToCaptureClient(
void CaptureSynchronizer::DetachFromCaptureClient(
client::CaptureClient* capture_client) {
- SetCaptureWindow(nullptr);
+ if (capture_window_ &&
+ client::GetCaptureClient(capture_window_->GetWindow()->GetRootWindow()) ==
+ capture_client) {
+ SetCaptureWindow(nullptr);
+ }
capture_client->RemoveObserver(this);
}
diff --git a/chromium/ui/aura/mus/capture_synchronizer.h b/chromium/ui/aura/mus/capture_synchronizer.h
index 4b300160f29..c2202165b23 100644
--- a/chromium/ui/aura/mus/capture_synchronizer.h
+++ b/chromium/ui/aura/mus/capture_synchronizer.h
@@ -12,7 +12,7 @@
#include "ui/aura/client/capture_client_observer.h"
#include "ui/aura/window_observer.h"
-namespace ui {
+namespace ws {
namespace mojom {
class WindowTree;
}
@@ -32,7 +32,7 @@ class AURA_EXPORT CaptureSynchronizer : public WindowObserver,
public client::CaptureClientObserver {
public:
CaptureSynchronizer(CaptureSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree);
+ ws::mojom::WindowTree* window_tree);
~CaptureSynchronizer() override;
WindowMus* capture_window() { return capture_window_; }
@@ -56,7 +56,7 @@ class AURA_EXPORT CaptureSynchronizer : public WindowObserver,
void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override;
CaptureSynchronizerDelegate* delegate_;
- ui::mojom::WindowTree* window_tree_;
+ ws::mojom::WindowTree* window_tree_;
// Window that currently has capture.
WindowMus* capture_window_ = nullptr;
diff --git a/chromium/ui/aura/mus/capture_synchronizer_delegate.h b/chromium/ui/aura/mus/capture_synchronizer_delegate.h
index 0df9da69458..7f2a58c06a3 100644
--- a/chromium/ui/aura/mus/capture_synchronizer_delegate.h
+++ b/chromium/ui/aura/mus/capture_synchronizer_delegate.h
@@ -14,7 +14,7 @@ namespace aura {
class WindowMus;
// Used by CaptureSynchronizer to create a change id when capture changes. The
-// change id is then sent to ui::mojom::WindowTree.
+// change id is then sent to ws::mojom::WindowTree.
class AURA_EXPORT CaptureSynchronizerDelegate {
public:
virtual uint32_t CreateChangeIdForCapture(WindowMus* window) = 0;
diff --git a/chromium/ui/aura/mus/drag_drop_controller_host.h b/chromium/ui/aura/mus/drag_drop_controller_host.h
index ba33ad928ab..14427ff05cb 100644
--- a/chromium/ui/aura/mus/drag_drop_controller_host.h
+++ b/chromium/ui/aura/mus/drag_drop_controller_host.h
@@ -14,7 +14,7 @@ namespace aura {
class WindowMus;
// Used by DragDropControllerMus to create a change id when a drag starts that
-// is sent to ui::mojom::WindowTree.
+// is sent to ws::mojom::WindowTree.
class AURA_EXPORT DragDropControllerHost {
public:
virtual uint32_t CreateChangeIdForDrag(WindowMus* window) = 0;
diff --git a/chromium/ui/aura/mus/drag_drop_controller_mus.cc b/chromium/ui/aura/mus/drag_drop_controller_mus.cc
index ffab655f551..9670df44ac9 100644
--- a/chromium/ui/aura/mus/drag_drop_controller_mus.cc
+++ b/chromium/ui/aura/mus/drag_drop_controller_mus.cc
@@ -11,8 +11,8 @@
#include "base/auto_reset.h"
#include "base/run_loop.h"
#include "mojo/public/cpp/bindings/map.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/client/drag_drop_client_observer.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/env.h"
@@ -25,20 +25,20 @@
#include "ui/base/dragdrop/drop_target_event.h"
// Interaction with DragDropDelegate assumes constants are the same.
-static_assert(ui::DragDropTypes::DRAG_NONE == ui::mojom::kDropEffectNone,
+static_assert(ui::DragDropTypes::DRAG_NONE == ws::mojom::kDropEffectNone,
"Drag constants must be the same");
-static_assert(ui::DragDropTypes::DRAG_MOVE == ui::mojom::kDropEffectMove,
+static_assert(ui::DragDropTypes::DRAG_MOVE == ws::mojom::kDropEffectMove,
"Drag constants must be the same");
-static_assert(ui::DragDropTypes::DRAG_COPY == ui::mojom::kDropEffectCopy,
+static_assert(ui::DragDropTypes::DRAG_COPY == ws::mojom::kDropEffectCopy,
"Drag constants must be the same");
-static_assert(ui::DragDropTypes::DRAG_LINK == ui::mojom::kDropEffectLink,
+static_assert(ui::DragDropTypes::DRAG_LINK == ws::mojom::kDropEffectLink,
"Drag constants must be the same");
namespace aura {
// State related to a drag initiated by this client.
struct DragDropControllerMus::CurrentDragState {
- ui::Id window_id;
+ ws::Id window_id;
// The change id of the drag. Used to identify the drag on the server.
uint32_t change_id;
@@ -57,7 +57,7 @@ struct DragDropControllerMus::CurrentDragState {
DragDropControllerMus::DragDropControllerMus(
DragDropControllerHost* drag_drop_controller_host,
- ui::mojom::WindowTree* window_tree)
+ ws::mojom::WindowTree* window_tree)
: drag_drop_controller_host_(drag_drop_controller_host),
window_tree_(window_tree) {}
@@ -104,7 +104,7 @@ uint32_t DragDropControllerMus::OnCompleteDrop(
const gfx::Point& screen_location,
uint32_t effect_bitmask) {
if (drop_target_window_tracker_.windows().empty())
- return ui::mojom::kDropEffectNone;
+ return ws::mojom::kDropEffectNone;
DCHECK(window);
Window* current_target = drop_target_window_tracker_.Pop();
@@ -141,7 +141,7 @@ int DragDropControllerMus::StartDragAndDrop(
const uint32_t change_id =
drag_drop_controller_host_->CreateChangeIdForDrag(root_window_mus);
CurrentDragState current_drag_state = {root_window_mus->server_id(),
- change_id, ui::mojom::kDropEffectNone,
+ change_id, ws::mojom::kDropEffectNone,
data, run_loop.QuitClosure()};
// current_drag_state_ will be reset in |OnPerformDragDropCompleted| before
@@ -203,7 +203,7 @@ uint32_t DragDropControllerMus::HandleDragEnterOrOver(
if ((!is_enter && drop_target_window_tracker_.windows().empty()) ||
!drag_drop_delegate || !window_tree_host) {
drop_target_window_tracker_.RemoveAll();
- return ui::mojom::kDropEffectNone;
+ return ws::mojom::kDropEffectNone;
}
drop_target_window_tracker_.Add(window->GetWindow());
@@ -222,13 +222,13 @@ DragDropControllerMus::CreateDropTargetEvent(Window* window,
DCHECK(window->GetHost());
gfx::Point root_location = screen_location;
window->GetHost()->ConvertScreenInPixelsToDIP(&root_location);
- gfx::Point location = root_location;
+ gfx::PointF location(root_location);
Window::ConvertPointToTarget(window->GetRootWindow(), window, &location);
std::unique_ptr<ui::DropTargetEvent> event =
std::make_unique<ui::DropTargetEvent>(
current_drag_state_ ? current_drag_state_->drag_data
: *(os_exchange_data_.get()),
- location, root_location, effect_bitmask);
+ location, gfx::PointF(root_location), effect_bitmask);
event->set_flags(event_flags);
ui::Event::DispatcherApi(event.get()).set_target(window);
return event;
diff --git a/chromium/ui/aura/mus/drag_drop_controller_mus.h b/chromium/ui/aura/mus/drag_drop_controller_mus.h
index e161339ded1..0bcb808a73f 100644
--- a/chromium/ui/aura/mus/drag_drop_controller_mus.h
+++ b/chromium/ui/aura/mus/drag_drop_controller_mus.h
@@ -17,15 +17,17 @@
#include "ui/aura/window_tracker.h"
#include "ui/base/dragdrop/drag_drop_types.h"
-namespace ui {
-class DropTargetEvent;
-class OSExchangeData;
-
+namespace ws {
namespace mojom {
class WindowTree;
}
}
+namespace ui {
+class DropTargetEvent;
+class OSExchangeData;
+} // namespace ui
+
namespace aura {
class DragDropControllerHost;
@@ -37,7 +39,7 @@ class WindowMus;
class AURA_EXPORT DragDropControllerMus : public client::DragDropClient {
public:
DragDropControllerMus(DragDropControllerHost* drag_drop_controller_host,
- ui::mojom::WindowTree* window_tree);
+ ws::mojom::WindowTree* window_tree);
~DragDropControllerMus() override;
// Returns true if a drag was initiated and |id| identifies the change if of
@@ -45,7 +47,7 @@ class AURA_EXPORT DragDropControllerMus : public client::DragDropClient {
bool DoesChangeIdMatchDragChangeId(uint32_t id) const;
// Forwarded from WindowTreeClient. These correspond to the functions of the
- // same name defined in ui::mojom::WindowTreeClient.
+ // same name defined in ws::mojom::WindowTreeClient.
void OnDragDropStart(std::map<std::string, std::vector<uint8_t>> data);
uint32_t OnDragEnter(WindowMus* window,
uint32_t event_flags,
@@ -93,7 +95,7 @@ class AURA_EXPORT DragDropControllerMus : public client::DragDropClient {
DragDropControllerHost* drag_drop_controller_host_;
- ui::mojom::WindowTree* window_tree_;
+ ws::mojom::WindowTree* window_tree_;
// State related to being the initiator of a drag started with
// PerformDragDrop(). If non-null a drag was started by this client and is
@@ -109,7 +111,7 @@ class AURA_EXPORT DragDropControllerMus : public client::DragDropClient {
// Used to track the current drop target.
WindowTracker drop_target_window_tracker_;
- base::ObserverList<client::DragDropClientObserver> observers_;
+ base::ObserverList<client::DragDropClientObserver>::Unchecked observers_;
DISALLOW_COPY_AND_ASSIGN(DragDropControllerMus);
};
diff --git a/chromium/ui/aura/mus/drag_drop_controller_mus_unittest.cc b/chromium/ui/aura/mus/drag_drop_controller_mus_unittest.cc
index 24227cf7076..753d7c9d3ba 100644
--- a/chromium/ui/aura/mus/drag_drop_controller_mus_unittest.cc
+++ b/chromium/ui/aura/mus/drag_drop_controller_mus_unittest.cc
@@ -8,7 +8,7 @@
#include "base/callback_forward.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/aura/client/drag_drop_client_observer.h"
#include "ui/aura/client/drag_drop_delegate.h"
@@ -16,29 +16,30 @@
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/test/aura_mus_test_base.h"
#include "ui/aura/test/mus/test_window_tree.h"
+#include "ui/aura/window.h"
#include "ui/base/dragdrop/drop_target_event.h"
#include "ui/events/event_utils.h"
namespace aura {
namespace {
-class DragDropControllerMusTest : public test::AuraMusWmTestBase {
+class DragDropControllerMusTest : public test::AuraMusClientTestBase {
public:
DragDropControllerMusTest() = default;
- // test::AuraMusWmTestBase
+ // test::AuraMusClientTestBase:
void SetUp() override {
- AuraMusWmTestBase::SetUp();
+ AuraMusClientTestBase::SetUp();
controller_ = std::make_unique<DragDropControllerMus>(&controller_host_,
window_tree());
- window_ = std::unique_ptr<aura::Window>(
- CreateNormalWindow(0, root_window(), nullptr));
+ window_ =
+ std::unique_ptr<Window>(CreateNormalWindow(0, root_window(), nullptr));
}
void TearDown() override {
window_.reset();
controller_.reset();
- AuraMusWmTestBase::TearDown();
+ AuraMusClientTestBase::TearDown();
}
protected:
@@ -58,7 +59,7 @@ class DragDropControllerMusTest : public test::AuraMusWmTestBase {
}
std::unique_ptr<DragDropControllerMus> controller_;
- std::unique_ptr<aura::Window> window_;
+ std::unique_ptr<Window> window_;
private:
void DragMoveAndDrop() {
@@ -127,7 +128,7 @@ TEST_F(DragDropControllerMusTest, EventTarget) {
class TestDelegate : public client::DragDropDelegate {
public:
- TestDelegate(aura::Window* window) : window_(window) {}
+ explicit TestDelegate(Window* window) : window_(window) {}
State state() const { return state_; }
// Overrides from client::DragDropClientObserver:
@@ -152,7 +153,7 @@ TEST_F(DragDropControllerMusTest, EventTarget) {
}
private:
- aura::Window* const window_;
+ Window* const window_;
State state_{State::kNotInvoked};
DISALLOW_COPY_AND_ASSIGN(TestDelegate);
diff --git a/chromium/ui/aura/mus/embed_root.cc b/chromium/ui/aura/mus/embed_root.cc
index 058bacaaeb4..372988eaa30 100644
--- a/chromium/ui/aura/mus/embed_root.cc
+++ b/chromium/ui/aura/mus/embed_root.cc
@@ -84,7 +84,7 @@ class EmbeddedFocusClient : public client::FocusClient, public WindowObserver {
Window* focused_window_ = nullptr;
- base::ObserverList<client::FocusChangeObserver> observers_;
+ base::ObserverList<client::FocusChangeObserver>::Unchecked observers_;
DISALLOW_COPY_AND_ASSIGN(EmbeddedFocusClient);
};
@@ -104,7 +104,7 @@ Window* EmbedRoot::window() {
EmbedRoot::EmbedRoot(WindowTreeClient* window_tree_client,
EmbedRootDelegate* delegate,
- ui::ClientSpecificId window_id)
+ ws::ClientSpecificId window_id)
: window_tree_client_(window_tree_client),
delegate_(delegate),
weak_factory_(this) {
diff --git a/chromium/ui/aura/mus/embed_root.h b/chromium/ui/aura/mus/embed_root.h
index f1aa46dffb7..46293ee61fc 100644
--- a/chromium/ui/aura/mus/embed_root.h
+++ b/chromium/ui/aura/mus/embed_root.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/unguessable_token.h"
-#include "services/ui/common/types.h"
+#include "services/ws/common/types.h"
#include "ui/aura/aura_export.h"
namespace aura {
@@ -49,7 +49,7 @@ class AURA_EXPORT EmbedRoot {
EmbedRoot(WindowTreeClient* window_tree_client,
EmbedRootDelegate* delegate,
- ui::ClientSpecificId window_id);
+ ws::ClientSpecificId window_id);
// Callback from WindowTreeClient once the token has been determined.
void OnScheduledEmbedForExistingClient(const base::UnguessableToken& token);
diff --git a/chromium/ui/aura/mus/focus_synchronizer.cc b/chromium/ui/aura/mus/focus_synchronizer.cc
index fee1d4559b4..e70c82509da 100644
--- a/chromium/ui/aura/mus/focus_synchronizer.cc
+++ b/chromium/ui/aura/mus/focus_synchronizer.cc
@@ -5,7 +5,7 @@
#include "ui/aura/mus/focus_synchronizer.h"
#include "base/auto_reset.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/mus/focus_synchronizer_delegate.h"
@@ -15,7 +15,7 @@
namespace aura {
FocusSynchronizer::FocusSynchronizer(FocusSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree)
+ ws::mojom::WindowTree* window_tree)
: delegate_(delegate), window_tree_(window_tree) {}
FocusSynchronizer::~FocusSynchronizer() {
@@ -44,16 +44,11 @@ void FocusSynchronizer::SetFocusFromServer(WindowMus* window) {
Window* root = window->GetWindow()->GetRootWindow();
// The client should provide a focus client for all roots.
DCHECK(client::GetFocusClient(root));
- if (is_singleton_focus_client_)
- DCHECK_EQ(active_focus_client_, client::GetFocusClient(root));
- else if (active_focus_client_root_ != root)
+ if (active_focus_client_root_ != root)
SetActiveFocusClient(client::GetFocusClient(root), root);
window->GetWindow()->Focus();
} else if (active_focus_client_) {
- if (is_singleton_focus_client_)
- active_focus_client_->FocusWindow(nullptr);
- else
- SetActiveFocusClient(nullptr, nullptr);
+ SetActiveFocusClient(nullptr, nullptr);
}
}
@@ -61,13 +56,6 @@ void FocusSynchronizer::OnFocusedWindowDestroyed() {
focused_window_ = nullptr;
}
-void FocusSynchronizer::SetSingletonFocusClient(
- client::FocusClient* focus_client) {
- SetActiveFocusClient(focus_client, nullptr);
- if (focus_client)
- is_singleton_focus_client_ = true;
-}
-
void FocusSynchronizer::SetActiveFocusClient(client::FocusClient* focus_client,
Window* focus_client_root) {
if (focus_client == active_focus_client_ &&
@@ -75,8 +63,6 @@ void FocusSynchronizer::SetActiveFocusClient(client::FocusClient* focus_client,
return;
}
- is_singleton_focus_client_ = false;
-
if (active_focus_client_root_)
active_focus_client_root_->RemoveObserver(this);
active_focus_client_root_ = focus_client_root;
@@ -137,14 +123,12 @@ void FocusSynchronizer::OnWindowFocused(Window* gained_focus,
}
void FocusSynchronizer::OnWindowDestroying(Window* window) {
- DCHECK(!is_singleton_focus_client_);
SetActiveFocusClient(nullptr, nullptr);
}
void FocusSynchronizer::OnWindowPropertyChanged(Window* window,
const void* key,
intptr_t old) {
- DCHECK(!is_singleton_focus_client_);
if (key != client::kFocusClientKey)
return;
diff --git a/chromium/ui/aura/mus/focus_synchronizer.h b/chromium/ui/aura/mus/focus_synchronizer.h
index ebacfcea6b4..f054cac8fd6 100644
--- a/chromium/ui/aura/mus/focus_synchronizer.h
+++ b/chromium/ui/aura/mus/focus_synchronizer.h
@@ -12,7 +12,7 @@
#include "ui/aura/mus/focus_synchronizer_observer.h"
#include "ui/aura/window_observer.h"
-namespace ui {
+namespace ws {
namespace mojom {
class WindowTree;
}
@@ -28,17 +28,12 @@ class FocusClient;
}
// FocusSynchronizer is responsible for keeping focus in sync between aura
-// and the mus server. FocusSynchronizer may be configured in two distinct
-// ways:
-// . SetSingletonFocusClient(). Use this when a single FocusClient is shared
-// among all windows and never changes.
-// . SetActiveFocusClient(). Use this when there may be more than one
-// FocusClient.
+// and the mus server.
class AURA_EXPORT FocusSynchronizer : public client::FocusChangeObserver,
public WindowObserver {
public:
FocusSynchronizer(FocusSynchronizerDelegate* delegate,
- ui::mojom::WindowTree* window_tree);
+ ws::mojom::WindowTree* window_tree);
~FocusSynchronizer() override;
client::FocusClient* active_focus_client() { return active_focus_client_; }
@@ -56,11 +51,6 @@ class AURA_EXPORT FocusSynchronizer : public client::FocusChangeObserver,
// Called when the focused window is destroyed.
void OnFocusedWindowDestroyed();
- // Used when the focus client is shared among all windows. See class
- // description for details.
- void SetSingletonFocusClient(client::FocusClient* focus_client);
- bool is_singleton_focus_client() const { return is_singleton_focus_client_; }
-
// Sets the active FocusClient and the window the FocusClient is associated
// with. |focus_client_root| is not necessarily the window that actually has
// focus.
@@ -89,15 +79,13 @@ class AURA_EXPORT FocusSynchronizer : public client::FocusChangeObserver,
intptr_t old) override;
FocusSynchronizerDelegate* delegate_;
- ui::mojom::WindowTree* window_tree_;
+ ws::mojom::WindowTree* window_tree_;
- base::ObserverList<FocusSynchronizerObserver> observers_;
+ base::ObserverList<FocusSynchronizerObserver>::Unchecked observers_;
bool setting_focus_ = false;
WindowMus* window_setting_focus_to_ = nullptr;
- bool is_singleton_focus_client_ = false;
-
client::FocusClient* active_focus_client_ = nullptr;
// The window that |active_focus_client_| is associated with.
Window* active_focus_client_root_ = nullptr;
diff --git a/chromium/ui/aura/mus/focus_synchronizer_delegate.h b/chromium/ui/aura/mus/focus_synchronizer_delegate.h
index 69685c599d2..71a5a1d73f2 100644
--- a/chromium/ui/aura/mus/focus_synchronizer_delegate.h
+++ b/chromium/ui/aura/mus/focus_synchronizer_delegate.h
@@ -14,7 +14,7 @@ namespace aura {
class WindowMus;
// Used by FocusSynchronizer to create a change id when focus changes. The
-// change id is then sent to ui::mojom::WindowTree.
+// change id is then sent to ws::mojom::WindowTree.
class AURA_EXPORT FocusSynchronizerDelegate {
public:
virtual uint32_t CreateChangeIdForFocus(WindowMus* window) = 0;
diff --git a/chromium/ui/aura/mus/in_flight_change.cc b/chromium/ui/aura/mus/in_flight_change.cc
index ad5a993550e..fe5ed3153b7 100644
--- a/chromium/ui/aura/mus/in_flight_change.cc
+++ b/chromium/ui/aura/mus/in_flight_change.cc
@@ -15,6 +15,51 @@
namespace aura {
+std::string ChangeTypeToString(ChangeType change_type) {
+ switch (change_type) {
+ case ChangeType::ADD_CHILD:
+ return "ADD_CHILD";
+ case ChangeType::ADD_TRANSIENT_WINDOW:
+ return "ADD_TRANSIENT_WINDOW";
+ case ChangeType::BOUNDS:
+ return "BOUNDS";
+ case ChangeType::CAPTURE:
+ return "CAPTURE";
+ case ChangeType::CHILD_MODAL_PARENT:
+ return "CHILD_MODAL_PARENT";
+ case ChangeType::DELETE_WINDOW:
+ return "DELETE_WINDOW";
+ case ChangeType::DRAG_LOOP:
+ return "DRAG_LOOP";
+ case ChangeType::FOCUS:
+ return "FOCUS";
+ case ChangeType::MOVE_LOOP:
+ return "MOVE_LOOP";
+ case ChangeType::NEW_TOP_LEVEL_WINDOW:
+ return "NEW_TOP_LEVEL_WINDOW";
+ case ChangeType::NEW_WINDOW:
+ return "NEW_WINDOW";
+ case ChangeType::OPACITY:
+ return "OPACITY";
+ case ChangeType::CURSOR:
+ return "CURSOR";
+ case ChangeType::PROPERTY:
+ return "PROPERTY";
+ case ChangeType::REMOVE_CHILD:
+ return "REMOVE_CHILD";
+ case ChangeType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT:
+ return "REMOVE_TRANSIENT_WINDOW_FROM_PARENT";
+ case ChangeType::REORDER:
+ return "REORDER";
+ case ChangeType::SET_MODAL:
+ return "SET_MODAL";
+ case ChangeType::TRANSFORM:
+ return "TRANSFORM";
+ case ChangeType::VISIBLE:
+ return "VISIBLE";
+ }
+}
+
// InFlightChange -------------------------------------------------------------
InFlightChange::InFlightChange(WindowMus* window, ChangeType type)
@@ -100,8 +145,7 @@ void CrashInFlightChange::SetRevertValueFrom(const InFlightChange& change) {
}
void CrashInFlightChange::ChangeFailed() {
- DLOG(ERROR) << "change failed, type=" << static_cast<int>(change_type());
- CHECK(false);
+ CHECK(false) << "change failed, type=" << static_cast<int>(change_type());
}
void CrashInFlightChange::Revert() {
diff --git a/chromium/ui/aura/mus/in_flight_change.h b/chromium/ui/aura/mus/in_flight_change.h
index 0422d2f20be..bfb8761a3b7 100644
--- a/chromium/ui/aura/mus/in_flight_change.h
+++ b/chromium/ui/aura/mus/in_flight_change.h
@@ -22,11 +22,9 @@
#include "ui/gfx/transform.h"
namespace ui {
-
namespace mojom {
enum class CursorType : int32_t;
}
-
} // namespace ui
namespace aura {
@@ -59,6 +57,9 @@ enum class ChangeType {
VISIBLE,
};
+// Print a human-readable string representation of |change_type| for logging.
+std::string ChangeTypeToString(ChangeType change_type);
+
// InFlightChange is used to track function calls to the server and take the
// appropriate action when the call fails, or the same property changes while
// waiting for the response. When a function is called on the server an
diff --git a/chromium/ui/aura/mus/input_method_mus.cc b/chromium/ui/aura/mus/input_method_mus.cc
index 7d1f500384c..f840416fe0f 100644
--- a/chromium/ui/aura/mus/input_method_mus.cc
+++ b/chromium/ui/aura/mus/input_method_mus.cc
@@ -6,9 +6,9 @@
#include <utility>
-#include "services/ui/public/interfaces/constants.mojom.h"
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
+#include "services/ws/public/mojom/constants.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/mus/input_method_mus_delegate.h"
#include "ui/aura/mus/text_input_client_impl.h"
#include "ui/base/ime/text_input_client.h"
@@ -16,7 +16,7 @@
#include "ui/platform_window/mojo/ime_type_converters.h"
#include "ui/platform_window/mojo/text_input_state.mojom.h"
-using ui::mojom::EventResult;
+using ws::mojom::EventResult;
namespace aura {
@@ -39,7 +39,7 @@ InputMethodMus::~InputMethodMus() {
void InputMethodMus::Init(service_manager::Connector* connector) {
if (connector)
- connector->BindInterface(ui::mojom::kServiceName, &ime_driver_);
+ connector->BindInterface(ws::mojom::kServiceName, &ime_driver_);
}
ui::EventDispatchDetails InputMethodMus::DispatchKeyEvent(
@@ -114,14 +114,21 @@ void InputMethodMus::CancelComposition(const ui::TextInputClient* client) {
void InputMethodMus::OnInputLocaleChanged() {
// TODO(moshayedi): crbug.com/637418. Not supported in ChromeOS. Investigate
// whether we want to support this or not.
+ NOTIMPLEMENTED_LOG_ONCE();
}
bool InputMethodMus::IsCandidatePopupOpen() const {
// TODO(moshayedi): crbug.com/637416. Implement this properly when we have a
// mean for displaying candidate list popup.
+ NOTIMPLEMENTED_LOG_ONCE();
return false;
}
+void InputMethodMus::ShowVirtualKeyboardIfEnabled() {
+ if (input_method_)
+ input_method_->ShowVirtualKeyboardIfEnabled();
+}
+
ui::EventDispatchDetails InputMethodMus::SendKeyEventToInputMethod(
const ui::KeyEvent& event,
EventResultCallback ack_callback) {
@@ -166,8 +173,8 @@ void InputMethodMus::OnDidChangeFocusedClient(
std::make_unique<TextInputClientImpl>(focused, delegate());
if (ime_driver_) {
- ui::mojom::StartSessionDetailsPtr details =
- ui::mojom::StartSessionDetails::New();
+ ws::mojom::StartSessionDetailsPtr details =
+ ws::mojom::StartSessionDetails::New();
details->client =
text_input_client_->CreateInterfacePtrAndBind().PassInterface();
details->input_method_request = MakeRequest(&input_method_ptr_);
diff --git a/chromium/ui/aura/mus/input_method_mus.h b/chromium/ui/aura/mus/input_method_mus.h
index f47be868061..d47ed317001 100644
--- a/chromium/ui/aura/mus/input_method_mus.h
+++ b/chromium/ui/aura/mus/input_method_mus.h
@@ -9,11 +9,11 @@
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/base/ime/input_method_base.h"
-namespace ui {
+namespace ws {
namespace mojom {
enum class EventResult;
}
@@ -27,7 +27,7 @@ class TextInputClientImpl;
class AURA_EXPORT InputMethodMus : public ui::InputMethodBase {
public:
- using EventResultCallback = base::OnceCallback<void(ui::mojom::EventResult)>;
+ using EventResultCallback = base::OnceCallback<void(ws::mojom::EventResult)>;
InputMethodMus(ui::internal::InputMethodDelegate* delegate,
InputMethodMusDelegate* input_method_mus_delegate);
@@ -47,6 +47,7 @@ class AURA_EXPORT InputMethodMus : public ui::InputMethodBase {
void CancelComposition(const ui::TextInputClient* client) override;
void OnInputLocaleChanged() override;
bool IsCandidatePopupOpen() const override;
+ void ShowVirtualKeyboardIfEnabled() override;
private:
friend class InputMethodMusTestApi;
@@ -78,11 +79,11 @@ class AURA_EXPORT InputMethodMus : public ui::InputMethodBase {
InputMethodMusDelegate* input_method_mus_delegate_;
// May be null in tests.
- ui::mojom::IMEDriverPtr ime_driver_;
- ui::mojom::InputMethodPtr input_method_ptr_;
+ ws::mojom::IMEDriverPtr ime_driver_;
+ ws::mojom::InputMethodPtr input_method_ptr_;
// Typically this is the same as |input_method_ptr_|, but it may be mocked
// in tests.
- ui::mojom::InputMethod* input_method_ = nullptr;
+ ws::mojom::InputMethod* input_method_ = nullptr;
std::unique_ptr<TextInputClientImpl> text_input_client_;
// Callbacks supplied to DispatchKeyEvent() are added here while awaiting
diff --git a/chromium/ui/aura/mus/input_method_mus_delegate.h b/chromium/ui/aura/mus/input_method_mus_delegate.h
index 789c5900f1e..22df54980e4 100644
--- a/chromium/ui/aura/mus/input_method_mus_delegate.h
+++ b/chromium/ui/aura/mus/input_method_mus_delegate.h
@@ -5,7 +5,7 @@
#ifndef UI_AURA_MUS_INPUT_METHOD_MUS_DELEGATE_H_
#define UI_AURA_MUS_INPUT_METHOD_MUS_DELEGATE_H_
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
#include "ui/aura/aura_export.h"
namespace aura {
diff --git a/chromium/ui/aura/mus/input_method_mus_unittest.cc b/chromium/ui/aura/mus/input_method_mus_unittest.cc
index c3c1bd6eac6..eaa79232a93 100644
--- a/chromium/ui/aura/mus/input_method_mus_unittest.cc
+++ b/chromium/ui/aura/mus/input_method_mus_unittest.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/mus/input_method_mus_test_api.h"
#include "ui/base/ime/dummy_text_input_client.h"
@@ -32,11 +32,11 @@ class TestInputMethodDelegate : public ui::internal::InputMethodDelegate {
using ProcessKeyEventCallback = base::OnceCallback<void(bool)>;
using ProcessKeyEventCallbacks = std::vector<ProcessKeyEventCallback>;
-using EventResultCallback = base::OnceCallback<void(ui::mojom::EventResult)>;
+using EventResultCallback = base::OnceCallback<void(ws::mojom::EventResult)>;
// InputMethod implementation that queues up the callbacks supplied to
// ProcessKeyEvent().
-class TestInputMethod : public ui::mojom::InputMethod {
+class TestInputMethod : public ws::mojom::InputMethod {
public:
TestInputMethod() {}
~TestInputMethod() override {}
@@ -57,6 +57,9 @@ class TestInputMethod : public ui::mojom::InputMethod {
process_key_event_callbacks_.push_back(std::move(callback));
}
void CancelComposition() override { was_cancel_composition_called_ = true; }
+ void ShowVirtualKeyboardIfEnabled() override {
+ was_show_virtual_keyboard_if_enabled_called_ = true;
+ }
bool was_on_text_input_type_changed_called() {
return was_on_text_input_type_changed_called_;
@@ -70,10 +73,15 @@ class TestInputMethod : public ui::mojom::InputMethod {
return was_cancel_composition_called_;
}
+ bool was_show_virtual_keyboard_if_enabled_called() {
+ return was_show_virtual_keyboard_if_enabled_called_;
+ }
+
private:
bool was_on_text_input_type_changed_called_ = false;
bool was_on_caret_bounds_changed_called_ = false;
bool was_cancel_composition_called_ = false;
+ bool was_show_virtual_keyboard_if_enabled_called_ = false;
ProcessKeyEventCallbacks process_key_event_callbacks_;
DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
@@ -86,7 +94,7 @@ using InputMethodMusTest = test::AuraTestBaseMus;
namespace {
// Used in closure supplied to processing the event.
-void RunFunctionWithEventResult(bool* was_run, ui::mojom::EventResult result) {
+void RunFunctionWithEventResult(bool* was_run, ws::mojom::EventResult result) {
*was_run = true;
}
@@ -298,4 +306,15 @@ TEST_F(InputMethodMusTest, CancelCompositionFromUnfocusedClient) {
EXPECT_FALSE(test_input_method.was_cancel_composition_called());
}
+// Calling ShowVirtualKeyboardIfEnabled should notify the mus side.
+TEST_F(InputMethodMusTest, ShowVirtualKeyboardIfEnabled) {
+ TestInputMethodDelegate input_method_delegate;
+ InputMethodMus input_method_mus(&input_method_delegate, nullptr);
+ TestInputMethod test_input_method;
+ InputMethodMusTestApi::SetInputMethod(&input_method_mus, &test_input_method);
+ EXPECT_FALSE(test_input_method.was_show_virtual_keyboard_if_enabled_called());
+ input_method_mus.ShowVirtualKeyboardIfEnabled();
+ EXPECT_TRUE(test_input_method.was_show_virtual_keyboard_if_enabled_called());
+}
+
} // namespace aura
diff --git a/chromium/ui/aura/mus/mus_context_factory.cc b/chromium/ui/aura/mus/mus_context_factory.cc
index 014c75d8c46..7b25807bf1c 100644
--- a/chromium/ui/aura/mus/mus_context_factory.cc
+++ b/chromium/ui/aura/mus/mus_context_factory.cc
@@ -9,7 +9,7 @@
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/host/renderer_settings_creation.h"
-#include "services/ui/public/cpp/gpu/gpu.h"
+#include "services/ws/public/cpp/gpu/gpu.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/window_tree_host.h"
#include "ui/compositor/compositor_switches.h"
@@ -19,9 +19,8 @@
namespace aura {
-MusContextFactory::MusContextFactory(ui::Gpu* gpu)
- : gpu_(gpu),
- weak_ptr_factory_(this) {}
+MusContextFactory::MusContextFactory(ws::Gpu* gpu)
+ : gpu_(gpu), weak_ptr_factory_(this) {}
MusContextFactory::~MusContextFactory() {}
diff --git a/chromium/ui/aura/mus/mus_context_factory.h b/chromium/ui/aura/mus/mus_context_factory.h
index 08340f36654..25e0c0d09af 100644
--- a/chromium/ui/aura/mus/mus_context_factory.h
+++ b/chromium/ui/aura/mus/mus_context_factory.h
@@ -12,8 +12,8 @@
#include "base/memory/weak_ptr.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/gpu/context_provider.h"
-#include "services/ui/public/cpp/raster_thread_helper.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "services/ws/public/cpp/raster_thread_helper.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/compositor/compositor.h"
@@ -21,7 +21,7 @@ namespace gpu {
class GpuChannelHost;
}
-namespace ui {
+namespace ws {
class Gpu;
}
@@ -30,7 +30,7 @@ namespace aura {
// ContextFactory implementation that can be used with Mus.
class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
public:
- explicit MusContextFactory(ui::Gpu* gpu);
+ explicit MusContextFactory(ws::Gpu* gpu);
~MusContextFactory() override;
private:
@@ -51,8 +51,8 @@ class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
void RemoveObserver(ui::ContextFactoryObserver* observer) override {}
bool SyncTokensRequiredForDisplayCompositor() override;
- ui::RasterThreadHelper raster_thread_helper_;
- ui::Gpu* gpu_;
+ ws::RasterThreadHelper raster_thread_helper_;
+ ws::Gpu* gpu_;
scoped_refptr<viz::ContextProvider> shared_main_thread_context_provider_;
base::WeakPtrFactory<MusContextFactory> weak_ptr_factory_;
diff --git a/chromium/ui/aura/mus/mus_mouse_location_updater.cc b/chromium/ui/aura/mus/mus_mouse_location_updater.cc
index 0a9d6201747..32aa588cb61 100644
--- a/chromium/ui/aura/mus/mus_mouse_location_updater.cc
+++ b/chromium/ui/aura/mus/mus_mouse_location_updater.cc
@@ -4,6 +4,7 @@
#include "ui/aura/mus/mus_mouse_location_updater.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/events/event.h"
@@ -43,8 +44,20 @@ void MusMouseLocationUpdater::OnEventProcessingStarted(const ui::Event& event) {
}
is_processing_trigger_event_ = true;
- Env::GetInstance()->SetLastMouseLocation(
- event.AsMouseEvent()->root_location());
+ gfx::Point location_in_screen = event.AsMouseEvent()->root_location();
+ // event.target() may not exist in some tests.
+ if (event.target()) {
+ aura::Window* root_window =
+ static_cast<aura::Window*>(event.target())->GetRootWindow();
+ auto* screen_position_client =
+ aura::client::GetScreenPositionClient(root_window);
+ // screen_position_client may not exist in tests.
+ if (screen_position_client) {
+ screen_position_client->ConvertPointToScreen(root_window,
+ &location_in_screen);
+ }
+ }
+ Env::GetInstance()->SetLastMouseLocation(location_in_screen);
Env::GetInstance()->get_last_mouse_location_from_mus_ = false;
}
diff --git a/chromium/ui/aura/mus/mus_types.h b/chromium/ui/aura/mus/mus_types.h
index bc82f736308..4f406261d73 100644
--- a/chromium/ui/aura/mus/mus_types.h
+++ b/chromium/ui/aura/mus/mus_types.h
@@ -7,14 +7,14 @@
#include <stdint.h>
-#include "services/ui/common/types.h"
+#include "services/ws/common/types.h"
// Typedefs for the transport types. These typedefs match that of the mojom
// file, see it for specifics.
namespace aura {
-constexpr ui::Id kInvalidServerId = 0;
+constexpr ws::Id kInvalidServerId = 0;
enum class WindowMusType {
// The window is an embed root in the embedded client. That is, the client
@@ -33,33 +33,15 @@ enum class WindowMusType {
// The window was created by requesting a top level
// (WindowTree::NewTopLevel()).
- // NOTE: in the window manager (the one responsible for actually creating the
- // real window) the window is of type TOP_LEVEL_IN_WM.
TOP_LEVEL,
- // The window is a top level window in the window manager.
- // TODO(sky): this should be removed when --mash goes away.
- // https://crbug.com/842365.
- TOP_LEVEL_IN_WM,
-
- // The window is a display root for the window manager and was automatically
- // created by mus.
- // TODO(sky): this should be removed when --mash goes away.
- // https://crbug.com/842365.
- DISPLAY_AUTOMATICALLY_CREATED,
-
- // The window is a display root for the window manager and was manually
- // created.
- // TODO(sky): this should be removed when --mash goes away.
- // https://crbug.com/842365.
- DISPLAY_MANUALLY_CREATED,
-
// The window was created locally.
LOCAL,
// Not one of the above. This means the window is visible to the client and
- // not one of the above values. Practically this means this client is the
- // window manager and the window was created by another client.
+ // not one of the above values. For example, if
+ // |kEmbedFlagEmbedderInterceptsEvents| is used, then the embedder sees
+ // Windows created by the embedded client.
OTHER,
};
diff --git a/chromium/ui/aura/mus/platform_event_source_mus_ozone.cc b/chromium/ui/aura/mus/platform_event_source_mus_ozone.cc
deleted file mode 100644
index dfd4133673b..00000000000
--- a/chromium/ui/aura/mus/platform_event_source_mus_ozone.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/aura/mus/platform_event_source_mus_ozone.h"
-
-#include "ui/events/event.h"
-#include "ui/events/platform/platform_event_observer.h"
-
-namespace aura {
-
-PlatformEventSourceMus::PlatformEventSourceMus() = default;
-
-PlatformEventSourceMus::~PlatformEventSourceMus() = default;
-
-void PlatformEventSourceMus::OnWillProcessEvent(ui::Event* event) {
- for (ui::PlatformEventObserver& observer : observers())
- observer.WillProcessEvent(event);
-}
-
-void PlatformEventSourceMus::OnDidProcessEvent(ui::Event* event) {
- for (ui::PlatformEventObserver& observer : observers())
- observer.DidProcessEvent(event);
-}
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/platform_event_source_mus_ozone.h b/chromium/ui/aura/mus/platform_event_source_mus_ozone.h
deleted file mode 100644
index 8557688c8d7..00000000000
--- a/chromium/ui/aura/mus/platform_event_source_mus_ozone.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_AURA_MUS_PLATFORM_EVENT_SOURCE_MUS_OZONE_H_
-#define UI_AURA_MUS_PLATFORM_EVENT_SOURCE_MUS_OZONE_H_
-
-#include "ui/events/platform/platform_event_source.h"
-
-namespace ui {
-class Event;
-}
-
-namespace aura {
-
-// PlatformEventSource implementation for mus with ozone. WindowTreeClient owns
-// and installs this. WindowTreeClient calls this to notify observers as
-// necessary.
-class PlatformEventSourceMus : public ui::PlatformEventSource {
- public:
- PlatformEventSourceMus();
- ~PlatformEventSourceMus() override;
-
- // These two functions are called from WindowTreeClient before/after
- // dispatching events. They forward to observers.
- void OnWillProcessEvent(ui::Event* event);
- void OnDidProcessEvent(ui::Event* event);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PlatformEventSourceMus);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_PLATFORM_EVENT_SOURCE_MUS_OZONE_H_
diff --git a/chromium/ui/aura/mus/property_converter.cc b/chromium/ui/aura/mus/property_converter.cc
index f90bc3c73d6..51cd00e1d81 100644
--- a/chromium/ui/aura/mus/property_converter.cc
+++ b/chromium/ui/aura/mus/property_converter.cc
@@ -6,8 +6,9 @@
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/type_converter.h"
-#include "services/ui/public/cpp/property_type_converters.h"
-#include "services/ui/public/interfaces/window_manager.mojom.h"
+#include "services/ws/public/cpp/property_type_converters.h"
+#include "services/ws/public/mojom/window_manager.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/base/class_property.h"
@@ -34,19 +35,18 @@ bool AlwaysTrue(int64_t value) {
bool ValidateResizeBehaviour(int64_t value) {
// Resize behaviour is a 3 bitfield.
- return value >= 0 &&
- value <= (ui::mojom::kResizeBehaviorCanMaximize |
- ui::mojom::kResizeBehaviorCanMinimize |
- ui::mojom::kResizeBehaviorCanResize);
+ return value >= 0 && value <= (ws::mojom::kResizeBehaviorCanMaximize |
+ ws::mojom::kResizeBehaviorCanMinimize |
+ ws::mojom::kResizeBehaviorCanResize);
}
bool ValidateShowState(int64_t value) {
- return value == int64_t(ui::mojom::ShowState::DEFAULT) ||
- value == int64_t(ui::mojom::ShowState::NORMAL) ||
- value == int64_t(ui::mojom::ShowState::MINIMIZED) ||
- value == int64_t(ui::mojom::ShowState::MAXIMIZED) ||
- value == int64_t(ui::mojom::ShowState::INACTIVE) ||
- value == int64_t(ui::mojom::ShowState::FULLSCREEN);
+ return value == int64_t(ws::mojom::ShowState::DEFAULT) ||
+ value == int64_t(ws::mojom::ShowState::NORMAL) ||
+ value == int64_t(ws::mojom::ShowState::MINIMIZED) ||
+ value == int64_t(ws::mojom::ShowState::MAXIMIZED) ||
+ value == int64_t(ws::mojom::ShowState::INACTIVE) ||
+ value == int64_t(ws::mojom::ShowState::FULLSCREEN);
}
bool ValidateWindowCornerRadius(int64_t value) {
@@ -71,39 +71,43 @@ PropertyConverter::CreateAcceptAnyValueCallback() {
PropertyConverter::PropertyConverter() {
// Add known aura properties with associated mus properties.
RegisterImageSkiaProperty(client::kAppIconKey,
- ui::mojom::WindowManager::kAppIcon_Property);
+ ws::mojom::WindowManager::kAppIcon_Property);
RegisterImageSkiaProperty(client::kWindowIconKey,
- ui::mojom::WindowManager::kWindowIcon_Property);
+ ws::mojom::WindowManager::kWindowIcon_Property);
RegisterPrimitiveProperty(client::kAlwaysOnTopKey,
- ui::mojom::WindowManager::kAlwaysOnTop_Property,
+ ws::mojom::WindowManager::kAlwaysOnTop_Property,
CreateAcceptAnyValueCallback());
RegisterPrimitiveProperty(client::kDrawAttentionKey,
- ui::mojom::WindowManager::kDrawAttention_Property,
+ ws::mojom::WindowManager::kDrawAttention_Property,
CreateAcceptAnyValueCallback());
RegisterPrimitiveProperty(
client::kImmersiveFullscreenKey,
- ui::mojom::WindowManager::kImmersiveFullscreen_Property,
+ ws::mojom::WindowManager::kImmersiveFullscreen_Property,
CreateAcceptAnyValueCallback());
RegisterPrimitiveProperty(client::kResizeBehaviorKey,
- ui::mojom::WindowManager::kResizeBehavior_Property,
+ ws::mojom::WindowManager::kResizeBehavior_Property,
base::Bind(&ValidateResizeBehaviour));
RegisterPrimitiveProperty(client::kShowStateKey,
- ui::mojom::WindowManager::kShowState_Property,
+ ws::mojom::WindowManager::kShowState_Property,
base::Bind(&ValidateShowState));
RegisterRectProperty(client::kRestoreBoundsKey,
- ui::mojom::WindowManager::kRestoreBounds_Property);
+ ws::mojom::WindowManager::kRestoreBounds_Property);
RegisterSizeProperty(client::kPreferredSize,
- ui::mojom::WindowManager::kPreferredSize_Property);
+ ws::mojom::WindowManager::kPreferredSize_Property);
RegisterSizeProperty(client::kMinimumSize,
- ui::mojom::WindowManager::kMinimumSize_Property);
+ ws::mojom::WindowManager::kMinimumSize_Property);
RegisterStringProperty(client::kNameKey,
- ui::mojom::WindowManager::kName_Property);
+ ws::mojom::WindowManager::kName_Property);
RegisterString16Property(client::kTitleKey,
- ui::mojom::WindowManager::kWindowTitle_Property);
+ ws::mojom::WindowManager::kWindowTitle_Property);
RegisterPrimitiveProperty(
client::kWindowCornerRadiusKey,
- ui::mojom::WindowManager::kWindowCornerRadius_Property,
+ ws::mojom::WindowManager::kWindowCornerRadius_Property,
base::BindRepeating(&ValidateWindowCornerRadius));
+ RegisterPrimitiveProperty(
+ client::kAnimationsDisabledKey,
+ ws::mojom::WindowManager::kAnimationsDisabled_Property,
+ CreateAcceptAnyValueCallback());
}
PropertyConverter::~PropertyConverter() {}
@@ -290,12 +294,15 @@ void PropertyConverter::SetPropertyFromTransportValue(
for (const auto& unguessable_token_property : unguessable_token_properties_) {
if (unguessable_token_property.second == transport_name) {
- auto* token = new base::UnguessableToken();
- *token = mojo::ConvertTo<base::UnguessableToken>(*data);
- if (token->is_empty())
+ base::UnguessableToken token =
+ mojo::ConvertTo<base::UnguessableToken>(*data);
+ if (token.is_empty()) {
window->ClearProperty(unguessable_token_property.first);
- else
- window->SetProperty(unguessable_token_property.first, token);
+ } else {
+ // |window| takes ownership of the newly allocated token.
+ window->SetProperty(unguessable_token_property.first,
+ new base::UnguessableToken(token));
+ }
return;
}
}
diff --git a/chromium/ui/aura/mus/property_converter_unittest.cc b/chromium/ui/aura/mus/property_converter_unittest.cc
index 682dd385369..50838071d5f 100644
--- a/chromium/ui/aura/mus/property_converter_unittest.cc
+++ b/chromium/ui/aura/mus/property_converter_unittest.cc
@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
-#include "services/ui/public/cpp/property_type_converters.h"
+#include "services/ws/public/cpp/property_type_converters.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/aura_test_base.h"
diff --git a/chromium/ui/aura/mus/property_utils.cc b/chromium/ui/aura/mus/property_utils.cc
index a23bff6b114..94546d1f2ec 100644
--- a/chromium/ui/aura/mus/property_utils.cc
+++ b/chromium/ui/aura/mus/property_utils.cc
@@ -4,9 +4,9 @@
#include "ui/aura/mus/property_utils.h"
-#include "services/ui/public/cpp/property_type_converters.h"
-#include "services/ui/public/interfaces/window_manager.mojom.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
+#include "services/ws/public/cpp/property_type_converters.h"
+#include "services/ws/public/mojom/window_manager.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_types.h"
#include "ui/aura/window.h"
@@ -14,24 +14,24 @@
namespace aura {
namespace {
-client::WindowType UiWindowTypeToWindowType(ui::mojom::WindowType type) {
+client::WindowType UiWindowTypeToWindowType(ws::mojom::WindowType type) {
switch (type) {
- case ui::mojom::WindowType::WINDOW:
+ case ws::mojom::WindowType::WINDOW:
return client::WINDOW_TYPE_NORMAL;
- case ui::mojom::WindowType::PANEL:
+ case ws::mojom::WindowType::PANEL:
return client::WINDOW_TYPE_PANEL;
- case ui::mojom::WindowType::CONTROL:
+ case ws::mojom::WindowType::CONTROL:
return client::WINDOW_TYPE_CONTROL;
- case ui::mojom::WindowType::WINDOW_FRAMELESS:
- case ui::mojom::WindowType::POPUP:
- case ui::mojom::WindowType::BUBBLE:
- case ui::mojom::WindowType::DRAG:
+ case ws::mojom::WindowType::WINDOW_FRAMELESS:
+ case ws::mojom::WindowType::POPUP:
+ case ws::mojom::WindowType::BUBBLE:
+ case ws::mojom::WindowType::DRAG:
return client::WINDOW_TYPE_POPUP;
- case ui::mojom::WindowType::MENU:
+ case ws::mojom::WindowType::MENU:
return client::WINDOW_TYPE_MENU;
- case ui::mojom::WindowType::TOOLTIP:
+ case ws::mojom::WindowType::TOOLTIP:
return client::WINDOW_TYPE_TOOLTIP;
- case ui::mojom::WindowType::UNKNOWN:
+ case ws::mojom::WindowType::UNKNOWN:
return client::WINDOW_TYPE_UNKNOWN;
}
NOTREACHED();
@@ -40,20 +40,20 @@ client::WindowType UiWindowTypeToWindowType(ui::mojom::WindowType type) {
} // namespace
-void SetWindowType(Window* window, ui::mojom::WindowType window_type) {
- if (window_type == ui::mojom::WindowType::UNKNOWN)
+void SetWindowType(Window* window, ws::mojom::WindowType window_type) {
+ if (window_type == ws::mojom::WindowType::UNKNOWN)
return;
window->SetProperty(client::kWindowTypeKey, window_type);
window->SetType(UiWindowTypeToWindowType(window_type));
}
-ui::mojom::WindowType GetWindowTypeFromProperties(
+ws::mojom::WindowType GetWindowTypeFromProperties(
const std::map<std::string, std::vector<uint8_t>>& properties) {
auto iter =
- properties.find(ui::mojom::WindowManager::kWindowType_InitProperty);
+ properties.find(ws::mojom::WindowManager::kWindowType_InitProperty);
if (iter == properties.end())
- return ui::mojom::WindowType::UNKNOWN;
- return static_cast<ui::mojom::WindowType>(
+ return ws::mojom::WindowType::UNKNOWN;
+ return static_cast<ws::mojom::WindowType>(
mojo::ConvertTo<int32_t>(iter->second));
}
diff --git a/chromium/ui/aura/mus/property_utils.h b/chromium/ui/aura/mus/property_utils.h
index b1440bdf0ee..eb16e2ef075 100644
--- a/chromium/ui/aura/mus/property_utils.h
+++ b/chromium/ui/aura/mus/property_utils.h
@@ -12,7 +12,7 @@
#include "ui/aura/aura_export.h"
-namespace ui {
+namespace ws {
namespace mojom {
enum class WindowType;
}
@@ -26,10 +26,10 @@ class Window;
// sets the property client::kWindowTypeKey as well as calling SetType().
// This *must* be called before Init(). No-op for WindowType::UNKNOWN.
AURA_EXPORT void SetWindowType(Window* window,
- ui::mojom::WindowType window_type);
+ ws::mojom::WindowType window_type);
// Returns the window type specified in |properties|, or WindowType::UNKNOWN.
-AURA_EXPORT ui::mojom::WindowType GetWindowTypeFromProperties(
+AURA_EXPORT ws::mojom::WindowType GetWindowTypeFromProperties(
const std::map<std::string, std::vector<uint8_t>>& properties);
} // namespace aura
diff --git a/chromium/ui/aura/mus/system_input_injector_mus.cc b/chromium/ui/aura/mus/system_input_injector_mus.cc
index 7402b7405d6..83a80944f30 100644
--- a/chromium/ui/aura/mus/system_input_injector_mus.cc
+++ b/chromium/ui/aura/mus/system_input_injector_mus.cc
@@ -5,7 +5,7 @@
#include "ui/aura/mus/system_input_injector_mus.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "services/ui/public/interfaces/constants.mojom.h"
+#include "services/ws/public/mojom/constants.mojom.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
@@ -13,19 +13,19 @@ namespace aura {
namespace {
-ui::mojom::InjectedMouseButtonType EventFlagsToInjectedMouseButtonType(
+ws::mojom::InjectedMouseButtonType EventFlagsToInjectedMouseButtonType(
ui::EventFlags flags) {
switch (flags) {
case ui::EF_LEFT_MOUSE_BUTTON:
- return ui::mojom::InjectedMouseButtonType::kLeft;
+ return ws::mojom::InjectedMouseButtonType::kLeft;
case ui::EF_MIDDLE_MOUSE_BUTTON:
- return ui::mojom::InjectedMouseButtonType::kMiddle;
+ return ws::mojom::InjectedMouseButtonType::kMiddle;
case ui::EF_RIGHT_MOUSE_BUTTON:
- return ui::mojom::InjectedMouseButtonType::kRight;
+ return ws::mojom::InjectedMouseButtonType::kRight;
default:
LOG(WARNING) << "Invalid flag: " << flags << " for the button parameter";
}
- return ui::mojom::InjectedMouseButtonType::kLeft;
+ return ws::mojom::InjectedMouseButtonType::kLeft;
}
} // namespace
@@ -34,7 +34,7 @@ SystemInputInjectorMus::SystemInputInjectorMus(
service_manager::Connector* connector) {
// Tests may use a null connector.
if (connector)
- connector->BindInterface(ui::mojom::kServiceName,
+ connector->BindInterface(ws::mojom::kServiceName,
&remoting_event_injector_);
}
diff --git a/chromium/ui/aura/mus/system_input_injector_mus.h b/chromium/ui/aura/mus/system_input_injector_mus.h
index 01ea4ab175b..55aa916f412 100644
--- a/chromium/ui/aura/mus/system_input_injector_mus.h
+++ b/chromium/ui/aura/mus/system_input_injector_mus.h
@@ -5,7 +5,7 @@
#ifndef UI_AURA_MUS_SYSTEM_INPUT_INJECTOR_MUS_H_
#define UI_AURA_MUS_SYSTEM_INPUT_INJECTOR_MUS_H_
-#include "services/ui/public/interfaces/remoting_event_injector.mojom.h"
+#include "services/ws/public/mojom/remoting_event_injector.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/system_input_injector.h"
@@ -38,7 +38,7 @@ class AURA_EXPORT SystemInputInjectorMus : public ui::SystemInputInjector {
// Updates |modifiers_| based on an incoming event.
void UpdateModifier(unsigned int modifier, bool down);
- ui::mojom::RemotingEventInjectorPtr remoting_event_injector_;
+ ws::mojom::RemotingEventInjectorPtr remoting_event_injector_;
DISALLOW_COPY_AND_ASSIGN(SystemInputInjectorMus);
};
diff --git a/chromium/ui/aura/mus/system_input_injector_mus_unittest.cc b/chromium/ui/aura/mus/system_input_injector_mus_unittest.cc
deleted file mode 100644
index baa10c70b28..00000000000
--- a/chromium/ui/aura/mus/system_input_injector_mus_unittest.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/aura/mus/system_input_injector_mus.h"
-
-#include <vector>
-
-#include "ui/aura/mus/window_manager_delegate.h"
-#include "ui/aura/mus/window_tree_host_mus_init_params.h"
-#include "ui/aura/test/aura_test_base.h"
-#include "ui/events/event.h"
-#include "ui/events/keycodes/dom/dom_code.h"
-#include "ui/events/keycodes/keyboard_codes.h"
-
-namespace aura {
-
-class TestDispaterchWindowManagerClient : public aura::WindowManagerClient {
- public:
- TestDispaterchWindowManagerClient() {}
- ~TestDispaterchWindowManagerClient() override {}
-
- const std::vector<std::unique_ptr<ui::Event>>& events() const {
- return events_;
- }
-
- // This is the one method in this interface that we're using to grab data.
- void InjectEvent(const ui::Event& event, int64_t display_id) override {
- events_.push_back(ui::Event::Clone(event));
- }
-
- // The rest of these interfaces aren't relevant to testing
- // SystemInputInjectorMus and are left empty.
- void SetFrameDecorationValues(
- ui::mojom::FrameDecorationValuesPtr values) override {}
- void SetNonClientCursor(Window* window,
- const ui::CursorData& non_client_cursor) override {}
- void AddAccelerators(std::vector<ui::mojom::WmAcceleratorPtr> accelerators,
- const base::Callback<void(bool)>& callback) override {}
- void RemoveAccelerator(uint32_t id) override {}
- void AddActivationParent(Window* window) override {}
- void RemoveActivationParent(Window* window) override {}
- void SetExtendedHitRegionForChildren(Window* window,
- const gfx::Insets& mouse_area,
- const gfx::Insets& touch_area) override {
- }
- void LockCursor() override {}
- void UnlockCursor() override {}
- void SetCursorVisible(bool visible) override {}
- void SetCursorSize(ui::CursorSize cursor_size) override {}
- void SetGlobalOverrideCursor(base::Optional<ui::CursorData> cursor) override {
- }
- void SetCursorTouchVisible(bool enabled) override {}
- void SetKeyEventsThatDontHideCursor(
- std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) override {}
- void RequestClose(Window* window) override {}
- void SetBlockingContainers(
- const std::vector<BlockingContainers>& all_blocking_containers) override {
- }
- bool WaitForInitialDisplays() override { return false; }
- WindowTreeHostMusInitParams CreateInitParamsForNewDisplay() override {
- return WindowTreeHostMusInitParams();
- }
- void SetDisplayConfiguration(
- const std::vector<display::Display>& displays,
- std::vector<ui::mojom::WmViewportMetricsPtr> viewport_metrics,
- int64_t primary_display_id,
- const std::vector<display::Display>& mirrors) override {}
- void AddDisplayReusingWindowTreeHost(
- WindowTreeHostMus* window_tree_host,
- const display::Display& display,
- ui::mojom::WmViewportMetricsPtr viewport_metrics) override {}
- void SwapDisplayRoots(WindowTreeHostMus* window_tree_host1,
- WindowTreeHostMus* window_tree_host2) override {}
-
- private:
- std::vector<std::unique_ptr<ui::Event>> events_;
-
- DISALLOW_COPY_AND_ASSIGN(TestDispaterchWindowManagerClient);
-};
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/text_input_client_impl.cc b/chromium/ui/aura/mus/text_input_client_impl.cc
index 514a69a5611..0ce8eb10c23 100644
--- a/chromium/ui/aura/mus/text_input_client_impl.cc
+++ b/chromium/ui/aura/mus/text_input_client_impl.cc
@@ -5,7 +5,7 @@
#include "ui/aura/mus/text_input_client_impl.h"
#include "base/strings/utf_string_conversions.h"
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
#include "ui/aura/mus/input_method_mus.h"
#include "ui/base/ime/text_input_client.h"
@@ -20,8 +20,8 @@ TextInputClientImpl::TextInputClientImpl(
TextInputClientImpl::~TextInputClientImpl() {}
-ui::mojom::TextInputClientPtr TextInputClientImpl::CreateInterfacePtrAndBind() {
- ui::mojom::TextInputClientPtr ptr;
+ws::mojom::TextInputClientPtr TextInputClientImpl::CreateInterfacePtrAndBind() {
+ ws::mojom::TextInputClientPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
return ptr;
}
diff --git a/chromium/ui/aura/mus/text_input_client_impl.h b/chromium/ui/aura/mus/text_input_client_impl.h
index 5f5b98d4807..5d50c815023 100644
--- a/chromium/ui/aura/mus/text_input_client_impl.h
+++ b/chromium/ui/aura/mus/text_input_client_impl.h
@@ -6,7 +6,7 @@
#define UI_AURA_MUS_TEXT_INPUT_CLIENT_IMPL_H_
#include "mojo/public/cpp/bindings/binding.h"
-#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "services/ws/public/mojom/ime/ime.mojom.h"
#include "ui/base/ime/composition_text.h"
#include "ui/base/ime/input_method_delegate.h"
@@ -18,16 +18,16 @@ namespace aura {
// TextInputClientImpl receieves updates from IME drivers over Mojo IPC, and
// notifies the underlying ui::TextInputClient accordingly.
-class TextInputClientImpl : public ui::mojom::TextInputClient {
+class TextInputClientImpl : public ws::mojom::TextInputClient {
public:
TextInputClientImpl(ui::TextInputClient* text_input_client,
ui::internal::InputMethodDelegate* delegate);
~TextInputClientImpl() override;
- ui::mojom::TextInputClientPtr CreateInterfacePtrAndBind();
+ ws::mojom::TextInputClientPtr CreateInterfacePtrAndBind();
private:
- // ui::mojom::TextInputClient:
+ // ws::mojom::TextInputClient:
void SetCompositionText(const ui::CompositionText& composition) override;
void ConfirmCompositionText() override;
void ClearCompositionText() override;
@@ -38,7 +38,7 @@ class TextInputClientImpl : public ui::mojom::TextInputClient {
DispatchKeyEventPostIMECallback callback) override;
ui::TextInputClient* text_input_client_;
- mojo::Binding<ui::mojom::TextInputClient> binding_;
+ mojo::Binding<ws::mojom::TextInputClient> binding_;
ui::internal::InputMethodDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(TextInputClientImpl);
diff --git a/chromium/ui/aura/mus/topmost_window_tracker.cc b/chromium/ui/aura/mus/topmost_window_tracker.cc
new file mode 100644
index 00000000000..da1dd99d3c9
--- /dev/null
+++ b/chromium/ui/aura/mus/topmost_window_tracker.cc
@@ -0,0 +1,41 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/mus/topmost_window_tracker.h"
+
+#include "ui/aura/mus/window_mus.h"
+#include "ui/aura/mus/window_tree_client.h"
+#include "ui/aura/window.h"
+
+namespace aura {
+
+namespace {
+
+Window* GetRootOrNull(WindowMus* window_mus) {
+ return window_mus ? window_mus->GetWindow()->GetRootWindow() : nullptr;
+}
+
+} // namespace
+
+TopmostWindowTracker::TopmostWindowTracker(WindowTreeClient* client)
+ : client_(client) {}
+
+TopmostWindowTracker::~TopmostWindowTracker() {
+ client_->StopObservingTopmostWindow();
+}
+
+void TopmostWindowTracker::OnTopmostWindowChanged(
+ const std::vector<WindowMus*> topmosts) {
+ DCHECK_LE(topmosts.size(), 2u);
+ // topmosts can be empty if the mouse/touch event happens outside of the
+ // screen. This rarely happens on device but can happen easily when Chrome
+ // runs within a Linux desktop. It's fine to just ignore such case.
+ if (topmosts.empty())
+ return;
+ topmost_ = GetRootOrNull(topmosts[0]);
+ second_topmost_ =
+ (topmosts.size() > 1) ? GetRootOrNull(topmosts[1]) : topmost_;
+}
+
+} // namespace aura
diff --git a/chromium/ui/aura/mus/topmost_window_tracker.h b/chromium/ui/aura/mus/topmost_window_tracker.h
new file mode 100644
index 00000000000..47f590ffca8
--- /dev/null
+++ b/chromium/ui/aura/mus/topmost_window_tracker.h
@@ -0,0 +1,52 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_MUS_TOPMOST_WINDOW_TRACKER_H_
+#define UI_AURA_MUS_TOPMOST_WINDOW_TRACKER_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "ui/aura/aura_export.h"
+
+namespace aura {
+class Window;
+class WindowMus;
+class WindowTreeClient;
+
+// TopmostWindowTracker keeps track of the topmost window under the touch/mouse.
+// It is created through WindowTreeClient::StartObservingTopmostWindow().
+class AURA_EXPORT TopmostWindowTracker {
+ public:
+ explicit TopmostWindowTracker(WindowTreeClient* client);
+ ~TopmostWindowTracker();
+
+ aura::Window* topmost() { return topmost_; }
+ aura::Window* second_topmost() { return second_topmost_; }
+
+ private:
+ friend class WindowTreeClient;
+
+ // Updates the topmost and the real_topmost windows to the specified ones.
+ // Will be called by WindowTreeClient.
+ void OnTopmostWindowChanged(const std::vector<WindowMus*> topmosts);
+
+ WindowTreeClient* client_;
+
+ // The root window for the topmost window under the current cursor position.
+ // This can be the event target.
+ aura::Window* topmost_ = nullptr;
+
+ // Another root window for the topmost window under the current cursor
+ // position. This is the second topmost window if the topmost window happens
+ // to be the current event target. If the topmost window isn't the event
+ // target, this will point to the same topmost window.
+ aura::Window* second_topmost_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(TopmostWindowTracker);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_MUS_TOPMOST_WINDOW_TRACKER_H_
diff --git a/chromium/ui/aura/mus/user_activity_forwarder.cc b/chromium/ui/aura/mus/user_activity_forwarder.cc
index c1c9590b88b..e3d56b2b0c4 100644
--- a/chromium/ui/aura/mus/user_activity_forwarder.cc
+++ b/chromium/ui/aura/mus/user_activity_forwarder.cc
@@ -12,7 +12,7 @@
namespace aura {
UserActivityForwarder::UserActivityForwarder(
- ui::mojom::UserActivityMonitorPtr monitor,
+ ws::mojom::UserActivityMonitorPtr monitor,
ui::UserActivityDetector* detector)
: monitor_(std::move(monitor)), binding_(this), detector_(detector) {
DCHECK(detector_);
@@ -21,7 +21,7 @@ UserActivityForwarder::UserActivityForwarder(
// second (the granularity exposed by UserActivityMonitor).
const uint32_t kNotifyIntervalSec = static_cast<uint32_t>(
ceil(ui::UserActivityDetector::kNotifyIntervalMs / 1000.0));
- ui::mojom::UserActivityObserverPtr observer;
+ ws::mojom::UserActivityObserverPtr observer;
binding_.Bind(mojo::MakeRequest(&observer));
monitor_->AddUserActivityObserver(kNotifyIntervalSec, std::move(observer));
}
diff --git a/chromium/ui/aura/mus/user_activity_forwarder.h b/chromium/ui/aura/mus/user_activity_forwarder.h
index 58d28529ed1..4823cc12cb1 100644
--- a/chromium/ui/aura/mus/user_activity_forwarder.h
+++ b/chromium/ui/aura/mus/user_activity_forwarder.h
@@ -8,7 +8,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "services/ui/public/interfaces/user_activity_monitor.mojom.h"
+#include "services/ws/public/mojom/user_activity_monitor.mojom.h"
#include "ui/aura/aura_export.h"
namespace ui {
@@ -24,18 +24,18 @@ namespace aura {
// downstream of ui::UserActivityDetector) instead observe UserActivityMonitor
// directly: http://crbug.com/626899
class AURA_EXPORT UserActivityForwarder
- : public ui::mojom::UserActivityObserver {
+ : public ws::mojom::UserActivityObserver {
public:
- UserActivityForwarder(ui::mojom::UserActivityMonitorPtr monitor,
+ UserActivityForwarder(ws::mojom::UserActivityMonitorPtr monitor,
ui::UserActivityDetector* detector);
~UserActivityForwarder() override;
private:
- // ui::mojom::UserActivityObserver:
+ // ws::mojom::UserActivityObserver:
void OnUserActivity() override;
- ui::mojom::UserActivityMonitorPtr monitor_;
- mojo::Binding<ui::mojom::UserActivityObserver> binding_;
+ ws::mojom::UserActivityMonitorPtr monitor_;
+ mojo::Binding<ws::mojom::UserActivityObserver> binding_;
ui::UserActivityDetector* detector_; // Not owned.
diff --git a/chromium/ui/aura/mus/user_activity_forwarder_unittest.cc b/chromium/ui/aura/mus/user_activity_forwarder_unittest.cc
index 249cc0ad150..2f01215bd2d 100644
--- a/chromium/ui/aura/mus/user_activity_forwarder_unittest.cc
+++ b/chromium/ui/aura/mus/user_activity_forwarder_unittest.cc
@@ -10,48 +10,48 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "mojo/public/cpp/bindings/interface_request.h"
-#include "services/ui/common/task_runner_test_base.h"
-#include "services/ui/public/interfaces/user_activity_monitor.mojom.h"
+#include "services/ws/common/task_runner_test_base.h"
+#include "services/ws/public/mojom/user_activity_monitor.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/user_activity/user_activity_detector.h"
namespace {
-// Fake implementation of ui::mojom::UserActivityMonitor for testing that just
+// Fake implementation of ws::mojom::UserActivityMonitor for testing that just
// supports tracking and notifying observers.
-class FakeUserActivityMonitor : public ui::mojom::UserActivityMonitor {
+class FakeUserActivityMonitor : public ws::mojom::UserActivityMonitor {
public:
FakeUserActivityMonitor() : binding_(this) {}
~FakeUserActivityMonitor() override {}
- ui::mojom::UserActivityMonitorPtr GetPtr() {
- ui::mojom::UserActivityMonitorPtr ptr;
+ ws::mojom::UserActivityMonitorPtr GetPtr() {
+ ws::mojom::UserActivityMonitorPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
return ptr;
}
// Notifies all observers about user activity.
- // ui::TaskRunnerTestBase::RunUntilIdle() must be called after this method in
+ // ws::TaskRunnerTestBase::RunUntilIdle() must be called after this method in
// order for observers to receive notifications.
void NotifyUserActivityObservers() {
for (auto& observer : activity_observers_)
observer->OnUserActivity();
}
- // ui::mojom::UserActivityMonitor:
+ // ws::mojom::UserActivityMonitor:
void AddUserActivityObserver(
uint32_t delay_between_notify_secs,
- ui::mojom::UserActivityObserverPtr observer) override {
+ ws::mojom::UserActivityObserverPtr observer) override {
activity_observers_.push_back(std::move(observer));
}
void AddUserIdleObserver(uint32_t idleness_in_minutes,
- ui::mojom::UserIdleObserverPtr observer) override {
+ ws::mojom::UserIdleObserverPtr observer) override {
NOTREACHED() << "Unexpected AddUserIdleObserver call";
}
private:
- mojo::Binding<ui::mojom::UserActivityMonitor> binding_;
- std::vector<ui::mojom::UserActivityObserverPtr> activity_observers_;
+ mojo::Binding<ws::mojom::UserActivityMonitor> binding_;
+ std::vector<ws::mojom::UserActivityObserverPtr> activity_observers_;
DISALLOW_COPY_AND_ASSIGN(FakeUserActivityMonitor);
};
@@ -60,7 +60,7 @@ class FakeUserActivityMonitor : public ui::mojom::UserActivityMonitor {
namespace aura {
-using UserActivityForwarderTest = ui::TaskRunnerTestBase;
+using UserActivityForwarderTest = ws::TaskRunnerTestBase;
TEST_F(UserActivityForwarderTest, ForwardActivityToDetector) {
FakeUserActivityMonitor monitor;
diff --git a/chromium/ui/aura/mus/window_manager_delegate.cc b/chromium/ui/aura/mus/window_manager_delegate.cc
deleted file mode 100644
index 9f380900da3..00000000000
--- a/chromium/ui/aura/mus/window_manager_delegate.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/aura/mus/window_manager_delegate.h"
-
-namespace aura {
-
-void WindowManagerDelegate::OnWmConnected() {}
-
-ui::mojom::EventResult WindowManagerDelegate::OnAccelerator(
- uint32_t id,
- const ui::Event& event,
- base::flat_map<std::string, std::vector<uint8_t>>* properties) {
- return ui::mojom::EventResult::UNHANDLED;
-}
-
-void WindowManagerDelegate::OnWmPerformAction(Window* window,
- const std::string& action) {}
-
-void WindowManagerDelegate::OnEventBlockedByModalWindow(Window* window) {}
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/window_manager_delegate.h b/chromium/ui/aura/mus/window_manager_delegate.h
deleted file mode 100644
index a171f69a217..00000000000
--- a/chromium/ui/aura/mus/window_manager_delegate.h
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_AURA_MUS_WINDOW_MANAGER_DELEGATE_H_
-#define UI_AURA_MUS_WINDOW_MANAGER_DELEGATE_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "base/callback_forward.h"
-#include "base/containers/flat_map.h"
-#include "services/ui/public/interfaces/cursor/cursor.mojom.h"
-#include "services/ui/public/interfaces/window_manager.mojom.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
-#include "ui/aura/aura_export.h"
-#include "ui/events/mojo/event.mojom.h"
-#include "ui/gfx/native_widget_types.h"
-
-namespace display {
-class Display;
-}
-
-namespace gfx {
-class Insets;
-class Rect;
-}
-
-namespace ui {
-class Event;
-}
-
-namespace aura {
-
-class Window;
-class WindowTreeHostMus;
-
-struct WindowTreeHostMusInitParams;
-
-// This mirrors ui::mojom::BlockingContainers. See it for details.
-struct BlockingContainers {
- aura::Window* system_modal_container = nullptr;
- aura::Window* min_container = nullptr;
-};
-
-// See the mojom with the same name for details on the functions in this
-// interface.
-class AURA_EXPORT WindowManagerClient {
- public:
- virtual void SetFrameDecorationValues(
- ui::mojom::FrameDecorationValuesPtr values) = 0;
- virtual void SetNonClientCursor(Window* window,
- const ui::CursorData& non_client_cursor) = 0;
-
- virtual void AddAccelerators(
- std::vector<ui::mojom::WmAcceleratorPtr> accelerators,
- const base::Callback<void(bool)>& callback) = 0;
- virtual void RemoveAccelerator(uint32_t id) = 0;
- virtual void AddActivationParent(Window* window) = 0;
- virtual void RemoveActivationParent(Window* window) = 0;
- virtual void SetExtendedHitRegionForChildren(
- Window* window,
- const gfx::Insets& mouse_area,
- const gfx::Insets& touch_area) = 0;
-
- // Queues changes to the cursor instead of applying them instantly. Queued
- // changes will be executed on UnlockCursor().
- virtual void LockCursor() = 0;
-
- // Executes queued changes.
- virtual void UnlockCursor() = 0;
-
- // Globally shows or hides the cursor.
- virtual void SetCursorVisible(bool visible) = 0;
-
- // Globally sets whether we use normal or large cursors.
- virtual void SetCursorSize(ui::CursorSize cursor_size) = 0;
-
- // Sets a cursor which is used instead of the per window cursors. Pass a
- // nullopt in |cursor| to clear the override.
- virtual void SetGlobalOverrideCursor(
- base::Optional<ui::CursorData> cursor) = 0;
-
- // Sets whether the cursor is visible because the user touched the
- // screen. This bit is separate from SetCursorVisible(), as it implicitly is
- // set in the window server when a touch event occurs, and is implicitly
- // cleared when the mouse moves.
- virtual void SetCursorTouchVisible(bool enabled) = 0;
-
- // Sends |event| to mus to be dispatched.
- virtual void InjectEvent(const ui::Event& event, int64_t display_id) = 0;
-
- // Sets the list of keys which don't hide the cursor.
- virtual void SetKeyEventsThatDontHideCursor(
- std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) = 0;
-
- // Requests the client embedded in |window| to close the window. Only
- // applicable to top-level windows. If a client is not embedded in |window|,
- // this does nothing.
- virtual void RequestClose(Window* window) = 0;
-
- // See mojom::WindowManager::SetBlockingContainers() and
- // mojom::BlockingContainers for details on what this does.
- virtual void SetBlockingContainers(
- const std::vector<BlockingContainers>& all_blocking_containers) = 0;
-
- // Blocks until the initial displays have been received, or if displays are
- // not automatically created until the connection to mus has been
- // established.
- virtual bool WaitForInitialDisplays() = 0;
-
- // Used by the window manager to create a new display. This is only useful if
- // the WindowTreeClient was configured not to automatically create displays
- // (see ConnectAsWindowManager()). The caller needs to configure
- // DisplayInitParams on the returned object.
- virtual WindowTreeHostMusInitParams CreateInitParamsForNewDisplay() = 0;
-
- // Configures the displays. This is used when the window manager manually
- // configures display roots.
- virtual void SetDisplayConfiguration(
- const std::vector<display::Display>& displays,
- std::vector<ui::mojom::WmViewportMetricsPtr> viewport_metrics,
- int64_t primary_display_id,
- const std::vector<display::Display>& mirrors) = 0;
-
- // Adds |display| as a new display moving |window_tree_host| to the new
- // display. This results in closing the previous display |window_tree_host|
- // was associated with.
- virtual void AddDisplayReusingWindowTreeHost(
- WindowTreeHostMus* window_tree_host,
- const display::Display& display,
- ui::mojom::WmViewportMetricsPtr viewport_metrics) = 0;
-
- // Swaps the roots of the two displays.
- virtual void SwapDisplayRoots(WindowTreeHostMus* window_tree_host1,
- WindowTreeHostMus* window_tree_host2) = 0;
-
- protected:
- virtual ~WindowManagerClient() {}
-};
-
-// Used by clients implementing a window manager.
-// TODO(sky): this should be called WindowManager, but that's rather confusing
-// currently.
-class AURA_EXPORT WindowManagerDelegate {
- public:
- // Called once to give the delegate access to functions only exposed to
- // the WindowManager.
- virtual void SetWindowManagerClient(WindowManagerClient* client) = 0;
-
- // Called if the window server requires the window manager to manage the real
- // accelerated widget. This is the case when mus expects the window manager to
- // set up viz (instead of mus itself hosting viz).
- virtual void OnWmAcceleratedWidgetAvailableForDisplay(
- int64_t display_id,
- gfx::AcceleratedWidget widget) = 0;
-
- // Called when the connection to mus has been fully established.
- virtual void OnWmConnected();
-
- // A client requested the bounds of |window| to change to |bounds|.
- virtual void OnWmSetBounds(Window* window, const gfx::Rect& bounds) = 0;
-
- // A client requested the shared property named |name| to change to
- // |new_data|. Return true to allow the change to |new_data|, false
- // otherwise. If true is returned the property is set via
- // PropertyConverter::SetPropertyFromTransportValue().
- virtual bool OnWmSetProperty(
- Window* window,
- const std::string& name,
- std::unique_ptr<std::vector<uint8_t>>* new_data) = 0;
-
- // A client requested the modal type to be changed to |type|.
- virtual void OnWmSetModalType(Window* window, ui::ModalType type) = 0;
-
- // A client requested to change focusibility of |window|. We currently assume
- // this always succeeds.
- virtual void OnWmSetCanFocus(Window* window, bool can_focus) = 0;
-
- // A client has requested a new top level window. The delegate should create
- // and parent the window appropriately and return it. |properties| is the
- // supplied properties from the client requesting the new window. The
- // delegate may modify |properties| before calling NewWindow(), but the
- // delegate does *not* own |properties|, they are valid only for the life
- // of OnWmCreateTopLevelWindow(). |window_type| is the type of window
- // requested by the client. Use SetWindowType() with |window_type| (in
- // property_utils.h) to configure the type on the newly created window.
- virtual Window* OnWmCreateTopLevelWindow(
- ui::mojom::WindowType window_type,
- std::map<std::string, std::vector<uint8_t>>* properties) = 0;
-
- // Called when a Mus client's jankiness changes. |windows| is the set of
- // windows owned by the window manager in which the client is embedded.
- virtual void OnWmClientJankinessChanged(
- const std::set<Window*>& client_windows,
- bool janky) = 0;
-
- // Called when a Mus client has started a drag, and wants this image to be
- // the drag representation.
- virtual void OnWmBuildDragImage(const gfx::Point& screen_location,
- const gfx::ImageSkia& drag_image,
- const gfx::Vector2d& drag_image_offset,
- ui::mojom::PointerKind source) = 0;
-
- // Called during drags when the drag location has changed and the drag
- // representation must be moved.
- virtual void OnWmMoveDragImage(const gfx::Point& screen_location) = 0;
-
- // Called when a drag is complete or canceled, and signals that the drag image
- // should be removed.
- virtual void OnWmDestroyDragImage() = 0;
-
- // When a new display is added OnWmWillCreateDisplay() is called, and then
- // OnWmNewDisplay(). OnWmWillCreateDisplay() is intended to add the display
- // to the set of displays (see Screen).
- virtual void OnWmWillCreateDisplay(const display::Display& display) = 0;
-
- // Called when a WindowTreeHostMus is created for a new display
- // Called when a display is added. |window_tree_host| is the WindowTreeHost
- // for the new display.
- virtual void OnWmNewDisplay(
- std::unique_ptr<WindowTreeHostMus> window_tree_host,
- const display::Display& display) = 0;
-
- // Called when a display is removed. |window_tree_host| is the WindowTreeHost
- // for the display.
- virtual void OnWmDisplayRemoved(WindowTreeHostMus* window_tree_host) = 0;
-
- // Called when a display is modified.
- virtual void OnWmDisplayModified(const display::Display& display) = 0;
-
- // Called when an accelerator is received. |id| is the id previously
- // registered via AddAccelerators(). For pre-target accelerators the delegate
- // may add key/value pairs to |properties| that are then added to the
- // KeyEvent that is sent to the client with the focused window (only if this
- // returns UNHANDLED). |properties| may be used to pass around state from the
- // window manager to clients.
- virtual ui::mojom::EventResult OnAccelerator(
- uint32_t id,
- const ui::Event& event,
- base::flat_map<std::string, std::vector<uint8_t>>* properties);
-
- // Called when the mouse cursor is shown or hidden in response to a touch
- // event or window manager call.
- virtual void OnCursorTouchVisibleChanged(bool enabled) = 0;
-
- virtual void OnWmPerformMoveLoop(
- Window* window,
- ui::mojom::MoveLoopSource source,
- const gfx::Point& cursor_location,
- const base::Callback<void(bool)>& on_done) = 0;
-
- virtual void OnWmCancelMoveLoop(Window* window) = 0;
-
- // Called when then client changes the client area of a window.
- virtual void OnWmSetClientArea(
- Window* window,
- const gfx::Insets& insets,
- const std::vector<gfx::Rect>& additional_client_areas) = 0;
-
- // Returns whether |window| is the current active window.
- virtual bool IsWindowActive(Window* window) = 0;
-
- // Called when a client requests that its activation be given to another
- // window.
- virtual void OnWmDeactivateWindow(Window* window) = 0;
-
- // Called when a client requests that a generic action be performed. |window|
- // can never be null.
- virtual void OnWmPerformAction(Window* window, const std::string& action);
-
- // Called when an event is blocked by a modal window. |window| is the modal
- // window that blocked the event.
- virtual void OnEventBlockedByModalWindow(Window* window);
-
- protected:
- virtual ~WindowManagerDelegate() {}
-};
-
-} // namespace ui
-
-#endif // UI_AURA_MUS_WINDOW_MANAGER_DELEGATE_H_
diff --git a/chromium/ui/aura/mus/window_mus.h b/chromium/ui/aura/mus/window_mus.h
index ade1846d660..bac124e8b37 100644
--- a/chromium/ui/aura/mus/window_mus.h
+++ b/chromium/ui/aura/mus/window_mus.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "services/ui/public/interfaces/cursor/cursor.mojom.h"
+#include "services/ws/public/mojom/cursor/cursor.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/mus/mus_types.h"
@@ -19,7 +19,7 @@ class Rect;
class Transform;
}
-namespace ui {
+namespace ws {
namespace mojom {
enum class OrderDirection;
}
@@ -67,7 +67,7 @@ class AURA_EXPORT WindowMus {
}
static WindowMus* Get(Window* window);
- ui::Id server_id() const { return server_id_; }
+ ws::Id server_id() const { return server_id_; }
WindowMusType window_mus_type() const { return window_mus_type_; }
@@ -81,7 +81,7 @@ class AURA_EXPORT WindowMus {
virtual void RemoveChildFromServer(WindowMus* child) = 0;
virtual void ReorderFromServer(WindowMus* child,
WindowMus* relative,
- ui::mojom::OrderDirection) = 0;
+ ws::mojom::OrderDirection) = 0;
virtual void SetBoundsFromServer(
const gfx::Rect& bounds,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) = 0;
@@ -135,9 +135,9 @@ class AURA_EXPORT WindowMus {
// Just for set_server_id(), which other places should not call.
friend class WindowTreeClient;
- void set_server_id(ui::Id id) { server_id_ = id; }
+ void set_server_id(ws::Id id) { server_id_ = id; }
- ui::Id server_id_ = kInvalidServerId;
+ ws::Id server_id_ = kInvalidServerId;
const WindowMusType window_mus_type_;
};
diff --git a/chromium/ui/aura/mus/window_port_mus.cc b/chromium/ui/aura/mus/window_port_mus.cc
index 074d5453644..9db986531be 100644
--- a/chromium/ui/aura/mus/window_port_mus.cc
+++ b/chromium/ui/aura/mus/window_port_mus.cc
@@ -77,7 +77,7 @@ void WindowPortMus::SetCursor(const ui::CursorData& cursor) {
}
void WindowPortMus::SetEventTargetingPolicy(
- ui::mojom::EventTargetingPolicy policy) {
+ ws::mojom::EventTargetingPolicy policy) {
window_tree_client_->SetEventTargetingPolicy(this, policy);
}
@@ -85,20 +85,13 @@ void WindowPortMus::SetCanAcceptDrops(bool can_accept_drops) {
window_tree_client_->SetCanAcceptDrops(this, can_accept_drops);
}
-void WindowPortMus::SetExtendedHitRegionForChildren(
- const gfx::Insets& mouse_insets,
- const gfx::Insets& touch_insets) {
- window_tree_client_->SetExtendedHitRegionForChildren(window_, mouse_insets,
- touch_insets);
+void WindowPortMus::SetHitTestMask(const base::Optional<gfx::Rect>& mask) {
+ window_tree_client_->SetHitTestMask(this, mask);
}
-void WindowPortMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) {
- window_tree_client_->SetHitTestMask(this, rect);
-}
-
-void WindowPortMus::Embed(ui::mojom::WindowTreeClientPtr client,
+void WindowPortMus::Embed(ws::mojom::WindowTreeClientPtr client,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback) {
+ ws::mojom::WindowTree::EmbedCallback callback) {
window_tree_client_->Embed(window_, std::move(client), flags,
std::move(callback));
}
@@ -106,7 +99,7 @@ void WindowPortMus::Embed(ui::mojom::WindowTreeClientPtr client,
void WindowPortMus::EmbedUsingToken(
const base::UnguessableToken& token,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback) {
+ ws::mojom::WindowTree::EmbedCallback callback) {
window_tree_client_->EmbedUsingToken(window_, token, flags,
std::move(callback));
}
@@ -244,7 +237,7 @@ void WindowPortMus::RemoveChildFromServer(WindowMus* child) {
void WindowPortMus::ReorderFromServer(WindowMus* child,
WindowMus* relative,
- ui::mojom::OrderDirection direction) {
+ ws::mojom::OrderDirection direction) {
// Keying off solely the id isn't entirely accurate, in so far as if Window
// does some other reordering then the server and client are out of sync.
// But we assume only one client can make changes to a particular window at
@@ -252,7 +245,7 @@ void WindowPortMus::ReorderFromServer(WindowMus* child,
ServerChangeData data;
data.child_id = child->server_id();
ScopedServerChange change(this, ServerChangeType::REORDER, data);
- if (direction == ui::mojom::OrderDirection::BELOW)
+ if (direction == ws::mojom::OrderDirection::BELOW)
window_->StackChildBelow(child->GetWindow(), relative->GetWindow());
else
window_->StackChildAbove(child->GetWindow(), relative->GetWindow());
@@ -312,8 +305,7 @@ void WindowPortMus::SetPropertyFromServer(
void WindowPortMus::SetFrameSinkIdFromServer(
const viz::FrameSinkId& frame_sink_id) {
- DCHECK(window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
- window_mus_type() == WindowMusType::EMBED_IN_OWNER);
+ DCHECK(window_mus_type() == WindowMusType::EMBED_IN_OWNER);
window_->SetEmbedFrameSinkId(frame_sink_id);
UpdatePrimarySurfaceId();
}
@@ -491,8 +483,6 @@ void WindowPortMus::OnDeviceScaleFactorChanged(float old_device_scale_factor,
local_surface_id_ = parent_local_surface_id_allocator_.GenerateId();
local_layer_tree_frame_sink_->SetLocalSurfaceId(local_surface_id_);
}
- window_tree_client_->OnWindowMusDeviceScaleFactorChanged(
- this, old_device_scale_factor, new_device_scale_factor);
if (window_->delegate()) {
window_->delegate()->OnDeviceScaleFactorChanged(old_device_scale_factor,
@@ -610,9 +600,7 @@ bool WindowPortMus::ShouldRestackTransientChildren() {
}
void WindowPortMus::UpdatePrimarySurfaceId() {
- if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
- window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
- window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
+ if (window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
window_mus_type() != WindowMusType::LOCAL) {
return;
}
@@ -626,27 +614,18 @@ void WindowPortMus::UpdatePrimarySurfaceId() {
}
void WindowPortMus::UpdateClientSurfaceEmbedder() {
- if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
- window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
- window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
+ if (window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
window_mus_type() != WindowMusType::LOCAL) {
return;
}
if (!client_surface_embedder_) {
client_surface_embedder_ = std::make_unique<ClientSurfaceEmbedder>(
- window_, window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM,
- window_tree_client_->normal_client_area_insets_);
+ window_, /* inject_gutter */ false, gfx::Insets());
}
client_surface_embedder_->SetPrimarySurfaceId(primary_surface_id_);
client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_);
}
-void WindowPortMus::OnSurfaceChanged(const viz::SurfaceInfo& surface_info) {
- // TODO(fsamuel): Rename OnFirstSurfaceActivation() and set primary earlier
- // based on feedback from LayerTreeFrameSinkLocal.
- NOTREACHED();
-}
-
} // namespace aura
diff --git a/chromium/ui/aura/mus/window_port_mus.h b/chromium/ui/aura/mus/window_port_mus.h
index a23afac3407..e6ec469c098 100644
--- a/chromium/ui/aura/mus/window_port_mus.h
+++ b/chromium/ui/aura/mus/window_port_mus.h
@@ -16,11 +16,10 @@
#include "base/optional.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/common/surfaces/surface_info.h"
-#include "services/ui/public/interfaces/cursor/cursor.mojom.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
+#include "services/ws/public/mojom/cursor/cursor.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/aura_export.h"
-#include "ui/aura/local/layer_tree_frame_sink_local.h"
#include "ui/aura/mus/mus_types.h"
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/window_port.h"
@@ -33,8 +32,12 @@ class AsyncLayerTreeFrameSink;
}
}
-namespace gfx {
-class Insets;
+namespace gpu {
+class GpuMemoryBufferManager;
+}
+
+namespace viz {
+class ContextProvider;
}
namespace aura {
@@ -78,27 +81,22 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
void SetCursor(const ui::CursorData& cursor);
// Sets the EventTargetingPolicy, default is TARGET_AND_DESCENDANTS.
- void SetEventTargetingPolicy(ui::mojom::EventTargetingPolicy policy);
+ void SetEventTargetingPolicy(ws::mojom::EventTargetingPolicy policy);
// Sets whether this window can accept drops, defaults to false.
void SetCanAcceptDrops(bool can_accept_drops);
- // See description in mojom for details on this. Has no effect if not running
- // in the window manager.
- void SetExtendedHitRegionForChildren(const gfx::Insets& mouse_insets,
- const gfx::Insets& touch_insets);
-
// See description in mojom for details on this.
- void SetHitTestMask(const base::Optional<gfx::Rect>& rect);
+ void SetHitTestMask(const base::Optional<gfx::Rect>& mask);
// Embeds a new client in this Window. See WindowTreeClient::Embed() for
// details on arguments.
- void Embed(ui::mojom::WindowTreeClientPtr client,
+ void Embed(ws::mojom::WindowTreeClientPtr client,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback);
+ ws::mojom::WindowTree::EmbedCallback callback);
void EmbedUsingToken(const base::UnguessableToken& token,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback);
+ ws::mojom::WindowTree::EmbedCallback callback);
std::unique_ptr<cc::mojo_embedder::AsyncLayerTreeFrameSink>
RequestLayerTreeFrameSink(
@@ -160,7 +158,7 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
// Contains data needed to identify a change from the server.
struct ServerChangeData {
// Applies to ADD, ADD_TRANSIENT, REMOVE, REMOVE_TRANSIENT, and REORDER.
- ui::Id child_id;
+ ws::Id child_id;
// Applies to BOUNDS. This should be in dip.
gfx::Rect bounds_in_dip;
// Applies to VISIBLE.
@@ -231,7 +229,7 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
void RemoveChildFromServer(WindowMus* child) override;
void ReorderFromServer(WindowMus* child,
WindowMus* relative,
- ui::mojom::OrderDirection) override;
+ ws::mojom::OrderDirection) override;
void SetBoundsFromServer(
const gfx::Rect& bounds,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
@@ -291,8 +289,6 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
void UpdatePrimarySurfaceId();
void UpdateClientSurfaceEmbedder();
- void OnSurfaceChanged(const viz::SurfaceInfo& surface_info);
-
WindowTreeClient* window_tree_client_;
Window* window_ = nullptr;
diff --git a/chromium/ui/aura/mus/window_port_mus_unittest.cc b/chromium/ui/aura/mus/window_port_mus_unittest.cc
index c6e53129ae8..0e05b5886d5 100644
--- a/chromium/ui/aura/mus/window_port_mus_unittest.cc
+++ b/chromium/ui/aura/mus/window_port_mus_unittest.cc
@@ -6,7 +6,6 @@
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/local/layer_tree_frame_sink_local.h"
#include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
diff --git a/chromium/ui/aura/mus/window_tree_client.cc b/chromium/ui/aura/mus/window_tree_client.cc
index c0619812c40..517bd131eaf 100644
--- a/chromium/ui/aura/mus/window_tree_client.cc
+++ b/chromium/ui/aura/mus/window_tree_client.cc
@@ -23,16 +23,13 @@
#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h"
#include "mojo/public/cpp/bindings/map.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "services/ui/common/accelerator_util.h"
-#include "services/ui/common/util.h"
-#include "services/ui/public/cpp/gpu/gpu.h"
-#include "services/ui/public/cpp/property_type_converters.h"
-#include "services/ui/public/interfaces/constants.mojom.h"
-#include "services/ui/public/interfaces/window_manager.mojom.h"
-#include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom.h"
-#include "services/ui/public/interfaces/window_tree_host_factory.mojom.h"
+#include "services/ws/common/util.h"
+#include "services/ws/public/cpp/gpu/gpu.h"
+#include "services/ws/public/cpp/property_type_converters.h"
+#include "services/ws/public/mojom/constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/drag_drop_client.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/transient_window_client.h"
#include "ui/aura/env.h"
#include "ui/aura/env_input_state_controller.h"
@@ -46,7 +43,7 @@
#include "ui/aura/mus/mus_context_factory.h"
#include "ui/aura/mus/property_converter.h"
#include "ui/aura/mus/property_utils.h"
-#include "ui/aura/mus/window_manager_delegate.h"
+#include "ui/aura/mus/topmost_window_tracker.h"
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/mus/window_tree_client_delegate.h"
@@ -63,6 +60,7 @@
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/base/ui_base_types.h"
+#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/display/types/display_constants.h"
#include "ui/events/event.h"
@@ -70,10 +68,6 @@
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size.h"
-#if defined(USE_OZONE)
-#include "ui/aura/mus/platform_event_source_mus_ozone.h"
-#endif
-
namespace aura {
namespace {
@@ -95,48 +89,25 @@ class EventAckHandler : public base::RunLoop::NestingObserver {
~EventAckHandler() override {
base::RunLoop::RemoveNestingObserverOnCurrentThread(this);
if (ack_callback_) {
- NotifyPlatformEventSource();
std::move(ack_callback_)
- .Run(handled_ ? ui::mojom::EventResult::HANDLED
- : ui::mojom::EventResult::UNHANDLED);
+ .Run(handled_ ? ws::mojom::EventResult::HANDLED
+ : ws::mojom::EventResult::UNHANDLED);
}
}
-#if defined(USE_OZONE)
- void SetPlatformEventSourceAndEvent(
- PlatformEventSourceMus* platform_event_source,
- ui::Event* event) {
- event_ = event;
- platform_event_source_ = platform_event_source;
- }
-#endif
-
void set_handled(bool handled) { handled_ = handled; }
// base::RunLoop::NestingObserver:
void OnBeginNestedRunLoop() override {
// Acknowledge the event immediately if a nested run loop starts.
// Otherwise we appear unresponsive for the life of the nested run loop.
- if (ack_callback_) {
- NotifyPlatformEventSource();
- std::move(ack_callback_).Run(ui::mojom::EventResult::HANDLED);
- }
+ if (ack_callback_)
+ std::move(ack_callback_).Run(ws::mojom::EventResult::HANDLED);
}
private:
- void NotifyPlatformEventSource() {
-#if defined(USE_OZONE)
- if (platform_event_source_)
- platform_event_source_->OnDidProcessEvent(event_);
-#endif
- }
-
EventResultCallback ack_callback_;
bool handled_ = false;
-#if defined(USE_OZONE)
- ui::Event* event_ = nullptr;
- PlatformEventSourceMus* platform_event_source_ = nullptr;
-#endif
DISALLOW_COPY_AND_ASSIGN(EventAckHandler);
};
@@ -178,79 +149,17 @@ std::unique_ptr<ui::Event> MapEvent(const ui::Event& event) {
return ui::Event::Clone(event);
}
-// Use for acks from mus that are expected to always succeed and if they don't
-// a crash is triggered.
-void OnAckMustSucceed(const base::Location& from_here, bool success) {
- CHECK(success) << "Context: " << from_here.ToString();
-}
-
-ui::Id GetServerIdForWindow(Window* window) {
- return window ? WindowMus::Get(window)->server_id() : kInvalidServerId;
-}
-
-gfx::Transform ConvertTransformFromServer(WindowMus* window,
- const gfx::Transform& transform) {
- const float scale = window->GetDeviceScaleFactor();
- if (scale == 1.0f)
- return transform;
-
- gfx::Transform dip_transform = transform;
- dip_transform.matrix().set(0, 3, dip_transform.matrix().get(0, 3) / scale);
- dip_transform.matrix().set(1, 3, dip_transform.matrix().get(1, 3) / scale);
- dip_transform.matrix().set(2, 3, dip_transform.matrix().get(2, 3) / scale);
- return dip_transform;
-}
-
-// See the comment for ConvertTransformFromServer().
-gfx::Transform ConvertTransformToServer(WindowMus* window,
- const gfx::Transform& transform) {
- const float scale = window->GetDeviceScaleFactor();
- if (scale == 1.0f)
- return transform;
-
- gfx::Transform pixel_transform = transform;
- pixel_transform.matrix().set(0, 3, transform.matrix().get(0, 3) * scale);
- pixel_transform.matrix().set(1, 3, transform.matrix().get(1, 3) * scale);
- pixel_transform.matrix().set(2, 3, transform.matrix().get(2, 3) * scale);
- return pixel_transform;
-}
-
} // namespace
// static
-std::unique_ptr<WindowTreeClient> WindowTreeClient::CreateForWindowManager(
- service_manager::Connector* connector,
- WindowTreeClientDelegate* delegate,
- WindowManagerDelegate* window_manager_delegate,
- bool automatically_create_display_roots,
- bool create_discardable_memory) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- std::unique_ptr<WindowTreeClient> wtc(
- new WindowTreeClient(connector, delegate, window_manager_delegate,
- nullptr, nullptr, create_discardable_memory));
-
- ui::mojom::WindowManagerWindowTreeFactoryPtr factory;
- connector->BindInterface(ui::mojom::kServiceName, &factory);
- ui::mojom::WindowTreePtr window_tree;
- ui::mojom::WindowTreeClientPtr client;
- wtc->binding_.Bind(MakeRequest(&client));
- factory->CreateWindowTree(MakeRequest(&window_tree), std::move(client),
- automatically_create_display_roots);
- wtc->SetWindowTree(std::move(window_tree));
- wtc->CreatePlatformEventSourceIfNecessary();
- return wtc;
-}
-
-// static
std::unique_ptr<WindowTreeClient> WindowTreeClient::CreateForEmbedding(
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
- ui::mojom::WindowTreeClientRequest request,
+ ws::mojom::WindowTreeClientRequest request,
bool create_discardable_memory) {
std::unique_ptr<WindowTreeClient> wtc(
- new WindowTreeClient(connector, delegate, nullptr, std::move(request),
- nullptr, create_discardable_memory));
+ new WindowTreeClient(connector, delegate, std::move(request), nullptr,
+ create_discardable_memory));
return wtc;
}
@@ -259,41 +168,20 @@ std::unique_ptr<WindowTreeClient> WindowTreeClient::CreateForWindowTreeFactory(
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
bool create_discardable_memory,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
- Config config) {
- std::unique_ptr<WindowTreeClient> wtc(
- new WindowTreeClient(connector, delegate, nullptr, nullptr, nullptr,
- create_discardable_memory, config));
- ui::mojom::WindowTreeFactoryPtr factory;
- connector->BindInterface(ui::mojom::kServiceName, &factory);
- ui::mojom::WindowTreePtr window_tree;
- ui::mojom::WindowTreeClientPtr client;
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) {
+ std::unique_ptr<WindowTreeClient> wtc(new WindowTreeClient(
+ connector, delegate, nullptr, std::move(io_task_runner),
+ create_discardable_memory));
+ ws::mojom::WindowTreeFactoryPtr factory;
+ connector->BindInterface(ws::mojom::kServiceName, &factory);
+ ws::mojom::WindowTreePtr window_tree;
+ ws::mojom::WindowTreeClientPtr client;
wtc->binding_.Bind(MakeRequest(&client));
factory->CreateWindowTree(MakeRequest(&window_tree), std::move(client));
wtc->SetWindowTree(std::move(window_tree));
return wtc;
}
-// static
-std::unique_ptr<WindowTreeClient>
-WindowTreeClient::CreateForWindowTreeHostFactory(
- service_manager::Connector* connector,
- WindowTreeClientDelegate* delegate,
- bool create_discardable_memory) {
- std::unique_ptr<WindowTreeClient> wtc(
- new WindowTreeClient(connector, delegate, nullptr, nullptr, nullptr,
- create_discardable_memory));
- ui::mojom::WindowTreeHostFactoryPtr factory;
- connector->BindInterface(ui::mojom::kServiceName, &factory);
-
- ui::mojom::WindowTreeHostPtr window_tree_host;
- ui::mojom::WindowTreeClientPtr client;
- wtc->binding_.Bind(MakeRequest(&client));
- factory->CreateWindowTreeHost(MakeRequest(&window_tree_host),
- std::move(client));
- return wtc;
-}
-
WindowTreeClient::~WindowTreeClient() {
in_destructor_ = true;
@@ -345,8 +233,14 @@ WindowTreeClient::~WindowTreeClient() {
}
bool WindowTreeClient::WaitForDisplays() {
- // TODO(sky): move WaitForInitialDisplays() here. https://crbug.com/837713
- return WaitForInitialDisplays();
+ if (got_initial_displays_)
+ return true;
+
+ bool valid_wait = true;
+ // TODO(sky): having to block here is not ideal. http://crbug.com/594852.
+ while (!got_initial_displays_ && valid_wait)
+ valid_wait = binding_.WaitForIncomingMethodCall();
+ return valid_wait;
}
void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) {
@@ -382,23 +276,14 @@ void WindowTreeClient::SetImeVisibility(WindowMus* window,
void WindowTreeClient::SetHitTestMask(
WindowMus* window,
const base::Optional<gfx::Rect>& mask_rect) {
- base::Optional<gfx::Rect> out_rect = base::nullopt;
- if (mask_rect) {
- if (is_using_pixels()) {
- out_rect = gfx::ConvertRectToPixel(window->GetDeviceScaleFactor(),
- mask_rect.value());
- } else {
- out_rect = mask_rect.value();
- }
- }
-
- tree_->SetHitTestMask(window->server_id(), out_rect);
+ DCHECK(tree_);
+ tree_->SetHitTestMask(window->server_id(), mask_rect);
}
void WindowTreeClient::Embed(Window* window,
- ui::mojom::WindowTreeClientPtr client,
+ ws::mojom::WindowTreeClientPtr client,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback) {
+ ws::mojom::WindowTree::EmbedCallback callback) {
DCHECK(tree_);
// Window::Init() must be called before Embed() (otherwise the server hasn't
// been told about the window).
@@ -416,7 +301,7 @@ void WindowTreeClient::Embed(Window* window,
}
void WindowTreeClient::ScheduleEmbed(
- ui::mojom::WindowTreeClientPtr client,
+ ws::mojom::WindowTreeClientPtr client,
base::OnceCallback<void(const base::UnguessableToken&)> callback) {
tree_->ScheduleEmbed(std::move(client), std::move(callback));
}
@@ -425,7 +310,7 @@ void WindowTreeClient::EmbedUsingToken(
Window* window,
const base::UnguessableToken& token,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback) {
+ ws::mojom::WindowTree::EmbedCallback callback) {
DCHECK(tree_);
// Window::Init() must be called before Embed() (otherwise the server hasn't
// been told about the window).
@@ -443,7 +328,7 @@ void WindowTreeClient::EmbedUsingToken(
}
void WindowTreeClient::AttachCompositorFrameSink(
- ui::Id window_id,
+ ws::Id window_id,
viz::mojom::CompositorFrameSinkRequest compositor_frame_sink,
viz::mojom::CompositorFrameSinkClientPtr client) {
DCHECK(tree_);
@@ -462,17 +347,13 @@ std::unique_ptr<EmbedRoot> WindowTreeClient::CreateEmbedRoot(
WindowTreeClient::WindowTreeClient(
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
- WindowManagerDelegate* window_manager_delegate,
- mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
+ mojo::InterfaceRequest<ws::mojom::WindowTreeClient> request,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
- bool create_discardable_memory,
- Config config)
- : config_(config),
- connector_(connector),
+ bool create_discardable_memory)
+ : connector_(connector),
next_window_id_(1),
next_change_id_(1),
delegate_(delegate),
- window_manager_delegate_(window_manager_delegate),
binding_(this),
tree_(nullptr),
in_destructor_(false),
@@ -484,12 +365,10 @@ WindowTreeClient::WindowTreeClient(
// Some tests may not create a TransientWindowClient.
if (client::GetTransientWindowClient())
client::GetTransientWindowClient()->AddObserver(this);
- if (window_manager_delegate)
- window_manager_delegate->SetWindowManagerClient(this);
if (connector) { // |connector| can be null in tests.
if (!io_task_runner) {
- // |io_task_runner| is null in most case. But for the browser process,
- // the |io_task_runner| is the browser's IO thread.
+ // |io_task_runner| is typically null. When used in the browser process,
+ // |io_task_runner| is the browser's IO thread.
io_thread_ = std::make_unique<base::Thread>("IOThread");
base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
thread_options.priority = base::ThreadPriority::NORMAL;
@@ -497,7 +376,7 @@ WindowTreeClient::WindowTreeClient(
io_task_runner = io_thread_->task_runner();
}
- gpu_ = ui::Gpu::Create(connector, ui::mojom::kServiceName, io_task_runner);
+ gpu_ = ws::Gpu::Create(connector, ws::mojom::kServiceName, io_task_runner);
compositor_context_factory_ =
std::make_unique<MusContextFactory>(gpu_.get());
initial_context_factory_ = Env::GetInstance()->context_factory();
@@ -507,7 +386,7 @@ WindowTreeClient::WindowTreeClient(
// create the discardable memory manager for those tests.
if (create_discardable_memory) {
discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
- connector->BindInterface(ui::mojom::kServiceName, &manager_ptr);
+ connector->BindInterface(ws::mojom::kServiceName, &manager_ptr);
discardable_shared_memory_manager_ = std::make_unique<
discardable_memory::ClientDiscardableSharedMemoryManager>(
std::move(manager_ptr), std::move(io_task_runner));
@@ -517,13 +396,6 @@ WindowTreeClient::WindowTreeClient(
}
}
-void WindowTreeClient::CreatePlatformEventSourceIfNecessary() {
-#if defined(USE_OZONE)
- if (!ui::PlatformEventSource::GetInstance())
- platform_event_source_ = std::make_unique<PlatformEventSourceMus>();
-#endif
-}
-
void WindowTreeClient::RegisterWindowMus(WindowMus* window) {
DCHECK(windows_.find(window->server_id()) == windows_.end());
windows_[window->server_id()] = window;
@@ -534,7 +406,7 @@ void WindowTreeClient::RegisterWindowMus(WindowMus* window) {
}
}
-WindowMus* WindowTreeClient::GetWindowByServerId(ui::Id id) {
+WindowMus* WindowTreeClient::GetWindowByServerId(ws::Id id) {
IdToWindowMap::const_iterator it = windows_.find(id);
return it != windows_.end() ? it->second : nullptr;
}
@@ -544,78 +416,6 @@ bool WindowTreeClient::IsWindowKnown(aura::Window* window) {
return windows_.count(window_mus->server_id()) > 0;
}
-void WindowTreeClient::ConvertPointerEventLocationToDip(
- int64_t display_id,
- WindowMus* window,
- ui::LocatedEvent* event) const {
- // PointerEvents shouldn't have the target set.
- DCHECK(!event->target());
-
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- if (!is_using_pixels()) {
- if (!window) {
- // When there is no window force the root and location to be the same.
- // They may differ if |window| was valid at the time of the event, but
- // was since deleted.
- event->set_location_f(event->root_location_f());
- }
- return;
- }
-
- if (window_manager_delegate_) {
- ConvertPointerEventLocationToDipInWindowManager(display_id, window, event);
- return;
- }
- display::Screen* screen = display::Screen::GetScreen();
- display::Display display;
- // TODO(sky): this needs to take into account the ui display scale.
- // http://crbug.com/758399.
- if (!screen->GetDisplayWithDisplayId(display_id, &display) ||
- display.device_scale_factor() == 1.f) {
- return;
- }
- const gfx::Point root_location = gfx::ConvertPointToDIP(
- display.device_scale_factor(), event->root_location());
- event->set_root_location(root_location);
- if (window) {
- const gfx::Point host_location = gfx::ConvertPointToDIP(
- display.device_scale_factor(), event->location());
- event->set_location(host_location);
- } else {
- // When there is no window force the root and location to be the same. They
- // may differ it |window| was valid at the time of the event, but was since
- // deleted.
- event->set_location(root_location);
- }
-}
-
-void WindowTreeClient::ConvertPointerEventLocationToDipInWindowManager(
- int64_t display_id,
- WindowMus* window,
- ui::LocatedEvent* event) const {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- const WindowTreeHostMus* window_tree_host =
- GetWindowTreeHostForDisplayId(display_id);
- if (!window_tree_host)
- return;
-
- ui::Event::DispatcherApi dispatcher_api(event);
- if (window) {
- dispatcher_api.set_target(window->GetWindow());
- } else {
- // UpdateForRootTransform() in the case of no target uses |location_|.
- // |location_| may be relative to a window that wasn't found. To ensure we
- // convert from the root, reset |location_| to |root_location_|.
- event->set_location_f(event->root_location_f());
- }
- event->UpdateForRootTransform(
- window_tree_host->GetInverseRootTransform(),
- window_tree_host->GetInverseRootTransformForLocalEventCoordinates());
- dispatcher_api.set_target(nullptr);
-}
-
InFlightChange* WindowTreeClient::GetOldestInFlightChangeMatching(
const InFlightChange& change) {
for (const auto& pair : in_flight_map_) {
@@ -651,13 +451,13 @@ bool WindowTreeClient::ApplyServerChangeToExistingInFlightChange(
}
void WindowTreeClient::BuildWindowTree(
- const std::vector<ui::mojom::WindowDataPtr>& windows) {
+ const std::vector<ws::mojom::WindowDataPtr>& windows) {
for (const auto& window_data : windows)
CreateOrUpdateWindowFromWindowData(*window_data);
}
void WindowTreeClient::CreateOrUpdateWindowFromWindowData(
- const ui::mojom::WindowData& window_data) {
+ const ws::mojom::WindowData& window_data) {
WindowMus* parent = window_data.parent_id == kInvalidServerId
? nullptr
: GetWindowByServerId(window_data.parent_id);
@@ -695,7 +495,7 @@ void WindowTreeClient::CreateOrUpdateWindowFromWindowData(
}
std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
- const ui::mojom::WindowData& window_data,
+ const ws::mojom::WindowData& window_data,
WindowMusType window_mus_type) {
std::unique_ptr<WindowPortMus> window_port_mus(
std::make_unique<WindowPortMus>(this, window_mus_type));
@@ -706,28 +506,14 @@ std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
void WindowTreeClient::SetLocalPropertiesFromServerProperties(
WindowMus* window,
- const ui::mojom::WindowData& window_data) {
+ const ws::mojom::WindowData& window_data) {
for (auto& pair : window_data.properties)
window->SetPropertyFromServer(pair.first, &pair.second);
}
-const WindowTreeHostMus* WindowTreeClient::GetWindowTreeHostForDisplayId(
- int64_t display_id) const {
- if (!window_manager_delegate_)
- return nullptr;
-
- for (WindowMus* window : roots_) {
- WindowTreeHostMus* window_tree_host =
- static_cast<WindowTreeHostMus*>(window->GetWindow()->GetHost());
- if (window_tree_host->display_id() == display_id)
- return window_tree_host;
- }
- return nullptr;
-}
-
std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
WindowMusType window_mus_type,
- const ui::mojom::WindowData& window_data,
+ const ws::mojom::WindowData& window_data,
int64_t display_id,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
std::unique_ptr<WindowPortMus> window_port =
@@ -754,7 +540,7 @@ std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
WindowMus* WindowTreeClient::NewWindowFromWindowData(
WindowMus* parent,
- const ui::mojom::WindowData& window_data) {
+ const ws::mojom::WindowData& window_data) {
// This function is only called for windows coming from other clients.
std::unique_ptr<WindowPortMus> window_port_mus(
CreateWindowPortMus(window_data, WindowMusType::OTHER));
@@ -771,12 +557,7 @@ WindowMus* WindowTreeClient::NewWindowFromWindowData(
SetWindowType(window, GetWindowTypeFromProperties(properties));
window->Init(ui::LAYER_NOT_DRAWN);
SetLocalPropertiesFromServerProperties(window_mus, window_data);
- window_mus->SetBoundsFromServer(
- is_using_pixels()
- ? gfx::ConvertRectToDIP(window_mus->GetDeviceScaleFactor(),
- window_data.bounds)
- : window_data.bounds,
- base::nullopt);
+ window_mus->SetBoundsFromServer(window_data.bounds, base::nullopt);
if (parent)
parent->AddChildFromServer(window_port_mus_ptr);
if (window_data.visible)
@@ -784,7 +565,7 @@ WindowMus* WindowTreeClient::NewWindowFromWindowData(
return window_port_mus_ptr;
}
-void WindowTreeClient::SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr) {
+void WindowTreeClient::SetWindowTree(ws::mojom::WindowTreePtr window_tree_ptr) {
tree_ptr_ = std::move(window_tree_ptr);
WindowTreeConnectionEstablished(tree_ptr_.get());
@@ -794,16 +575,10 @@ void WindowTreeClient::SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr) {
tree_ptr_.set_connection_error_handler(base::BindOnce(
&WindowTreeClient::OnConnectionLost, weak_factory_.GetWeakPtr()));
-
- if (window_manager_delegate_) {
- tree_ptr_->GetWindowManagerClient(
- MakeRequest(&window_manager_internal_client_));
- window_manager_client_ = window_manager_internal_client_.get();
- }
}
void WindowTreeClient::WindowTreeConnectionEstablished(
- ui::mojom::WindowTree* window_tree) {
+ ws::mojom::WindowTree* window_tree) {
tree_ = window_tree;
drag_drop_controller_ = std::make_unique<DragDropControllerMus>(this, tree_);
@@ -842,10 +617,10 @@ bool WindowTreeClient::HandleInternalPropertyChanged(WindowMus* window,
}
void WindowTreeClient::OnEmbedImpl(
- ui::mojom::WindowTree* window_tree,
- ui::mojom::WindowDataPtr root_data,
+ ws::mojom::WindowTree* window_tree,
+ ws::mojom::WindowDataPtr root_data,
int64_t display_id,
- ui::Id focused_window_id,
+ ws::Id focused_window_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
WindowTreeConnectionEstablished(window_tree);
@@ -872,32 +647,9 @@ void WindowTreeClient::OnEmbedRootDestroyed(EmbedRoot* embed_root) {
embed_roots_.erase(embed_root);
}
-WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
- const display::Display& display,
- ui::mojom::WindowDataPtr root_data,
- bool parent_drawn,
- const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- DCHECK(window_manager_delegate_);
-
- got_initial_displays_ = true;
-
- window_manager_delegate_->OnWmWillCreateDisplay(display);
-
- std::unique_ptr<WindowTreeHostMus> window_tree_host =
- CreateWindowTreeHost(WindowMusType::DISPLAY_AUTOMATICALLY_CREATED,
- *root_data, display.id(), local_surface_id);
-
- WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
- window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
- display);
- return window_tree_host_ptr;
-}
-
EventResultCallback WindowTreeClient::CreateEventResultCallback(
int32_t event_id) {
- return base::BindOnce(&ui::mojom::WindowTree::OnWindowInputEventAck,
+ return base::BindOnce(&ws::mojom::WindowTree::OnWindowInputEventAck,
base::Unretained(tree_), event_id);
}
@@ -918,32 +670,22 @@ void WindowTreeClient::SetWindowBoundsFromServer(
// scale factor set on the display. It's the call to
// SetBoundsFromServerInPixels() that is responsible for updating the scale
// factor in the Compositor.
+ // Do not use ConvertRectToPixel, enclosing rects cause problems.
const float dsf = ui::GetScaleFactorForNativeView(window->GetWindow());
+ const gfx::Rect rect(gfx::ScaleToFlooredPoint(revert_bounds.origin(), dsf),
+ gfx::ScaleToCeiledSize(revert_bounds.size(), dsf));
GetWindowTreeHostMus(window)->SetBoundsFromServerInPixels(
- is_using_pixels() ? revert_bounds
- : gfx::ConvertRectToPixel(dsf, revert_bounds),
- local_surface_id ? *local_surface_id : viz::LocalSurfaceId());
+ rect, local_surface_id ? *local_surface_id : viz::LocalSurfaceId());
return;
}
- // NOTE: |revert_bounds| is pixels for kMash, and DIPs for kMus2.
- // Window::SetBoundsFromServer() expects DIPs.
- window->SetBoundsFromServer(
- is_using_pixels()
- ? gfx::ConvertRectToDIP(window->GetDeviceScaleFactor(), revert_bounds)
- : revert_bounds,
- local_surface_id);
+ window->SetBoundsFromServer(revert_bounds, local_surface_id);
}
void WindowTreeClient::SetWindowTransformFromServer(
WindowMus* window,
const gfx::Transform& transform) {
- if (is_using_pixels()) {
- window->SetTransformFromServer(
- ConvertTransformFromServer(window, transform));
- } else {
- window->SetTransformFromServer(transform);
- }
+ window->SetTransformFromServer(transform);
}
void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window,
@@ -962,8 +704,30 @@ void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window,
window_tree_host->Hide();
}
-// NOTE: this function takes pixels if is_using_pixels() is true, otherwise
-// DIPs. Eventually this will only take DIPs (https://crbug.com/842365).
+void WindowTreeClient::NotifyPointerEventObserved(ui::PointerEvent* event,
+ uint64_t display_id,
+ WindowMus* window_mus) {
+ aura::Window* window = window_mus ? window_mus->GetWindow() : nullptr;
+ gfx::Point location_in_screen;
+ if (window) {
+ location_in_screen = event->location();
+ client::GetScreenPositionClient(window->GetRootWindow())
+ ->ConvertPointToScreen(window, &location_in_screen);
+ } else {
+ // When there is no window force the root and location to be the same.
+ // They may differ if |window| was valid at the time of the event, but
+ // was since deleted.
+ event->set_location_f(event->root_location_f());
+ location_in_screen = event->root_location();
+ display::Display display;
+ if (display::Screen::GetScreen()->GetDisplayWithDisplayId(display_id,
+ &display)) {
+ location_in_screen += display.bounds().OffsetFromOrigin();
+ }
+ }
+ delegate_->OnPointerEventObserved(*event, location_in_screen, window);
+}
+
void WindowTreeClient::ScheduleInFlightBoundsChange(
WindowMus* window,
const gfx::Rect& old_bounds,
@@ -972,15 +736,12 @@ void WindowTreeClient::ScheduleInFlightBoundsChange(
ScheduleInFlightChange(std::make_unique<InFlightBoundsChange>(
this, window, old_bounds, window->GetLocalSurfaceId()));
base::Optional<viz::LocalSurfaceId> local_surface_id;
- if (window->window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
- window->window_mus_type() == WindowMusType::EMBED_IN_OWNER ||
- window->window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED ||
+ if (window->window_mus_type() == WindowMusType::EMBED_IN_OWNER ||
window->HasLocalLayerTreeFrameSink()) {
- local_surface_id = window->GetOrAllocateLocalSurfaceId(
- is_using_pixels() ? new_bounds.size()
- : gfx::ConvertRectToPixel(
- window->GetDeviceScaleFactor(), new_bounds)
- .size());
+ // Do not use ConvertRectToPixel, enclosing rects cause problems.
+ const gfx::Size size = gfx::ScaleToCeiledSize(
+ new_bounds.size(), window->GetDeviceScaleFactor());
+ local_surface_id = window->GetOrAllocateLocalSurfaceId(size);
// |window_tree_host| may be null if this is called during creation of
// the window associated with the WindowTreeHostMus.
WindowTreeHost* window_tree_host = window->GetWindow()->GetHost();
@@ -998,7 +759,7 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
window->set_server_id(next_window_id_++);
RegisterWindowMus(window);
- DCHECK(window_manager_delegate_ || !IsRoot(window));
+ DCHECK(!IsRoot(window));
PropertyConverter* property_converter = delegate_->GetPropertyConverter();
base::flat_map<std::string, std::vector<uint8_t>> transport_properties =
@@ -1009,41 +770,10 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
tree_->NewWindow(change_id, window->server_id(),
std::move(transport_properties));
if (window->GetWindow()->event_targeting_policy() !=
- ui::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS) {
+ ws::mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS) {
SetEventTargetingPolicy(window,
window->GetWindow()->event_targeting_policy());
}
- if (window->window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED) {
- WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window);
- std::unique_ptr<DisplayInitParams> display_init_params =
- window_tree_host->ReleaseDisplayInitParams();
- DCHECK(display_init_params);
- display::Display display;
- if (display_init_params->display) {
- display = *display_init_params->display;
- } else {
- const bool has_display =
- display::Screen::GetScreen()->GetDisplayWithDisplayId(
- window_tree_host->display_id(), &display);
- DCHECK(has_display);
- }
- // As |window| is a root, changes to its bounds are ignored (it's assumed
- // bounds changes are routed through OnWindowTreeHostBoundsWillChange()).
- // But the display is created with an initial bounds, and we need to push
- // that to the server.
- ScheduleInFlightBoundsChange(
- window, gfx::Rect(),
- gfx::Rect(
- display_init_params->viewport_metrics.bounds_in_pixels.size()));
-
- if (window_manager_client_) {
- window_manager_client_->SetDisplayRoot(
- display, display_init_params->viewport_metrics.Clone(),
- display_init_params->is_primary_display, window->server_id(),
- display_init_params->mirrors,
- base::BindOnce(&OnAckMustSucceed, FROM_HERE));
- }
- }
}
void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
@@ -1064,14 +794,6 @@ void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
windows_.erase(window->server_id());
- for (auto& entry : embedded_windows_) {
- auto it = entry.second.find(window->GetWindow());
- if (it != entry.second.end()) {
- entry.second.erase(it);
- break;
- }
- }
-
// Remove any InFlightChanges associated with the window.
std::set<uint32_t> in_flight_change_ids_to_remove;
for (const auto& pair : in_flight_map_) {
@@ -1095,15 +817,7 @@ void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
// already been set.
return;
}
- const float device_scale_factor = window->GetDeviceScaleFactor();
- ScheduleInFlightBoundsChange(
- window,
- is_using_pixels()
- ? gfx::ConvertRectToPixel(device_scale_factor, old_bounds)
- : old_bounds,
- is_using_pixels()
- ? gfx::ConvertRectToPixel(device_scale_factor, new_bounds)
- : new_bounds);
+ ScheduleInFlightBoundsChange(window, old_bounds, new_bounds);
}
void WindowTreeClient::OnWindowMusTransformChanged(
@@ -1112,10 +826,7 @@ void WindowTreeClient::OnWindowMusTransformChanged(
const gfx::Transform& new_transform) {
const uint32_t change_id = ScheduleInFlightChange(
std::make_unique<InFlightTransformChange>(this, window, old_transform));
- tree_->SetWindowTransform(
- change_id, window->server_id(),
- is_using_pixels() ? ConvertTransformToServer(window, new_transform)
- : new_transform);
+ tree_->SetWindowTransform(change_id, window->server_id(), new_transform);
}
void WindowTreeClient::OnWindowMusAddChild(WindowMus* parent,
@@ -1144,15 +855,15 @@ void WindowTreeClient::OnWindowMusMoveChild(WindowMus* parent,
WindowMus* window =
WindowMus::Get(parent->GetWindow()->children()[current_index]);
WindowMus* relative_window = nullptr;
- ui::mojom::OrderDirection direction;
+ ws::mojom::OrderDirection direction;
if (dest_index < current_index) {
relative_window =
WindowMus::Get(parent->GetWindow()->children()[dest_index]);
- direction = ui::mojom::OrderDirection::BELOW;
+ direction = ws::mojom::OrderDirection::BELOW;
} else {
relative_window =
WindowMus::Get(parent->GetWindow()->children()[dest_index]);
- direction = ui::mojom::OrderDirection::ABOVE;
+ direction = ws::mojom::OrderDirection::ABOVE;
}
tree_->ReorderWindow(change_id, window->server_id(),
relative_window->server_id(), direction);
@@ -1212,35 +923,6 @@ void WindowTreeClient::OnWindowMusPropertyChanged(
transport_value_mojo);
}
-void WindowTreeClient::OnWindowMusDeviceScaleFactorChanged(
- WindowMus* window,
- float old_scale_factor,
- float new_scale_factor) {
- if (!is_using_pixels())
- return; // device-scale factor doesn't impact DIP bounds.
-
- // Root changes are handled else where.
- if (IsRoot(window))
- return;
-
- const gfx::Rect old_bounds =
- gfx::ConvertRectToPixel(old_scale_factor, window->GetWindow()->bounds());
- const gfx::Rect new_bounds =
- gfx::ConvertRectToPixel(new_scale_factor, window->GetWindow()->bounds());
- ScheduleInFlightBoundsChange(window, old_bounds, new_bounds);
-}
-
-void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id,
- bool completed) {
- if (window_manager_client_)
- window_manager_client_->WmResponse(change_id, completed);
-
- if (change_id == current_wm_move_loop_change_) {
- current_wm_move_loop_change_ = 0;
- current_wm_move_loop_window_id_ = 0;
- }
-}
-
std::set<Window*> WindowTreeClient::GetRoots() {
std::set<Window*> roots;
for (WindowMus* window : roots_)
@@ -1251,7 +933,7 @@ std::set<Window*> WindowTreeClient::GetRoots() {
bool WindowTreeClient::WasCreatedByThisClient(const WindowMus* window) const {
// Windows created via CreateTopLevelWindow() are not owned by us, but don't
// have high-word set. const_cast is required by set.
- return !ui::ClientIdFromTransportId(window->server_id()) &&
+ return !ws::ClientIdFromTransportId(window->server_id()) &&
roots_.count(const_cast<WindowMus*>(window)) == 0;
}
@@ -1303,16 +985,16 @@ void WindowTreeClient::SetCanAcceptDrops(WindowMus* window,
void WindowTreeClient::SetEventTargetingPolicy(
WindowMus* window,
- ui::mojom::EventTargetingPolicy policy) {
+ ws::mojom::EventTargetingPolicy policy) {
DCHECK(tree_);
tree_->SetEventTargetingPolicy(window->server_id(), policy);
}
void WindowTreeClient::OnEmbed(
- ui::mojom::WindowDataPtr root_data,
- ui::mojom::WindowTreePtr tree,
+ ws::mojom::WindowDataPtr root_data,
+ ws::mojom::WindowTreePtr tree,
int64_t display_id,
- ui::Id focused_window_id,
+ ws::Id focused_window_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
DCHECK(!tree_ptr_);
@@ -1321,18 +1003,13 @@ void WindowTreeClient::OnEmbed(
is_from_embed_ = true;
got_initial_displays_ = true;
- if (window_manager_delegate_) {
- tree_ptr_->GetWindowManagerClient(
- MakeRequest(&window_manager_internal_client_));
- window_manager_client_ = window_manager_internal_client_.get();
- }
OnEmbedImpl(tree_ptr_.get(), std::move(root_data), display_id,
focused_window_id, drawn, local_surface_id);
}
void WindowTreeClient::OnEmbedFromToken(
const base::UnguessableToken& token,
- ui::mojom::WindowDataPtr root,
+ ws::mojom::WindowDataPtr root,
int64_t display_id,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
for (EmbedRoot* embed_root : embed_roots_) {
@@ -1344,13 +1021,13 @@ void WindowTreeClient::OnEmbedFromToken(
}
}
-void WindowTreeClient::OnEmbeddedAppDisconnected(ui::Id window_id) {
+void WindowTreeClient::OnEmbeddedAppDisconnected(ws::Id window_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (window)
window->NotifyEmbeddedAppDisconnected();
}
-void WindowTreeClient::OnUnembed(ui::Id window_id) {
+void WindowTreeClient::OnUnembed(ws::Id window_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
@@ -1366,8 +1043,8 @@ void WindowTreeClient::OnUnembed(ui::Id window_id) {
delete window;
}
-void WindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id,
- ui::Id old_capture_window_id) {
+void WindowTreeClient::OnCaptureChanged(ws::Id new_capture_window_id,
+ ws::Id old_capture_window_id) {
WindowMus* new_capture_window = GetWindowByServerId(new_capture_window_id);
WindowMus* lost_capture_window = GetWindowByServerId(old_capture_window_id);
if (!new_capture_window && !lost_capture_window)
@@ -1382,7 +1059,7 @@ void WindowTreeClient::OnCaptureChanged(ui::Id new_capture_window_id,
}
void WindowTreeClient::OnFrameSinkIdAllocated(
- ui::Id window_id,
+ ws::Id window_id,
const viz::FrameSinkId& frame_sink_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
@@ -1393,7 +1070,7 @@ void WindowTreeClient::OnFrameSinkIdAllocated(
void WindowTreeClient::OnTopLevelCreated(
uint32_t change_id,
- ui::mojom::WindowDataPtr data,
+ ws::mojom::WindowDataPtr data,
int64_t display_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
@@ -1435,17 +1112,10 @@ void WindowTreeClient::OnTopLevelCreated(
InFlightBoundsChange bounds_change(this, window, bounds, local_surface_id);
InFlightChange* current_change =
GetOldestInFlightChangeMatching(bounds_change);
- if (current_change) {
+ if (current_change)
current_change->SetRevertValueFrom(bounds_change);
- } else {
- const gfx::Rect window_bounds =
- is_using_pixels()
- ? gfx::ConvertRectToPixel(window->GetDeviceScaleFactor(),
- window->GetWindow()->bounds())
- : window->GetWindow()->bounds();
- if (window_bounds != bounds)
- SetWindowBoundsFromServer(window, bounds, local_surface_id);
- }
+ else if (window->GetWindow()->GetBoundsInScreen() != bounds)
+ SetWindowBoundsFromServer(window, bounds, local_surface_id);
}
// There is currently no API to bulk set properties, so we iterate over each
@@ -1469,7 +1139,7 @@ void WindowTreeClient::OnTopLevelCreated(
}
void WindowTreeClient::OnWindowBoundsChanged(
- ui::Id window_id,
+ ws::Id window_id,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
@@ -1485,7 +1155,7 @@ void WindowTreeClient::OnWindowBoundsChanged(
}
void WindowTreeClient::OnWindowTransformChanged(
- ui::Id window_id,
+ ws::Id window_id,
const gfx::Transform& old_transform,
const gfx::Transform& new_transform) {
WindowMus* window = GetWindowByServerId(window_id);
@@ -1499,33 +1169,8 @@ void WindowTreeClient::OnWindowTransformChanged(
SetWindowTransformFromServer(window, new_transform);
}
-void WindowTreeClient::OnClientAreaChanged(
- ui::Id window_id,
- const gfx::Insets& new_client_area,
- const std::vector<gfx::Rect>& new_additional_client_areas) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- if (!is_using_pixels())
- return;
-
- WindowMus* window = GetWindowByServerId(window_id);
- if (!window)
- return;
-
- float device_scale_factor = window->GetDeviceScaleFactor();
- std::vector<gfx::Rect> new_additional_client_areas_in_dip;
- for (const gfx::Rect& area : new_additional_client_areas) {
- new_additional_client_areas_in_dip.push_back(
- gfx::ConvertRectToDIP(device_scale_factor, area));
- }
- window_manager_delegate_->OnWmSetClientArea(
- window->GetWindow(),
- gfx::ConvertInsetsToDIP(device_scale_factor, new_client_area),
- new_additional_client_areas_in_dip);
-}
-
-void WindowTreeClient::OnTransientWindowAdded(ui::Id window_id,
- ui::Id transient_window_id) {
+void WindowTreeClient::OnTransientWindowAdded(ws::Id window_id,
+ ws::Id transient_window_id) {
WindowMus* window = GetWindowByServerId(window_id);
WindowMus* transient_window = GetWindowByServerId(transient_window_id);
// window or transient_window or both may be null if a local delete occurs
@@ -1534,8 +1179,8 @@ void WindowTreeClient::OnTransientWindowAdded(ui::Id window_id,
window->AddTransientChildFromServer(transient_window);
}
-void WindowTreeClient::OnTransientWindowRemoved(ui::Id window_id,
- ui::Id transient_window_id) {
+void WindowTreeClient::OnTransientWindowRemoved(ws::Id window_id,
+ ws::Id transient_window_id) {
WindowMus* window = GetWindowByServerId(window_id);
WindowMus* transient_window = GetWindowByServerId(transient_window_id);
// window or transient_window or both may be null if a local delete occurs
@@ -1545,10 +1190,10 @@ void WindowTreeClient::OnTransientWindowRemoved(ui::Id window_id,
}
void WindowTreeClient::OnWindowHierarchyChanged(
- ui::Id window_id,
- ui::Id old_parent_id,
- ui::Id new_parent_id,
- std::vector<ui::mojom::WindowDataPtr> windows) {
+ ws::Id window_id,
+ ws::Id old_parent_id,
+ ws::Id new_parent_id,
+ std::vector<ws::mojom::WindowDataPtr> windows) {
const bool was_window_known = GetWindowByServerId(window_id) != nullptr;
BuildWindowTree(windows);
@@ -1567,9 +1212,9 @@ void WindowTreeClient::OnWindowHierarchyChanged(
old_parent->RemoveChildFromServer(window);
}
-void WindowTreeClient::OnWindowReordered(ui::Id window_id,
- ui::Id relative_window_id,
- ui::mojom::OrderDirection direction) {
+void WindowTreeClient::OnWindowReordered(ws::Id window_id,
+ ws::Id relative_window_id,
+ ws::mojom::OrderDirection direction) {
WindowMus* window = GetWindowByServerId(window_id);
WindowMus* relative_window = GetWindowByServerId(relative_window_id);
WindowMus* parent = WindowMus::Get(window->GetWindow()->parent());
@@ -1579,7 +1224,7 @@ void WindowTreeClient::OnWindowReordered(ui::Id window_id,
}
}
-void WindowTreeClient::OnWindowDeleted(ui::Id window_id) {
+void WindowTreeClient::OnWindowDeleted(ws::Id window_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
@@ -1601,7 +1246,7 @@ void WindowTreeClient::OnWindowDeleted(ui::Id window_id) {
}
}
-void WindowTreeClient::OnWindowVisibilityChanged(ui::Id window_id,
+void WindowTreeClient::OnWindowVisibilityChanged(ws::Id window_id,
bool visible) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
@@ -1614,7 +1259,7 @@ void WindowTreeClient::OnWindowVisibilityChanged(ui::Id window_id,
SetWindowVisibleFromServer(window, visible);
}
-void WindowTreeClient::OnWindowOpacityChanged(ui::Id window_id,
+void WindowTreeClient::OnWindowOpacityChanged(ws::Id window_id,
float old_opacity,
float new_opacity) {
WindowMus* window = GetWindowByServerId(window_id);
@@ -1628,7 +1273,7 @@ void WindowTreeClient::OnWindowOpacityChanged(ui::Id window_id,
window->SetOpacityFromServer(new_opacity);
}
-void WindowTreeClient::OnWindowParentDrawnStateChanged(ui::Id window_id,
+void WindowTreeClient::OnWindowParentDrawnStateChanged(ws::Id window_id,
bool drawn) {
// TODO: route to WindowTreeHost.
/*
@@ -1639,7 +1284,7 @@ void WindowTreeClient::OnWindowParentDrawnStateChanged(ui::Id window_id,
}
void WindowTreeClient::OnWindowSharedPropertyChanged(
- ui::Id window_id,
+ ws::Id window_id,
const std::string& name,
const base::Optional<std::vector<uint8_t>>& transport_data) {
WindowMus* window = GetWindowByServerId(window_id);
@@ -1658,25 +1303,19 @@ void WindowTreeClient::OnWindowSharedPropertyChanged(
name, transport_data.has_value() ? &transport_data.value() : nullptr);
}
-void WindowTreeClient::OnWindowInputEvent(
- uint32_t event_id,
- ui::Id window_id,
- int64_t display_id,
- ui::Id display_root_window_id,
- const gfx::PointF& event_location_in_screen_pixel_layout,
- std::unique_ptr<ui::Event> event,
- bool matches_pointer_watcher) {
+void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
+ ws::Id window_id,
+ int64_t display_id,
+ std::unique_ptr<ui::Event> event,
+ bool matches_pointer_watcher) {
DCHECK(event);
WindowMus* window = GetWindowByServerId(window_id); // May be null.
if (matches_pointer_watcher && has_pointer_watcher_) {
DCHECK(event->IsPointerEvent());
std::unique_ptr<ui::Event> event_in_dip(ui::Event::Clone(*event));
- ConvertPointerEventLocationToDip(display_id, window,
- event_in_dip->AsLocatedEvent());
- delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(),
- display_id,
- window ? window->GetWindow() : nullptr);
+ NotifyPointerEventObserved(event_in_dip->AsPointerEvent(), display_id,
+ window);
}
// If the window has already been deleted, use |event| to update event states
@@ -1691,7 +1330,7 @@ void WindowTreeClient::OnWindowInputEvent(
} else if (mapped_event->IsTouchEvent()) {
env_controller->UpdateStateForTouchEvent(*mapped_event->AsTouchEvent());
}
- tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED);
+ tree_->OnWindowInputEventAck(event_id, ws::mojom::EventResult::UNHANDLED);
return;
}
@@ -1708,66 +1347,15 @@ void WindowTreeClient::OnWindowInputEvent(
// ui::TouchEvent once we have proper support for pointer events.
std::unique_ptr<ui::Event> mapped_event = MapEvent(*event.get());
ui::Event* event_to_dispatch = mapped_event.get();
-// Ash wants the native events in one place (see ExtendedMouseWarpController).
-// By using the constructor that takes a MouseEvent we ensure the MouseEvent
-// has a NativeEvent that can be used to extract the pixel coordinates.
-//
-// TODO: this should really be covered by |root_location|. See 608547 for
-// details.
-#if defined(USE_OZONE)
- // TODO(sky): remove conditional. This code was only necessary when ash used
- // this code. Now that ash does not use it, it can be removed once --mash is
- // removed. https://crbug.com/842365.
- std::unique_ptr<ui::MouseEvent> mapped_event_with_native;
- if (config_ == Config::kMashDeprecated) {
- if (mapped_event->type() == ui::ET_MOUSE_MOVED ||
- mapped_event->type() == ui::ET_MOUSE_DRAGGED) {
- mapped_event_with_native = std::make_unique<ui::MouseEvent>(
- static_cast<const ui::PlatformEvent&>(mapped_event.get()));
- // MouseEvent(NativeEvent) sets the root_location to location.
- mapped_event_with_native->set_root_location_f(
- event_location_in_screen_pixel_layout);
- // |mapped_event| is now the NativeEvent. It's expected the location of
- // the NativeEvent is the same as root_location.
- mapped_event->AsMouseEvent()->set_location_f(
- event_location_in_screen_pixel_layout);
- event_to_dispatch = mapped_event_with_native.get();
- }
- }
-#endif
// |ack_handler| may use |event_to_dispatch| from its destructor, so it needs
// to be destroyed after |event_to_dispatch| is destroyed.
EventAckHandler ack_handler(CreateEventResultCallback(event_id));
-#if defined(USE_OZONE)
- ack_handler.SetPlatformEventSourceAndEvent(platform_event_source_.get(),
- event_to_dispatch);
-#endif
-
- WindowMus* display_root_window = GetWindowByServerId(display_root_window_id);
- // TODO(sky): simplify conditional. See comment in USE_OZONE above for why
- // this isn't necessary with kMus2. https://crbug.com/842365.
- if (config_ == Config::kMashDeprecated && display_root_window &&
- event->IsLocatedEvent() &&
- display::Screen::GetScreen()->GetPrimaryDisplay().id() ==
- display::kUnifiedDisplayId) {
- // In Ash's unified desktop mode, each physical display mirrors part of a
- // single virtual display. Dispatch events to the root window of the mirror
- // display supplying the event, using locations relative to that display.
- // Use a null target to ensure events reach the MusUnifiedEventTargeter.
- // This paralells the behavior of unified desktop mode in classic Ash.
- ui::Event::DispatcherApi(event_to_dispatch).set_target(nullptr);
- ui::LocatedEvent* located_event = event_to_dispatch->AsLocatedEvent();
- located_event->set_location_f(located_event->root_location_f());
- window = display_root_window;
- } else if (!event->IsKeyEvent()) {
+
+ if (!event->IsKeyEvent()) {
// Set |window| as the target, except for key events. Key events go to the
// focused window, which may have changed by the time we process the event.
ui::Event::DispatcherApi(event_to_dispatch).set_target(window->GetWindow());
}
-#if defined(USE_OZONE)
- if (platform_event_source_)
- platform_event_source_->OnWillProcessEvent(event_to_dispatch);
-#endif
GetWindowTreeHostMus(window)->SendEventToSink(event_to_dispatch);
@@ -1775,22 +1363,18 @@ void WindowTreeClient::OnWindowInputEvent(
}
void WindowTreeClient::OnPointerEventObserved(std::unique_ptr<ui::Event> event,
- ui::Id window_id,
+ ws::Id window_id,
int64_t display_id) {
DCHECK(event);
DCHECK(event->IsPointerEvent());
if (!has_pointer_watcher_)
return;
- WindowMus* target_window = GetWindowByServerId(window_id);
- ConvertPointerEventLocationToDip(display_id, target_window,
- event->AsLocatedEvent());
- delegate_->OnPointerEventObserved(
- *event->AsPointerEvent(), display_id,
- target_window ? target_window->GetWindow() : nullptr);
+ NotifyPointerEventObserved(event->AsPointerEvent(), display_id,
+ GetWindowByServerId(window_id));
}
-void WindowTreeClient::OnWindowFocused(ui::Id focused_window_id) {
+void WindowTreeClient::OnWindowFocused(ws::Id focused_window_id) {
WindowMus* focused_window = GetWindowByServerId(focused_window_id);
InFlightFocusChange new_change(this, focus_synchronizer_.get(),
focused_window);
@@ -1800,7 +1384,7 @@ void WindowTreeClient::OnWindowFocused(ui::Id focused_window_id) {
focus_synchronizer_->SetFocusFromServer(focused_window);
}
-void WindowTreeClient::OnWindowCursorChanged(ui::Id window_id,
+void WindowTreeClient::OnWindowCursorChanged(ws::Id window_id,
ui::CursorData cursor) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
@@ -1814,7 +1398,7 @@ void WindowTreeClient::OnWindowCursorChanged(ui::Id window_id,
}
void WindowTreeClient::OnWindowSurfaceChanged(
- ui::Id window_id,
+ ws::Id window_id,
const viz::SurfaceInfo& surface_info) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
@@ -1833,7 +1417,7 @@ void WindowTreeClient::OnDragDropStart(
drag_drop_controller_->OnDragDropStart(mojo::FlatMapToMap(mime_data));
}
-void WindowTreeClient::OnDragEnter(ui::Id window_id,
+void WindowTreeClient::OnDragEnter(ws::Id window_id,
uint32_t key_state,
const gfx::Point& position,
uint32_t effect_bitmask,
@@ -1842,7 +1426,7 @@ void WindowTreeClient::OnDragEnter(ui::Id window_id,
GetWindowByServerId(window_id), key_state, position, effect_bitmask));
}
-void WindowTreeClient::OnDragOver(ui::Id window_id,
+void WindowTreeClient::OnDragOver(ws::Id window_id,
uint32_t key_state,
const gfx::Point& position,
uint32_t effect_bitmask,
@@ -1851,7 +1435,7 @@ void WindowTreeClient::OnDragOver(ui::Id window_id,
GetWindowByServerId(window_id), key_state, position, effect_bitmask));
}
-void WindowTreeClient::OnDragLeave(ui::Id window_id) {
+void WindowTreeClient::OnDragLeave(ws::Id window_id) {
drag_drop_controller_->OnDragLeave(GetWindowByServerId(window_id));
}
@@ -1859,7 +1443,7 @@ void WindowTreeClient::OnDragDropDone() {
drag_drop_controller_->OnDragDropDone();
}
-void WindowTreeClient::OnCompleteDrop(ui::Id window_id,
+void WindowTreeClient::OnCompleteDrop(ws::Id window_id,
uint32_t key_state,
const gfx::Point& position,
uint32_t effect_bitmask,
@@ -1876,17 +1460,61 @@ void WindowTreeClient::OnPerformDragDropCompleted(uint32_t change_id,
drag_drop_controller_->OnPerformDragDropCompleted(action_taken);
}
+std::unique_ptr<TopmostWindowTracker>
+WindowTreeClient::StartObservingTopmostWindow(ws::mojom::MoveLoopSource source,
+ aura::Window* initial_target) {
+ DCHECK(!topmost_window_tracker_);
+ WindowMus* window = WindowMus::Get(initial_target->GetRootWindow());
+ DCHECK(window);
+
+ tree_->ObserveTopmostWindow(source, window->server_id());
+ auto topmost_window_tracker = std::make_unique<TopmostWindowTracker>(this);
+ topmost_window_tracker_ = topmost_window_tracker.get();
+ return topmost_window_tracker;
+}
+
+void WindowTreeClient::StopObservingTopmostWindow() {
+ DCHECK(topmost_window_tracker_);
+ tree_->StopObservingTopmostWindow();
+ topmost_window_tracker_ = nullptr;
+}
+
+void WindowTreeClient::OnTopmostWindowChanged(
+ const std::vector<ws::Id>& topmost_ids) {
+ DCHECK_LE(topmost_ids.size(), 2u);
+ // There's a slight chance of |topmost_window_tracker_| to be nullptr at the
+ // end of a session of observing topmost window.
+ if (!topmost_window_tracker_)
+ return;
+ std::vector<WindowMus*> windows;
+ for (auto& id : topmost_ids)
+ windows.push_back(GetWindowByServerId(id));
+ topmost_window_tracker_->OnTopmostWindowChanged(windows);
+}
+
void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) {
std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
in_flight_map_.erase(change_id);
+
+ // |change| might not exist if OnChangeCompleted is called after the window
+ // is deleted, but still we want to invoke the finished callback.
+ if (change_id == current_move_loop_change_) {
+ current_move_loop_change_ = 0;
+ on_current_move_finished_.Run(success);
+ on_current_move_finished_.Reset();
+ }
+
if (!change)
return;
for (auto& observer : test_observers_)
observer.OnChangeCompleted(change_id, change->change_type(), success);
- if (!success)
+ if (!success) {
+ DVLOG(1) << "Change failed id=" << change_id
+ << " type=" << ChangeTypeToString(change->change_type());
change->ChangeFailed();
+ }
InFlightChange* next_change = GetOldestInFlightChangeMatching(*change);
if (next_change) {
@@ -1895,60 +1523,24 @@ void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) {
} else if (!success) {
change->Revert();
}
-
- if (change_id == current_move_loop_change_) {
- current_move_loop_change_ = 0;
- on_current_move_finished_.Run(success);
- on_current_move_finished_.Reset();
- }
-}
-
-void WindowTreeClient::SetBlockingContainers(
- const std::vector<BlockingContainers>& all_blocking_containers) {
- std::vector<ui::mojom::BlockingContainersPtr>
- transport_all_blocking_containers;
- for (const BlockingContainers& blocking_containers :
- all_blocking_containers) {
- ui::mojom::BlockingContainersPtr transport_blocking_containers =
- ui::mojom::BlockingContainers::New();
- // The |system_modal_container| must be specified, |min_container| may be
- // null.
- DCHECK(blocking_containers.system_modal_container);
- transport_blocking_containers->system_modal_container_id =
- GetServerIdForWindow(blocking_containers.system_modal_container);
- transport_blocking_containers->min_container_id =
- GetServerIdForWindow(blocking_containers.min_container);
- transport_all_blocking_containers.push_back(
- std::move(transport_blocking_containers));
- }
- window_manager_client_->SetBlockingContainers(
- std::move(transport_all_blocking_containers),
- base::BindOnce(&OnAckMustSucceed, FROM_HERE));
-}
-
-void WindowTreeClient::GetWindowManager(
- mojo::AssociatedInterfaceRequest<WindowManager> internal) {
- window_manager_internal_.reset(
- new mojo::AssociatedBinding<ui::mojom::WindowManager>(
- this, std::move(internal)));
}
void WindowTreeClient::GetScreenProviderObserver(
- ui::mojom::ScreenProviderObserverAssociatedRequest observer) {
- DCHECK_EQ(Config::kMus2, config_);
+ ws::mojom::ScreenProviderObserverAssociatedRequest observer) {
screen_provider_observer_binding_.Bind(std::move(observer));
}
void WindowTreeClient::OnDisplaysChanged(
- std::vector<ui::mojom::WsDisplayPtr> ws_displays,
+ std::vector<ws::mojom::WsDisplayPtr> ws_displays,
int64_t primary_display_id,
- int64_t internal_display_id) {
+ int64_t internal_display_id,
+ int64_t display_id_for_new_windows) {
got_initial_displays_ = true;
delegate_->OnDisplaysChanged(std::move(ws_displays), primary_display_id,
- internal_display_id);
+ internal_display_id, display_id_for_new_windows);
}
-void WindowTreeClient::RequestClose(ui::Id window_id) {
+void WindowTreeClient::RequestClose(ws::Id window_id) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window || !IsRoot(window))
return;
@@ -1958,527 +1550,14 @@ void WindowTreeClient::RequestClose(ui::Id window_id) {
GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest();
}
-bool WindowTreeClient::WaitForInitialDisplays() {
- if (got_initial_displays_)
- return true;
-
- bool valid_wait = true;
- // TODO(sky): having to block here is not ideal. http://crbug.com/594852.
- while (!got_initial_displays_ && valid_wait)
- valid_wait = binding_.WaitForIncomingMethodCall();
- return valid_wait;
-}
-
-WindowTreeHostMusInitParams WindowTreeClient::CreateInitParamsForNewDisplay() {
- WindowTreeHostMusInitParams init_params;
- init_params.window_port = std::make_unique<WindowPortMus>(
- this, WindowMusType::DISPLAY_MANUALLY_CREATED);
- roots_.insert(init_params.window_port.get());
- init_params.window_tree_client = this;
- return init_params;
-}
-
-void WindowTreeClient::OnConnect() {
- got_initial_displays_ = true;
- if (window_manager_delegate_)
- window_manager_delegate_->OnWmConnected();
-}
-
-void WindowTreeClient::WmOnAcceleratedWidgetForDisplay(
- int64_t display,
- gpu::SurfaceHandle surface_handle) {
- if (window_manager_delegate_) {
- window_manager_delegate_->OnWmAcceleratedWidgetAvailableForDisplay(
- display, surface_handle);
- }
-}
-
-void WindowTreeClient::WmNewDisplayAdded(
- const display::Display& display,
- ui::mojom::WindowDataPtr root_data,
- bool parent_drawn,
- const base::Optional<viz::LocalSurfaceId>& local_surface_id) {
- WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn,
- local_surface_id);
-}
-
-void WindowTreeClient::WmDisplayRemoved(int64_t display_id) {
- DCHECK(window_manager_delegate_);
- for (WindowMus* root : roots_) {
- DCHECK(root->GetWindow()->GetHost());
- WindowTreeHostMus* window_tree_host =
- static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost());
- if (window_tree_host->display_id() == display_id) {
- window_manager_delegate_->OnWmDisplayRemoved(window_tree_host);
- return;
- }
- }
-}
-
-void WindowTreeClient::WmDisplayModified(const display::Display& display) {
- DCHECK(window_manager_delegate_);
- // TODO(sky): this should likely route to WindowTreeHost.
- window_manager_delegate_->OnWmDisplayModified(display);
-}
-
-void WindowTreeClient::WmSetBounds(uint32_t change_id,
- ui::Id window_id,
- const gfx::Rect& transit_bounds_in_pixels) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- WindowMus* window = GetWindowByServerId(window_id);
- if (window) {
- float device_scale_factor = window->GetDeviceScaleFactor();
- DCHECK(window_manager_delegate_);
- gfx::Rect transit_bounds_in_dip =
- gfx::ConvertRectToDIP(device_scale_factor, transit_bounds_in_pixels);
- window_manager_delegate_->OnWmSetBounds(window->GetWindow(),
- transit_bounds_in_dip);
- } else {
- DVLOG(1) << "Unknown window passed to WmSetBounds().";
- }
- if (window_manager_client_)
- window_manager_client_->WmSetBoundsResponse(change_id);
-}
-
-void WindowTreeClient::WmSetProperty(
- uint32_t change_id,
- ui::Id window_id,
- const std::string& name,
- const base::Optional<std::vector<uint8_t>>& transit_data) {
- WindowMus* window = GetWindowByServerId(window_id);
- bool result = false;
- if (window) {
- DCHECK(window_manager_delegate_);
- std::unique_ptr<std::vector<uint8_t>> data;
- if (transit_data.has_value())
- data.reset(new std::vector<uint8_t>(transit_data.value()));
-
- result = window_manager_delegate_->OnWmSetProperty(window->GetWindow(),
- name, &data);
- if (result) {
- delegate_->GetPropertyConverter()->SetPropertyFromTransportValue(
- window->GetWindow(), name, data.get());
- }
- }
- if (window_manager_client_)
- window_manager_client_->WmResponse(change_id, result);
-}
-
-void WindowTreeClient::WmSetModalType(ui::Id window_id, ui::ModalType type) {
- WindowMus* window = GetWindowByServerId(window_id);
- if (window)
- window_manager_delegate_->OnWmSetModalType(window->GetWindow(), type);
-}
-
-void WindowTreeClient::WmSetCanFocus(ui::Id window_id, bool can_focus) {
- WindowMus* window = GetWindowByServerId(window_id);
- if (window)
- window_manager_delegate_->OnWmSetCanFocus(window->GetWindow(), can_focus);
-}
-
-void WindowTreeClient::WmCreateTopLevelWindow(
- uint32_t change_id,
- const viz::FrameSinkId& frame_sink_id,
- const base::flat_map<std::string, std::vector<uint8_t>>&
- transport_properties) {
- DCHECK(frame_sink_id.is_valid());
- std::map<std::string, std::vector<uint8_t>> properties =
- mojo::FlatMapToMap(transport_properties);
- ui::mojom::WindowType window_type = GetWindowTypeFromProperties(properties);
- Window* window = window_manager_delegate_->OnWmCreateTopLevelWindow(
- window_type, &properties);
- if (!window) {
- window_manager_client_->OnWmCreatedTopLevelWindow(change_id,
- kInvalidServerId);
- return;
- }
- embedded_windows_[base::checked_cast<ui::ClientSpecificId>(
- frame_sink_id.client_id())]
- .insert(window);
- if (window_manager_client_) {
- window_manager_client_->OnWmCreatedTopLevelWindow(
- change_id, WindowMus::Get(window)->server_id());
- OnFrameSinkIdAllocated(WindowMus::Get(window)->server_id(), frame_sink_id);
- }
-}
-
-void WindowTreeClient::WmClientJankinessChanged(ui::ClientSpecificId client_id,
- bool janky) {
- if (window_manager_delegate_) {
- auto it = embedded_windows_.find(client_id);
- // TODO(sky): early return necessitated because of http://crbug.com/766890.
- if (it == embedded_windows_.end())
- return;
- window_manager_delegate_->OnWmClientJankinessChanged(
- embedded_windows_[client_id], janky);
- }
-}
-
-void WindowTreeClient::WmBuildDragImage(const gfx::Point& screen_location,
- const gfx::ImageSkia& drag_image,
- const gfx::Vector2d& drag_image_offset,
- ui::mojom::PointerKind source) {
- if (!window_manager_delegate_)
- return;
-
- window_manager_delegate_->OnWmBuildDragImage(screen_location, drag_image,
- drag_image_offset, source);
-}
-
-void WindowTreeClient::WmMoveDragImage(const gfx::Point& screen_location,
- WmMoveDragImageCallback callback) {
- if (window_manager_delegate_)
- window_manager_delegate_->OnWmMoveDragImage(screen_location);
- std::move(callback).Run();
-}
-
-void WindowTreeClient::WmDestroyDragImage() {
- if (!window_manager_delegate_)
- return;
-
- window_manager_delegate_->OnWmDestroyDragImage();
-}
-
-void WindowTreeClient::WmPerformMoveLoop(uint32_t change_id,
- ui::Id window_id,
- ui::mojom::MoveLoopSource source,
- const gfx::Point& cursor_location) {
- if (!window_manager_delegate_ || current_wm_move_loop_change_ != 0) {
- OnWmMoveLoopCompleted(change_id, false);
- return;
- }
-
- current_wm_move_loop_change_ = change_id;
- current_wm_move_loop_window_id_ = window_id;
- WindowMus* window = GetWindowByServerId(window_id);
- if (window) {
- window_manager_delegate_->OnWmPerformMoveLoop(
- window->GetWindow(), source, cursor_location,
- base::Bind(&WindowTreeClient::OnWmMoveLoopCompleted,
- weak_factory_.GetWeakPtr(), change_id));
- } else {
- OnWmMoveLoopCompleted(change_id, false);
- }
-}
-
-void WindowTreeClient::WmCancelMoveLoop(uint32_t change_id) {
- if (!window_manager_delegate_ || change_id != current_wm_move_loop_change_)
- return;
-
- WindowMus* window = GetWindowByServerId(current_wm_move_loop_window_id_);
- if (window)
- window_manager_delegate_->OnWmCancelMoveLoop(window->GetWindow());
-}
-
-void WindowTreeClient::WmDeactivateWindow(ui::Id window_id) {
- if (!window_manager_delegate_)
- return;
-
- WindowMus* window = GetWindowByServerId(window_id);
- if (!window) {
- DVLOG(1) << "Attempt to deactivate invalid window " << window_id;
- return;
- }
-
- if (!window_manager_delegate_->IsWindowActive(window->GetWindow())) {
- DVLOG(1) << "Non-active window requested deactivation.";
- return;
- }
-
- window_manager_delegate_->OnWmDeactivateWindow(window->GetWindow());
-}
-
-void WindowTreeClient::WmStackAbove(uint32_t wm_change_id,
- ui::Id above_id,
- ui::Id below_id) {
- if (!window_manager_delegate_)
- return;
-
- WindowMus* below_mus = GetWindowByServerId(below_id);
- if (!below_mus) {
- DVLOG(1) << "Attempt to stack at top invalid window " << below_id;
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, false);
- return;
- }
-
- WindowMus* above_mus = GetWindowByServerId(above_id);
- if (!above_mus) {
- DVLOG(1) << "Attempt to stack at top invalid window " << above_id;
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, false);
- return;
- }
-
- Window* above = above_mus->GetWindow();
- Window* below = below_mus->GetWindow();
-
- if (above->parent() != below->parent()) {
- DVLOG(1) << "Windows do not share the same parent";
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, false);
- return;
- }
-
- above->parent()->StackChildAbove(above, below);
-
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, true);
-}
-
-void WindowTreeClient::WmStackAtTop(uint32_t wm_change_id, ui::Id window_id) {
- if (!window_manager_delegate_)
- return;
-
- WindowMus* window = GetWindowByServerId(window_id);
- if (!window) {
- DVLOG(1) << "Attempt to stack at top invalid window " << window_id;
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, false);
- return;
- }
-
- Window* parent = window->GetWindow()->parent();
- parent->StackChildAtTop(window->GetWindow());
-
- if (window_manager_client_)
- window_manager_client_->WmResponse(wm_change_id, true);
-}
-
-void WindowTreeClient::WmPerformWmAction(ui::Id window_id,
- const std::string& action) {
- if (!window_manager_delegate_)
- return;
-
- WindowMus* window = GetWindowByServerId(window_id);
- if (window)
- window_manager_delegate_->OnWmPerformAction(window->GetWindow(), action);
-}
-
-void WindowTreeClient::OnAccelerator(uint32_t ack_id,
- uint32_t accelerator_id,
- std::unique_ptr<ui::Event> event) {
- DCHECK(event);
- base::flat_map<std::string, std::vector<uint8_t>> properties;
- const ui::mojom::EventResult result = window_manager_delegate_->OnAccelerator(
- accelerator_id, *event.get(), &properties);
- if (ack_id && window_manager_client_)
- window_manager_client_->OnAcceleratorAck(ack_id, result, properties);
-}
-
-void WindowTreeClient::OnCursorTouchVisibleChanged(bool enabled) {
- if (window_manager_client_)
- window_manager_delegate_->OnCursorTouchVisibleChanged(enabled);
-}
-
-void WindowTreeClient::OnEventBlockedByModalWindow(ui::Id window_id) {
- if (!window_manager_delegate_)
- return;
-
- WindowMus* window = GetWindowByServerId(window_id);
- if (window)
- window_manager_delegate_->OnEventBlockedByModalWindow(window->GetWindow());
-}
-
-void WindowTreeClient::SetFrameDecorationValues(
- ui::mojom::FrameDecorationValuesPtr values) {
- if (window_manager_client_) {
- normal_client_area_insets_ = values->normal_client_area_insets;
- window_manager_client_->WmSetFrameDecorationValues(std::move(values));
- }
-}
-
-void WindowTreeClient::SetNonClientCursor(Window* window,
- const ui::CursorData& cursor) {
- if (window_manager_client_) {
- window_manager_client_->WmSetNonClientCursor(
- WindowMus::Get(window)->server_id(), cursor);
- }
-}
-
-void WindowTreeClient::AddAccelerators(
- std::vector<ui::mojom::WmAcceleratorPtr> accelerators,
- const base::Callback<void(bool)>& callback) {
- if (window_manager_client_) {
- window_manager_client_->AddAccelerators(std::move(accelerators), callback);
- }
-}
-
-void WindowTreeClient::RemoveAccelerator(uint32_t id) {
- if (window_manager_client_) {
- window_manager_client_->RemoveAccelerator(id);
- }
-}
-
-void WindowTreeClient::AddActivationParent(Window* window) {
- if (window_manager_client_) {
- window_manager_client_->AddActivationParent(
- WindowMus::Get(window)->server_id());
- }
-}
-
-void WindowTreeClient::RemoveActivationParent(Window* window) {
- if (window_manager_client_) {
- window_manager_client_->RemoveActivationParent(
- WindowMus::Get(window)->server_id());
- }
-}
-
-void WindowTreeClient::SetExtendedHitRegionForChildren(
- Window* window,
- const gfx::Insets& mouse_insets,
- const gfx::Insets& touch_insets) {
- if (!window_manager_client_)
- return;
-
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- WindowMus* window_mus = WindowMus::Get(window);
- const float device_scale_factor = window_mus->GetDeviceScaleFactor();
- window_manager_client_->SetExtendedHitRegionForChildren(
- window_mus->server_id(),
- gfx::ConvertInsetsToPixel(device_scale_factor, mouse_insets),
- gfx::ConvertInsetsToPixel(device_scale_factor, touch_insets));
-}
-
-void WindowTreeClient::LockCursor() {
- if (window_manager_client_)
- window_manager_client_->WmLockCursor();
-}
-
-void WindowTreeClient::UnlockCursor() {
- if (window_manager_client_)
- window_manager_client_->WmUnlockCursor();
-}
-
-void WindowTreeClient::SetCursorVisible(bool visible) {
- if (window_manager_client_)
- window_manager_client_->WmSetCursorVisible(visible);
-}
-
-void WindowTreeClient::SetCursorSize(ui::CursorSize cursor_size) {
- if (window_manager_client_)
- window_manager_client_->WmSetCursorSize(cursor_size);
-}
-
-void WindowTreeClient::SetGlobalOverrideCursor(
- base::Optional<ui::CursorData> cursor) {
- if (window_manager_client_)
- window_manager_client_->WmSetGlobalOverrideCursor(std::move(cursor));
-}
-
-void WindowTreeClient::SetCursorTouchVisible(bool enabled) {
- if (window_manager_client_)
- window_manager_client_->WmSetCursorTouchVisible(enabled);
-}
-
-void WindowTreeClient::InjectEvent(const ui::Event& event, int64_t display_id) {
- if (!event_injector_)
- connector()->BindInterface(ui::mojom::kServiceName, &event_injector_);
- // Check event_injector_ so we don't crash if access to the interface was
- // refused.
- if (event_injector_) {
- event_injector_->InjectEvent(display_id, ui::Event::Clone(event),
- base::DoNothing());
- }
-}
-
-void WindowTreeClient::SetKeyEventsThatDontHideCursor(
- std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) {
- if (window_manager_client_) {
- window_manager_client_->SetKeyEventsThatDontHideCursor(
- std::move(cursor_key_list));
- }
-}
-
-void WindowTreeClient::RequestClose(Window* window) {
- DCHECK(window);
- if (window_manager_client_)
- window_manager_client_->WmRequestClose(WindowMus::Get(window)->server_id());
-}
-
-void WindowTreeClient::SetDisplayConfiguration(
- const std::vector<display::Display>& displays,
- std::vector<ui::mojom::WmViewportMetricsPtr> viewport_metrics,
- int64_t primary_display_id,
- const std::vector<display::Display>& mirrors) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- DCHECK_EQ(displays.size() + mirrors.size(), viewport_metrics.size());
- if (window_manager_client_) {
- const int64_t internal_display_id =
- display::Display::HasInternalDisplay()
- ? display::Display::InternalDisplayId()
- : display::kInvalidDisplayId;
- window_manager_client_->SetDisplayConfiguration(
- displays, std::move(viewport_metrics), primary_display_id,
- internal_display_id, mirrors,
- base::BindOnce(&OnAckMustSucceed, FROM_HERE));
- }
-}
-
-void WindowTreeClient::AddDisplayReusingWindowTreeHost(
- WindowTreeHostMus* window_tree_host,
- const display::Display& display,
- ui::mojom::WmViewportMetricsPtr viewport_metrics) {
- // TODO(sky): this function should be removed when --mash goes away.
- // https://crbug.com/842365.
- DCHECK_NE(display.id(), window_tree_host->display_id());
- window_tree_host->set_display_id(display.id());
- if (window_manager_client_) {
- // NOTE: The values of |is_primary_display| and |mirrors| do not matter,
- // because SetDisplayConfiguration() is called shortly after this completes.
- const bool is_primary_display = true;
- std::vector<display::Display> mirrors;
- WindowMus* display_root_window = WindowMus::Get(window_tree_host->window());
- window_manager_client_->SetDisplayRoot(
- display, std::move(viewport_metrics), is_primary_display,
- display_root_window->server_id(), mirrors,
- base::BindOnce(&OnAckMustSucceed, FROM_HERE));
- window_tree_host->compositor()->SetLocalSurfaceId(
- display_root_window->GetOrAllocateLocalSurfaceId(
- window_tree_host->GetBoundsInPixels().size()));
- }
-}
-
-void WindowTreeClient::SwapDisplayRoots(WindowTreeHostMus* window_tree_host1,
- WindowTreeHostMus* window_tree_host2) {
- DCHECK_NE(window_tree_host1, window_tree_host2);
- const int64_t display_id1 = window_tree_host1->display_id();
- const int64_t display_id2 = window_tree_host2->display_id();
- DCHECK_NE(display_id1, display_id2);
- window_tree_host1->set_display_id(display_id2);
- window_tree_host2->set_display_id(display_id1);
-
- // Swap the accelerated widgets so each host paints to the correct display.
- gfx::AcceleratedWidget widget1 = window_tree_host1->GetAcceleratedWidget();
- gfx::AcceleratedWidget widget2 = window_tree_host2->GetAcceleratedWidget();
- window_tree_host1->OverrideAcceleratedWidget(widget2);
- window_tree_host2->OverrideAcceleratedWidget(widget1);
-
- if (window_manager_client_) {
- window_manager_client_->SwapDisplayRoots(
- display_id1, display_id2, base::BindOnce(&OnAckMustSucceed, FROM_HERE));
- }
-}
-
void WindowTreeClient::OnWindowTreeHostBoundsWillChange(
WindowTreeHostMus* window_tree_host,
const gfx::Rect& bounds_in_pixels) {
gfx::Rect old_bounds = window_tree_host->GetBoundsInPixels();
gfx::Rect new_bounds = bounds_in_pixels;
- if (!is_using_pixels()) {
- const float device_scale_factor = window_tree_host->device_scale_factor();
- old_bounds = gfx::ConvertRectToDIP(device_scale_factor, old_bounds);
- new_bounds = gfx::ConvertRectToDIP(device_scale_factor, new_bounds);
- }
- if (window_manager_delegate_) {
- // The window manager origins should always be 0x0. The real origin is
- // communicated by way of SetDisplayConfiguration().
- old_bounds.set_origin(gfx::Point());
- new_bounds.set_origin(gfx::Point());
- }
+ const float device_scale_factor = window_tree_host->device_scale_factor();
+ old_bounds = gfx::ConvertRectToDIP(device_scale_factor, old_bounds);
+ new_bounds = gfx::ConvertRectToDIP(device_scale_factor, new_bounds);
ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()),
old_bounds, new_bounds);
}
@@ -2489,21 +1568,8 @@ void WindowTreeClient::OnWindowTreeHostClientAreaWillChange(
const std::vector<gfx::Rect>& additional_client_areas) {
DCHECK(tree_);
WindowMus* window = WindowMus::Get(window_tree_host->window());
- if (is_using_pixels()) {
- const float device_scale_factor = window->GetDeviceScaleFactor();
- std::vector<gfx::Rect> additional_client_areas_in_pixels;
- for (const gfx::Rect& area : additional_client_areas) {
- additional_client_areas_in_pixels.push_back(
- gfx::ConvertRectToPixel(device_scale_factor, area));
- }
- tree_->SetClientArea(
- window->server_id(),
- gfx::ConvertInsetsToPixel(device_scale_factor, client_area),
- additional_client_areas_in_pixels);
- } else {
- tree_->SetClientArea(window->server_id(), client_area,
- additional_client_areas);
- }
+ tree_->SetClientArea(window->server_id(), client_area,
+ additional_client_areas);
}
void WindowTreeClient::OnWindowTreeHostSetOpacity(
@@ -2548,7 +1614,7 @@ void WindowTreeClient::OnWindowTreeHostPerformWmAction(
void WindowTreeClient::OnWindowTreeHostPerformWindowMove(
WindowTreeHostMus* window_tree_host,
- ui::mojom::MoveLoopSource source,
+ ws::mojom::MoveLoopSource source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& callback) {
DCHECK(on_current_move_finished_.is_null());
@@ -2568,26 +1634,6 @@ void WindowTreeClient::OnWindowTreeHostCancelWindowMove(
WindowMus::Get(window_tree_host->window())->server_id());
}
-void WindowTreeClient::OnWindowTreeHostMoveCursorToDisplayLocation(
- const gfx::Point& location_in_pixels,
- int64_t display_id) {
- DCHECK(window_manager_client_);
- if (window_manager_client_) {
- window_manager_client_->WmMoveCursorToDisplayLocation(location_in_pixels,
- display_id);
- }
-}
-
-void WindowTreeClient::OnWindowTreeHostConfineCursorToBounds(
- const gfx::Rect& bounds_in_pixels,
- int64_t display_id) {
- DCHECK(window_manager_client_);
- if (window_manager_client_) {
- window_manager_client_->WmConfineCursorToBounds(bounds_in_pixels,
- display_id);
- }
-}
-
std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
const std::map<std::string, std::vector<uint8_t>>* properties) {
std::unique_ptr<WindowPortMus> window_port =
diff --git a/chromium/ui/aura/mus/window_tree_client.h b/chromium/ui/aura/mus/window_tree_client.h
index 70f07169653..f4d0931ed3e 100644
--- a/chromium/ui/aura/mus/window_tree_client.h
+++ b/chromium/ui/aura/mus/window_tree_client.h
@@ -21,19 +21,16 @@
#include "base/observer_list.h"
#include "base/optional.h"
#include "base/single_thread_task_runner.h"
-#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "services/ui/public/interfaces/event_injector.mojom.h"
-#include "services/ui/public/interfaces/screen_provider.mojom.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "services/ws/public/mojom/screen_provider_observer.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/client/transient_window_client_observer.h"
#include "ui/aura/mus/capture_synchronizer_delegate.h"
#include "ui/aura/mus/drag_drop_controller_host.h"
#include "ui/aura/mus/focus_synchronizer_delegate.h"
#include "ui/aura/mus/mus_types.h"
-#include "ui/aura/mus/window_manager_delegate.h"
#include "ui/aura/mus/window_tree_host_mus_delegate.h"
#include "ui/base/ui_base_types.h"
@@ -45,24 +42,19 @@ namespace discardable_memory {
class ClientDiscardableSharedMemoryManager;
}
-namespace display {
-class Display;
-}
-
-namespace gfx {
-class Insets;
-}
-
namespace service_manager {
class Connector;
}
namespace ui {
class ContextFactory;
-class Gpu;
struct PropertyData;
}
+namespace ws {
+class Gpu;
+}
+
namespace aura {
class CaptureSynchronizer;
class DragDropControllerMus;
@@ -74,8 +66,8 @@ class InFlightChange;
class InFlightFocusChange;
class InFlightPropertyChange;
class InFlightVisibleChange;
-class PlatformEventSourceMus;
class MusContextFactory;
+class TopmostWindowTracker;
class WindowMus;
class WindowPortMus;
class WindowTreeClientDelegate;
@@ -84,7 +76,7 @@ class WindowTreeClientObserver;
class WindowTreeClientTestObserver;
class WindowTreeHostMus;
-using EventResultCallback = base::OnceCallback<void(ui::mojom::EventResult)>;
+using EventResultCallback = base::OnceCallback<void(ws::mojom::EventResult)>;
// Used to enable Aura to act as the client-library for the Window Service.
//
@@ -97,42 +89,19 @@ using EventResultCallback = base::OnceCallback<void(ui::mojom::EventResult)>;
// When WindowTreeClient is deleted all windows are deleted (and observers
// notified).
class AURA_EXPORT WindowTreeClient
- : public ui::mojom::WindowTreeClient,
- public ui::mojom::WindowManager,
- public ui::mojom::ScreenProviderObserver,
+ : public ws::mojom::WindowTreeClient,
+ public ws::mojom::ScreenProviderObserver,
public CaptureSynchronizerDelegate,
public FocusSynchronizerDelegate,
public DragDropControllerHost,
- public WindowManagerClient,
public WindowTreeHostMusDelegate,
public client::TransientWindowClientObserver {
public:
- // TODO(sky): remove Config. https://crbug.com/842365.
- enum class Config {
- kMashDeprecated,
-
- // kMus2 targets ws2. services/ui/Service and services/ui/ws2/WindowService
- // provide an implementation of the same mojom interfaces, but differ in a
- // few key areas (such as whether pixels vs dips are used). The Config
- // parameter controls which server is being used.
- kMus2,
- };
-
- // Creates a WindowTreeClient to act as the window manager. See mojom for
- // details on |automatically_create_display_roots|.
- // TODO(sky): move |create_discardable_memory| out of this class.
- static std::unique_ptr<WindowTreeClient> CreateForWindowManager(
- service_manager::Connector* connector,
- WindowTreeClientDelegate* delegate,
- WindowManagerDelegate* window_manager_delegate,
- bool automatically_create_display_roots = true,
- bool create_discardable_memory = true);
-
// Creates a WindowTreeClient for use in embedding.
static std::unique_ptr<WindowTreeClient> CreateForEmbedding(
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
- ui::mojom::WindowTreeClientRequest request,
+ ws::mojom::WindowTreeClientRequest request,
bool create_discardable_memory = true);
// Creates a WindowTreeClient useful for creating top-level windows.
@@ -140,24 +109,10 @@ class AURA_EXPORT WindowTreeClient
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
bool create_discardable_memory = true,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr,
- Config config = Config::kMashDeprecated);
-
- // Creates a WindowTreeClient such that the Window Service creates a single
- // WindowTreeHost. This is useful for testing and examples.
- static std::unique_ptr<WindowTreeClient> CreateForWindowTreeHostFactory(
- service_manager::Connector* connector,
- WindowTreeClientDelegate* delegate,
- bool create_discardable_memory = true);
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr);
~WindowTreeClient() override;
- // Returns true if the server coordinate system is in pixels. If false, the
- // coordinate system is DIPs.
- bool is_using_pixels() const { return config_ != Config::kMus2; }
-
- Config config() const { return config_; }
-
service_manager::Connector* connector() { return connector_; }
CaptureSynchronizer* capture_synchronizer() {
return capture_synchronizer_.get();
@@ -172,7 +127,7 @@ class AURA_EXPORT WindowTreeClient
void SetCanFocus(Window* window, bool can_focus);
void SetCanAcceptDrops(WindowMus* window, bool can_accept_drops);
void SetEventTargetingPolicy(WindowMus* window,
- ui::mojom::EventTargetingPolicy policy);
+ ws::mojom::EventTargetingPolicy policy);
void SetCursor(WindowMus* window,
const ui::CursorData& old_cursor,
const ui::CursorData& new_cursor);
@@ -188,25 +143,25 @@ class AURA_EXPORT WindowTreeClient
// whether the embedding succeeded or failed and may be called immediately if
// the embedding is known to fail.
void Embed(Window* window,
- ui::mojom::WindowTreeClientPtr client,
+ ws::mojom::WindowTreeClientPtr client,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback);
+ ws::mojom::WindowTree::EmbedCallback callback);
void EmbedUsingToken(Window* window,
const base::UnguessableToken& token,
uint32_t flags,
- ui::mojom::WindowTree::EmbedCallback callback);
+ ws::mojom::WindowTree::EmbedCallback callback);
// Schedules an embed of a client. See
- // mojom::WindowTreeClient::ScheduleEmbed() for details.
+ // ws::mojom::WindowTreeClient::ScheduleEmbed() for details.
void ScheduleEmbed(
- ui::mojom::WindowTreeClientPtr client,
+ ws::mojom::WindowTreeClientPtr client,
base::OnceCallback<void(const base::UnguessableToken&)> callback);
// Creates a new EmbedRoot. See EmbedRoot for details.
std::unique_ptr<EmbedRoot> CreateEmbedRoot(EmbedRootDelegate* delegate);
void AttachCompositorFrameSink(
- ui::Id window_id,
+ ws::Id window_id,
viz::mojom::CompositorFrameSinkRequest compositor_frame_sink,
viz::mojom::CompositorFrameSinkClientPtr client);
@@ -215,6 +170,13 @@ class AURA_EXPORT WindowTreeClient
// Returns the root of this connection.
std::set<Window*> GetRoots();
+ // Start observing the topmost window at the cursor. The topmost window is
+ // tracked by the returned object. |source| specifies the event source which
+ // causes this, and |initial_target| specifies the target window of the event.
+ std::unique_ptr<TopmostWindowTracker> StartObservingTopmostWindow(
+ ws::mojom::MoveLoopSource source,
+ aura::Window* initial_target);
+
// Returns true if the specified window was created by this client.
bool WasCreatedByThisClient(const WindowMus* window) const;
@@ -241,6 +203,7 @@ class AURA_EXPORT WindowTreeClient
friend class InFlightPropertyChange;
friend class InFlightTransformChange;
friend class InFlightVisibleChange;
+ friend class TopmostWindowTracker;
friend class WindowPortMus;
friend class WindowTreeClientPrivate;
@@ -249,7 +212,7 @@ class AURA_EXPORT WindowTreeClient
SERVER,
};
- using IdToWindowMap = std::map<ui::Id, WindowMus*>;
+ using IdToWindowMap = std::map<ws::Id, WindowMus*>;
// TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>;
@@ -261,37 +224,16 @@ class AURA_EXPORT WindowTreeClient
WindowTreeClient(
service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
- WindowManagerDelegate* window_manager_delegate = nullptr,
- ui::mojom::WindowTreeClientRequest request = nullptr,
+ ws::mojom::WindowTreeClientRequest request = nullptr,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr,
- bool create_discardable_memory = true,
- Config config = Config::kMashDeprecated);
-
- // Creates a PlatformEventSourceMus if not created yet.
- void CreatePlatformEventSourceIfNecessary();
+ bool create_discardable_memory = true);
void RegisterWindowMus(WindowMus* window);
- WindowMus* GetWindowByServerId(ui::Id id);
+ WindowMus* GetWindowByServerId(ws::Id id);
bool IsWindowKnown(aura::Window* window);
- // Updates the coordinates of |event| to be in DIPs. |window| is the source
- // of the event, and may be null. A null |window| means either there is no
- // local window the event is targeted at *or* |window| was valid at the time
- // the event was generated at the server but was deleted locally before the
- // event was received.
- void ConvertPointerEventLocationToDip(int64_t display_id,
- WindowMus* window,
- ui::LocatedEvent* event) const;
-
- // Variant of ConvertPointerEventLocationToDip() that is used when in
- // the window-manager.
- void ConvertPointerEventLocationToDipInWindowManager(
- int64_t display_id,
- WindowMus* window,
- ui::LocatedEvent* event) const;
-
// Returns the oldest InFlightChange that matches |change|.
InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change);
@@ -304,44 +246,41 @@ class AURA_EXPORT WindowTreeClient
// See InFlightChange for details on how InFlightChanges are used.
bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change);
- void BuildWindowTree(const std::vector<ui::mojom::WindowDataPtr>& windows);
+ void BuildWindowTree(const std::vector<ws::mojom::WindowDataPtr>& windows);
// If the window identified by |window_data| doesn't exist a new window is
// created, otherwise the existing window is updated based on |window_data|.
void CreateOrUpdateWindowFromWindowData(
- const ui::mojom::WindowData& window_data);
+ const ws::mojom::WindowData& window_data);
// Creates a WindowPortMus from the server side data.
std::unique_ptr<WindowPortMus> CreateWindowPortMus(
- const ui::mojom::WindowData& window_data,
+ const ws::mojom::WindowData& window_data,
WindowMusType window_mus_type);
// Sets local properties on the associated Window from the server properties.
void SetLocalPropertiesFromServerProperties(
WindowMus* window,
- const ui::mojom::WindowData& window_data);
-
- const WindowTreeHostMus* GetWindowTreeHostForDisplayId(
- int64_t display_id) const;
+ const ws::mojom::WindowData& window_data);
// Creates a new WindowTreeHostMus.
std::unique_ptr<WindowTreeHostMus> CreateWindowTreeHost(
WindowMusType window_mus_type,
- const ui::mojom::WindowData& window_data,
+ const ws::mojom::WindowData& window_data,
int64_t display_id,
const base::Optional<viz::LocalSurfaceId>& local_surface_id =
base::nullopt);
WindowMus* NewWindowFromWindowData(WindowMus* parent,
- const ui::mojom::WindowData& window_data);
+ const ws::mojom::WindowData& window_data);
- // Sets the ui::mojom::WindowTree implementation.
- void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr);
+ // Sets the ws::mojom::WindowTree implementation.
+ void SetWindowTree(ws::mojom::WindowTreePtr window_tree_ptr);
// Called when the connection to the server is established.
- void WindowTreeConnectionEstablished(ui::mojom::WindowTree* window_tree);
+ void WindowTreeConnectionEstablished(ws::mojom::WindowTree* window_tree);
- // Called when the ui::mojom::WindowTree connection is lost, deletes this.
+ // Called when the ws::mojom::WindowTree connection is lost, deletes this.
void OnConnectionLost();
// Called when a Window property changes. If |key| is handled internally
@@ -351,10 +290,10 @@ class AURA_EXPORT WindowTreeClient
int64_t old_value);
// OnEmbed() calls into this. Exposed as a separate function for testing.
- void OnEmbedImpl(ui::mojom::WindowTree* window_tree,
- ui::mojom::WindowDataPtr root_data,
+ void OnEmbedImpl(ws::mojom::WindowTree* window_tree,
+ ws::mojom::WindowDataPtr root_data,
int64_t display_id,
- ui::Id focused_window_id,
+ ws::Id focused_window_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id);
@@ -364,13 +303,6 @@ class AURA_EXPORT WindowTreeClient
// Called from EmbedRoot's destructor.
void OnEmbedRootDestroyed(EmbedRoot* embed_root);
- // Called by WmNewDisplayAdded().
- WindowTreeHostMus* WmNewDisplayAddedImpl(
- const display::Display& display,
- ui::mojom::WindowDataPtr root_data,
- bool parent_drawn,
- const base::Optional<viz::LocalSurfaceId>& local_surface_id);
-
EventResultCallback CreateEventResultCallback(int32_t event_id);
void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle);
@@ -385,6 +317,14 @@ class AURA_EXPORT WindowTreeClient
const gfx::Transform& transform);
void SetWindowVisibleFromServer(WindowMus* window, bool visible);
+ // Stop observing the topmost window at the cursor. This deletes the
+ // TopmostWindowTracker.
+ void StopObservingTopmostWindow();
+
+ void NotifyPointerEventObserved(ui::PointerEvent* event,
+ uint64_t display_id,
+ WindowMus* window_mus);
+
// Called from OnWindowMusBoundsChanged() and SetRootWindowBounds().
void ScheduleInFlightBoundsChange(WindowMus* window,
const gfx::Rect& old_bounds,
@@ -412,101 +352,88 @@ class AURA_EXPORT WindowTreeClient
const void* key,
int64_t old_value,
std::unique_ptr<ui::PropertyData> data);
- void OnWindowMusDeviceScaleFactorChanged(WindowMus* window,
- float old_scale_factor,
- float new_scale_factor);
-
- // Callback passed from WmPerformMoveLoop().
- void OnWmMoveLoopCompleted(uint32_t change_id, bool completed);
// Overridden from WindowTreeClient:
void OnEmbed(
- ui::mojom::WindowDataPtr root,
- ui::mojom::WindowTreePtr tree,
+ ws::mojom::WindowDataPtr root,
+ ws::mojom::WindowTreePtr tree,
int64_t display_id,
- ui::Id focused_window_id,
+ ws::Id focused_window_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
void OnEmbedFromToken(
const base::UnguessableToken& token,
- ui::mojom::WindowDataPtr root,
+ ws::mojom::WindowDataPtr root,
int64_t display_id,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
- void OnEmbeddedAppDisconnected(ui::Id window_id) override;
- void OnUnembed(ui::Id window_id) override;
- void OnCaptureChanged(ui::Id new_capture_window_id,
- ui::Id old_capture_window_id) override;
- void OnFrameSinkIdAllocated(ui::Id window_id,
+ void OnEmbeddedAppDisconnected(ws::Id window_id) override;
+ void OnUnembed(ws::Id window_id) override;
+ void OnCaptureChanged(ws::Id new_capture_window_id,
+ ws::Id old_capture_window_id) override;
+ void OnFrameSinkIdAllocated(ws::Id window_id,
const viz::FrameSinkId& frame_sink_id) override;
void OnTopLevelCreated(
uint32_t change_id,
- ui::mojom::WindowDataPtr data,
+ ws::mojom::WindowDataPtr data,
int64_t display_id,
bool drawn,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
void OnWindowBoundsChanged(
- ui::Id window_id,
+ ws::Id window_id,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
- void OnWindowTransformChanged(ui::Id window_id,
+ void OnWindowTransformChanged(ws::Id window_id,
const gfx::Transform& old_transform,
const gfx::Transform& new_transform) override;
- void OnClientAreaChanged(
- ui::Id window_id,
- const gfx::Insets& new_client_area,
- const std::vector<gfx::Rect>& new_additional_client_areas) override;
- void OnTransientWindowAdded(ui::Id window_id,
- ui::Id transient_window_id) override;
- void OnTransientWindowRemoved(ui::Id window_id,
- ui::Id transient_window_id) override;
+ void OnTransientWindowAdded(ws::Id window_id,
+ ws::Id transient_window_id) override;
+ void OnTransientWindowRemoved(ws::Id window_id,
+ ws::Id transient_window_id) override;
void OnWindowHierarchyChanged(
- ui::Id window_id,
- ui::Id old_parent_id,
- ui::Id new_parent_id,
- std::vector<ui::mojom::WindowDataPtr> windows) override;
- void OnWindowReordered(ui::Id window_id,
- ui::Id relative_window_id,
- ui::mojom::OrderDirection direction) override;
- void OnWindowDeleted(ui::Id window_id) override;
- void OnWindowVisibilityChanged(ui::Id window_id, bool visible) override;
- void OnWindowOpacityChanged(ui::Id window_id,
+ ws::Id window_id,
+ ws::Id old_parent_id,
+ ws::Id new_parent_id,
+ std::vector<ws::mojom::WindowDataPtr> windows) override;
+ void OnWindowReordered(ws::Id window_id,
+ ws::Id relative_window_id,
+ ws::mojom::OrderDirection direction) override;
+ void OnWindowDeleted(ws::Id window_id) override;
+ void OnWindowVisibilityChanged(ws::Id window_id, bool visible) override;
+ void OnWindowOpacityChanged(ws::Id window_id,
float old_opacity,
float new_opacity) override;
- void OnWindowParentDrawnStateChanged(ui::Id window_id, bool drawn) override;
+ void OnWindowParentDrawnStateChanged(ws::Id window_id, bool drawn) override;
void OnWindowSharedPropertyChanged(
- ui::Id window_id,
+ ws::Id window_id,
const std::string& name,
const base::Optional<std::vector<uint8_t>>& transport_data) override;
- void OnWindowInputEvent(
- uint32_t event_id,
- ui::Id window_id,
- int64_t display_id,
- ui::Id display_root_window_id,
- const gfx::PointF& event_location_in_screen_pixel_layout,
- std::unique_ptr<ui::Event> event,
- bool matches_pointer_watcher) override;
+ void OnWindowInputEvent(uint32_t event_id,
+ ws::Id window_id,
+ int64_t display_id,
+ std::unique_ptr<ui::Event> event,
+ bool matches_pointer_watcher) override;
void OnPointerEventObserved(std::unique_ptr<ui::Event> event,
- ui::Id window_id,
+ ws::Id window_id,
int64_t display_id) override;
- void OnWindowFocused(ui::Id focused_window_id) override;
- void OnWindowCursorChanged(ui::Id window_id, ui::CursorData cursor) override;
- void OnWindowSurfaceChanged(ui::Id window_id,
+ void OnWindowFocused(ws::Id focused_window_id) override;
+ void OnWindowCursorChanged(ws::Id window_id, ui::CursorData cursor) override;
+ void OnWindowSurfaceChanged(ws::Id window_id,
const viz::SurfaceInfo& surface_info) override;
void OnDragDropStart(const base::flat_map<std::string, std::vector<uint8_t>>&
mime_data) override;
- void OnDragEnter(ui::Id window_id,
+ void OnDragEnter(ws::Id window_id,
uint32_t event_flags,
const gfx::Point& position,
uint32_t effect_bitmask,
OnDragEnterCallback callback) override;
- void OnDragOver(ui::Id window_id,
+ void OnDragOver(ws::Id window_id,
uint32_t event_flags,
const gfx::Point& position,
uint32_t effect_bitmask,
OnDragOverCallback callback) override;
- void OnDragLeave(ui::Id window_id) override;
- void OnCompleteDrop(ui::Id window_id,
+ void OnDragLeave(ws::Id window_id) override;
+ void OnCompleteDrop(ws::Id window_id,
uint32_t event_flags,
const gfx::Point& position,
uint32_t effect_bitmask,
@@ -515,110 +442,17 @@ class AURA_EXPORT WindowTreeClient
bool success,
uint32_t action_taken) override;
void OnDragDropDone() override;
+ void OnTopmostWindowChanged(const std::vector<ws::Id>& topmost_ids) override;
void OnChangeCompleted(uint32_t change_id, bool success) override;
- void RequestClose(ui::Id window_id) override;
- void SetBlockingContainers(
- const std::vector<BlockingContainers>& all_blocking_containers) override;
- void GetWindowManager(
- mojo::AssociatedInterfaceRequest<WindowManager> internal) override;
+ void RequestClose(ws::Id window_id) override;
void GetScreenProviderObserver(
- ui::mojom::ScreenProviderObserverAssociatedRequest observer) override;
+ ws::mojom::ScreenProviderObserverAssociatedRequest observer) override;
- // ui::mojom::ScreenProviderObserver:
- void OnDisplaysChanged(std::vector<ui::mojom::WsDisplayPtr> ws_displays,
+ // ws::mojom::ScreenProviderObserver:
+ void OnDisplaysChanged(std::vector<ws::mojom::WsDisplayPtr> ws_displays,
int64_t primary_display_id,
- int64_t internal_display_id) override;
-
- // Overridden from WindowManager:
- void OnConnect() override;
- void WmOnAcceleratedWidgetForDisplay(
- int64_t display,
- gpu::SurfaceHandle surface_handle) override;
- void WmNewDisplayAdded(
- const display::Display& display,
- ui::mojom::WindowDataPtr root_data,
- bool parent_drawn,
- const base::Optional<viz::LocalSurfaceId>& local_surface_id) override;
- void WmDisplayRemoved(int64_t display_id) override;
- void WmDisplayModified(const display::Display& display) override;
- void WmSetBounds(uint32_t change_id,
- ui::Id window_id,
- const gfx::Rect& transit_bounds_in_pixels) override;
- void WmSetProperty(
- uint32_t change_id,
- ui::Id window_id,
- const std::string& name,
- const base::Optional<std::vector<uint8_t>>& transit_data) override;
- void WmSetModalType(ui::Id window_id, ui::ModalType type) override;
- void WmSetCanFocus(ui::Id window_id, bool can_focus) override;
- void WmCreateTopLevelWindow(
- uint32_t change_id,
- const viz::FrameSinkId& frame_sink_id,
- const base::flat_map<std::string, std::vector<uint8_t>>&
- transport_properties) override;
- void WmClientJankinessChanged(ui::ClientSpecificId client_id,
- bool janky) override;
- void WmBuildDragImage(const gfx::Point& screen_location,
- const gfx::ImageSkia& drag_image,
- const gfx::Vector2d& drag_image_offset,
- ui::mojom::PointerKind source) override;
- void WmMoveDragImage(const gfx::Point& screen_location,
- WmMoveDragImageCallback callback) override;
- void WmDestroyDragImage() override;
- void WmPerformMoveLoop(uint32_t change_id,
- ui::Id window_id,
- ui::mojom::MoveLoopSource source,
- const gfx::Point& cursor_location) override;
- void WmCancelMoveLoop(uint32_t change_id) override;
- void WmDeactivateWindow(ui::Id window_id) override;
- void WmStackAbove(uint32_t change_id,
- ui::Id above_id,
- ui::Id below_id) override;
- void WmStackAtTop(uint32_t change_id, ui::Id window_id) override;
- void WmPerformWmAction(ui::Id window_id, const std::string& action) override;
- void OnAccelerator(uint32_t ack_id,
- uint32_t accelerator_id,
- std::unique_ptr<ui::Event> event) override;
- void OnCursorTouchVisibleChanged(bool enabled) override;
- void OnEventBlockedByModalWindow(ui::Id window_id) override;
-
- // Overridden from WindowManagerClient:
- void SetFrameDecorationValues(
- ui::mojom::FrameDecorationValuesPtr values) override;
- void SetNonClientCursor(Window* window,
- const ui::CursorData& cursor) override;
- void AddAccelerators(std::vector<ui::mojom::WmAcceleratorPtr> accelerators,
- const base::Callback<void(bool)>& callback) override;
- void RemoveAccelerator(uint32_t id) override;
- void AddActivationParent(Window* window) override;
- void RemoveActivationParent(Window* window) override;
- void SetExtendedHitRegionForChildren(
- Window* window,
- const gfx::Insets& mouse_insets,
- const gfx::Insets& touch_insets) override;
- void LockCursor() override;
- void UnlockCursor() override;
- void SetCursorVisible(bool visible) override;
- void SetCursorSize(ui::CursorSize cursor_size) override;
- void SetGlobalOverrideCursor(base::Optional<ui::CursorData> cursor) override;
- void SetCursorTouchVisible(bool enabled) override;
- void InjectEvent(const ui::Event& event, int64_t display_id) override;
- void SetKeyEventsThatDontHideCursor(
- std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) override;
- void RequestClose(Window* window) override;
- bool WaitForInitialDisplays() override;
- WindowTreeHostMusInitParams CreateInitParamsForNewDisplay() override;
- void SetDisplayConfiguration(
- const std::vector<display::Display>& displays,
- std::vector<ui::mojom::WmViewportMetricsPtr> viewport_metrics,
- int64_t primary_display_id,
- const std::vector<display::Display>& mirrors) override;
- void AddDisplayReusingWindowTreeHost(
- WindowTreeHostMus* window_tree_host,
- const display::Display& display,
- ui::mojom::WmViewportMetricsPtr viewport_metrics) override;
- void SwapDisplayRoots(WindowTreeHostMus* window_tree_host1,
- WindowTreeHostMus* window_tree_host2) override;
+ int64_t internal_display_id,
+ int64_t display_id_for_new_windows) override;
// Overriden from WindowTreeHostMusDelegate:
void OnWindowTreeHostBoundsWillChange(
@@ -639,16 +473,11 @@ class AURA_EXPORT WindowTreeClient
const std::string& action) override;
void OnWindowTreeHostPerformWindowMove(
WindowTreeHostMus* window_tree_host,
- ui::mojom::MoveLoopSource mus_source,
+ ws::mojom::MoveLoopSource mus_source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& callback) override;
void OnWindowTreeHostCancelWindowMove(
WindowTreeHostMus* window_tree_host) override;
- void OnWindowTreeHostMoveCursorToDisplayLocation(
- const gfx::Point& location_in_pixels,
- int64_t display_id) override;
- void OnWindowTreeHostConfineCursorToBounds(const gfx::Rect& bounds_in_pixels,
- int64_t display_id) override;
std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel(
const std::map<std::string, std::vector<uint8_t>>* properties) override;
void OnWindowTreeHostCreated(WindowTreeHostMus* window_tree_host) override;
@@ -675,13 +504,11 @@ class AURA_EXPORT WindowTreeClient
cursor_location_mapping_.get());
}
- const Config config_;
-
// This may be null in tests.
service_manager::Connector* connector_;
// Id assigned to the next window created.
- ui::ClientSpecificId next_window_id_;
+ ws::ClientSpecificId next_window_id_;
// Id used for the next change id supplied to the server.
uint32_t next_change_id_;
@@ -689,46 +516,34 @@ class AURA_EXPORT WindowTreeClient
WindowTreeClientDelegate* delegate_;
- WindowManagerDelegate* window_manager_delegate_;
-
std::set<WindowMus*> roots_;
base::flat_set<EmbedRoot*> embed_roots_;
IdToWindowMap windows_;
- std::map<ui::ClientSpecificId, std::set<Window*>> embedded_windows_;
std::unique_ptr<CaptureSynchronizer> capture_synchronizer_;
std::unique_ptr<FocusSynchronizer> focus_synchronizer_;
- mojo::Binding<ui::mojom::WindowTreeClient> binding_;
- ui::mojom::WindowTreePtr tree_ptr_;
+ mojo::Binding<ws::mojom::WindowTreeClient> binding_;
+ ws::mojom::WindowTreePtr tree_ptr_;
// Typically this is the value contained in |tree_ptr_|, but tests may
// directly set this.
- ui::mojom::WindowTree* tree_;
+ ws::mojom::WindowTree* tree_;
// Set to true if OnEmbed() was received.
bool is_from_embed_ = false;
bool in_destructor_;
+ TopmostWindowTracker* topmost_window_tracker_ = nullptr;
+
// A mapping to shared memory that is one 32 bit integer long. The window
// server uses this to let us synchronously read the cursor location.
mojo::ScopedSharedBufferMapping cursor_location_mapping_;
- base::ObserverList<WindowTreeClientObserver> observers_;
-
- std::unique_ptr<mojo::AssociatedBinding<ui::mojom::WindowManager>>
- window_manager_internal_;
- ui::mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_;
- // Normally the same as |window_manager_internal_client_|. Tests typically
- // run without a service_manager::Connector, which means this (and
- // |window_manager_internal_client_|) are null. Tests that need to test
- // WindowManagerClient set this, but not |window_manager_internal_client_|.
- ui::mojom::WindowManagerClient* window_manager_client_ = nullptr;
-
- ui::mojom::EventInjectorPtr event_injector_;
+ base::ObserverList<WindowTreeClientObserver>::Unchecked observers_;
bool has_pointer_watcher_ = false;
@@ -739,18 +554,14 @@ class AURA_EXPORT WindowTreeClient
// completed.
base::Callback<void(bool)> on_current_move_finished_;
- // The current change id for the window manager.
- uint32_t current_wm_move_loop_change_ = 0u;
- ui::Id current_wm_move_loop_window_id_ = 0u;
-
std::unique_ptr<DragDropControllerMus> drag_drop_controller_;
- base::ObserverList<WindowTreeClientTestObserver> test_observers_;
+ base::ObserverList<WindowTreeClientTestObserver>::Unchecked test_observers_;
// IO thread for GPU and discardable shared memory IPC.
std::unique_ptr<base::Thread> io_thread_;
- std::unique_ptr<ui::Gpu> gpu_;
+ std::unique_ptr<ws::Gpu> gpu_;
std::unique_ptr<MusContextFactory> compositor_context_factory_;
std::unique_ptr<discardable_memory::ClientDiscardableSharedMemoryManager>
@@ -763,15 +574,9 @@ class AURA_EXPORT WindowTreeClient
// Set to true once OnWmDisplayAdded() is called.
bool got_initial_displays_ = false;
- gfx::Insets normal_client_area_insets_;
-
bool in_shutdown_ = false;
-#if defined(USE_OZONE)
- std::unique_ptr<PlatformEventSourceMus> platform_event_source_;
-#endif
-
- mojo::AssociatedBinding<ui::mojom::ScreenProviderObserver>
+ mojo::AssociatedBinding<ws::mojom::ScreenProviderObserver>
screen_provider_observer_binding_{this};
base::WeakPtrFactory<WindowTreeClient> weak_factory_;
diff --git a/chromium/ui/aura/mus/window_tree_client_delegate.h b/chromium/ui/aura/mus/window_tree_client_delegate.h
index 4d8bb3e3ad1..0ac318a0e2f 100644
--- a/chromium/ui/aura/mus/window_tree_client_delegate.h
+++ b/chromium/ui/aura/mus/window_tree_client_delegate.h
@@ -12,8 +12,8 @@
#include <vector>
#include "services/service_manager/public/mojom/interface_provider.mojom.h"
-#include "services/ui/public/interfaces/screen_provider.mojom.h"
-#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "services/ws/public/mojom/screen_provider_observer.mojom.h"
+#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/aura_export.h"
namespace aura {
@@ -60,17 +60,18 @@ class AURA_EXPORT WindowTreeClientDelegate {
// StartPointerWatcher(). |target| may be null for events that were sent to
// windows owned by other processes.
virtual void OnPointerEventObserved(const ui::PointerEvent& event,
- int64_t display_id,
+ const gfx::Point& location_in_screen,
Window* target) = 0;
virtual PropertyConverter* GetPropertyConverter() = 0;
- // See ui::mojom::ScreenProviderObserver for details on this.
+ // See ws::mojom::ScreenProviderObserver for details on this.
// TODO(sky): consider moving ScreenMus from views to aura.
virtual void OnDisplaysChanged(
- std::vector<ui::mojom::WsDisplayPtr> ws_displays,
+ std::vector<ws::mojom::WsDisplayPtr> ws_displays,
int64_t primary_display_id,
- int64_t internal_display_id) {}
+ int64_t internal_display_id,
+ int64_t display_id_for_new_windows) {}
protected:
virtual ~WindowTreeClientDelegate() {}
diff --git a/chromium/ui/aura/mus/window_tree_client_unittest.cc b/chromium/ui/aura/mus/window_tree_client_unittest.cc
index 131dfe1b600..e8c841cb632 100644
--- a/chromium/ui/aura/mus/window_tree_client_unittest.cc
+++ b/chromium/ui/aura/mus/window_tree_client_unittest.cc
@@ -15,14 +15,15 @@
#include "cc/base/switches.h"
#include "components/viz/common/surfaces/surface_info.h"
#include "mojo/public/cpp/bindings/map.h"
-#include "services/ui/public/cpp/property_type_converters.h"
-#include "services/ui/public/interfaces/window_manager.mojom.h"
+#include "services/ws/public/cpp/property_type_converters.h"
+#include "services/ws/public/mojom/window_manager.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/capture_client_observer.h"
#include "ui/aura/client/default_capture_client.h"
#include "ui/aura/client/focus_client.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/transient_window_client.h"
#include "ui/aura/mus/capture_synchronizer.h"
#include "ui/aura/mus/client_surface_embedder.h"
@@ -37,9 +38,9 @@
#include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "ui/aura/test/aura_mus_test_base.h"
-#include "ui/aura/test/aura_test_suite.h"
#include "ui/aura/test/mus/test_window_tree.h"
#include "ui/aura/test/mus/window_tree_client_private.h"
+#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_window_targeter.h"
#include "ui/aura/window.h"
@@ -55,8 +56,6 @@
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
-#include "ui/events/platform/platform_event_observer.h"
-#include "ui/events/platform/platform_event_source.h"
#include "ui/events/test/test_event_handler.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/rect.h"
@@ -74,15 +73,15 @@ const char kTestPropertyServerKey1[] = "test-property-server1";
const char kTestPropertyServerKey2[] = "test-property-server2";
const char kTestPropertyServerKey3[] = "test-property-server3";
-ui::Id server_id(Window* window) {
+ws::Id server_id(Window* window) {
return window ? WindowMus::Get(window)->server_id() : 0;
}
std::unique_ptr<Window> CreateWindowUsingId(
WindowTreeClient* window_tree_client,
- ui::Id server_id,
+ ws::Id server_id,
Window* parent = nullptr) {
- ui::mojom::WindowData window_data;
+ ws::mojom::WindowData window_data;
window_data.window_id = server_id;
WindowMus* window_mus =
WindowTreeClientPrivate(window_tree_client)
@@ -122,34 +121,47 @@ std::vector<uint8_t> ConvertToPropertyTransportValue(int64_t value) {
return mojo::ConvertTo<std::vector<uint8_t>>(value);
}
-WindowTreeHostMusInitParams CreateWindowTreeHostMusInitParams(
- WindowTreeClient* window_tree_client,
- const gfx::Rect& bounds,
- int64_t display_id) {
- std::unique_ptr<DisplayInitParams> display_params =
- std::make_unique<DisplayInitParams>();
- display_params->display = std::make_unique<display::Display>(display_id);
- display_params->display->set_bounds(bounds);
- display_params->viewport_metrics.bounds_in_pixels = bounds;
- display_params->viewport_metrics.device_scale_factor = 1.0f;
- display_params->viewport_metrics.ui_scale_factor = 1.0f;
- WindowTreeHostMusInitParams init_params =
- WindowTreeClientPrivate(window_tree_client)
- .CallCreateInitParamsForNewDisplay();
- init_params.use_classic_ime = true;
- init_params.display_id = display_params->display->id();
- init_params.display_init_params = std::move(display_params);
- return init_params;
+class TestScreenPositionClient : public client::ScreenPositionClient {
+ public:
+ TestScreenPositionClient() = default;
+ ~TestScreenPositionClient() override = default;
+
+ private:
+ // ScreenPositionClient:
+ void ConvertPointToScreen(const Window* window, gfx::PointF* point) override {
+ const Window* root_window = window->GetRootWindow();
+ Window::ConvertPointToTarget(window, root_window, point);
+ gfx::Rect bounds = root_window->GetHost()->GetBoundsInPixels();
+ point->Offset(bounds.x(), bounds.y());
+ }
+ void ConvertPointFromScreen(const Window* window,
+ gfx::PointF* point) override {
+ // unused.
+ }
+ void ConvertHostPointToScreen(Window* root_window,
+ gfx::Point* point) override {
+ // unused.
+ }
+ void SetBounds(Window* window,
+ const gfx::Rect& bounds,
+ const display::Display& display) override {
+ // unused.
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(TestScreenPositionClient);
+};
+
+void OnWindowMoveDone(int* call_count, bool* last_result, bool result) {
+ (*call_count)++;
+ *last_result = result;
}
} // namespace
-using WindowTreeClientWmTest = test::AuraMusWmTestBase;
-
-class WindowTreeClientClientTest : public test::AuraMusClientTestBase {
+class WindowTreeClientTest : public test::AuraMusClientTestBase {
public:
- WindowTreeClientClientTest() = default;
- ~WindowTreeClientClientTest() override = default;
+ WindowTreeClientTest() = default;
+ ~WindowTreeClientTest() override = default;
struct TopLevel {
std::unique_ptr<client::DefaultCaptureClient> capture_client;
@@ -174,7 +186,7 @@ class WindowTreeClientClientTest : public test::AuraMusClientTestBase {
WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
EXPECT_EQ(window_tree()->window_id(), server_id(top_level_window));
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(top_level_window);
data->visible = true;
window_tree_client()->OnTopLevelCreated(
@@ -188,75 +200,59 @@ class WindowTreeClientClientTest : public test::AuraMusClientTestBase {
private:
int64_t next_display_id_ = 1;
- DISALLOW_COPY_AND_ASSIGN(WindowTreeClientClientTest);
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest);
};
-class WindowTreeClientWmTestSurfaceSync
- : public WindowTreeClientWmTest,
+class WindowTreeClientTestSurfaceSync
+ : public WindowTreeClientTest,
public ::testing::WithParamInterface<bool> {
public:
- WindowTreeClientWmTestSurfaceSync() {}
- ~WindowTreeClientWmTestSurfaceSync() override {}
+ WindowTreeClientTestSurfaceSync() {}
+ ~WindowTreeClientTestSurfaceSync() override {}
- // WindowTreeClientWmTest:
+ // WindowTreeClientTest:
void SetUp() override {
if (GetParam()) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kForceDeviceScaleFactor, "2");
}
- WindowTreeClientWmTest::SetUp();
+ WindowTreeClientTest::SetUp();
}
private:
- DISALLOW_COPY_AND_ASSIGN(WindowTreeClientWmTestSurfaceSync);
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTestSurfaceSync);
};
-// WindowTreeClientWmTest with --force-device-scale-factor=2.
-class WindowTreeClientWmTestHighDPI : public WindowTreeClientWmTest {
+// WindowTreeClientTest with --force-device-scale-factor=2.
+class WindowTreeClientTestHighDPI : public WindowTreeClientTest {
public:
- WindowTreeClientWmTestHighDPI() {}
- ~WindowTreeClientWmTestHighDPI() override {}
-
- // WindowTreeClientWmTest:
- void SetUp() override {
- base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kForceDeviceScaleFactor, "2");
- WindowTreeClientWmTest::SetUp();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WindowTreeClientWmTestHighDPI);
-};
-
-// WindowTreeClientClientTest with --force-device-scale-factor=2.
-class WindowTreeClientClientTestHighDPI : public WindowTreeClientClientTest {
- public:
- WindowTreeClientClientTestHighDPI() {}
- ~WindowTreeClientClientTestHighDPI() override {}
+ WindowTreeClientTestHighDPI() {}
+ ~WindowTreeClientTestHighDPI() override {}
const ui::PointerEvent* last_event_observed() const {
return last_event_observed_.get();
}
- // WindowTreeClientClientTest:
+ // WindowTreeClientTest:
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kForceDeviceScaleFactor, "2");
- WindowTreeClientClientTest::SetUp();
+ WindowTreeClientTest::SetUp();
}
void OnPointerEventObserved(const ui::PointerEvent& event,
- int64_t display_id,
+ const gfx::Point& location_in_screen,
Window* target) override {
last_event_observed_.reset(new ui::PointerEvent(event));
}
private:
std::unique_ptr<ui::PointerEvent> last_event_observed_;
- DISALLOW_COPY_AND_ASSIGN(WindowTreeClientClientTestHighDPI);
+
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTestHighDPI);
};
// Verifies bounds are reverted if the server replied that the change failed.
-TEST_F(WindowTreeClientWmTest, SetBoundsFailed) {
+TEST_F(WindowTreeClientTest, SetBoundsFailed) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
const gfx::Rect original_bounds(window.bounds());
@@ -271,7 +267,7 @@ TEST_F(WindowTreeClientWmTest, SetBoundsFailed) {
// Verifies bounds and the viz::LocalSurfaceId associated with the bounds are
// reverted if the server replied that the change failed.
-TEST_F(WindowTreeClientWmTest, SetBoundsFailedLocalSurfaceId) {
+TEST_F(WindowTreeClientTest, SetBoundsFailedLocalSurfaceId) {
Window window(nullptr);
// TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate viz::LocalSurfaceIds
// when their sizes change.
@@ -296,7 +292,7 @@ TEST_F(WindowTreeClientWmTest, SetBoundsFailedLocalSurfaceId) {
}
INSTANTIATE_TEST_CASE_P(/* no prefix */,
- WindowTreeClientWmTestSurfaceSync,
+ WindowTreeClientTestSurfaceSync,
::testing::Bool());
namespace {
@@ -324,14 +320,13 @@ class FirstSurfaceActivationWindowDelegate : public test::TestWindowDelegate {
// Verifies that a ClientSurfaceEmbedder is created for a window once it has
// a bounds, and a valid FrameSinkId.
-TEST_P(WindowTreeClientWmTestSurfaceSync,
- ClientSurfaceEmbedderOnValidEmbedding) {
+TEST_P(WindowTreeClientTestSurfaceSync, ClientSurfaceEmbedderOnValidEmbedding) {
FirstSurfaceActivationWindowDelegate delegate;
Window window(&delegate);
- // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate viz::LocalSurfaceIds
- // when their sizes change.
+ // EMBED_IN_OWNER windows allocate viz::LocalSurfaceIds when their sizes
+ // change.
window.SetProperty(aura::client::kEmbedType,
- aura::client::WindowEmbedType::TOP_LEVEL_IN_WM);
+ aura::client::WindowEmbedType::EMBED_IN_OWNER);
window.Init(ui::LAYER_NOT_DRAWN);
// The window will allocate a viz::LocalSurfaceId once it has a bounds.
@@ -359,16 +354,6 @@ TEST_P(WindowTreeClientWmTestSurfaceSync,
ASSERT_NE(nullptr, client_surface_embedder);
EXPECT_FALSE(delegate.last_surface_info().is_valid());
- // Until the fallback surface fills the window, we will have gutter.
- {
- ui::Layer* right_gutter = client_surface_embedder->RightGutterForTesting();
- ASSERT_NE(nullptr, right_gutter);
- EXPECT_EQ(gfx::Rect(100, 100), right_gutter->bounds());
- // We don't have a bottom gutter if the fallback surface size is (0, 0) as
- // the right gutter will fill the whole area.
- ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting());
- }
-
// When a SurfaceInfo arrives from the window server, we use it as the
// fallback SurfaceInfo. Here we issue the primary SurfaceId back to the
// client lib. This should cause the gutter to go away, eliminating overdraw.
@@ -379,33 +364,10 @@ TEST_P(WindowTreeClientWmTestSurfaceSync,
EXPECT_TRUE(delegate.last_surface_info().is_valid());
EXPECT_EQ(delegate.last_surface_info().id(),
window_port_mus->PrimarySurfaceIdForTesting());
-
- // The gutter is gone.
- ASSERT_EQ(nullptr, client_surface_embedder->BottomGutterForTesting());
- ASSERT_EQ(nullptr, client_surface_embedder->RightGutterForTesting());
-
- // Resize again: we should have gutter.
- new_bounds.SetRect(0, 0, 150, 150);
- ASSERT_NE(new_bounds, window.bounds());
- window.SetBounds(new_bounds);
- ASSERT_NE(nullptr, client_surface_embedder->BottomGutterForTesting());
- ASSERT_NE(nullptr, client_surface_embedder->RightGutterForTesting());
-
- // Until the fallback surface fills the window, we will have gutter.
- {
- ui::Layer* right_gutter = client_surface_embedder->RightGutterForTesting();
- ASSERT_NE(nullptr, right_gutter);
- EXPECT_EQ(gfx::Rect(100, 0, 50, 150), right_gutter->bounds());
-
- ui::Layer* bottom_gutter =
- client_surface_embedder->BottomGutterForTesting();
- ASSERT_NE(nullptr, bottom_gutter);
- EXPECT_EQ(gfx::Rect(0, 100, 100, 50), bottom_gutter->bounds());
- }
}
// Verifies that EMBED_IN_OWNER windows do not gutter.
-TEST_P(WindowTreeClientWmTestSurfaceSync, NoEmbedInOwnerGutter) {
+TEST_P(WindowTreeClientTestSurfaceSync, NoEmbedInOwnerGutter) {
FirstSurfaceActivationWindowDelegate delegate;
Window window(&delegate);
// TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate viz::LocalSurfaceIds
@@ -445,7 +407,7 @@ TEST_P(WindowTreeClientWmTestSurfaceSync, NoEmbedInOwnerGutter) {
// Verifies that the viz::LocalSurfaceId generated by an embedder changes when
// the size changes, but not when the position changes.
-TEST_P(WindowTreeClientWmTestSurfaceSync, SetBoundsLocalSurfaceIdChanges) {
+TEST_P(WindowTreeClientTestSurfaceSync, SetBoundsLocalSurfaceIdChanges) {
ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id());
Window window(nullptr);
// TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate viz::LocalSurfaceIds
@@ -488,14 +450,14 @@ TEST_P(WindowTreeClientWmTestSurfaceSync, SetBoundsLocalSurfaceIdChanges) {
// Verifies a new window from the server doesn't result in attempting to add
// the window back to the server.
-TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) {
- const ui::Id child_window_id = server_id(root_window()) + 11;
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+TEST_F(WindowTreeClientTest, AddFromServerDoesntAddAgain) {
+ const ws::Id child_window_id = server_id(root_window()) + 11;
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->parent_id = server_id(root_window());
data->window_id = child_window_id;
data->bounds = gfx::Rect(1, 2, 3, 4);
data->visible = false;
- std::vector<ui::mojom::WindowDataPtr> data_array(1);
+ std::vector<ws::mojom::WindowDataPtr> data_array(1);
data_array[0] = std::move(data);
ASSERT_TRUE(root_window()->children().empty());
window_tree_client()->OnWindowHierarchyChanged(
@@ -507,7 +469,7 @@ TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) {
}
// Verifies a reparent from the server doesn't attempt signal the server.
-TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) {
+TEST_F(WindowTreeClientTest, ReparentFromServerDoesntAddAgain) {
Window window1(nullptr);
window1.Init(ui::LAYER_NOT_DRAWN);
Window window2(nullptr);
@@ -519,7 +481,7 @@ TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) {
// Simulate moving |window1| to be a child of |window2| from the server.
window_tree_client()->OnWindowHierarchyChanged(
server_id(&window1), server_id(root_window()), server_id(&window2),
- std::vector<ui::mojom::WindowDataPtr>());
+ std::vector<ws::mojom::WindowDataPtr>());
ASSERT_FALSE(window_tree()->has_change());
EXPECT_EQ(&window2, window1.parent());
EXPECT_EQ(root_window(), window2.parent());
@@ -528,25 +490,25 @@ TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) {
// Verifies properties passed in OnWindowHierarchyChanged() make there way to
// the new window.
-TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
+TEST_F(WindowTreeClientTest, OnWindowHierarchyChangedWithProperties) {
RegisterTestProperties(GetPropertyConverter());
window_tree()->AckAllChanges();
- const ui::Id child_window_id = server_id(root_window()) + 11;
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ const ws::Id child_window_id = server_id(root_window()) + 11;
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
const uint8_t server_test_property1_value = 91;
data->properties[kTestPropertyServerKey1] =
ConvertToPropertyTransportValue(server_test_property1_value);
- data->properties[ui::mojom::WindowManager::kWindowType_InitProperty] =
+ data->properties[ws::mojom::WindowManager::kWindowType_InitProperty] =
mojo::ConvertTo<std::vector<uint8_t>>(
- static_cast<int32_t>(ui::mojom::WindowType::BUBBLE));
+ static_cast<int32_t>(ws::mojom::WindowType::BUBBLE));
constexpr int kWindowCornerRadiusValue = 6;
- data->properties[ui::mojom::WindowManager::kWindowCornerRadius_Property] =
+ data->properties[ws::mojom::WindowManager::kWindowCornerRadius_Property] =
ConvertToPropertyTransportValue(kWindowCornerRadiusValue);
data->parent_id = server_id(root_window());
data->window_id = child_window_id;
data->bounds = gfx::Rect(1, 2, 3, 4);
data->visible = false;
- std::vector<ui::mojom::WindowDataPtr> data_array(1);
+ std::vector<ws::mojom::WindowDataPtr> data_array(1);
data_array[0] = std::move(data);
ASSERT_TRUE(root_window()->children().empty());
window_tree_client()->OnWindowHierarchyChanged(
@@ -559,12 +521,12 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
EXPECT_EQ(kWindowCornerRadiusValue,
child->GetProperty(client::kWindowCornerRadiusKey));
EXPECT_EQ(child->type(), client::WINDOW_TYPE_POPUP);
- EXPECT_EQ(ui::mojom::WindowType::BUBBLE,
+ EXPECT_EQ(ws::mojom::WindowType::BUBBLE,
child->GetProperty(client::kWindowTypeKey));
}
// Verifies a move from the server doesn't attempt signal the server.
-TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) {
+TEST_F(WindowTreeClientTest, MoveFromServerDoesntAddAgain) {
Window window1(nullptr);
window1.Init(ui::LAYER_NOT_DRAWN);
Window window2(nullptr);
@@ -576,14 +538,14 @@ TEST_F(WindowTreeClientWmTest, MoveFromServerDoesntAddAgain) {
// Simulate moving |window1| to be a child of |window2| from the server.
window_tree_client()->OnWindowReordered(server_id(&window2),
server_id(&window1),
- ui::mojom::OrderDirection::BELOW);
+ ws::mojom::OrderDirection::BELOW);
ASSERT_FALSE(window_tree()->has_change());
ASSERT_EQ(2u, root_window()->children().size());
EXPECT_EQ(&window2, root_window()->children()[0]);
EXPECT_EQ(&window1, root_window()->children()[1]);
}
-TEST_F(WindowTreeClientWmTest, FocusFromServer) {
+TEST_F(WindowTreeClientTest, FocusFromServer) {
Window window1(nullptr);
window1.Init(ui::LAYER_NOT_DRAWN);
Window window2(nullptr);
@@ -604,7 +566,7 @@ TEST_F(WindowTreeClientWmTest, FocusFromServer) {
// server replies with a new bounds and the original bounds change fails.
// The server bounds change takes hold along with the associated
// viz::LocalSurfaceId.
-TEST_F(WindowTreeClientClientTest, SetBoundsFailedWithPendingChange) {
+TEST_F(WindowTreeClientTest, SetBoundsFailedWithPendingChange) {
aura::Window root_window(nullptr);
root_window.Init(ui::LAYER_NOT_DRAWN);
const gfx::Rect original_bounds(root_window.bounds());
@@ -644,7 +606,7 @@ TEST_F(WindowTreeClientClientTest, SetBoundsFailedWithPendingChange) {
EXPECT_FALSE(root_window_mus->GetLocalSurfaceId().is_valid());
}
-TEST_F(WindowTreeClientClientTest, TwoInFlightBoundsChangesBothCanceled) {
+TEST_F(WindowTreeClientTest, TwoInFlightBoundsChangesBothCanceled) {
aura::Window root_window(nullptr);
root_window.Init(ui::LAYER_NOT_DRAWN);
const gfx::Rect original_bounds(root_window.bounds());
@@ -669,7 +631,7 @@ TEST_F(WindowTreeClientClientTest, TwoInFlightBoundsChangesBothCanceled) {
EXPECT_EQ(original_bounds, root_window.bounds());
}
-TEST_F(WindowTreeClientWmTest, TwoInFlightTransformsChangesBothCanceled) {
+TEST_F(WindowTreeClientTest, TwoInFlightTransformsChangesBothCanceled) {
const gfx::Transform original_transform(root_window()->layer()->transform());
gfx::Transform transform1;
transform1.Scale(SkIntToMScalar(2), SkIntToMScalar(2));
@@ -695,7 +657,7 @@ TEST_F(WindowTreeClientWmTest, TwoInFlightTransformsChangesBothCanceled) {
}
// Verifies properties are set if the server replied that the change succeeded.
-TEST_F(WindowTreeClientWmTest, SetPropertySucceeded) {
+TEST_F(WindowTreeClientTest, SetPropertySucceeded) {
ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
root_window()->SetProperty(client::kAlwaysOnTopKey, true);
EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
@@ -712,7 +674,7 @@ TEST_F(WindowTreeClientWmTest, SetPropertySucceeded) {
// Verifies properties are reverted if the server replied that the change
// failed.
-TEST_F(WindowTreeClientWmTest, SetPropertyFailed) {
+TEST_F(WindowTreeClientTest, SetPropertyFailed) {
ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
root_window()->SetProperty(client::kAlwaysOnTopKey, true);
EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
@@ -729,7 +691,7 @@ TEST_F(WindowTreeClientWmTest, SetPropertyFailed) {
// Simulates a property change, and while the property change is in flight the
// server replies with a new property and the original property change fails.
-TEST_F(WindowTreeClientWmTest, SetPropertyFailedWithPendingChange) {
+TEST_F(WindowTreeClientTest, SetPropertyFailedWithPendingChange) {
RegisterTestProperties(GetPropertyConverter());
const uint8_t value1 = 11;
root_window()->SetProperty(kTestPropertyKey1, value1);
@@ -758,7 +720,7 @@ TEST_F(WindowTreeClientWmTest, SetPropertyFailedWithPendingChange) {
}
// Verifies property setting behavior with failures for primitive properties.
-TEST_F(WindowTreeClientWmTest, SetPrimitiveProperties) {
+TEST_F(WindowTreeClientTest, SetPrimitiveProperties) {
PropertyConverter* property_converter = GetPropertyConverter();
RegisterTestProperties(property_converter);
@@ -796,7 +758,7 @@ TEST_F(WindowTreeClientWmTest, SetPrimitiveProperties) {
}
// Verifies property setting behavior for a gfx::Rect* property.
-TEST_F(WindowTreeClientWmTest, SetRectProperty) {
+TEST_F(WindowTreeClientTest, SetRectProperty) {
gfx::Rect example(1, 2, 3, 4);
ASSERT_EQ(nullptr, root_window()->GetProperty(client::kRestoreBoundsKey));
root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect(example));
@@ -818,7 +780,7 @@ TEST_F(WindowTreeClientWmTest, SetRectProperty) {
}
// Verifies property setting behavior for a std::string* property.
-TEST_F(WindowTreeClientWmTest, SetStringProperty) {
+TEST_F(WindowTreeClientTest, SetStringProperty) {
std::string example = "123";
ASSERT_NE(nullptr, root_window()->GetProperty(client::kNameKey));
root_window()->SetProperty(client::kNameKey, new std::string(example));
@@ -839,7 +801,7 @@ TEST_F(WindowTreeClientWmTest, SetStringProperty) {
}
// Verifies visible is reverted if the server replied that the change failed.
-TEST_F(WindowTreeClientWmTest, SetVisibleFailed) {
+TEST_F(WindowTreeClientTest, SetVisibleFailed) {
const bool original_visible = root_window()->TargetVisibility();
const bool new_visible = !original_visible;
SetWindowVisibility(root_window(), new_visible);
@@ -850,7 +812,7 @@ TEST_F(WindowTreeClientWmTest, SetVisibleFailed) {
// Simulates a visible change, and while the visible change is in flight the
// server replies with a new visible and the original visible change fails.
-TEST_F(WindowTreeClientWmTest, SetVisibleFailedWithPendingChange) {
+TEST_F(WindowTreeClientTest, SetVisibleFailedWithPendingChange) {
const bool original_visible = root_window()->TargetVisibility();
const bool new_visible = !original_visible;
SetWindowVisibility(root_window(), new_visible);
@@ -993,7 +955,7 @@ class InputEventBasicTestEventHandler : public ui::test::TestEventHandler {
} // namespace
-TEST_F(WindowTreeClientClientTest, InputEventBasic) {
+TEST_F(WindowTreeClientTest, InputEventBasic) {
InputEventBasicTestWindowDelegate window_delegate(window_tree());
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
@@ -1018,18 +980,17 @@ TEST_F(WindowTreeClientClientTest, InputEventBasic) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child,
gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location_in_child), ui::Event::Clone(*ui_event.get()),
- 0);
+ event_id, server_id(&child), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate.move_count());
EXPECT_FALSE(window_delegate.was_acked());
EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
}
-TEST_F(WindowTreeClientClientTest, InputEventPointerEvent) {
+TEST_F(WindowTreeClientTest, InputEventPointerEvent) {
InputEventBasicTestWindowDelegate window_delegate(window_tree());
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
@@ -1053,17 +1014,17 @@ TEST_F(WindowTreeClientClientTest, InputEventPointerEvent) {
ui::ET_POINTER_MOVED, event_location, gfx::Point(), ui::EF_NONE, 0,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0),
base::TimeTicks());
- window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(pointer_event), 0);
+ window_tree_client()->OnWindowInputEvent(event_id, server_id(&child),
+ window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate.move_count());
EXPECT_EQ(event_location, window_delegate.last_event_location());
}
-TEST_F(WindowTreeClientClientTest, InputEventPen) {
+TEST_F(WindowTreeClientTest, InputEventPen) {
// Create a root window.
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
@@ -1089,19 +1050,19 @@ TEST_F(WindowTreeClientClientTest, InputEventPen) {
ui::ET_POINTER_DOWN, event_location, gfx::Point(), ui::EF_NONE, 0,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 0),
ui::EventTimeForNow());
- window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(pointer_event), 0);
+ window_tree_client()->OnWindowInputEvent(event_id, server_id(&child),
+ window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event), 0);
// Pen event was handled.
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_PEN,
window_delegate.last_pointer_type());
}
-TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) {
+TEST_F(WindowTreeClientTest, InputEventFindTargetAndConversion) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
Window* top_level = window_tree_host.window();
@@ -1138,10 +1099,10 @@ TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child1), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(&child1), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(0, window_delegate1.move_count());
EXPECT_EQ(1, window_delegate2.move_count());
@@ -1159,17 +1120,17 @@ TEST_F(WindowTreeClientClientTest, InputEventFindTargetAndConversion) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child1), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event1.get()), 0);
+ event_id, server_id(&child1), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event1.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1.move_count());
EXPECT_EQ(0, window_delegate2.move_count());
EXPECT_EQ(gfx::Point(50, 60), window_delegate1.last_event_location());
}
-TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) {
+TEST_F(WindowTreeClientTest, InputEventCustomWindowTargeter) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
Window* top_level = window_tree_host.window();
@@ -1198,7 +1159,7 @@ TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) {
// child1 has a custom targeter set which would always return itself as the
// target window therefore event should go to child1 unlike
- // WindowTreeClientClientTest.InputEventFindTargetAndConversion.
+ // WindowTreeClientTest.InputEventFindTargetAndConversion.
const gfx::Point event_location(50, 60);
uint32_t event_id = 1;
window_delegate1.set_event_id(event_id);
@@ -1207,10 +1168,10 @@ TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, gfx::Point(),
ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child1), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(&child1), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1.move_count());
EXPECT_EQ(0, window_delegate2.move_count());
@@ -1224,17 +1185,17 @@ TEST_F(WindowTreeClientClientTest, InputEventCustomWindowTargeter) {
window_delegate1.set_event_id(event_id);
window_delegate2.set_event_id(event_id);
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child2), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(&child2), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1.move_count());
EXPECT_EQ(0, window_delegate2.move_count());
EXPECT_EQ(gfx::Point(70, 90), window_delegate1.last_event_location());
}
-TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) {
+TEST_F(WindowTreeClientTest, InputEventCaptureWindow) {
std::unique_ptr<WindowTreeHostMus> window_tree_host =
std::make_unique<WindowTreeHostMus>(
CreateInitParamsForTopLevel(window_tree_client_impl()));
@@ -1278,10 +1239,9 @@ TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) {
ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
event_id, server_id(child1.get()), window_tree_host->display_id(),
- ui::Id(), gfx::PointF(root_location), ui::Event::Clone(*ui_event.get()),
- 0);
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1->move_count());
EXPECT_EQ(0, window_delegate2->move_count());
@@ -1302,10 +1262,9 @@ TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) {
window_delegate2->set_event_id(event_id);
window_tree_client()->OnWindowInputEvent(
event_id, server_id(child1.get()), window_tree_host->display_id(),
- ui::Id(), gfx::PointF(root_location), ui::Event::Clone(*ui_event.get()),
- 0);
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(0, window_delegate1->move_count());
EXPECT_EQ(1, window_delegate2->move_count());
@@ -1319,7 +1278,7 @@ TEST_F(WindowTreeClientClientTest, InputEventCaptureWindow) {
capture_client.reset();
}
-TEST_F(WindowTreeClientClientTest, InputEventRootWindow) {
+TEST_F(WindowTreeClientTest, InputEventRootWindow) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
Window* top_level = window_tree_host.window();
@@ -1349,11 +1308,11 @@ TEST_F(WindowTreeClientClientTest, InputEventRootWindow) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child,
gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(top_level), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(top_level), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, root_handler.move_count());
EXPECT_EQ(gfx::Point(20, 30), root_handler.last_event_location());
@@ -1361,7 +1320,7 @@ TEST_F(WindowTreeClientClientTest, InputEventRootWindow) {
EXPECT_EQ(gfx::Point(), child_delegate.last_event_location());
}
-TEST_F(WindowTreeClientClientTest, InputMouseEventNoWindow) {
+TEST_F(WindowTreeClientTest, InputMouseEventNoWindow) {
Env* env = Env::GetInstance();
InputEventBasicTestWindowDelegate window_delegate(window_tree());
WindowTreeHostMus window_tree_host(
@@ -1393,10 +1352,10 @@ TEST_F(WindowTreeClientClientTest, InputMouseEventNoWindow) {
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0),
ui::EventTimeForNow());
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(pointer_event_down), 0);
+ event_id, server_id(&child), window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event_down), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate.press_count());
EXPECT_TRUE(env->IsMouseButtonDown());
@@ -1413,13 +1372,13 @@ TEST_F(WindowTreeClientClientTest, InputMouseEventNoWindow) {
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE, 0),
ui::EventTimeForNow());
window_tree_client()->OnWindowInputEvent(
- event_id, kInvalidServerId, window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(pointer_event_up), 0);
+ event_id, kInvalidServerId, window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event_up), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
// WindowTreeClient::OnWindowInputEvent cannot find a target window with
// kInvalidServerId but should use the event to update event states kept in
// aura::Env, location shouldn't be updated.
- EXPECT_EQ(ui::mojom::EventResult::UNHANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::UNHANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(0, window_delegate.release_count());
EXPECT_FALSE(env->IsMouseButtonDown());
@@ -1427,7 +1386,7 @@ TEST_F(WindowTreeClientClientTest, InputMouseEventNoWindow) {
EXPECT_EQ(event_location, env->last_mouse_location());
}
-TEST_F(WindowTreeClientClientTest, InputTouchEventNoWindow) {
+TEST_F(WindowTreeClientTest, InputTouchEventNoWindow) {
Env* env = Env::GetInstance();
InputEventBasicTestWindowDelegate window_delegate(window_tree());
WindowTreeHostMus window_tree_host(
@@ -1456,10 +1415,10 @@ TEST_F(WindowTreeClientClientTest, InputTouchEventNoWindow) {
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0),
ui::EventTimeForNow());
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(), ui::Event::Clone(pointer_event_down), 0);
+ event_id, server_id(&child), window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event_down), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate.press_count());
EXPECT_TRUE(env->is_touch_down());
@@ -1472,19 +1431,19 @@ TEST_F(WindowTreeClientClientTest, InputTouchEventNoWindow) {
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0),
ui::EventTimeForNow());
window_tree_client()->OnWindowInputEvent(
- event_id, kInvalidServerId, window_tree_host.display_id(), ui::Id(),
- gfx::PointF(), ui::Event::Clone(pointer_event_up), 0);
+ event_id, kInvalidServerId, window_tree_host.display_id(),
+ ui::Event::Clone(pointer_event_up), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
// WindowTreeClient::OnWindowInputEvent cannot find a target window with
// kInvalidServerId but should use the event to update event states kept in
// aura::Env.
- EXPECT_EQ(ui::mojom::EventResult::UNHANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::UNHANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(0, window_delegate.release_count());
EXPECT_FALSE(env->is_touch_down());
}
-class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
+class WindowTreeClientPointerObserverTest : public WindowTreeClientTest {
public:
WindowTreeClientPointerObserverTest() {}
~WindowTreeClientPointerObserverTest() override {}
@@ -1493,19 +1452,27 @@ class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
const ui::PointerEvent* last_event_observed() const {
return last_event_observed_.get();
}
- int64_t last_display_id() const { return last_display_id_; }
+ const gfx::Point& last_location_in_screen() const {
+ return last_location_in_screen_;
+ }
- // WindowTreeClientClientTest:
+ // WindowTreeClientTest:
void OnPointerEventObserved(const ui::PointerEvent& event,
- int64_t display_id,
+ const gfx::Point& location_in_screen,
Window* target) override {
last_event_observed_.reset(new ui::PointerEvent(event));
- last_display_id_ = display_id;
+ last_location_in_screen_ = location_in_screen;
+ }
+
+ protected:
+ client::ScreenPositionClient* screen_position_client() {
+ return &screen_position_client_;
}
private:
std::unique_ptr<ui::PointerEvent> last_event_observed_;
- int64_t last_display_id_ = 0;
+ gfx::Point last_location_in_screen_;
+ TestScreenPositionClient screen_position_client_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeClientPointerObserverTest);
};
@@ -1522,8 +1489,12 @@ TEST_F(WindowTreeClientPointerObserverTest, OnPointerEventObserved) {
// Start a pointer watcher for all events excluding move events.
window_tree_client_impl()->StartPointerWatcher(false /* want_moves */);
- // Simulate the server sending an observed event.
const int64_t kDisplayId = 111;
+ test_screen()->display_list().AddDisplay(
+ display::Display(kDisplayId, gfx::Rect(800, 0, 400, 400)),
+ display::DisplayList::Type::NOT_PRIMARY);
+
+ // Simulate the server sending an observed event.
std::unique_ptr<ui::PointerEvent> pointer_event_down(new ui::PointerEvent(
ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_CONTROL_DOWN, 0,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1),
@@ -1536,7 +1507,7 @@ TEST_F(WindowTreeClientPointerObserverTest, OnPointerEventObserved) {
ASSERT_TRUE(last_event);
EXPECT_EQ(ui::ET_POINTER_DOWN, last_event->type());
EXPECT_EQ(ui::EF_CONTROL_DOWN, last_event->flags());
- EXPECT_EQ(kDisplayId, last_display_id());
+ EXPECT_EQ(gfx::Point(800, 0), last_location_in_screen());
DeleteLastEventObserved();
// Stop the pointer watcher.
@@ -1560,11 +1531,13 @@ TEST_F(WindowTreeClientPointerObserverTest,
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
Window* top_level = window_tree_host.window();
- const gfx::Rect bounds(0, 0, 100, 100);
+ const gfx::Rect bounds(50, 50, 100, 100);
window_tree_host.SetBoundsInPixels(bounds);
window_tree_host.InitHost();
window_tree_host.Show();
- EXPECT_EQ(bounds, top_level->bounds());
+ EXPECT_EQ(bounds.size(), top_level->bounds().size());
+ client::SetScreenPositionClient(window_tree_host.window(),
+ screen_position_client());
// Start a pointer watcher for all events excluding move events.
window_tree_client_impl()->StartPointerWatcher(false /* want_moves */);
@@ -1574,8 +1547,7 @@ TEST_F(WindowTreeClientPointerObserverTest,
ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_CONTROL_DOWN, 0,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1),
base::TimeTicks::Now()));
- window_tree_client()->OnWindowInputEvent(1, server_id(top_level), 0, ui::Id(),
- gfx::PointF(),
+ window_tree_client()->OnWindowInputEvent(1, server_id(top_level), 0,
std::move(pointer_event_down), true);
// Delegate sensed the event.
@@ -1583,15 +1555,16 @@ TEST_F(WindowTreeClientPointerObserverTest,
ASSERT_TRUE(last_event);
EXPECT_EQ(ui::ET_POINTER_DOWN, last_event->type());
EXPECT_EQ(ui::EF_CONTROL_DOWN, last_event->flags());
+ EXPECT_EQ(gfx::Point(50, 50), last_location_in_screen());
}
// Verifies focus is reverted if the server replied that the change failed.
-TEST_F(WindowTreeClientWmTest, SetFocusFailed) {
+TEST_F(WindowTreeClientTest, SetFocusFailed) {
Window child(nullptr);
child.Init(ui::LAYER_NOT_DRAWN);
root_window()->AddChild(&child);
// AuraTestHelper::SetUp sets the active focus client and focus client root,
- // root_window() is assumed to have focus until we actually focus on a
+ // root_window is assumed to have focus until we actually focus on a
// certain window.
EXPECT_EQ(WindowMus::Get(root_window()),
window_tree_client_impl()->focus_synchronizer()->focused_window());
@@ -1607,7 +1580,7 @@ TEST_F(WindowTreeClientWmTest, SetFocusFailed) {
// Simulates a focus change, and while the focus change is in flight the server
// replies with a new focus and the original focus change fails.
-TEST_F(WindowTreeClientWmTest, SetFocusFailedWithPendingChange) {
+TEST_F(WindowTreeClientTest, SetFocusFailedWithPendingChange) {
Window child1(nullptr);
child1.Init(ui::LAYER_NOT_DRAWN);
root_window()->AddChild(&child1);
@@ -1639,7 +1612,7 @@ TEST_F(WindowTreeClientWmTest, SetFocusFailedWithPendingChange) {
EXPECT_TRUE(child1.HasFocus());
}
-TEST_F(WindowTreeClientWmTest, FocusOnRemovedWindowWithInFlightFocusChange) {
+TEST_F(WindowTreeClientTest, FocusOnRemovedWindowWithInFlightFocusChange) {
std::unique_ptr<Window> child1(std::make_unique<Window>(nullptr));
child1->Init(ui::LAYER_NOT_DRAWN);
root_window()->AddChild(child1.get());
@@ -1693,7 +1666,7 @@ class ToggleVisibilityFromDestroyedObserver : public WindowObserver {
DISALLOW_COPY_AND_ASSIGN(ToggleVisibilityFromDestroyedObserver);
};
-TEST_F(WindowTreeClientWmTest, ToggleVisibilityFromWindowDestroyed) {
+TEST_F(WindowTreeClientTest, ToggleVisibilityFromWindowDestroyed) {
std::unique_ptr<Window> child(std::make_unique<Window>(nullptr));
child->Init(ui::LAYER_NOT_DRAWN);
root_window()->AddChild(child.get());
@@ -1707,7 +1680,7 @@ TEST_F(WindowTreeClientWmTest, ToggleVisibilityFromWindowDestroyed) {
WindowTreeChangeType::VISIBLE, true));
}
-TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
+TEST_F(WindowTreeClientTest, NewTopLevelWindow) {
const size_t initial_root_count =
window_tree_client_impl()->GetRoots().size();
std::unique_ptr<WindowTreeHostMus> window_tree_host =
@@ -1726,7 +1699,7 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(top_level);
const int64_t display_id = 1;
window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
@@ -1744,7 +1717,7 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
}
-TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
+TEST_F(WindowTreeClientTest, NewTopLevelWindowGetsPropertiesFromData) {
const size_t initial_root_count =
window_tree_client_impl()->GetRoots().size();
WindowTreeHostMus window_tree_host(
@@ -1762,7 +1735,7 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
// Ack the request to the windowtree to create the new window.
EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(top_level);
data->bounds.SetRect(1, 2, 3, 4);
data->visible = true;
@@ -1783,7 +1756,7 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
}
-TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
+TEST_F(WindowTreeClientTest, NewWindowGetsAllChangesInFlight) {
RegisterTestProperties(GetPropertyConverter());
WindowTreeHostMus window_tree_host(
@@ -1806,7 +1779,7 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
explicitly_set_test_property1_value);
// Ack the new window top level top_level Vis and bounds shouldn't change.
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(top_level);
const gfx::Rect bounds_from_server(1, 2, 3, 4);
data->bounds = bounds_from_server;
@@ -1857,7 +1830,7 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
top_level->GetProperty(kTestPropertyKey2));
}
-TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) {
+TEST_F(WindowTreeClientTest, NewWindowGetsProperties) {
RegisterTestProperties(GetPropertyConverter());
Window window(nullptr);
const uint8_t explicitly_set_test_property1_value = 29;
@@ -1877,7 +1850,7 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) {
}
// Assertions around transient windows.
-TEST_F(WindowTreeClientClientTest, Transients) {
+TEST_F(WindowTreeClientTest, Transients) {
aura::Window root_window(nullptr);
root_window.Init(ui::LAYER_NOT_DRAWN);
client::TransientWindowClient* transient_client =
@@ -1913,7 +1886,7 @@ TEST_F(WindowTreeClientClientTest, Transients) {
EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id);
}
-TEST_F(WindowTreeClientClientTest, DontRestackTransientsFromOtherClients) {
+TEST_F(WindowTreeClientTest, DontRestackTransientsFromOtherClients) {
// Create a window from another client with 3 children.
const int32_t other_client_id = 11 << 16;
int32_t other_client_window_id = 1;
@@ -1954,8 +1927,7 @@ TEST_F(WindowTreeClientClientTest, DontRestackTransientsFromOtherClients) {
// Verifies adding/removing a transient child notifies the server of the restack
// when the change originates from the server.
-TEST_F(WindowTreeClientClientTest,
- TransientChildServerMutateNotifiesOfRestack) {
+TEST_F(WindowTreeClientTest, TransientChildServerMutateNotifiesOfRestack) {
aura::Window root_window(nullptr);
root_window.Init(ui::LAYER_NOT_DRAWN);
Window* w1 = new Window(nullptr);
@@ -2003,8 +1975,7 @@ TEST_F(WindowTreeClientClientTest,
// Verifies adding/removing a transient child notifies the server of the
// restacks;
-TEST_F(WindowTreeClientClientTest,
- TransientChildClientMutateNotifiesOfRestack) {
+TEST_F(WindowTreeClientTest, TransientChildClientMutateNotifiesOfRestack) {
aura::Window root_window(nullptr);
root_window.Init(ui::LAYER_NOT_DRAWN);
@@ -2079,8 +2050,7 @@ TEST_F(WindowTreeClientClientTest,
EXPECT_EQ(0u, window_tree()->number_of_changes());
}
-TEST_F(WindowTreeClientClientTest,
- TopLevelWindowDestroyedBeforeCreateComplete) {
+TEST_F(WindowTreeClientTest, TopLevelWindowDestroyedBeforeCreateComplete) {
const size_t initial_root_count =
window_tree_client_impl()->GetRoots().size();
std::unique_ptr<WindowTreeHostMus> window_tree_host =
@@ -2090,7 +2060,7 @@ TEST_F(WindowTreeClientClientTest,
EXPECT_EQ(initial_root_count + 1,
window_tree_client_impl()->GetRoots().size());
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(window_tree_host->window());
// Destroy the window before the server has a chance to ack the window
@@ -2109,7 +2079,7 @@ TEST_F(WindowTreeClientClientTest,
EXPECT_EQ(initial_root_count, window_tree_client_impl()->GetRoots().size());
}
-TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
+TEST_F(WindowTreeClientTest, NewTopLevelWindowGetsProperties) {
RegisterTestProperties(GetPropertyConverter());
const uint8_t property_value = 11;
std::map<std::string, std::vector<uint8_t>> properties;
@@ -2174,7 +2144,7 @@ class CloseWindowWindowTreeHostObserver : public aura::WindowTreeHostObserver {
} // namespace
-TEST_F(WindowTreeClientClientTest, CloseWindow) {
+TEST_F(WindowTreeClientTest, CloseWindow) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
window_tree_host.InitHost();
@@ -2191,7 +2161,7 @@ TEST_F(WindowTreeClientClientTest, CloseWindow) {
// Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
// updated on failures.
-TEST_F(WindowTreeClientWmTest, ExplicitCapture) {
+TEST_F(WindowTreeClientTest, ExplicitCapture) {
root_window()->SetCapture();
EXPECT_TRUE(root_window()->HasCapture());
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
@@ -2218,7 +2188,7 @@ TEST_F(WindowTreeClientWmTest, ExplicitCapture) {
// Tests that when capture is lost, while there is a release capture request
// inflight, that the revert value of that request is updated correctly.
-TEST_F(WindowTreeClientWmTest, LostCaptureDifferentInFlightChange) {
+TEST_F(WindowTreeClientTest, LostCaptureDifferentInFlightChange) {
root_window()->SetCapture();
EXPECT_TRUE(root_window()->HasCapture());
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
@@ -2238,7 +2208,7 @@ TEST_F(WindowTreeClientWmTest, LostCaptureDifferentInFlightChange) {
// Tests that while two windows can inflight capture requests, that the
// WindowTreeClient only identifies one as having the current capture.
-TEST_F(WindowTreeClientWmTest, TwoWindowsRequestCapture) {
+TEST_F(WindowTreeClientTest, TwoWindowsRequestCapture) {
Window child(nullptr);
child.Init(ui::LAYER_NOT_DRAWN);
root_window()->AddChild(&child);
@@ -2265,7 +2235,7 @@ TEST_F(WindowTreeClientWmTest, TwoWindowsRequestCapture) {
EXPECT_FALSE(root_window()->HasCapture());
}
-TEST_F(WindowTreeClientWmTest, WindowDestroyedWhileTransientChildHasCapture) {
+TEST_F(WindowTreeClientTest, WindowDestroyedWhileTransientChildHasCapture) {
std::unique_ptr<Window> transient_parent(std::make_unique<Window>(nullptr));
transient_parent->Init(ui::LAYER_NOT_DRAWN);
// Owned by |transient_parent|.
@@ -2337,7 +2307,7 @@ class CaptureRecorder : public client::CaptureClientObserver {
} // namespace
-TEST_F(WindowTreeClientWmTest, OnWindowTreeCaptureChanged) {
+TEST_F(WindowTreeClientTest, OnWindowTreeCaptureChanged) {
CaptureRecorder capture_recorder(root_window());
std::unique_ptr<Window> child1(std::make_unique<Window>(nullptr));
@@ -2385,54 +2355,56 @@ TEST_F(WindowTreeClientWmTest, OnWindowTreeCaptureChanged) {
capture_recorder.reset_capture_captured_count();
}
-TEST_F(WindowTreeClientClientTest, TwoWindowTreesRequestCapture) {
+TEST_F(WindowTreeClientTest, TwoWindowTreesRequestCapture) {
std::unique_ptr<TopLevel> top_level1 = CreateWindowTreeHostForTopLevel();
std::unique_ptr<TopLevel> top_level2 = CreateWindowTreeHostForTopLevel();
- aura::Window* root_window1 = top_level1->host->window();
- aura::Window* root_window2 = top_level2->host->window();
- std::unique_ptr<CaptureRecorder> capture_recorder1(
- std::make_unique<CaptureRecorder>(root_window1));
- std::unique_ptr<CaptureRecorder> capture_recorder2(
- std::make_unique<CaptureRecorder>(root_window2));
- EXPECT_NE(client::GetCaptureClient(root_window1),
- client::GetCaptureClient(root_window2));
+ aura::Window* root1 = top_level1->host->window();
+ aura::Window* root2 = top_level2->host->window();
+ auto capture_recorder1 = std::make_unique<CaptureRecorder>(root1);
+ auto capture_recorder2 = std::make_unique<CaptureRecorder>(root2);
+ EXPECT_NE(client::GetCaptureClient(root1), client::GetCaptureClient(root2));
EXPECT_EQ(0, capture_recorder1->capture_changed_count());
EXPECT_EQ(0, capture_recorder2->capture_changed_count());
- // Give capture to root_window2 and ensure everyone is notified correctly.
- root_window2->SetCapture();
+ // Give capture to root2 and ensure everyone is notified correctly.
+ root2->SetCapture();
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
WindowTreeChangeType::CAPTURE, true));
EXPECT_EQ(0, capture_recorder1->capture_changed_count());
EXPECT_EQ(1, capture_recorder2->capture_changed_count());
- EXPECT_EQ(root_window2->id(),
- capture_recorder2->last_gained_capture_window_id());
+ EXPECT_EQ(root2->id(), capture_recorder2->last_gained_capture_window_id());
EXPECT_EQ(0, capture_recorder2->last_lost_capture_window_id());
- root_window2->ReleaseCapture();
+ root2->ReleaseCapture();
capture_recorder1->reset_capture_captured_count();
capture_recorder2->reset_capture_captured_count();
- // Release capture of shouldn't affect the capture of root_window1.
- root_window2->SetCapture();
- root_window1->SetCapture();
- root_window2->ReleaseCapture();
+ // Releasing capture of root2 shouldn't affect root1 capture.
+ root2->SetCapture();
+ root1->SetCapture();
+ root2->ReleaseCapture();
EXPECT_EQ(1, capture_recorder1->capture_changed_count());
EXPECT_EQ(2, capture_recorder2->capture_changed_count());
- EXPECT_EQ(root_window1->id(),
- capture_recorder1->last_gained_capture_window_id());
+ EXPECT_EQ(root1->id(), capture_recorder1->last_gained_capture_window_id());
EXPECT_EQ(0, capture_recorder1->last_lost_capture_window_id());
EXPECT_EQ(0, capture_recorder2->last_gained_capture_window_id());
- EXPECT_EQ(root_window2->id(),
- capture_recorder2->last_lost_capture_window_id());
-
+ EXPECT_EQ(root2->id(), capture_recorder2->last_lost_capture_window_id());
capture_recorder1->reset_capture_captured_count();
capture_recorder2->reset_capture_captured_count();
- capture_recorder1.reset();
+
+ // Destroying top_level2 shouldn't affect root1 capture; see crbug.com/873743.
+ auto* synchronizer = window_tree_client_impl()->capture_synchronizer();
+ EXPECT_EQ(WindowMus::Get(root1), synchronizer->capture_window());
+ synchronizer->DetachFromCaptureClient(top_level2->capture_client.get());
capture_recorder2.reset();
+ top_level2->host.reset();
+ EXPECT_EQ(WindowMus::Get(root1), synchronizer->capture_window());
+ EXPECT_EQ(0, capture_recorder1->capture_changed_count());
+ EXPECT_EQ(root1->id(), capture_recorder1->last_gained_capture_window_id());
+ EXPECT_EQ(0, capture_recorder1->last_lost_capture_window_id());
}
-TEST_F(WindowTreeClientClientTest, ModalTypeWindowFail) {
+TEST_F(WindowTreeClientTest, ModalTypeWindowFail) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW);
@@ -2449,7 +2421,7 @@ TEST_F(WindowTreeClientClientTest, ModalTypeWindowFail) {
EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey));
}
-TEST_F(WindowTreeClientClientTest, ModalTypeNoneFail) {
+TEST_F(WindowTreeClientTest, ModalTypeNoneFail) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
// First, set modality type to window sucessfully.
@@ -2471,7 +2443,7 @@ TEST_F(WindowTreeClientClientTest, ModalTypeNoneFail) {
EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey));
}
-TEST_F(WindowTreeClientClientTest, ModalTypeSuccess) {
+TEST_F(WindowTreeClientTest, ModalTypeSuccess) {
Window window(nullptr);
window.Init(ui::LAYER_NOT_DRAWN);
@@ -2494,16 +2466,16 @@ TEST_F(WindowTreeClientClientTest, ModalTypeSuccess) {
// Verifies OnWindowHierarchyChanged() deals correctly with identifying existing
// windows.
-TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) {
+TEST_F(WindowTreeClientTest, OnWindowHierarchyChangedWithExistingWindow) {
Window* window1 = new Window(nullptr);
window1->Init(ui::LAYER_NOT_DRAWN);
Window* window2 = new Window(nullptr);
window2->Init(ui::LAYER_NOT_DRAWN);
window_tree()->AckAllChanges();
- const ui::Id server_window_id = server_id(root_window()) + 11;
- ui::mojom::WindowDataPtr data1 = ui::mojom::WindowData::New();
- ui::mojom::WindowDataPtr data2 = ui::mojom::WindowData::New();
- ui::mojom::WindowDataPtr data3 = ui::mojom::WindowData::New();
+ const ws::Id server_window_id = server_id(root_window()) + 11;
+ ws::mojom::WindowDataPtr data1 = ws::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data2 = ws::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data3 = ws::mojom::WindowData::New();
data1->parent_id = server_id(root_window());
data1->window_id = server_window_id;
data1->bounds = gfx::Rect(1, 2, 3, 4);
@@ -2513,7 +2485,7 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) {
data3->parent_id = server_window_id;
data3->window_id = WindowMus::Get(window2)->server_id();
data3->bounds = gfx::Rect(1, 2, 3, 4);
- std::vector<ui::mojom::WindowDataPtr> data_array(3);
+ std::vector<ws::mojom::WindowDataPtr> data_array(3);
data_array[0] = std::move(data1);
data_array[1] = std::move(data2);
data_array[2] = std::move(data3);
@@ -2531,7 +2503,7 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) {
// Ensures when WindowTreeClient::OnWindowDeleted() is called nothing is
// scheduled on the server side.
-TEST_F(WindowTreeClientClientTest, OnWindowDeletedDoesntNotifyServer) {
+TEST_F(WindowTreeClientTest, OnWindowDeletedDoesntNotifyServer) {
Window window1(nullptr);
window1.Init(ui::LAYER_NOT_DRAWN);
Window* window2 = new Window(nullptr);
@@ -2542,207 +2514,30 @@ TEST_F(WindowTreeClientClientTest, OnWindowDeletedDoesntNotifyServer) {
EXPECT_FALSE(window_tree()->has_change());
}
-TEST_F(WindowTreeClientWmTest, NewWindowTreeHostIsConfiguredCorrectly) {
- display::Display display(201);
- display.set_bounds(gfx::Rect(1, 2, 101, 102));
-
- ui::mojom::WindowDataPtr root_data(ui::mojom::WindowData::New());
- root_data->parent_id = 0;
- root_data->window_id = 101;
- root_data->visible = true;
- root_data->bounds = display.bounds();
- const bool parent_drawn = true;
-
- // AuraTestBase ends up owning WindowTreeHost.
- WindowTreeHostMus* window_tree_host =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallWmNewDisplayAdded(display, std::move(root_data), parent_drawn);
- EXPECT_EQ(display.bounds(), window_tree_host->GetBoundsInPixels());
- // The root window of the WindowTreeHost always has an origin of 0,0.
- EXPECT_EQ(gfx::Rect(display.bounds().size()),
- window_tree_host->window()->bounds());
- EXPECT_TRUE(window_tree_host->window()->IsVisible());
- EXPECT_EQ(display.id(), window_tree_host->display_id());
-}
-
-TEST_F(WindowTreeClientWmTest, ManuallyCreateDisplay) {
- const gfx::Rect bounds(1, 2, 101, 102);
- std::unique_ptr<DisplayInitParams> display_params =
- std::make_unique<DisplayInitParams>();
- display_params->display = std::make_unique<display::Display>(201);
- display_params->display->set_bounds(bounds);
- display_params->viewport_metrics.bounds_in_pixels = bounds;
- display_params->viewport_metrics.device_scale_factor = 1.0f;
- display_params->viewport_metrics.ui_scale_factor = 1.0f;
- WindowTreeHostMusInitParams init_params =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallCreateInitParamsForNewDisplay();
- init_params.display_id = display_params->display->id();
- init_params.display_init_params = std::move(display_params);
- WindowTreeHostMus window_tree_host(std::move(init_params));
- window_tree_host.InitHost();
- EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
- EXPECT_EQ(gfx::Rect(bounds.size()), window_tree_host.window()->bounds());
-}
-
-TEST_F(WindowTreeClientWmTest, FocusInDifferentDisplayThanEvent) {
- constexpr int64_t kDisplayId1 = 201;
- WindowTreeHostMusInitParams init_params1 = CreateWindowTreeHostMusInitParams(
- window_tree_client_impl(), gfx::Rect(1, 2, 101, 102), kDisplayId1);
- WindowTreeHostMus window_tree_host1(std::move(init_params1));
- window_tree_host1.InitHost();
- window_tree_host1.Show();
- client::SetFocusClient(window_tree_host1.window(), focus_client());
-
- constexpr int64_t kDisplayId2 = 202;
- WindowTreeHostMusInitParams init_params2 = CreateWindowTreeHostMusInitParams(
- window_tree_client_impl(), gfx::Rect(501, 2, 101, 102), kDisplayId2);
- WindowTreeHostMus window_tree_host2(std::move(init_params2));
- window_tree_host2.InitHost();
- window_tree_host2.Show();
- client::SetFocusClient(window_tree_host2.window(), focus_client());
-
- aura::Window child1(nullptr);
- child1.Init(ui::LAYER_NOT_DRAWN);
- child1.Show();
- window_tree_host1.window()->AddChild(&child1);
- child1.Focus();
-
- aura::Window child2(nullptr);
- child2.Init(ui::LAYER_NOT_DRAWN);
- child2.Show();
- child2.SetEventTargeter(std::make_unique<WindowTargeter>());
- window_tree_host2.window()->AddChild(&child2);
-
- EXPECT_TRUE(child1.HasFocus());
-
- std::unique_ptr<ui::KeyEvent> key_event = std::make_unique<ui::KeyEvent>(
- ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE);
- window_tree_client()->OnWindowInputEvent(1, server_id(&child2), kDisplayId2,
- ui::Id(), gfx::PointF(),
- std::move(key_event), false);
-}
-
-// Test accelerated widget values cause compositor crashes without Ozone.
-#if defined(USE_OZONE)
-#define MAYBE_SwapDisplayRoots SwapDisplayRoots
-#else
-#define MAYBE_SwapDisplayRoots DISABLED_SwapDisplayRoots
-#endif
-TEST_F(WindowTreeClientWmTest, MAYBE_SwapDisplayRoots) {
- display::Display display1(201);
- ui::mojom::WindowDataPtr root_data1(ui::mojom::WindowData::New());
- root_data1->window_id = 101;
-
- display::Display display2(202);
- ui::mojom::WindowDataPtr root_data2(ui::mojom::WindowData::New());
- root_data2->window_id = 102;
-
- const bool parent_drawn = true;
-
- // AuraTestBase ends up owning WindowTreeHost.
- WindowTreeHostMus* window_tree_host1 =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallWmNewDisplayAdded(display1, std::move(root_data1), parent_drawn);
- WindowTreeHostMus* window_tree_host2 =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallWmNewDisplayAdded(display2, std::move(root_data2), parent_drawn);
-
-#if defined(OS_WIN) || defined(OS_ANDROID)
- gfx::AcceleratedWidget widget1 = reinterpret_cast<gfx::AcceleratedWidget>(1U);
- gfx::AcceleratedWidget widget2 = reinterpret_cast<gfx::AcceleratedWidget>(2U);
-#else
- gfx::AcceleratedWidget widget1 = static_cast<gfx::AcceleratedWidget>(1U);
- gfx::AcceleratedWidget widget2 = static_cast<gfx::AcceleratedWidget>(2U);
-#endif
-
- window_tree_host1->OverrideAcceleratedWidget(widget1);
- window_tree_host2->OverrideAcceleratedWidget(widget2);
- EXPECT_EQ(widget1, window_tree_host1->GetAcceleratedWidget());
- EXPECT_EQ(widget2, window_tree_host2->GetAcceleratedWidget());
-
- static_cast<WindowManagerClient*>(window_tree_client_impl())
- ->SwapDisplayRoots(window_tree_host1, window_tree_host2);
-
- // SwapDisplayRoots swaps the display ids and accelerated widgets.
- EXPECT_EQ(display2.id(), window_tree_host1->display_id());
- EXPECT_EQ(display1.id(), window_tree_host2->display_id());
- EXPECT_EQ(widget2, window_tree_host1->GetAcceleratedWidget());
- EXPECT_EQ(widget1, window_tree_host2->GetAcceleratedWidget());
-}
-
-TEST_F(WindowTreeClientWmTestHighDPI, BoundsChangeWhenAdded) {
- const gfx::Rect bounds(1, 2, 101, 102);
- std::unique_ptr<DisplayInitParams> display_params =
- std::make_unique<DisplayInitParams>();
- display_params->display = std::make_unique<display::Display>(201);
- display_params->display->set_bounds(bounds);
- display_params->viewport_metrics.bounds_in_pixels = bounds;
- const float device_scale_factor = 2.0f;
- display_params->viewport_metrics.device_scale_factor = device_scale_factor;
- display_params->viewport_metrics.ui_scale_factor = 1.0f;
- WindowTreeHostMusInitParams init_params =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallCreateInitParamsForNewDisplay();
- init_params.display_id = display_params->display->id();
- init_params.display_init_params = std::move(display_params);
- WindowTreeHostMus window_tree_host(std::move(init_params));
- window_tree_host.InitHost();
-
- const gfx::Rect bounds_in_dips(1, 2, 3, 4);
- aura::Window child_window(nullptr);
- child_window.SetProperty(aura::client::kEmbedType,
- aura::client::WindowEmbedType::EMBED_IN_OWNER);
- child_window.Init(ui::LAYER_NOT_DRAWN);
- EXPECT_EQ(1.0f, WindowMus::Get(&child_window)->GetDeviceScaleFactor());
- window_tree()->AckAllChanges();
- child_window.SetBounds(bounds_in_dips);
- ASSERT_EQ(1u,
- window_tree()->GetChangeCountForType(WindowTreeChangeType::BOUNDS));
- EXPECT_EQ(bounds_in_dips, window_tree()->last_set_window_bounds());
- base::Optional<viz::LocalSurfaceId> child_window_local_surface_id =
- window_tree()->last_local_surface_id();
- ASSERT_TRUE(child_window_local_surface_id);
- window_tree()->AckAllChanges();
-
- window_tree_host.window()->AddChild(&child_window);
- EXPECT_EQ(2.0f, WindowMus::Get(&child_window)->GetDeviceScaleFactor());
- EXPECT_EQ(bounds_in_dips, child_window.bounds());
- ASSERT_EQ(1u,
- window_tree()->GetChangeCountForType(WindowTreeChangeType::BOUNDS));
- EXPECT_EQ(gfx::ConvertRectToPixel(device_scale_factor, bounds_in_dips),
- window_tree()->last_set_window_bounds());
- base::Optional<viz::LocalSurfaceId> updated_child_window_local_surface_id =
- window_tree()->last_local_surface_id();
- ASSERT_TRUE(child_window_local_surface_id);
- EXPECT_NE(*child_window_local_surface_id,
- *updated_child_window_local_surface_id);
-}
-
-TEST_F(WindowTreeClientWmTestHighDPI, SetBounds) {
+TEST_F(WindowTreeClientTestHighDPI, SetBounds) {
const gfx::Rect original_bounds(root_window()->bounds());
const gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100));
ASSERT_NE(new_bounds, root_window()->bounds());
root_window()->SetBounds(new_bounds);
EXPECT_EQ(new_bounds, root_window()->bounds());
- // Simulate the server responding with a bounds change. Server should operate
- // in pixels.
+ // Simulate the server responding with a bounds change. Server operates in
+ // dips.
const gfx::Rect server_changed_bounds(gfx::Rect(0, 0, 200, 200));
window_tree_client()->OnWindowBoundsChanged(
server_id(root_window()), original_bounds, server_changed_bounds,
base::nullopt);
- EXPECT_EQ(new_bounds, root_window()->bounds());
+ EXPECT_EQ(server_changed_bounds, root_window()->bounds());
}
-TEST_F(WindowTreeClientClientTestHighDPI, NewTopLevelWindowBounds) {
+TEST_F(WindowTreeClientTestHighDPI, NewTopLevelWindowBounds) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
Window* top_level = window_tree_host.window();
window_tree_host.InitHost();
gfx::Rect bounds(2, 4, 6, 8);
- ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ ws::mojom::WindowDataPtr data = ws::mojom::WindowData::New();
data->window_id = server_id(top_level);
data->bounds = bounds;
const int64_t display_id = 10;
@@ -2761,7 +2556,7 @@ TEST_F(WindowTreeClientClientTestHighDPI, NewTopLevelWindowBounds) {
top_level->GetHost()->GetBoundsInPixels());
}
-TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) {
+TEST_F(WindowTreeClientTestHighDPI, PointerEventsInDip) {
display::Screen* screen = display::Screen::GetScreen();
const display::Display primary_display = screen->GetPrimaryDisplay();
ASSERT_EQ(2.0f, primary_display.device_scale_factor());
@@ -2794,7 +2589,7 @@ TEST_F(WindowTreeClientClientTestHighDPI, PointerEventsInDip) {
EXPECT_EQ(root_location, last_event->root_location());
}
-TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) {
+TEST_F(WindowTreeClientTestHighDPI, InputEventsInDip) {
WindowTreeHostMus window_tree_host(
CreateInitParamsForTopLevel(window_tree_client_impl()));
display::Screen* screen = display::Screen::GetScreen();
@@ -2838,10 +2633,10 @@ TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) {
new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location, event_location,
ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child1), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(&child1), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1.move_count());
EXPECT_EQ(0, window_delegate2.move_count());
@@ -2854,10 +2649,10 @@ TEST_F(WindowTreeClientClientTestHighDPI, InputEventsInDip) {
window_delegate1.set_event_id(event_id);
window_delegate2.set_event_id(event_id);
window_tree_client()->OnWindowInputEvent(
- event_id, server_id(&child2), window_tree_host.display_id(), ui::Id(),
- gfx::PointF(event_location), ui::Event::Clone(*ui_event.get()), 0);
+ event_id, server_id(&child2), window_tree_host.display_id(),
+ ui::Event::Clone(*ui_event.get()), 0);
EXPECT_TRUE(window_tree()->WasEventAcked(event_id));
- EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ EXPECT_EQ(ws::mojom::EventResult::HANDLED,
window_tree()->GetEventResult(event_id));
EXPECT_EQ(1, window_delegate1.move_count());
EXPECT_EQ(0, window_delegate2.move_count());
@@ -2892,78 +2687,6 @@ TEST_F(WindowTreeClientDestructionTest, WindowsFromOtherConnectionsDeleted) {
EXPECT_TRUE(window_tracker.windows().empty());
}
-TEST_F(WindowTreeClientWmTestHighDPI, ObservedPointerEvents) {
- const gfx::Rect bounds(1, 2, 101, 102);
- std::unique_ptr<DisplayInitParams> display_params =
- std::make_unique<DisplayInitParams>();
- const int64_t display_id = 201;
- float device_scale_factor = 2.0f;
- float ui_scale_factor = 1.5f;
- display_params->display = std::make_unique<display::Display>(display_id);
- display_params->display->set_bounds(bounds);
- display_params->viewport_metrics.bounds_in_pixels = bounds;
- display_params->viewport_metrics.device_scale_factor = device_scale_factor;
- display_params->viewport_metrics.ui_scale_factor = ui_scale_factor;
- WindowTreeHostMusInitParams init_params =
- WindowTreeClientPrivate(window_tree_client_impl())
- .CallCreateInitParamsForNewDisplay();
- init_params.display_id = display_id;
- init_params.display_init_params = std::move(display_params);
-
- WindowTreeHostMus window_tree_host(std::move(init_params));
- window_tree_host.InitHost();
- gfx::Transform scale_transform;
- scale_transform.Scale(ui_scale_factor, ui_scale_factor);
- window_tree_host.window()->SetTransform(scale_transform);
- window_tree_host.compositor()->SetScaleAndSize(
- device_scale_factor, bounds.size(), viz::LocalSurfaceId());
-
- // Start a pointer watcher for all events excluding move events.
- window_tree_client_impl()->StartPointerWatcher(false /* want_moves */);
-
- // Simulate the server sending an observed event.
- const gfx::Point location_pixels(10, 12);
- const gfx::Point root_location_pixels(14, 16);
- std::unique_ptr<ui::PointerEvent> pointer_event_down(new ui::PointerEvent(
- ui::ET_POINTER_DOWN, location_pixels, root_location_pixels,
- ui::EF_CONTROL_DOWN, 0,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1),
- base::TimeTicks()));
- std::unique_ptr<ui::PointerEvent> pointer_event_down2(
- ui::Event::Clone(*pointer_event_down).release()->AsPointerEvent());
- window_tree_client()->OnPointerEventObserved(std::move(pointer_event_down),
- 0u, display_id);
-
- ASSERT_FALSE(observed_pointer_events().empty());
- const ui::PointerEvent* last_event = observed_pointer_events().back().get();
- ASSERT_TRUE(last_event);
- EXPECT_EQ(nullptr, last_event->target());
- // NOTE: the root and location are the same as there was no window supplied to
- // OnPointerEventObserved().
- EXPECT_EQ(gfx::ConvertPointToDIP(device_scale_factor * ui_scale_factor,
- root_location_pixels),
- last_event->location());
- EXPECT_EQ(gfx::ConvertPointToDIP(device_scale_factor * ui_scale_factor,
- root_location_pixels),
- last_event->root_location());
-
- observed_pointer_events().clear();
- window_tree_client()->OnPointerEventObserved(
- std::move(pointer_event_down2),
- WindowMus::Get(window_tree_host.window())->server_id(), display_id);
- ASSERT_FALSE(observed_pointer_events().empty());
- last_event = observed_pointer_events().back().get();
- ASSERT_TRUE(last_event);
- EXPECT_EQ(nullptr, last_event->target());
- // |location| from the server has already had |ui_scale_factor| applied, so
- // it won't be reapplied here.
- EXPECT_EQ(gfx::ConvertPointToDIP(device_scale_factor, location_pixels),
- last_event->location());
- EXPECT_EQ(gfx::ConvertPointToDIP(device_scale_factor * ui_scale_factor,
- root_location_pixels),
- last_event->root_location());
-}
-
class TestEmbedRootDelegate : public EmbedRootDelegate {
public:
TestEmbedRootDelegate() = default;
@@ -2979,7 +2702,7 @@ class TestEmbedRootDelegate : public EmbedRootDelegate {
};
// Verifies we don't crash when focus changes to a window in an EmbedRoot.
-TEST_F(WindowTreeClientClientTest, ChangeFocusInEmbedRootWindow) {
+TEST_F(WindowTreeClientTest, ChangeFocusInEmbedRootWindow) {
TestEmbedRootDelegate embed_root_delegate;
std::unique_ptr<EmbedRoot> embed_root =
window_tree_client_impl()->CreateEmbedRoot(&embed_root_delegate);
@@ -2989,84 +2712,47 @@ TEST_F(WindowTreeClientClientTest, ChangeFocusInEmbedRootWindow) {
window_tree_client()->OnWindowFocused(server_id(embed_root->window()));
}
-#if defined(USE_OZONE)
-
-class TestPlatformEventObserver : public ui::PlatformEventObserver {
- public:
- TestPlatformEventObserver() = default;
- ~TestPlatformEventObserver() override = default;
-
- int will_process_count() const { return will_process_count_; }
- int did_process_count() const { return did_process_count_; }
- ui::EventType will_process_type() const { return will_process_type_; }
- ui::EventType did_process_type() const { return did_process_type_; }
-
- // PlatformEventObserver:
- void WillProcessEvent(const ui::PlatformEvent& event) override {
- will_process_count_++;
- will_process_type_ = static_cast<const ui::Event*>(event)->type();
- }
- void DidProcessEvent(const ui::PlatformEvent& event) override {
- did_process_count_++;
- did_process_type_ = static_cast<const ui::Event*>(event)->type();
- }
+TEST_F(WindowTreeClientTest, PerformWindowMove) {
+ int call_count = 0;
+ bool last_result = false;
- private:
- int will_process_count_ = 0;
- int did_process_count_ = 0;
- ui::EventType will_process_type_ = ui::ET_UNKNOWN;
- ui::EventType did_process_type_ = ui::ET_UNKNOWN;
+ WindowTreeHostMus* host_mus = static_cast<WindowTreeHostMus*>(host());
+ host_mus->PerformWindowMove(
+ ws::mojom::MoveLoopSource::MOUSE, gfx::Point(),
+ base::Bind(&OnWindowMoveDone, &call_count, &last_result));
+ EXPECT_EQ(0, call_count);
- DISALLOW_COPY_AND_ASSIGN(TestPlatformEventObserver);
-};
+ window_tree()->AckAllChanges();
+ EXPECT_EQ(1, call_count);
+ EXPECT_TRUE(last_result);
-// Base class that installs a new version of Env configured for Mus in SetUp()
-// (and installs a new version of Env configured for Local during TearDown()).
-// This is necessary as when Env is created with a Model of Local it installs
-// a PlatformEventSource, not the one that WindowTreeClient installs.
-class WindowTreeClientWmOzoneTest : public test::AuraMusWmTestBase {
- public:
- WindowTreeClientWmOzoneTest() = default;
- ~WindowTreeClientWmOzoneTest() override = default;
+ host_mus->PerformWindowMove(
+ ws::mojom::MoveLoopSource::MOUSE, gfx::Point(),
+ base::Bind(&OnWindowMoveDone, &call_count, &last_result));
+ window_tree()->AckAllChangesOfType(WindowTreeChangeType::OTHER, false);
+ EXPECT_EQ(2, call_count);
+ EXPECT_FALSE(last_result);
+}
- // test::AuraMusWmTestBase:
- void SetUp() override {
- env_reinstaller_ = std::make_unique<test::EnvReinstaller>();
- env_ = Env::CreateInstance(Env::Mode::MUS);
- AuraMusWmTestBase::SetUp();
- }
+TEST_F(WindowTreeClientTest, PerformWindowMoveDoneAfterDelete) {
+ int call_count = 0;
+ bool last_result = false;
- void TearDown() override {
- AuraMusWmTestBase::TearDown();
- env_.reset();
- env_reinstaller_.reset();
- }
+ auto host_mus = std::make_unique<WindowTreeHostMus>(
+ CreateInitParamsForTopLevel(window_tree_client_impl()));
+ host_mus->InitHost();
+ window_tree()->AckAllChanges();
- private:
- std::unique_ptr<test::EnvReinstaller> env_reinstaller_;
- std::unique_ptr<Env> env_;
+ host_mus->PerformWindowMove(
+ ws::mojom::MoveLoopSource::MOUSE, gfx::Point(),
+ base::Bind(&OnWindowMoveDone, &call_count, &last_result));
+ EXPECT_EQ(0, call_count);
- DISALLOW_COPY_AND_ASSIGN(WindowTreeClientWmOzoneTest);
-};
+ host_mus.reset();
+ window_tree()->AckAllChanges();
-// Used to verify PlatformEventSource is correctly wired up in ozone.
-TEST_F(WindowTreeClientWmOzoneTest, PlatformEventSourceInstalled) {
- ASSERT_TRUE(ui::PlatformEventSource::GetInstance());
- TestPlatformEventObserver test_observer;
- ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(
- &test_observer);
- ui::MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
- ui::EventTimeForNow(), ui::EF_NONE, 0);
- window_tree_client()->OnWindowInputEvent(1, server_id(root_window()), 0,
- ui::Id(), gfx::PointF(),
- ui::Event::Clone(event), 0);
- ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(
- &test_observer);
- EXPECT_EQ(1, test_observer.will_process_count());
- EXPECT_EQ(1, test_observer.did_process_count());
- EXPECT_EQ(ui::ET_MOUSE_MOVED, test_observer.will_process_type());
- EXPECT_EQ(ui::ET_MOUSE_MOVED, test_observer.did_process_type());
-}
-#endif
+ EXPECT_EQ(1, call_count);
+ EXPECT_TRUE(last_result);
+}
} // namespace aura
diff --git a/chromium/ui/aura/mus/window_tree_host_mus.cc b/chromium/ui/aura/mus/window_tree_host_mus.cc
index 1fe190dd636..4714427d756 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus.cc
+++ b/chromium/ui/aura/mus/window_tree_host_mus.cc
@@ -38,19 +38,15 @@ static uint32_t accelerated_widget_count = 1;
// WindowTreeHostMus, public:
WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params)
- : WindowTreeHostPlatform(std::move(init_params.window_port)),
+ : WindowTreeHostPlatform(
+ std::make_unique<Window>(nullptr,
+ std::move(init_params.window_port))),
display_id_(init_params.display_id),
delegate_(init_params.window_tree_client) {
gfx::Rect bounds_in_pixels;
- display_init_params_ = std::move(init_params.display_init_params);
- if (display_init_params_) {
- bounds_in_pixels = display_init_params_->viewport_metrics.bounds_in_pixels;
- if (display_init_params_->display)
- DCHECK_EQ(display_id_, display_init_params_->display->id());
- }
window()->SetProperty(kWindowTreeHostMusKey, this);
- // TODO(sky): find a cleaner way to set this! Better solution is to likely
- // have constructor take aura::Window.
+ // TODO(sky): find a cleaner way to set this! Revisit this now that
+ // constructor takes a Window.
WindowPortMus* window_mus = WindowPortMus::Get(window());
window_mus->window_ = window();
// Apply the properties before initializing the window, that way the server
@@ -62,8 +58,7 @@ WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params)
// context_factory_private().
const bool force_software_compositor = false;
const bool external_begin_frames_enabled = false;
- const bool are_events_in_pixels =
- init_params.window_tree_client->is_using_pixels();
+ const bool are_events_in_pixels = false;
CreateCompositor(window_mus->GenerateFrameSinkIdFromServerId(),
force_software_compositor, external_begin_frames_enabled,
are_events_in_pixels);
@@ -77,8 +72,7 @@ WindowTreeHostMus::WindowTreeHostMus(WindowTreeHostMusInitParams init_params)
accelerated_widget =
static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
#endif
- OnAcceleratedWidgetAvailable(accelerated_widget,
- GetDisplay().device_scale_factor());
+ OnAcceleratedWidgetAvailable(accelerated_widget);
delegate_->OnWindowTreeHostCreated(this);
@@ -157,7 +151,7 @@ void WindowTreeHostMus::PerformWmAction(const std::string& action) {
}
void WindowTreeHostMus::PerformWindowMove(
- ui::mojom::MoveLoopSource mus_source,
+ ws::mojom::MoveLoopSource mus_source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& callback) {
delegate_->OnWindowTreeHostPerformWindowMove(
@@ -168,37 +162,12 @@ void WindowTreeHostMus::CancelWindowMove() {
delegate_->OnWindowTreeHostCancelWindowMove(this);
}
-void WindowTreeHostMus::ConfineCursorToBounds(
- const gfx::Rect& bounds_in_pixels) {
- delegate_->OnWindowTreeHostConfineCursorToBounds(bounds_in_pixels,
- display_id_);
-}
-
display::Display WindowTreeHostMus::GetDisplay() const {
display::Display display;
display::Screen::GetScreen()->GetDisplayWithDisplayId(display_id_, &display);
return display;
}
-void WindowTreeHostMus::OverrideAcceleratedWidget(
- gfx::AcceleratedWidget widget) {
- bool was_visible = compositor()->IsVisible();
- if (was_visible)
- compositor()->SetVisible(false);
- compositor()->ReleaseAcceleratedWidget();
- OnAcceleratedWidgetAvailable(widget, GetDisplay().device_scale_factor());
- if (was_visible)
- compositor()->SetVisible(true);
-
- for (WindowTreeHostObserver& observer : observers())
- observer.OnAcceleratedWidgetOverridden(this);
-}
-
-std::unique_ptr<DisplayInitParams>
-WindowTreeHostMus::ReleaseDisplayInitParams() {
- return std::move(display_init_params_);
-}
-
void WindowTreeHostMus::HideImpl() {
WindowTreeHostPlatform::HideImpl();
window()->Hide();
@@ -232,27 +201,6 @@ void WindowTreeHostMus::OnCloseRequest() {
OnHostCloseRequested();
}
-void WindowTreeHostMus::MoveCursorToScreenLocationInPixels(
- const gfx::Point& location_in_pixels) {
- // |location_in_pixels| is relative to the display.
- delegate_->OnWindowTreeHostMoveCursorToDisplayLocation(location_in_pixels,
- display_id_);
-}
-
-gfx::Transform WindowTreeHostMus::GetRootTransformForLocalEventCoordinates()
- const {
- if (WindowMus::Get(window())->window_mus_type() !=
- WindowMusType::DISPLAY_MANUALLY_CREATED) {
- return WindowTreeHost::GetRootTransformForLocalEventCoordinates();
- }
- // Local events already have the transform set on the window applied, so
- // don't apply it again.
- gfx::Transform transform;
- const float scale = window()->layer()->device_scale_factor();
- transform.Scale(scale, scale);
- return transform;
-}
-
int64_t WindowTreeHostMus::GetDisplayId() {
return display_id_;
}
diff --git a/chromium/ui/aura/mus/window_tree_host_mus.h b/chromium/ui/aura/mus/window_tree_host_mus.h
index 1ce0eec31dc..c023265a716 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus.h
+++ b/chromium/ui/aura/mus/window_tree_host_mus.h
@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
+#include "services/ws/public/mojom/window_tree_constants.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/mus/input_method_mus_delegate.h"
#include "ui/aura/window_tree_host_platform.h"
@@ -27,7 +27,6 @@ class InputMethodMus;
class WindowTreeClient;
class WindowTreeHostMusDelegate;
-struct DisplayInitParams;
struct WindowTreeHostMusInitParams;
class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
@@ -74,7 +73,7 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
// Tells the window manager to take control of moving the window. Returns
// true if the move wasn't canceled.
- void PerformWindowMove(ui::mojom::MoveLoopSource mus_source,
+ void PerformWindowMove(ws::mojom::MoveLoopSource mus_source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& callback);
@@ -82,22 +81,11 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
// PerformWindowMove().
void CancelWindowMove();
- // Tells the window manager to confine the cursor to these specific bounds.
- void ConfineCursorToBounds(const gfx::Rect& pixel_bounds);
-
- // Used during initial setup. Returns the DisplayInitParams
- // supplied to the constructor.
- std::unique_ptr<DisplayInitParams> ReleaseDisplayInitParams();
-
// Intended only for WindowTreeClient to call.
void set_display_id(int64_t id) { display_id_ = id; }
int64_t display_id() const { return display_id_; }
display::Display GetDisplay() const;
- // Forces WindowTreeHost to re-setup the compositor to use the provided
- // |widget|.
- void OverrideAcceleratedWidget(gfx::AcceleratedWidget widget);
-
// aura::WindowTreeHostPlatform:
void HideImpl() override;
void SetBoundsInPixels(const gfx::Rect& bounds,
@@ -107,9 +95,6 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
void OnClosed() override;
void OnActivationChanged(bool active) override;
void OnCloseRequest() override;
- void MoveCursorToScreenLocationInPixels(
- const gfx::Point& location_in_pixels) override;
- gfx::Transform GetRootTransformForLocalEventCoordinates() const override;
int64_t GetDisplayId() override;
// InputMethodMusDelegate:
@@ -126,8 +111,6 @@ class AURA_EXPORT WindowTreeHostMus : public WindowTreeHostPlatform,
std::unique_ptr<InputMethodMus> input_method_;
- std::unique_ptr<DisplayInitParams> display_init_params_;
-
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMus);
};
diff --git a/chromium/ui/aura/mus/window_tree_host_mus_delegate.h b/chromium/ui/aura/mus/window_tree_host_mus_delegate.h
index e9131d83cee..636d7018f35 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus_delegate.h
+++ b/chromium/ui/aura/mus/window_tree_host_mus_delegate.h
@@ -63,7 +63,7 @@ class AURA_EXPORT WindowTreeHostMusDelegate {
// moving a window during a drag.
virtual void OnWindowTreeHostPerformWindowMove(
WindowTreeHostMus* window_tree_host,
- ui::mojom::MoveLoopSource mus_source,
+ ws::mojom::MoveLoopSource mus_source,
const gfx::Point& cursor_location,
const base::Callback<void(bool)>& callback) = 0;
@@ -71,17 +71,6 @@ class AURA_EXPORT WindowTreeHostMusDelegate {
virtual void OnWindowTreeHostCancelWindowMove(
WindowTreeHostMus* window_tree_host) = 0;
- // Called to move the location of the cursor.
- virtual void OnWindowTreeHostMoveCursorToDisplayLocation(
- const gfx::Point& location_in_pixels,
- int64_t display_id) = 0;
-
- // Called to confine the cursor to a set of bounds in pixels. Only available
- // to the window manager.
- virtual void OnWindowTreeHostConfineCursorToBounds(
- const gfx::Rect& bounds_in_pixels,
- int64_t display_id) = 0;
-
// Called when a WindowTreeHostMus is created without a WindowPort.
// TODO: this should take an unordered_map, see http://crbug.com/670515.
virtual std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel(
diff --git a/chromium/ui/aura/mus/window_tree_host_mus_init_params.cc b/chromium/ui/aura/mus/window_tree_host_mus_init_params.cc
index 0f24ecc5851..11c2ceaa3e9 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus_init_params.cc
+++ b/chromium/ui/aura/mus/window_tree_host_mus_init_params.cc
@@ -4,8 +4,8 @@
#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 "services/ws/public/cpp/property_type_converters.h"
+#include "services/ws/public/mojom/window_manager.mojom.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/display/display.h"
@@ -17,7 +17,7 @@ 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);
+ auto it = properties.find(ws::mojom::WindowManager::kDisplayId_InitProperty);
if (it == properties.end())
return false;
@@ -28,7 +28,7 @@ bool GetInitialDisplayId(
bool GetInitialBounds(
const std::map<std::string, std::vector<uint8_t>>& properties,
gfx::Rect* bounds) {
- auto it = properties.find(ui::mojom::WindowManager::kBounds_InitProperty);
+ auto it = properties.find(ws::mojom::WindowManager::kBounds_InitProperty);
if (it == properties.end())
return false;
@@ -38,10 +38,6 @@ bool GetInitialBounds(
} // namespace
-DisplayInitParams::DisplayInitParams() = default;
-
-DisplayInitParams::~DisplayInitParams() = default;
-
WindowTreeHostMusInitParams::WindowTreeHostMusInitParams() = default;
WindowTreeHostMusInitParams::WindowTreeHostMusInitParams(
@@ -65,9 +61,8 @@ WindowTreeHostMusInitParams CreateInitParamsForTopLevel(
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();
+ params.display_id =
+ display::Screen::GetScreen()->GetDisplayForNewWindows().id();
}
// Pass |properties| to CreateWindowPortForTopLevel() so that |properties|
diff --git a/chromium/ui/aura/mus/window_tree_host_mus_init_params.h b/chromium/ui/aura/mus/window_tree_host_mus_init_params.h
index 4a59380240c..ef5c9855ccd 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus_init_params.h
+++ b/chromium/ui/aura/mus/window_tree_host_mus_init_params.h
@@ -13,39 +13,13 @@
#include <vector>
#include "components/viz/common/surfaces/frame_sink_id.h"
-#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/aura_export.h"
-namespace display {
-class Display;
-}
-
namespace aura {
class WindowPortMus;
class WindowTreeClient;
-// Used for a WindowTreeHost that corresponds to a Display that is manually
-// created by the window manager.
-struct AURA_EXPORT DisplayInitParams {
- DisplayInitParams();
- ~DisplayInitParams();
-
- // The display, if not provided then the Display identified by
- // |WindowTreeHostMusInitParams::display_id| must be one of the Displays
- // contained in Screen.
- std::unique_ptr<display::Display> display;
-
- ui::mojom::WmViewportMetrics viewport_metrics;
-
- bool is_primary_display = false;
-
- // |mirrors| contains a list of physical displays presenting contents mirrored
- // from another physical display, or from part of a virtual unified display.
- // See |display::DisplayManager::software_mirroring_display_list_| for info.
- std::vector<display::Display> mirrors;
-};
-
// Used to create a WindowTreeHostMus. The typical case is to use
// CreateInitParamsForTopLevel().
struct AURA_EXPORT WindowTreeHostMusInitParams {
@@ -67,10 +41,6 @@ struct AURA_EXPORT WindowTreeHostMusInitParams {
// Id of the display the window should be created on.
int64_t display_id = 0;
- // Used when the WindowTreeHostMus corresponds to a new display manually
- // created by the window manager.
- std::unique_ptr<DisplayInitParams> display_init_params;
-
// Use classic IME (i.e. InputMethodChromeOS) instead of servicified IME
// (i.e. InputMethodMus).
bool use_classic_ime = false;