summaryrefslogtreecommitdiff
path: root/chromium/ui/aura
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-05 14:08:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-11 07:46:53 +0000
commit6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch)
treeab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/ui/aura
parente733310db58160074f574c429d48f8308c0afe17 (diff)
downloadqtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r--chromium/ui/aura/BUILD.gn25
-rw-r--r--chromium/ui/aura/DEPS1
-rw-r--r--chromium/ui/aura/client/aura_constants.cc20
-rw-r--r--chromium/ui/aura/client/aura_constants.h34
-rw-r--r--chromium/ui/aura/client/transient_window_client_observer.h10
-rw-r--r--chromium/ui/aura/demo/demo_main.cc6
-rw-r--r--chromium/ui/aura/env.cc3
-rw-r--r--chromium/ui/aura/env.h13
-rw-r--r--chromium/ui/aura/gestures/gesture_recognizer_unittest.cc1
-rw-r--r--chromium/ui/aura/mus/DEPS8
-rw-r--r--chromium/ui/aura/mus/client_surface_embedder.cc74
-rw-r--r--chromium/ui/aura/mus/client_surface_embedder.h45
-rw-r--r--chromium/ui/aura/mus/drag_drop_controller_mus.cc11
-rw-r--r--chromium/ui/aura/mus/gpu_memory_buffer_impl.cc46
-rw-r--r--chromium/ui/aura/mus/gpu_memory_buffer_impl.h59
-rw-r--r--chromium/ui/aura/mus/gpu_service.cc155
-rw-r--r--chromium/ui/aura/mus/gpu_service.h84
-rw-r--r--chromium/ui/aura/mus/in_flight_change.cc2
-rw-r--r--chromium/ui/aura/mus/in_flight_change.h1
-rw-r--r--chromium/ui/aura/mus/input_method_mus.cc30
-rw-r--r--chromium/ui/aura/mus/input_method_mus.h3
-rw-r--r--chromium/ui/aura/mus/mojo_gpu_memory_buffer.cc132
-rw-r--r--chromium/ui/aura/mus/mojo_gpu_memory_buffer.h61
-rw-r--r--chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.cc40
-rw-r--r--chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.h39
-rw-r--r--chromium/ui/aura/mus/mus_context_factory.cc69
-rw-r--r--chromium/ui/aura/mus/mus_context_factory.h39
-rw-r--r--chromium/ui/aura/mus/os_exchange_data_provider_mus.cc4
-rw-r--r--chromium/ui/aura/mus/os_exchange_data_provider_mus.h1
-rw-r--r--chromium/ui/aura/mus/property_converter.cc142
-rw-r--r--chromium/ui/aura/mus/property_converter.h48
-rw-r--r--chromium/ui/aura/mus/property_converter_unittest.cc168
-rw-r--r--chromium/ui/aura/mus/property_utils.cc46
-rw-r--r--chromium/ui/aura/mus/property_utils.h30
-rw-r--r--chromium/ui/aura/mus/surface_id_handler.h40
-rw-r--r--chromium/ui/aura/mus/text_input_client_impl.cc44
-rw-r--r--chromium/ui/aura/mus/text_input_client_impl.h9
-rw-r--r--chromium/ui/aura/mus/window_compositor_frame_sink.cc31
-rw-r--r--chromium/ui/aura/mus/window_compositor_frame_sink.h17
-rw-r--r--chromium/ui/aura/mus/window_manager_delegate.h42
-rw-r--r--chromium/ui/aura/mus/window_mus.h22
-rw-r--r--chromium/ui/aura/mus/window_port_mus.cc151
-rw-r--r--chromium/ui/aura/mus/window_port_mus.h49
-rw-r--r--chromium/ui/aura/mus/window_tree_client.cc597
-rw-r--r--chromium/ui/aura/mus/window_tree_client.h130
-rw-r--r--chromium/ui/aura/mus/window_tree_client_delegate.h15
-rw-r--r--chromium/ui/aura/mus/window_tree_client_unittest.cc416
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus.cc56
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus.h32
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus_delegate.h25
-rw-r--r--chromium/ui/aura/mus/window_tree_host_mus_unittest.cc38
-rw-r--r--chromium/ui/aura/test/ui_controls_factory_ozone.cc4
-rw-r--r--chromium/ui/aura/window.cc36
-rw-r--r--chromium/ui/aura/window.h13
-rw-r--r--chromium/ui/aura/window_delegate.cc11
-rw-r--r--chromium/ui/aura/window_delegate.h3
-rw-r--r--chromium/ui/aura/window_event_dispatcher.cc26
-rw-r--r--chromium/ui/aura/window_event_dispatcher.h2
-rw-r--r--chromium/ui/aura/window_event_dispatcher_unittest.cc6
-rw-r--r--chromium/ui/aura/window_tree_host.cc112
-rw-r--r--chromium/ui/aura/window_tree_host.h58
-rw-r--r--chromium/ui/aura/window_tree_host_observer.h4
-rw-r--r--chromium/ui/aura/window_tree_host_platform.cc15
-rw-r--r--chromium/ui/aura/window_tree_host_platform.h9
-rw-r--r--chromium/ui/aura/window_tree_host_unittest.cc8
-rw-r--r--chromium/ui/aura/window_tree_host_x11.cc25
-rw-r--r--chromium/ui/aura/window_tree_host_x11.h9
-rw-r--r--chromium/ui/aura/window_unittest.cc8
68 files changed, 2050 insertions, 1463 deletions
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn
index 8ad575c389f..4b87bc15c98 100644
--- a/chromium/ui/aura/BUILD.gn
+++ b/chromium/ui/aura/BUILD.gn
@@ -71,24 +71,18 @@ component("aura") {
"mus/capture_synchronizer.cc",
"mus/capture_synchronizer.h",
"mus/capture_synchronizer_delegate.h",
+ "mus/client_surface_embedder.cc",
+ "mus/client_surface_embedder.h",
"mus/drag_drop_controller_host.h",
"mus/drag_drop_controller_mus.cc",
"mus/drag_drop_controller_mus.h",
"mus/focus_synchronizer.cc",
"mus/focus_synchronizer.h",
"mus/focus_synchronizer_delegate.h",
- "mus/gpu_memory_buffer_impl.cc",
- "mus/gpu_memory_buffer_impl.h",
- "mus/gpu_service.cc",
- "mus/gpu_service.h",
"mus/in_flight_change.cc",
"mus/in_flight_change.h",
"mus/input_method_mus.cc",
"mus/input_method_mus.h",
- "mus/mojo_gpu_memory_buffer.cc",
- "mus/mojo_gpu_memory_buffer.h",
- "mus/mojo_gpu_memory_buffer_manager.cc",
- "mus/mojo_gpu_memory_buffer_manager.h",
"mus/mus_context_factory.cc",
"mus/mus_context_factory.h",
"mus/mus_types.h",
@@ -98,7 +92,8 @@ component("aura") {
"mus/os_exchange_data_provider_mus.h",
"mus/property_converter.cc",
"mus/property_converter.h",
- "mus/surface_id_handler.h",
+ "mus/property_utils.cc",
+ "mus/property_utils.h",
"mus/text_input_client_impl.cc",
"mus/text_input_client_impl.h",
"mus/window_compositor_frame_sink.cc",
@@ -120,7 +115,6 @@ component("aura") {
"scoped_window_targeter.h",
"window.cc",
"window.h",
- "window_delegate.cc",
"window_delegate.h",
"window_event_dispatcher.cc",
"window_event_dispatcher.h",
@@ -152,7 +146,6 @@ component("aura") {
"//base/third_party/dynamic_annotations",
"//cc",
"//cc/surfaces",
- "//gpu/command_buffer/client",
"//gpu/ipc/client",
"//mojo/public/cpp/system",
"//net",
@@ -162,7 +155,6 @@ component("aura") {
"//skia",
"//ui/base",
"//ui/base/ime",
- "//ui/compositor",
"//ui/display",
"//ui/events",
"//ui/events:events_base",
@@ -175,6 +167,14 @@ component("aura") {
"//ui/platform_window/stub",
]
+ public_deps = [
+ "//ui/compositor",
+ ]
+
+ data_deps = [
+ "//services/ui",
+ ]
+
if (use_x11) {
configs += [
"//build/config/linux:x11",
@@ -336,6 +336,7 @@ test("aura_unittests") {
"mus/os_exchange_data_provider_mus_unittest.cc",
"mus/property_converter_unittest.cc",
"mus/window_tree_client_unittest.cc",
+ "mus/window_tree_host_mus_unittest.cc",
"test/run_all_unittests.cc",
"window_event_dispatcher_unittest.cc",
"window_targeter_unittest.cc",
diff --git a/chromium/ui/aura/DEPS b/chromium/ui/aura/DEPS
index 0f7a2b087d8..7db76bbbc10 100644
--- a/chromium/ui/aura/DEPS
+++ b/chromium/ui/aura/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+cc/surfaces/surface_id.h",
"+cc/surfaces/surface_sequence.h",
+ "+cc/surfaces/frame_sink_id.h",
"+mojo/common",
"+mojo/public/cpp/bindings",
"+net/base/filename_util.h",
diff --git a/chromium/ui/aura/client/aura_constants.cc b/chromium/ui/aura/client/aura_constants.cc
index b8d08438fe8..eea792948fc 100644
--- a/chromium/ui/aura/client/aura_constants.cc
+++ b/chromium/ui/aura/client/aura_constants.cc
@@ -4,16 +4,19 @@
#include "ui/aura/client/aura_constants.h"
+#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/window_property.h"
#include "ui/gfx/geometry/rect.h"
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, bool)
+DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, base::string16*)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::ModalType)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, gfx::ImageSkia*)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, gfx::Rect*)
+DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, gfx::Size*)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, std::string*)
-DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::InputMethod*)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::WindowShowState)
+DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, ui::mojom::WindowType);
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, void*)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, SkColor)
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(AURA_EXPORT, int32_t)
@@ -30,25 +33,28 @@ DEFINE_WINDOW_PROPERTY_KEY(bool, kAnimationsDisabledKey, false);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::ImageSkia, kAppIconKey, nullptr);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(std::string, kAppIdKey, nullptr);
DEFINE_WINDOW_PROPERTY_KEY(int, kAppType, 0);
-DEFINE_WINDOW_PROPERTY_KEY(bool, kCanMaximizeKey, false);
-DEFINE_WINDOW_PROPERTY_KEY(bool, kCanMinimizeKey, false);
-DEFINE_WINDOW_PROPERTY_KEY(bool, kCanResizeKey, true);
DEFINE_WINDOW_PROPERTY_KEY(bool, kConstrainedWindowKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kDrawAttentionKey, false);
-DEFINE_WINDOW_PROPERTY_KEY(bool, kExcludeFromMruKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kMirroringEnabledKey, false);
DEFINE_WINDOW_PROPERTY_KEY(Window*, kHostWindowKey, nullptr);
DEFINE_WINDOW_PROPERTY_KEY(ui::ModalType, kModalKey, ui::MODAL_TYPE_NONE);
-// gfx::Rect object for RestoreBoundsKey property is owned by the window
-// and will be freed automatically.
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(std::string, kNameKey, nullptr);
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Size, kPreferredSize, nullptr);
+DEFINE_WINDOW_PROPERTY_KEY(int32_t,
+ kResizeBehaviorKey,
+ ui::mojom::kResizeBehaviorCanResize);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr);
DEFINE_WINDOW_PROPERTY_KEY(
ui::WindowShowState, kRestoreShowStateKey, ui::SHOW_STATE_DEFAULT);
DEFINE_WINDOW_PROPERTY_KEY(
ui::WindowShowState, kShowStateKey, ui::SHOW_STATE_DEFAULT);
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(base::string16, kTitleKey, nullptr);
DEFINE_WINDOW_PROPERTY_KEY(int, kTopViewInset, 0);
DEFINE_WINDOW_PROPERTY_KEY(SkColor, kTopViewColor, SK_ColorTRANSPARENT);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::ImageSkia, kWindowIconKey, nullptr);
+DEFINE_WINDOW_PROPERTY_KEY(ui::mojom::WindowType,
+ kWindowTypeKey,
+ ui::mojom::WindowType::UNKNOWN);
} // namespace client
} // namespace aura
diff --git a/chromium/ui/aura/client/aura_constants.h b/chromium/ui/aura/client/aura_constants.h
index 032168d2ea1..06256e828ef 100644
--- a/chromium/ui/aura/client/aura_constants.h
+++ b/chromium/ui/aura/client/aura_constants.h
@@ -7,13 +7,16 @@
#include <string>
+#include "base/strings/string16.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
namespace ui {
-class InputMethod;
+namespace mojom {
+enum class WindowType;
+}
}
namespace aura {
@@ -43,15 +46,6 @@ AURA_EXPORT extern const WindowProperty<std::string*>* const kAppIdKey;
// pointer metrics. See AppType in ash/shared/app_types.h for more details.
AURA_EXPORT extern const WindowProperty<int>* const kAppType;
-// A property key to store the can-maximize flag.
-AURA_EXPORT extern const WindowProperty<bool>* const kCanMaximizeKey;
-
-// A property key to store the can-minimize flag.
-AURA_EXPORT extern const WindowProperty<bool>* const kCanMinimizeKey;
-
-// A property key to store the can-resize flag.
-AURA_EXPORT extern const WindowProperty<bool>* const kCanResizeKey;
-
// A property key to store if a window is a constrained window or not.
AURA_EXPORT extern const WindowProperty<bool>* const kConstrainedWindowKey;
@@ -59,10 +53,6 @@ AURA_EXPORT extern const WindowProperty<bool>* const kConstrainedWindowKey;
// attention.
AURA_EXPORT extern const aura::WindowProperty<bool>* const kDrawAttentionKey;
-// A property key to indicate that a window should be excluded from the most
-// recently used windows list.
-AURA_EXPORT extern const aura::WindowProperty<bool>* const kExcludeFromMruKey;
-
// A property key to indicate that a window is being "mirrored" and its contents
// should render regardless of its actual visibility state.
AURA_EXPORT extern const aura::WindowProperty<bool>* const kMirroringEnabledKey;
@@ -74,6 +64,16 @@ AURA_EXPORT extern const WindowProperty<Window*>* const kHostWindowKey;
// A property key to store the window modality.
AURA_EXPORT extern const WindowProperty<ui::ModalType>* const kModalKey;
+// A property key to store the name of the window; mostly used for debugging.
+AURA_EXPORT extern const WindowProperty<std::string*>* const kNameKey;
+
+// A property key to store the preferred size of the window.
+AURA_EXPORT extern const WindowProperty<gfx::Size*>* const kPreferredSize;
+
+// A property key to store the resize behavior, which is a bitmask of the
+// ui::mojom::kResizeBehavior values.
+AURA_EXPORT extern const WindowProperty<int32_t>* const kResizeBehaviorKey;
+
// A property key to store the restore bounds for a window.
AURA_EXPORT extern const WindowProperty<gfx::Rect*>* const kRestoreBoundsKey;
@@ -87,6 +87,9 @@ AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const
AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const
kShowStateKey;
+// A property key to store the title of the window; sometimes shown to users.
+AURA_EXPORT extern const WindowProperty<base::string16*>* const kTitleKey;
+
// The inset of the topmost view in the client view from the top of the
// non-client view. The topmost view depends on the window type. The topmost
// view is the tab strip for tabbed browser windows, the toolbar for popups,
@@ -99,6 +102,9 @@ AURA_EXPORT extern const aura::WindowProperty<SkColor>* const kTopViewColor;
// A property key to store the window icon, typically 16x16 for title bars.
AURA_EXPORT extern const WindowProperty<gfx::ImageSkia*>* const kWindowIconKey;
+AURA_EXPORT extern const aura::WindowProperty<ui::mojom::WindowType>* const
+ kWindowTypeKey;
+
// Alphabetical sort.
} // namespace client
diff --git a/chromium/ui/aura/client/transient_window_client_observer.h b/chromium/ui/aura/client/transient_window_client_observer.h
index 27dc39bf44a..7213d827d0d 100644
--- a/chromium/ui/aura/client/transient_window_client_observer.h
+++ b/chromium/ui/aura/client/transient_window_client_observer.h
@@ -25,6 +25,16 @@ class AURA_EXPORT TransientWindowClientObserver {
virtual void OnTransientChildWindowRemoved(Window* parent,
Window* transient_child) = 0;
+ // Called when adding or removing a transient results in restacking.
+ // |transient_child| is the window being stacked above |parent|. |parent| is
+ // the window the transient was added or removed from. This is followed by a
+ // call to Window::StackChildAbove() and then
+ // OnDidRestackTransientChildAbove().
+ virtual void OnWillRestackTransientChildAbove(Window* parent,
+ Window* transient_child) = 0;
+ virtual void OnDidRestackTransientChildAbove(Window* parent,
+ Window* transient_child) = 0;
+
protected:
virtual ~TransientWindowClientObserver() {}
};
diff --git a/chromium/ui/aura/demo/demo_main.cc b/chromium/ui/aura/demo/demo_main.cc
index 61ea75fe877..6f398cf3619 100644
--- a/chromium/ui/aura/demo/demo_main.cc
+++ b/chromium/ui/aura/demo/demo_main.cc
@@ -15,7 +15,7 @@
#include "base/run_loop.h"
#include "build/build_config.h"
#include "cc/surfaces/surface_manager.h"
-#include "third_party/skia/include/core/SkXfermode.h"
+#include "third_party/skia/include/core/SkBlendMode.h"
#include "ui/aura/client/default_capture_client.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/env.h"
@@ -72,14 +72,14 @@ class DemoWindowDelegate : public aura::WindowDelegate {
void OnCaptureLost() override {}
void OnPaint(const ui::PaintContext& context) override {
ui::PaintRecorder recorder(context, window_bounds_.size());
- recorder.canvas()->DrawColor(color_, SkXfermode::kSrc_Mode);
+ recorder.canvas()->DrawColor(color_, SkBlendMode::kSrc);
gfx::Rect r;
recorder.canvas()->GetClipBounds(&r);
// Fill with a non-solid color so that the compositor will exercise its
// texture upload path.
while (!r.IsEmpty()) {
r.Inset(2, 2);
- recorder.canvas()->FillRect(r, color_, SkXfermode::kXor_Mode);
+ recorder.canvas()->FillRect(r, color_, SkBlendMode::kXor);
}
}
void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc
index d4b5cdfe43d..5e9411332e3 100644
--- a/chromium/ui/aura/env.cc
+++ b/chromium/ui/aura/env.cc
@@ -156,7 +156,8 @@ Env::Env(Mode mode)
mouse_button_flags_(0),
is_touch_down_(false),
input_state_lookup_(InputStateLookup::Create()),
- context_factory_(NULL) {
+ context_factory_(nullptr),
+ context_factory_private_(nullptr) {
DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
lazy_tls_ptr.Pointer()->Set(this);
}
diff --git a/chromium/ui/aura/env.h b/chromium/ui/aura/env.h
index 274c9e74bc7..3d2bccc124d 100644
--- a/chromium/ui/aura/env.h
+++ b/chromium/ui/aura/env.h
@@ -17,6 +17,7 @@
namespace ui {
class ContextFactory;
+class ContextFactoryPrivate;
class PlatformEventSource;
}
namespace aura {
@@ -55,6 +56,8 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
static Env* GetInstance();
static Env* GetInstanceDontCreate();
+ Mode mode() const { return mode_; }
+
// Called internally to create the appropriate WindowPort implementation.
std::unique_ptr<WindowPort> CreateWindowPort(Window* window);
@@ -85,8 +88,17 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
}
ui::ContextFactory* context_factory() { return context_factory_; }
+ void set_context_factory_private(
+ ui::ContextFactoryPrivate* context_factory_private) {
+ context_factory_private_ = context_factory_private;
+ }
+ ui::ContextFactoryPrivate* context_factory_private() {
+ return context_factory_private_;
+ }
+
// See CreateInstance() for description.
void SetWindowTreeClient(WindowTreeClient* window_tree_client);
+ bool HasWindowTreeClient() const { return window_tree_client_ != nullptr; }
// Sets the active FocusClient and the window the FocusClient is associated
// with. |window| is not necessarily the window that actually has focus.
@@ -140,6 +152,7 @@ class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
std::unique_ptr<ui::PlatformEventSource> event_source_;
ui::ContextFactory* context_factory_;
+ ui::ContextFactoryPrivate* context_factory_private_;
Window* active_focus_client_root_ = nullptr;
client::FocusClient* active_focus_client_ = nullptr;
diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
index cb152db9c9c..0424fe113b4 100644
--- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
diff --git a/chromium/ui/aura/mus/DEPS b/chromium/ui/aura/mus/DEPS
index a67b740f18a..39280c0febd 100644
--- a/chromium/ui/aura/mus/DEPS
+++ b/chromium/ui/aura/mus/DEPS
@@ -3,13 +3,17 @@ include_rules = [
"+cc/output/compositor_frame_sink_client.h",
"+cc/output/compositor_frame_sink.h",
"+cc/scheduler/begin_frame_source.h",
+ "+cc/surfaces/surface_id_allocator.h",
+ "+cc/surfaces/surface_info.h",
"+cc/surfaces/surface_manager.h",
+ "+cc/surfaces/surface_reference_factory.h",
"+gpu/command_buffer/client/gpu_memory_buffer_manager.h",
"+gpu/ipc/client/gpu_channel_host.h",
"+mojo/public/cpp/system/buffer.h",
"+mojo/public/cpp/system/platform_handle.h",
- "+services/ui/public/cpp/context_provider.h",
+ "+services/ui/common/accelerator_util.h",
+ "+services/ui/public/cpp/gpu",
"+services/ui/public/cpp/property_type_converters.h",
"+services/ui/public/cpp/raster_thread_helper.h",
"+ui/gl/gl_bindings.h",
-] \ No newline at end of file
+]
diff --git a/chromium/ui/aura/mus/client_surface_embedder.cc b/chromium/ui/aura/mus/client_surface_embedder.cc
new file mode 100644
index 00000000000..da2bb615984
--- /dev/null
+++ b/chromium/ui/aura/mus/client_surface_embedder.cc
@@ -0,0 +1,74 @@
+// 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/client_surface_embedder.h"
+
+#include "cc/surfaces/surface_reference_factory.h"
+#include "ui/aura/window.h"
+
+namespace aura {
+namespace {
+
+// TODO(mfomitchev, samans): Remove these stub classes once the SurfaceReference
+// work is complete.
+class StubSurfaceReferenceFactory : public cc::SurfaceReferenceFactory {
+ public:
+ StubSurfaceReferenceFactory() = default;
+
+ // cc::SurfaceReferenceFactory:
+ base::Closure CreateReference(
+ cc::SurfaceReferenceOwner* owner,
+ const cc::SurfaceId& surface_id) const override {
+ return base::Closure();
+ }
+
+ protected:
+ ~StubSurfaceReferenceFactory() override = default;
+
+ DISALLOW_COPY_AND_ASSIGN(StubSurfaceReferenceFactory);
+};
+} // namespace
+
+ClientSurfaceEmbedder::ClientSurfaceEmbedder(Window* window) : window_(window) {
+ surface_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_TEXTURED);
+ surface_layer_->SetVisible(true);
+ // The frame provided by the parent window->layer() needs to show through
+ // the surface layer.
+ surface_layer_->SetFillsBoundsOpaquely(false);
+
+ clip_layer_ = base::MakeUnique<ui::Layer>(ui::LAYER_NOT_DRAWN);
+ clip_layer_->SetFillsBoundsOpaquely(false);
+
+ clip_layer_->Add(surface_layer_.get());
+ window_->layer()->Add(clip_layer_.get());
+
+ // Window's layer may contain content from this client (the embedder), e.g.
+ // this is the case with window decorations provided by Window Manager.
+ // This content should appear underneath the content of the embedded client.
+ window_->layer()->StackAtTop(clip_layer_.get());
+
+ // We can't set this on window's layer, because that would clip the window
+ // shadow.
+ clip_layer_->SetMasksToBounds(true);
+}
+
+ClientSurfaceEmbedder::~ClientSurfaceEmbedder() = default;
+
+void ClientSurfaceEmbedder::UpdateSurface(const cc::SurfaceInfo& surface_info) {
+ // TODO(mfomitchev): Currently the frame size may not match the window size.
+ // In the future the surface id will be created by Ash (and used with the
+ // surface layer) when the window resize happens, which will ensure that the
+ // surface size matches the window size (unless a timeout occurs).
+ gfx::Size frame_size = surface_info.size_in_pixels();
+ surface_layer_->SetBounds(
+ gfx::Rect(0, 0, frame_size.width(), frame_size.height()));
+ // Clip to window bounds.
+ clip_layer_->SetBounds(
+ gfx::Rect(0, 0, window_->bounds().width(), window_->bounds().height()));
+
+ surface_layer_->SetShowSurface(
+ surface_info, make_scoped_refptr(new StubSurfaceReferenceFactory));
+}
+
+} // namespace aura
diff --git a/chromium/ui/aura/mus/client_surface_embedder.h b/chromium/ui/aura/mus/client_surface_embedder.h
new file mode 100644
index 00000000000..75b45c224fe
--- /dev/null
+++ b/chromium/ui/aura/mus/client_surface_embedder.h
@@ -0,0 +1,45 @@
+// 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 <memory>
+
+#include "base/macros.h"
+
+namespace cc {
+class SurfaceInfo;
+}
+
+namespace ui {
+class Layer;
+}
+
+namespace aura {
+
+class Window;
+
+// Used by WindowPortMus when it is embedding a client. Responsible for setting
+// up layers containing content from the client, parenting them to the window's
+// layer, and updating them when the client submits new surfaces.
+class ClientSurfaceEmbedder {
+ public:
+ explicit ClientSurfaceEmbedder(Window* window);
+ ~ClientSurfaceEmbedder();
+
+ // Updates the surface layer and the clip layer based on the surface info.
+ void UpdateSurface(const cc::SurfaceInfo& surface_info);
+
+ private:
+ // The window which embeds the client.
+ Window* window_;
+
+ // Contains the client's content.
+ std::unique_ptr<ui::Layer> surface_layer_;
+
+ // Used for clipping the surface layer to the window bounds.
+ std::unique_ptr<ui::Layer> clip_layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClientSurfaceEmbedder);
+};
+
+} // namespace aura
diff --git a/chromium/ui/aura/mus/drag_drop_controller_mus.cc b/chromium/ui/aura/mus/drag_drop_controller_mus.cc
index b59f17792c3..a82841c80c0 100644
--- a/chromium/ui/aura/mus/drag_drop_controller_mus.cc
+++ b/chromium/ui/aura/mus/drag_drop_controller_mus.cc
@@ -9,8 +9,10 @@
#include <vector>
#include "base/auto_reset.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.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 "ui/aura/client/drag_drop_delegate.h"
@@ -146,10 +148,9 @@ int DragDropControllerMus::StartDragAndDrop(
std::map<std::string, std::vector<uint8_t>> drag_data =
static_cast<const aura::OSExchangeDataProviderMus&>(data.provider())
.GetData();
- window_tree_->PerformDragDrop(
- change_id, source_window_mus->server_id(),
- mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(drag_data),
- drag_operations);
+ window_tree_->PerformDragDrop(change_id, source_window_mus->server_id(),
+ mojo::MapToUnorderedMap(drag_data),
+ drag_operations);
base::MessageLoop* loop = base::MessageLoop::current();
base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
@@ -199,7 +200,7 @@ DragDropControllerMus::CreateDropTargetEvent(Window* window,
uint32_t effect_bitmask) {
DCHECK(window->GetHost());
gfx::Point root_location = screen_location;
- window->GetHost()->ConvertPointFromNativeScreen(&root_location);
+ window->GetHost()->ConvertScreenInPixelsToDIP(&root_location);
gfx::Point location = root_location;
Window::ConvertPointToTarget(window->GetRootWindow(), window, &location);
std::unique_ptr<ui::DropTargetEvent> event =
diff --git a/chromium/ui/aura/mus/gpu_memory_buffer_impl.cc b/chromium/ui/aura/mus/gpu_memory_buffer_impl.cc
deleted file mode 100644
index 63489549e0d..00000000000
--- a/chromium/ui/aura/mus/gpu_memory_buffer_impl.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2013 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/gpu_memory_buffer_impl.h"
-
-namespace aura {
-
-GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id,
- const gfx::Size& size,
- gfx::BufferFormat format)
- : id_(id), size_(size), format_(format), mapped_(false) {}
-
-GpuMemoryBufferImpl::~GpuMemoryBufferImpl() {
- DCHECK(!mapped_);
-}
-
-// static
-GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer(
- ClientBuffer buffer) {
- return reinterpret_cast<GpuMemoryBufferImpl*>(buffer);
-}
-
-gfx::Size GpuMemoryBufferImpl::GetSize() const {
- return size_;
-}
-
-gfx::BufferFormat GpuMemoryBufferImpl::GetFormat() const {
- return format_;
-}
-
-gfx::GpuMemoryBufferId GpuMemoryBufferImpl::GetId() const {
- return id_;
-}
-
-ClientBuffer GpuMemoryBufferImpl::AsClientBuffer() {
- return reinterpret_cast<ClientBuffer>(this);
-}
-
-#if defined(USE_OZONE)
-scoped_refptr<ui::NativePixmap> GpuMemoryBufferImpl::GetNativePixmap() {
- return scoped_refptr<ui::NativePixmap>();
-}
-#endif
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/gpu_memory_buffer_impl.h b/chromium/ui/aura/mus/gpu_memory_buffer_impl.h
deleted file mode 100644
index 4f8534778f9..00000000000
--- a/chromium/ui/aura/mus/gpu_memory_buffer_impl.h
+++ /dev/null
@@ -1,59 +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.
-
-#ifndef UI_AURA_MUS_CPP_GPU_MEMORY_BUFFER_IMPL_H_
-#define UI_AURA_MUS_CPP_GPU_MEMORY_BUFFER_IMPL_H_
-
-#include <memory>
-
-#include "base/callback.h"
-#include "base/macros.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/gpu_memory_buffer.h"
-
-#if defined(USE_OZONE)
-#include "ui/ozone/public/native_pixmap.h"
-#endif
-
-namespace aura {
-
-// Provides common implementation of a GPU memory buffer.
-class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
- public:
- ~GpuMemoryBufferImpl() override;
-
- // Type-checking upcast routine. Returns an NULL on failure.
- static GpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer);
-
- // Overridden from gfx::GpuMemoryBuffer:
- gfx::Size GetSize() const override;
- gfx::BufferFormat GetFormat() const override;
- gfx::GpuMemoryBufferId GetId() const override;
- ClientBuffer AsClientBuffer() override;
-
- // Returns the type of this GpuMemoryBufferImpl.
- virtual gfx::GpuMemoryBufferType GetBufferType() const = 0;
-
-#if defined(USE_OZONE)
- // Returns a ui::NativePixmap when one is available.
- virtual scoped_refptr<ui::NativePixmap> GetNativePixmap();
-#endif
-
- protected:
- GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id,
- const gfx::Size& size,
- gfx::BufferFormat format);
-
- const gfx::GpuMemoryBufferId id_;
- const gfx::Size size_;
- const gfx::BufferFormat format_;
- bool mapped_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_CPP_GPU_MEMORY_BUFFER_IMPL_H_
diff --git a/chromium/ui/aura/mus/gpu_service.cc b/chromium/ui/aura/mus/gpu_service.cc
deleted file mode 100644
index 4ffe4900c46..00000000000
--- a/chromium/ui/aura/mus/gpu_service.cc
+++ /dev/null
@@ -1,155 +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/gpu_service.h"
-
-#include "base/command_line.h"
-#include "base/memory/singleton.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "build/build_config.h"
-#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
-#include "mojo/public/cpp/system/platform_handle.h"
-#include "services/service_manager/public/cpp/connector.h"
-#include "services/ui/public/interfaces/constants.mojom.h"
-#include "services/ui/public/interfaces/gpu_service.mojom.h"
-#include "ui/aura/mus/mojo_gpu_memory_buffer_manager.h"
-
-namespace aura {
-
-GpuService::GpuService(service_manager::Connector* connector,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner)
- : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
- io_task_runner_(std::move(task_runner)),
- connector_(connector),
- shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED),
- gpu_memory_buffer_manager_(new MojoGpuMemoryBufferManager) {
- DCHECK(main_task_runner_);
- DCHECK(connector_);
- if (!io_task_runner_) {
- io_thread_.reset(new base::Thread("GPUIOThread"));
- base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
- thread_options.priority = base::ThreadPriority::NORMAL;
- CHECK(io_thread_->StartWithOptions(thread_options));
- io_task_runner_ = io_thread_->task_runner();
- }
-}
-
-GpuService::~GpuService() {
- DCHECK(IsMainThread());
- for (const auto& callback : establish_callbacks_)
- callback.Run(nullptr);
- shutdown_event_.Signal();
- if (gpu_channel_)
- gpu_channel_->DestroyChannel();
-}
-
-// static
-std::unique_ptr<GpuService> GpuService::Create(
- service_manager::Connector* connector,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
- return base::WrapUnique(new GpuService(connector, std::move(task_runner)));
-}
-
-void GpuService::EstablishGpuChannel(
- const gpu::GpuChannelEstablishedCallback& callback) {
- DCHECK(IsMainThread());
- scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel();
- if (channel) {
- main_task_runner_->PostTask(FROM_HERE,
- base::Bind(callback, std::move(channel)));
- return;
- }
- establish_callbacks_.push_back(callback);
- if (gpu_service_)
- return;
-
- connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_service_);
- gpu_service_->EstablishGpuChannel(
- base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this)));
-}
-
-scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() {
- DCHECK(IsMainThread());
- if (GetGpuChannel())
- return gpu_channel_;
-
- int client_id = 0;
- mojo::ScopedMessagePipeHandle channel_handle;
- gpu::GPUInfo gpu_info;
- connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_service_);
-
- mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
- if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle,
- &gpu_info)) {
- DLOG(WARNING)
- << "Channel encountered error while establishing gpu channel.";
- return nullptr;
- }
- OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info);
- return gpu_channel_;
-}
-
-gpu::GpuMemoryBufferManager* GpuService::GetGpuMemoryBufferManager() {
- return gpu_memory_buffer_manager_.get();
-}
-
-scoped_refptr<gpu::GpuChannelHost> GpuService::GetGpuChannel() {
- DCHECK(IsMainThread());
- if (gpu_channel_ && gpu_channel_->IsLost()) {
- gpu_channel_->DestroyChannel();
- gpu_channel_ = nullptr;
- }
- return gpu_channel_;
-}
-
-void GpuService::OnEstablishedGpuChannel(
- int client_id,
- mojo::ScopedMessagePipeHandle channel_handle,
- const gpu::GPUInfo& gpu_info) {
- DCHECK(IsMainThread());
- DCHECK(gpu_service_.get());
- DCHECK(!gpu_channel_);
-
- if (client_id) {
- gpu_channel_ = gpu::GpuChannelHost::Create(
- this, client_id, gpu_info, IPC::ChannelHandle(channel_handle.release()),
- &shutdown_event_, gpu_memory_buffer_manager_.get());
- }
-
- gpu_service_.reset();
- for (const auto& i : establish_callbacks_)
- i.Run(gpu_channel_);
- establish_callbacks_.clear();
-}
-
-bool GpuService::IsMainThread() {
- return main_task_runner_->BelongsToCurrentThread();
-}
-
-scoped_refptr<base::SingleThreadTaskRunner>
-GpuService::GetIOThreadTaskRunner() {
- return io_task_runner_;
-}
-
-std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory(
- size_t size) {
- mojo::ScopedSharedBufferHandle handle =
- mojo::SharedBufferHandle::Create(size);
- if (!handle.is_valid())
- return nullptr;
-
- base::SharedMemoryHandle platform_handle;
- size_t shared_memory_size;
- bool readonly;
- MojoResult result = mojo::UnwrapSharedMemoryHandle(
- std::move(handle), &platform_handle, &shared_memory_size, &readonly);
- if (result != MOJO_RESULT_OK)
- return nullptr;
- DCHECK_EQ(shared_memory_size, size);
-
- return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
-}
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/gpu_service.h b/chromium/ui/aura/mus/gpu_service.h
deleted file mode 100644
index c20239c1748..00000000000
--- a/chromium/ui/aura/mus/gpu_service.h
+++ /dev/null
@@ -1,84 +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.
-
-#ifndef UI_AURA_MUS_GPU_SERVICE_H_
-#define UI_AURA_MUS_GPU_SERVICE_H_
-
-#include <stdint.h>
-#include <vector>
-
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
-#include "base/synchronization/lock.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "gpu/ipc/client/gpu_channel_host.h"
-#include "services/ui/public/interfaces/gpu_service.mojom.h"
-#include "ui/aura/aura_export.h"
-#include "ui/aura/mus/mojo_gpu_memory_buffer_manager.h"
-
-namespace service_manager {
-class Connector;
-}
-
-namespace aura {
-
-class AURA_EXPORT GpuService : public gpu::GpuChannelHostFactory,
- public gpu::GpuChannelEstablishFactory {
- public:
- ~GpuService() override;
-
- gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
- return gpu_memory_buffer_manager_.get();
- }
-
- // The GpuService has to be initialized in the main thread before establishing
- // the gpu channel. If no |task_runner| is provided, then a new thread is
- // created and used.
- static std::unique_ptr<GpuService> Create(
- service_manager::Connector* connector,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner = nullptr);
-
- // gpu::GpuChannelEstablishFactory:
- void EstablishGpuChannel(
- const gpu::GpuChannelEstablishedCallback& callback) override;
- scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync() override;
- gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
-
- private:
- friend struct base::DefaultSingletonTraits<GpuService>;
-
- GpuService(service_manager::Connector* connector,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner);
-
- scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
- void EstablishGpuChannelOnMainThreadSyncLocked();
- void OnEstablishedGpuChannel(int client_id,
- mojo::ScopedMessagePipeHandle channel_handle,
- const gpu::GPUInfo& gpu_info);
-
- // gpu::GpuChannelHostFactory overrides:
- bool IsMainThread() override;
- scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
- std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
- size_t size) override;
-
- scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
- service_manager::Connector* connector_;
- base::WaitableEvent shutdown_event_;
- std::unique_ptr<base::Thread> io_thread_;
- std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
-
- ui::mojom::GpuServicePtr gpu_service_;
- scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
- std::vector<gpu::GpuChannelEstablishedCallback> establish_callbacks_;
-
- DISALLOW_COPY_AND_ASSIGN(GpuService);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_GPU_SERVICE_H_
diff --git a/chromium/ui/aura/mus/in_flight_change.cc b/chromium/ui/aura/mus/in_flight_change.cc
index 9fd0eb9b34e..3b369a5455d 100644
--- a/chromium/ui/aura/mus/in_flight_change.cc
+++ b/chromium/ui/aura/mus/in_flight_change.cc
@@ -70,7 +70,7 @@ void CrashInFlightChange::SetRevertValueFrom(const InFlightChange& change) {
}
void CrashInFlightChange::ChangeFailed() {
- DLOG(ERROR) << "changed failed, type=" << static_cast<int>(change_type());
+ DLOG(ERROR) << "change failed, type=" << static_cast<int>(change_type());
CHECK(false);
}
diff --git a/chromium/ui/aura/mus/in_flight_change.h b/chromium/ui/aura/mus/in_flight_change.h
index 0808fe5e77d..6a8b6d4fa88 100644
--- a/chromium/ui/aura/mus/in_flight_change.h
+++ b/chromium/ui/aura/mus/in_flight_change.h
@@ -13,7 +13,6 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "mojo/public/cpp/bindings/array.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/aura/mus/input_method_mus.cc b/chromium/ui/aura/mus/input_method_mus.cc
index 49043572447..230dfff77c4 100644
--- a/chromium/ui/aura/mus/input_method_mus.cc
+++ b/chromium/ui/aura/mus/input_method_mus.cc
@@ -6,8 +6,9 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "services/ui/public/interfaces/constants.mojom.h"
-#include "services/ui/public/interfaces/ime.mojom.h"
+#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/aura/mus/text_input_client_impl.h"
#include "ui/aura/mus/window_port_mus.h"
@@ -33,7 +34,8 @@ InputMethodMus::InputMethodMus(ui::internal::InputMethodDelegate* delegate,
InputMethodMus::~InputMethodMus() {}
void InputMethodMus::Init(service_manager::Connector* connector) {
- connector->ConnectToInterface(ui::mojom::kServiceName, &ime_server_);
+ if (connector)
+ connector->BindInterface(ui::mojom::kServiceName, &ime_server_);
}
void InputMethodMus::DispatchKeyEvent(
@@ -90,10 +92,8 @@ void InputMethodMus::OnTextInputTypeChanged(const ui::TextInputClient* client) {
UpdateTextInputType();
InputMethodBase::OnTextInputTypeChanged(client);
- if (input_method_) {
- input_method_->OnTextInputTypeChanged(
- static_cast<ui::mojom::TextInputType>(client->GetTextInputType()));
- }
+ if (input_method_)
+ input_method_->OnTextInputTypeChanged(client->GetTextInputType());
}
void InputMethodMus::OnCaretBoundsChanged(const ui::TextInputClient* client) {
@@ -123,9 +123,23 @@ void InputMethodMus::OnDidChangeFocusedClient(
InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
UpdateTextInputType();
+ // TODO(moshayedi): crbug.com/681563. Handle when there is no focused clients.
+ if (!focused)
+ return;
+
text_input_client_ = base::MakeUnique<TextInputClientImpl>(focused);
- ime_server_->StartSession(text_input_client_->CreateInterfacePtrAndBind(),
- GetProxy(&input_method_));
+ if (ime_server_) {
+ ui::mojom::StartSessionDetailsPtr details =
+ ui::mojom::StartSessionDetails::New();
+ details->client = text_input_client_->CreateInterfacePtrAndBind();
+ details->input_method_request = MakeRequest(&input_method_);
+ details->text_input_type = focused->GetTextInputType();
+ details->text_input_mode = focused->GetTextInputMode();
+ details->text_direction = focused->GetTextDirection();
+ details->text_input_flags = focused->GetTextInputFlags();
+ details->caret_bounds = focused->GetCaretBounds();
+ ime_server_->StartSession(std::move(details));
+ }
}
void InputMethodMus::UpdateTextInputType() {
diff --git a/chromium/ui/aura/mus/input_method_mus.h b/chromium/ui/aura/mus/input_method_mus.h
index c34cac833a9..d5400248afc 100644
--- a/chromium/ui/aura/mus/input_method_mus.h
+++ b/chromium/ui/aura/mus/input_method_mus.h
@@ -8,7 +8,7 @@
#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.mojom.h"
+#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/base/ime/input_method_base.h"
@@ -64,6 +64,7 @@ class AURA_EXPORT InputMethodMus : public ui::InputMethodBase {
// for tests.
Window* window_;
+ // May be null in tests.
ui::mojom::IMEServerPtr ime_server_;
ui::mojom::InputMethodPtr input_method_;
std::unique_ptr<TextInputClientImpl> text_input_client_;
diff --git a/chromium/ui/aura/mus/mojo_gpu_memory_buffer.cc b/chromium/ui/aura/mus/mojo_gpu_memory_buffer.cc
deleted file mode 100644
index 7523d86355b..00000000000
--- a/chromium/ui/aura/mus/mojo_gpu_memory_buffer.cc
+++ /dev/null
@@ -1,132 +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.
-
-#include "ui/aura/mus/mojo_gpu_memory_buffer.h"
-
-#include <stdint.h>
-
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/memory/shared_memory.h"
-#include "base/numerics/safe_conversions.h"
-#include "build/build_config.h"
-#include "mojo/public/cpp/system/buffer.h"
-#include "mojo/public/cpp/system/platform_handle.h"
-#include "ui/gfx/buffer_format_util.h"
-
-namespace aura {
-
-// TODO(rjkroege): Support running a destructor callback as necessary.
-MojoGpuMemoryBufferImpl::~MojoGpuMemoryBufferImpl() {}
-
-// static
-std::unique_ptr<gfx::GpuMemoryBuffer> MojoGpuMemoryBufferImpl::Create(
- const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage) {
- size_t bytes = gfx::BufferSizeForBufferFormat(size, format);
-
- mojo::ScopedSharedBufferHandle handle =
- mojo::SharedBufferHandle::Create(bytes);
- if (!handle.is_valid())
- return nullptr;
-
- base::SharedMemoryHandle platform_handle;
- size_t shared_memory_size;
- bool readonly;
- MojoResult result = mojo::UnwrapSharedMemoryHandle(
- std::move(handle), &platform_handle, &shared_memory_size, &readonly);
- if (result != MOJO_RESULT_OK)
- return nullptr;
- DCHECK_EQ(shared_memory_size, bytes);
-
- auto shared_memory =
- base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
- const int stride = base::checked_cast<int>(
- gfx::RowSizeForBufferFormat(size.width(), format, 0));
- return base::WrapUnique(new MojoGpuMemoryBufferImpl(
- size, format, std::move(shared_memory), 0, stride));
-}
-
-// static
-std::unique_ptr<gfx::GpuMemoryBuffer> MojoGpuMemoryBufferImpl::CreateFromHandle(
- const gfx::GpuMemoryBufferHandle& handle,
- const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage) {
- DCHECK_EQ(handle.type, gfx::SHARED_MEMORY_BUFFER);
- DCHECK(base::SharedMemory::IsHandleValid(handle.handle));
- const bool readonly = false;
- auto shared_memory =
- base::MakeUnique<base::SharedMemory>(handle.handle, readonly);
- return base::WrapUnique(new MojoGpuMemoryBufferImpl(
- size, format, std::move(shared_memory), handle.offset, handle.stride));
-}
-
-MojoGpuMemoryBufferImpl* MojoGpuMemoryBufferImpl::FromClientBuffer(
- ClientBuffer buffer) {
- return reinterpret_cast<MojoGpuMemoryBufferImpl*>(buffer);
-}
-
-const unsigned char* MojoGpuMemoryBufferImpl::GetMemory() const {
- return static_cast<const unsigned char*>(shared_memory_->memory());
-}
-
-bool MojoGpuMemoryBufferImpl::Map() {
- DCHECK(!mapped_);
- DCHECK_EQ(static_cast<size_t>(stride_),
- gfx::RowSizeForBufferFormat(size_.width(), format_, 0));
- const size_t buffer_size = gfx::BufferSizeForBufferFormat(size_, format_);
- const size_t map_size = offset_ + buffer_size;
- if (!shared_memory_->Map(map_size))
- return false;
- mapped_ = true;
- return true;
-}
-
-void* MojoGpuMemoryBufferImpl::memory(size_t plane) {
- DCHECK(mapped_);
- DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
- return reinterpret_cast<uint8_t*>(shared_memory_->memory()) + offset_ +
- gfx::BufferOffsetForBufferFormat(size_, format_, plane);
-}
-
-void MojoGpuMemoryBufferImpl::Unmap() {
- DCHECK(mapped_);
- shared_memory_->Unmap();
- mapped_ = false;
-}
-
-int MojoGpuMemoryBufferImpl::stride(size_t plane) const {
- DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
- return base::checked_cast<int>(gfx::RowSizeForBufferFormat(
- size_.width(), format_, static_cast<int>(plane)));
-}
-
-gfx::GpuMemoryBufferHandle MojoGpuMemoryBufferImpl::GetHandle() const {
- gfx::GpuMemoryBufferHandle handle;
- handle.type = gfx::SHARED_MEMORY_BUFFER;
- handle.handle = shared_memory_->handle();
- handle.offset = offset_;
- handle.stride = stride_;
-
- return handle;
-}
-
-gfx::GpuMemoryBufferType MojoGpuMemoryBufferImpl::GetBufferType() const {
- return gfx::SHARED_MEMORY_BUFFER;
-}
-
-MojoGpuMemoryBufferImpl::MojoGpuMemoryBufferImpl(
- const gfx::Size& size,
- gfx::BufferFormat format,
- std::unique_ptr<base::SharedMemory> shared_memory,
- uint32_t offset,
- int32_t stride)
- : GpuMemoryBufferImpl(gfx::GenericSharedMemoryId(0), size, format),
- shared_memory_(std::move(shared_memory)),
- offset_(offset),
- stride_(stride) {}
-
-} // namespace ui
diff --git a/chromium/ui/aura/mus/mojo_gpu_memory_buffer.h b/chromium/ui/aura/mus/mojo_gpu_memory_buffer.h
deleted file mode 100644
index 40d83103dce..00000000000
--- a/chromium/ui/aura/mus/mojo_gpu_memory_buffer.h
+++ /dev/null
@@ -1,61 +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_CPP_MOJO_GPU_MEMORY_BUFFER_H_
-#define UI_AURA_MUS_CPP_MOJO_GPU_MEMORY_BUFFER_H_
-
-#include <stddef.h>
-
-#include <memory>
-
-#include "base/macros.h"
-#include "ui/aura/mus/gpu_memory_buffer_impl.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/gpu_memory_buffer.h"
-
-namespace aura {
-
-class MojoGpuMemoryBufferImpl : public GpuMemoryBufferImpl {
- public:
- ~MojoGpuMemoryBufferImpl() override;
-
- static std::unique_ptr<gfx::GpuMemoryBuffer> Create(const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage);
- static std::unique_ptr<gfx::GpuMemoryBuffer> CreateFromHandle(
- const gfx::GpuMemoryBufferHandle& handle,
- const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage);
- static MojoGpuMemoryBufferImpl* FromClientBuffer(ClientBuffer buffer);
-
- const unsigned char* GetMemory() const;
-
- // Overridden from gfx::GpuMemoryBuffer:
- bool Map() override;
- void* memory(size_t plane) override;
- void Unmap() override;
- int stride(size_t plane) const override;
- gfx::GpuMemoryBufferHandle GetHandle() const override;
-
- // Overridden from gfx::GpuMemoryBufferImpl
- gfx::GpuMemoryBufferType GetBufferType() const override;
-
- private:
- MojoGpuMemoryBufferImpl(const gfx::Size& size,
- gfx::BufferFormat format,
- std::unique_ptr<base::SharedMemory> shared_memory,
- uint32_t offset,
- int32_t stride);
-
- std::unique_ptr<base::SharedMemory> shared_memory_;
- const uint32_t offset_;
- const int32_t stride_;
-
- DISALLOW_COPY_AND_ASSIGN(MojoGpuMemoryBufferImpl);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_CPP_MOJO_GPU_MEMORY_BUFFER_H_
diff --git a/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.cc b/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.cc
deleted file mode 100644
index ff5a7c7d305..00000000000
--- a/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.cc
+++ /dev/null
@@ -1,40 +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.
-
-#include "ui/aura/mus/mojo_gpu_memory_buffer_manager.h"
-
-#include "base/logging.h"
-#include "ui/aura/mus/mojo_gpu_memory_buffer.h"
-
-namespace aura {
-
-MojoGpuMemoryBufferManager::MojoGpuMemoryBufferManager() {}
-
-MojoGpuMemoryBufferManager::~MojoGpuMemoryBufferManager() {}
-
-std::unique_ptr<gfx::GpuMemoryBuffer>
-MojoGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
- const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage,
- gpu::SurfaceHandle surface_handle) {
- return MojoGpuMemoryBufferImpl::Create(size, format, usage);
-}
-
-std::unique_ptr<gfx::GpuMemoryBuffer>
-MojoGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle(
- const gfx::GpuMemoryBufferHandle& handle,
- const gfx::Size& size,
- gfx::BufferFormat format) {
- const gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ;
- return MojoGpuMemoryBufferImpl::CreateFromHandle(handle, size, format, usage);
-}
-
-void MojoGpuMemoryBufferManager::SetDestructionSyncToken(
- gfx::GpuMemoryBuffer* buffer,
- const gpu::SyncToken& sync_token) {
- NOTIMPLEMENTED();
-}
-
-} // namespace aura
diff --git a/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.h b/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.h
deleted file mode 100644
index a5c35760a7a..00000000000
--- a/chromium/ui/aura/mus/mojo_gpu_memory_buffer_manager.h
+++ /dev/null
@@ -1,39 +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_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
-#define UI_AURA_MUS_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
-
-#include <memory>
-
-#include "base/macros.h"
-#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
-
-namespace aura {
-
-class MojoGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager {
- public:
- MojoGpuMemoryBufferManager();
- ~MojoGpuMemoryBufferManager() override;
-
- // Overridden from gpu::GpuMemoryBufferManager:
- std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
- const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage,
- gpu::SurfaceHandle surface_handle) override;
- std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle(
- const gfx::GpuMemoryBufferHandle& handle,
- const gfx::Size& size,
- gfx::BufferFormat format) override;
- void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
- const gpu::SyncToken& sync_token) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MojoGpuMemoryBufferManager);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
diff --git a/chromium/ui/aura/mus/mus_context_factory.cc b/chromium/ui/aura/mus/mus_context_factory.cc
index 0116d2f3244..6a099290099 100644
--- a/chromium/ui/aura/mus/mus_context_factory.cc
+++ b/chromium/ui/aura/mus/mus_context_factory.cc
@@ -5,55 +5,38 @@
#include "ui/aura/mus/mus_context_factory.h"
#include "base/memory/ptr_util.h"
-#include "services/ui/public/cpp/context_provider.h"
-#include "ui/aura/mus/gpu_service.h"
+#include "services/ui/public/cpp/gpu/gpu.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/window_tree_host.h"
-#include "ui/compositor/reflector.h"
#include "ui/gl/gl_bindings.h"
namespace aura {
-namespace {
-class FakeReflector : public ui::Reflector {
- public:
- FakeReflector() {}
- ~FakeReflector() override {}
- void OnMirroringCompositorResized() override {}
- void AddMirroringLayer(ui::Layer* layer) override {}
- void RemoveMirroringLayer(ui::Layer* layer) override {}
-};
-
-} // namespace
-
-MusContextFactory::MusContextFactory(GpuService* gpu_service)
- : next_sink_id_(1u), gpu_service_(gpu_service) {}
+MusContextFactory::MusContextFactory(ui::Gpu* gpu)
+ : gpu_(gpu), weak_ptr_factory_(this) {}
MusContextFactory::~MusContextFactory() {}
-void MusContextFactory::CreateCompositorFrameSink(
- base::WeakPtr<ui::Compositor> compositor) {
+void MusContextFactory::OnEstablishedGpuChannel(
+ base::WeakPtr<ui::Compositor> compositor,
+ scoped_refptr<gpu::GpuChannelHost> gpu_channel) {
+ if (!compositor)
+ return;
WindowTreeHost* host =
WindowTreeHost::GetForAcceleratedWidget(compositor->widget());
WindowPortMus* window_port = WindowPortMus::Get(host->window());
DCHECK(window_port);
auto compositor_frame_sink = window_port->RequestCompositorFrameSink(
- ui::mojom::CompositorFrameSinkType::DEFAULT,
- make_scoped_refptr(
- new ui::ContextProvider(gpu_service_->EstablishGpuChannelSync())),
- gpu_service_->gpu_memory_buffer_manager());
+ gpu_->CreateContextProvider(std::move(gpu_channel)),
+ gpu_->gpu_memory_buffer_manager());
compositor->SetCompositorFrameSink(std::move(compositor_frame_sink));
}
-std::unique_ptr<ui::Reflector> MusContextFactory::CreateReflector(
- ui::Compositor* mirroed_compositor,
- ui::Layer* mirroring_layer) {
- // NOTIMPLEMENTED();
- return base::WrapUnique(new FakeReflector);
-}
-
-void MusContextFactory::RemoveReflector(ui::Reflector* reflector) {
- // NOTIMPLEMENTED();
+void MusContextFactory::CreateCompositorFrameSink(
+ base::WeakPtr<ui::Compositor> compositor) {
+ gpu_->EstablishGpuChannel(
+ base::Bind(&MusContextFactory::OnEstablishedGpuChannel,
+ weak_ptr_factory_.GetWeakPtr(), compositor));
}
scoped_refptr<cc::ContextProvider>
@@ -72,34 +55,16 @@ bool MusContextFactory::DoesCreateTestContexts() {
uint32_t MusContextFactory::GetImageTextureTarget(gfx::BufferFormat format,
gfx::BufferUsage usage) {
- // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D.
+ // TODO(sad): http://crbug.com/675431
return GL_TEXTURE_2D;
}
gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() {
- return gpu_service_->gpu_memory_buffer_manager();
+ return gpu_->gpu_memory_buffer_manager();
}
cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() {
return raster_thread_helper_.task_graph_runner();
}
-cc::FrameSinkId MusContextFactory::AllocateFrameSinkId() {
- return cc::FrameSinkId(0, next_sink_id_++);
-}
-
-cc::SurfaceManager* MusContextFactory::GetSurfaceManager() {
- return &surface_manager_;
-}
-
-void MusContextFactory::SetDisplayVisible(ui::Compositor* compositor,
- bool visible) {
- // TODO(fsamuel): display[compositor]->SetVisible(visible);
-}
-
-void MusContextFactory::ResizeDisplay(ui::Compositor* compositor,
- const gfx::Size& size) {
- // TODO(fsamuel): display[compositor]->Resize(size);
-}
-
} // namespace aura
diff --git a/chromium/ui/aura/mus/mus_context_factory.h b/chromium/ui/aura/mus/mus_context_factory.h
index 1ec518d233c..babca4790a3 100644
--- a/chromium/ui/aura/mus/mus_context_factory.h
+++ b/chromium/ui/aura/mus/mus_context_factory.h
@@ -8,29 +8,38 @@
#include <stdint.h>
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "cc/surfaces/surface_manager.h"
#include "services/ui/public/cpp/raster_thread_helper.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/compositor/compositor.h"
+namespace gpu {
+class GpuChannelHost;
+}
+
+namespace ui {
+class Gpu;
+}
+
namespace aura {
-class GpuService;
// ContextFactory implementation that can be used with Mus.
class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
public:
- explicit MusContextFactory(GpuService* gpu_service);
+ explicit MusContextFactory(ui::Gpu* gpu);
~MusContextFactory() override;
private:
+ // Callback function for Gpu::EstablishGpuChannel().
+ void OnEstablishedGpuChannel(base::WeakPtr<ui::Compositor> compositor,
+ scoped_refptr<gpu::GpuChannelHost> gpu_channel);
+
// ContextFactory:
void CreateCompositorFrameSink(
base::WeakPtr<ui::Compositor> compositor) override;
- std::unique_ptr<ui::Reflector> CreateReflector(
- ui::Compositor* mirrored_compositor,
- ui::Layer* mirroring_layer) override;
- void RemoveReflector(ui::Reflector* reflector) override;
scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override;
void RemoveCompositor(ui::Compositor* compositor) override;
bool DoesCreateTestContexts() override;
@@ -38,26 +47,12 @@ class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
gfx::BufferUsage usage) override;
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
- cc::FrameSinkId AllocateFrameSinkId() override;
- cc::SurfaceManager* GetSurfaceManager() override;
- void SetDisplayVisible(ui::Compositor* compositor, bool visible) override;
- void ResizeDisplay(ui::Compositor* compositor,
- const gfx::Size& size) override;
- void SetDisplayColorSpace(ui::Compositor* compositor,
- const gfx::ColorSpace& color_space) override {}
- void SetAuthoritativeVSyncInterval(ui::Compositor* compositor,
- base::TimeDelta interval) override {}
- void SetDisplayVSyncParameters(ui::Compositor* compositor,
- base::TimeTicks timebase,
- base::TimeDelta interval) override {}
- void SetOutputIsSecure(ui::Compositor* compositor, bool secure) override {}
void AddObserver(ui::ContextFactoryObserver* observer) override {}
void RemoveObserver(ui::ContextFactoryObserver* observer) override {}
- cc::SurfaceManager surface_manager_;
- uint32_t next_sink_id_;
ui::RasterThreadHelper raster_thread_helper_;
- GpuService* gpu_service_;
+ ui::Gpu* gpu_;
+ base::WeakPtrFactory<MusContextFactory> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(MusContextFactory);
};
diff --git a/chromium/ui/aura/mus/os_exchange_data_provider_mus.cc b/chromium/ui/aura/mus/os_exchange_data_provider_mus.cc
index 00831e526d0..538cbb155cc 100644
--- a/chromium/ui/aura/mus/os_exchange_data_provider_mus.cc
+++ b/chromium/ui/aura/mus/os_exchange_data_provider_mus.cc
@@ -9,11 +9,11 @@
#include <utility>
#include <vector>
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "mojo/common/common_type_converters.h"
#include "net/base/filename_util.h"
#include "services/ui/public/interfaces/clipboard.mojom.h"
#include "ui/base/dragdrop/file_info.h"
@@ -130,7 +130,7 @@ void OSExchangeDataProviderMus::SetPickledData(
reinterpret_cast<const unsigned char*>(pickle.data());
mime_data_[format.Serialize()] =
- mojo::Array<uint8_t>(std::vector<uint8_t>(bytes, bytes + pickle.size()));
+ std::vector<uint8_t>(bytes, bytes + pickle.size());
}
bool OSExchangeDataProviderMus::GetString(base::string16* data) const {
diff --git a/chromium/ui/aura/mus/os_exchange_data_provider_mus.h b/chromium/ui/aura/mus/os_exchange_data_provider_mus.h
index 4293faf9634..e8037bfeda8 100644
--- a/chromium/ui/aura/mus/os_exchange_data_provider_mus.h
+++ b/chromium/ui/aura/mus/os_exchange_data_provider_mus.h
@@ -11,7 +11,6 @@
#include <utility>
#include <vector>
-#include "mojo/public/cpp/bindings/map.h"
#include "ui/aura/aura_export.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/gfx/geometry/vector2d.h"
diff --git a/chromium/ui/aura/mus/property_converter.cc b/chromium/ui/aura/mus/property_converter.cc
index c4122a3f899..47fe11b2a69 100644
--- a/chromium/ui/aura/mus/property_converter.cc
+++ b/chromium/ui/aura/mus/property_converter.cc
@@ -4,6 +4,7 @@
#include "ui/aura/mus/property_converter.h"
+#include "base/memory/ptr_util.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"
@@ -32,12 +33,23 @@ PropertyConverter::PropertyConverter() {
// Add known aura properties with associated mus properties.
RegisterProperty(client::kAlwaysOnTopKey,
ui::mojom::WindowManager::kAlwaysOnTop_Property);
+ RegisterProperty(client::kAppIconKey,
+ ui::mojom::WindowManager::kAppIcon_Property);
RegisterProperty(client::kAppIdKey,
ui::mojom::WindowManager::kAppID_Property);
- RegisterProperty(client::kExcludeFromMruKey,
- ui::mojom::WindowManager::kExcludeFromMru_Property);
+ RegisterProperty(client::kNameKey, ui::mojom::WindowManager::kName_Property);
+ RegisterProperty(client::kPreferredSize,
+ ui::mojom::WindowManager::kPreferredSize_Property);
+ RegisterProperty(client::kResizeBehaviorKey,
+ ui::mojom::WindowManager::kResizeBehavior_Property);
RegisterProperty(client::kRestoreBoundsKey,
ui::mojom::WindowManager::kRestoreBounds_Property);
+ RegisterProperty(client::kShowStateKey,
+ ui::mojom::WindowManager::kShowState_Property);
+ RegisterProperty(client::kTitleKey,
+ ui::mojom::WindowManager::kWindowTitle_Property);
+ RegisterProperty(client::kWindowIconKey,
+ ui::mojom::WindowManager::kWindowIcon_Property);
}
PropertyConverter::~PropertyConverter() {}
@@ -51,22 +63,49 @@ bool PropertyConverter::ConvertPropertyForTransport(
if (transport_name->empty())
return false;
+ auto image_key = static_cast<const WindowProperty<gfx::ImageSkia*>*>(key);
+ if (image_properties_.count(image_key) > 0) {
+ const gfx::ImageSkia* value = window->GetProperty(image_key);
+ if (value) {
+ // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
+ SkBitmap bitmap = value->GetRepresentation(1.f).sk_bitmap();
+ *transport_value = base::MakeUnique<std::vector<uint8_t>>(
+ mojo::ConvertTo<std::vector<uint8_t>>(bitmap));
+ } else {
+ *transport_value = base::MakeUnique<std::vector<uint8_t>>();
+ }
+ return true;
+ }
+
auto rect_key = static_cast<const WindowProperty<gfx::Rect*>*>(key);
if (rect_properties_.count(rect_key) > 0) {
*transport_value = GetArray(window, rect_key);
return true;
}
+ auto size_key = static_cast<const WindowProperty<gfx::Size*>*>(key);
+ if (size_properties_.count(size_key) > 0) {
+ *transport_value = GetArray(window, size_key);
+ return true;
+ }
+
auto string_key = static_cast<const WindowProperty<std::string*>*>(key);
if (string_properties_.count(string_key) > 0) {
*transport_value = GetArray(window, string_key);
return true;
}
+ auto string16_key = static_cast<const WindowProperty<base::string16*>*>(key);
+ if (string16_properties_.count(string16_key) > 0) {
+ *transport_value = GetArray(window, string16_key);
+ return true;
+ }
+
// Handle primitive property types generically.
DCHECK_GT(primitive_properties_.count(key), 0u);
+ PrimitiveType default_value = primitive_properties_[key].default_value;
// TODO(msw): Using the int64_t accessor is wasteful for smaller types.
- const int64_t value = window->GetPropertyInternal(key, 0);
+ const PrimitiveType value = window->GetPropertyInternal(key, default_value);
*transport_value = base::MakeUnique<std::vector<uint8_t>>(
mojo::ConvertTo<std::vector<uint8_t>>(value));
return true;
@@ -74,16 +113,28 @@ bool PropertyConverter::ConvertPropertyForTransport(
std::string PropertyConverter::GetTransportNameForPropertyKey(const void* key) {
if (primitive_properties_.count(key) > 0)
- return primitive_properties_[key].second;
+ return primitive_properties_[key].transport_name;
+
+ auto image_key = static_cast<const WindowProperty<gfx::ImageSkia*>*>(key);
+ if (image_properties_.count(image_key) > 0)
+ return image_properties_[image_key];
auto rect_key = static_cast<const WindowProperty<gfx::Rect*>*>(key);
if (rect_properties_.count(rect_key) > 0)
return rect_properties_[rect_key];
+ auto size_key = static_cast<const WindowProperty<gfx::Size*>*>(key);
+ if (size_properties_.count(size_key) > 0)
+ return size_properties_[size_key];
+
auto string_key = static_cast<const WindowProperty<std::string*>*>(key);
if (string_properties_.count(string_key) > 0)
return string_properties_[string_key];
+ auto string16_key = static_cast<const WindowProperty<base::string16*>*>(key);
+ if (string16_properties_.count(string16_key) > 0)
+ return string16_properties_[string16_key];
+
return std::string();
}
@@ -92,17 +143,29 @@ void PropertyConverter::SetPropertyFromTransportValue(
const std::string& transport_name,
const std::vector<uint8_t>* data) {
for (const auto& primitive_property : primitive_properties_) {
- if (primitive_property.second.second == transport_name) {
- // aura::Window only supports property types that fit in int64_t.
+ if (primitive_property.second.transport_name == transport_name) {
+ // aura::Window only supports property types that fit in PrimitiveType.
if (data->size() != 8u) {
- DVLOG(2) << "Property size mismatch (int64_t): " << transport_name;
+ DVLOG(2) << "Property size mismatch (PrimitiveType): "
+ << transport_name;
return;
}
- const int64_t value = mojo::ConvertTo<int64_t>(*data);
+ const PrimitiveType value = mojo::ConvertTo<PrimitiveType>(*data);
// TODO(msw): Should aura::Window just store all properties by name?
- window->SetPropertyInternal(primitive_property.first,
- primitive_property.second.first, nullptr,
- value, 0);
+ window->SetPropertyInternal(
+ primitive_property.first, primitive_property.second.property_name,
+ nullptr, value, primitive_property.second.default_value);
+ return;
+ }
+ }
+
+ for (const auto& image_property : image_properties_) {
+ if (image_property.second == transport_name) {
+ // TODO(msw): Validate the data somehow, before trying to convert?
+ // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
+ const SkBitmap bitmap = mojo::ConvertTo<SkBitmap>(*data);
+ const gfx::ImageSkia image = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
+ window->SetProperty(image_property.first, new gfx::ImageSkia(image));
return;
}
}
@@ -119,6 +182,18 @@ void PropertyConverter::SetPropertyFromTransportValue(
}
}
+ for (const auto& size_property : size_properties_) {
+ if (size_property.second == transport_name) {
+ if (data->size() != 8u) {
+ DVLOG(2) << "Property size mismatch (gfx::Size): " << transport_name;
+ return;
+ }
+ const gfx::Size value = mojo::ConvertTo<gfx::Size>(*data);
+ window->SetProperty(size_property.first, new gfx::Size(value));
+ return;
+ }
+ }
+
for (const auto& string_property : string_properties_) {
if (string_property.second == transport_name) {
// TODO(msw): Validate the data somehow, before trying to convert?
@@ -128,9 +203,42 @@ void PropertyConverter::SetPropertyFromTransportValue(
}
}
+ for (const auto& string16_property : string16_properties_) {
+ if (string16_property.second == transport_name) {
+ // TODO(msw): Validate the data somehow, before trying to convert?
+ const base::string16 value = mojo::ConvertTo<base::string16>(*data);
+ window->SetProperty(string16_property.first, new base::string16(value));
+ return;
+ }
+ }
+
DVLOG(2) << "Unknown mus property name: " << transport_name;
}
+bool PropertyConverter::GetPropertyValueFromTransportValue(
+ const std::string& transport_name,
+ const std::vector<uint8_t>& transport_data,
+ PrimitiveType* value) {
+ // aura::Window only supports property types that fit in PrimitiveType.
+ if (transport_data.size() != 8u) {
+ DVLOG(2) << "Property size mismatch (PrimitiveType): " << transport_name;
+ return false;
+ }
+ for (const auto& primitive_property : primitive_properties_) {
+ if (primitive_property.second.transport_name == transport_name) {
+ *value = mojo::ConvertTo<PrimitiveType>(transport_data);
+ return true;
+ }
+ }
+ return false;
+}
+
+void PropertyConverter::RegisterProperty(
+ const WindowProperty<gfx::ImageSkia*>* property,
+ const char* transport_name) {
+ image_properties_[property] = transport_name;
+}
+
void PropertyConverter::RegisterProperty(
const WindowProperty<gfx::Rect*>* property,
const char* transport_name) {
@@ -138,9 +246,21 @@ void PropertyConverter::RegisterProperty(
}
void PropertyConverter::RegisterProperty(
+ const WindowProperty<gfx::Size*>* property,
+ const char* transport_name) {
+ size_properties_[property] = transport_name;
+}
+
+void PropertyConverter::RegisterProperty(
const WindowProperty<std::string*>* property,
const char* transport_name) {
string_properties_[property] = transport_name;
}
+void PropertyConverter::RegisterProperty(
+ const WindowProperty<base::string16*>* property,
+ const char* transport_name) {
+ string16_properties_[property] = transport_name;
+}
+
} // namespace aura
diff --git a/chromium/ui/aura/mus/property_converter.h b/chromium/ui/aura/mus/property_converter.h
index 93187951142..68222213bb5 100644
--- a/chromium/ui/aura/mus/property_converter.h
+++ b/chromium/ui/aura/mus/property_converter.h
@@ -18,6 +18,7 @@
namespace gfx {
class Rect;
+class Size;
}
namespace aura {
@@ -29,6 +30,9 @@ namespace aura {
// Window properties.
class AURA_EXPORT PropertyConverter {
public:
+ // All primitive values are stored using this type.
+ using PrimitiveType = int64_t;
+
PropertyConverter();
~PropertyConverter();
@@ -52,31 +56,63 @@ class AURA_EXPORT PropertyConverter {
const std::string& transport_name,
const std::vector<uint8_t>* transport_data);
+ // Returns the value for a particular transport value. All primitives are
+ // serialized as a PrimitiveType, so this function may be used for any
+ // primitive. Returns true on success and sets |value| accordingly. A return
+ // value of false indicates the value isn't known or the property type isn't
+ // primitive.
+ bool GetPropertyValueFromTransportValue(
+ const std::string& transport_name,
+ const std::vector<uint8_t>& transport_data,
+ PrimitiveType* value);
+
// Register a property to support conversion between mus and aura.
template<typename T>
void RegisterProperty(const WindowProperty<T>* property,
const char* transport_name) {
- primitive_properties_[property] =
- PropertyNames(property->name, transport_name);
+ PrimitiveProperty primitive_property;
+ primitive_property.property_name = property->name;
+ primitive_property.transport_name = transport_name;
+ primitive_property.default_value = property->default_value;
+ primitive_properties_[property] = primitive_property;
}
// Specializations for properties to pointer types supporting mojo conversion.
+ void RegisterProperty(const WindowProperty<gfx::ImageSkia*>* property,
+ const char* transport_name);
void RegisterProperty(const WindowProperty<gfx::Rect*>* property,
const char* transport_name);
+ void RegisterProperty(const WindowProperty<gfx::Size*>* property,
+ const char* transport_name);
void RegisterProperty(const WindowProperty<std::string*>* property,
const char* transport_name);
+ void RegisterProperty(const WindowProperty<base::string16*>* property,
+ const char* transport_name);
private:
- // A pair with the aura::WindowProperty::name and the mus property name.
- using PropertyNames = std::pair<const char*, const char*>;
- // A map of aura::WindowProperty<T> to its aura and mus property names.
+ // Contains data needed to store and convert primitive-type properties.
+ struct PrimitiveProperty {
+ // The aura::WindowProperty::name used for storage.
+ const char* property_name = nullptr;
+ // The mus property name used for transport.
+ const char* transport_name = nullptr;
+ // The aura::WindowProperty::default_value stored using PrimitiveType.
+ PrimitiveType default_value = 0;
+ };
+
+ // A map of aura::WindowProperty<T> to PrimitiveProperty structs.
// This supports the internal codepaths for primitive types, eg. T=bool.
- std::map<const void*, PropertyNames> primitive_properties_;
+ std::map<const void*, PrimitiveProperty> primitive_properties_;
// Maps of aura::WindowProperty<T> to their mus property names.
// This supports types that can be serialized for Mojo, eg. T=std::string*.
+ std::map<const WindowProperty<gfx::ImageSkia*>*, const char*>
+ image_properties_;
std::map<const WindowProperty<gfx::Rect*>*, const char*> rect_properties_;
+ std::map<const WindowProperty<gfx::Size*>*, const char*> size_properties_;
std::map<const WindowProperty<std::string*>*, const char*> string_properties_;
+ std::map<const WindowProperty<base::string16*>*, const char*>
+ string16_properties_;
DISALLOW_COPY_AND_ASSIGN(PropertyConverter);
};
diff --git a/chromium/ui/aura/mus/property_converter_unittest.cc b/chromium/ui/aura/mus/property_converter_unittest.cc
index f1f1358fcb2..0e22f83b252 100644
--- a/chromium/ui/aura/mus/property_converter_unittest.cc
+++ b/chromium/ui/aura/mus/property_converter_unittest.cc
@@ -9,14 +9,19 @@
#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 "third_party/skia/include/core/SkBitmap.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
#include "ui/aura/window_property.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/skia_util.h"
-// See aura_constants.cc for bool, int32_t, int64_t, std::string, and gfx::Rect.
-// That same file also declares the uint32_t type via SkColor.
+// See aura_constants.cc for bool, int32_t, int64_t, std::string, gfx::Rect,
+// base::string16, uint32_t (via SkColor), and gfx::ImageSkia.
DECLARE_WINDOW_PROPERTY_TYPE(uint8_t)
DECLARE_WINDOW_PROPERTY_TYPE(uint16_t)
DECLARE_WINDOW_PROPERTY_TYPE(uint64_t)
@@ -28,17 +33,23 @@ namespace aura {
namespace {
DEFINE_WINDOW_PROPERTY_KEY(bool, kTestPropertyKey0, false);
-DEFINE_WINDOW_PROPERTY_KEY(uint8_t, kTestPropertyKey1, 0);
-DEFINE_WINDOW_PROPERTY_KEY(uint16_t, kTestPropertyKey2, 0);
-DEFINE_WINDOW_PROPERTY_KEY(uint32_t, kTestPropertyKey3, 0);
-DEFINE_WINDOW_PROPERTY_KEY(uint64_t, kTestPropertyKey4, 0);
-DEFINE_WINDOW_PROPERTY_KEY(int8_t, kTestPropertyKey5, 0);
-DEFINE_WINDOW_PROPERTY_KEY(int16_t, kTestPropertyKey6, 0);
-DEFINE_WINDOW_PROPERTY_KEY(int32_t, kTestPropertyKey7, 0);
-DEFINE_WINDOW_PROPERTY_KEY(int64_t, kTestPropertyKey8, 0);
-
+DEFINE_WINDOW_PROPERTY_KEY(bool, kTestPropertyKey1, true);
+DEFINE_WINDOW_PROPERTY_KEY(uint8_t, kTestPropertyKey2, UINT8_MAX / 3);
+DEFINE_WINDOW_PROPERTY_KEY(uint16_t, kTestPropertyKey3, UINT16_MAX / 3);
+DEFINE_WINDOW_PROPERTY_KEY(uint32_t, kTestPropertyKey4, UINT32_MAX);
+DEFINE_WINDOW_PROPERTY_KEY(uint64_t, kTestPropertyKey5, UINT64_MAX);
+DEFINE_WINDOW_PROPERTY_KEY(int8_t, kTestPropertyKey6, 0);
+DEFINE_WINDOW_PROPERTY_KEY(int16_t, kTestPropertyKey7, 1);
+DEFINE_WINDOW_PROPERTY_KEY(int32_t, kTestPropertyKey8, -1);
+DEFINE_WINDOW_PROPERTY_KEY(int64_t, kTestPropertyKey9, 777);
+
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::ImageSkia, kTestImagePropertyKey,
+ nullptr);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Rect, kTestRectPropertyKey, nullptr);
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(gfx::Size, kTestSizePropertyKey, nullptr);
DEFINE_OWNED_WINDOW_PROPERTY_KEY(std::string, kTestStringPropertyKey, nullptr);
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(base::string16, kTestString16PropertyKey,
+ nullptr);
const char kTestPropertyServerKey0[] = "test-property-server0";
const char kTestPropertyServerKey1[] = "test-property-server1";
@@ -49,9 +60,13 @@ const char kTestPropertyServerKey5[] = "test-property-server5";
const char kTestPropertyServerKey6[] = "test-property-server6";
const char kTestPropertyServerKey7[] = "test-property-server7";
const char kTestPropertyServerKey8[] = "test-property-server8";
+const char kTestPropertyServerKey9[] = "test-property-server9";
+const char kTestImagePropertyServerKey[] = "test-image-property-server";
const char kTestRectPropertyServerKey[] = "test-rect-property-server";
+const char kTestSizePropertyServerKey[] = "test-size-property-server";
const char kTestStringPropertyServerKey[] = "test-string-property-server";
+const char kTestString16PropertyServerKey[] = "test-string16-property-server";
// Test registration, naming and value conversion for primitive property types.
template <typename T>
@@ -78,12 +93,21 @@ void TestPrimitiveProperty(PropertyConverter* property_converter,
mojo::ConvertTo<std::vector<uint8_t>>(storage_value_1);
EXPECT_EQ(transport_value1, *transport_value_out.get());
+ int64_t decoded_value_1 = 0;
+ EXPECT_TRUE(property_converter->GetPropertyValueFromTransportValue(
+ transport_name, *transport_value_out, &decoded_value_1));
+ EXPECT_EQ(value_1, static_cast<T>(decoded_value_1));
+
const int64_t storage_value_2 = static_cast<int64_t>(value_2);
std::vector<uint8_t> transport_value2 =
mojo::ConvertTo<std::vector<uint8_t>>(storage_value_2);
property_converter->SetPropertyFromTransportValue(window, transport_name,
&transport_value2);
EXPECT_EQ(value_2, window->GetProperty(key));
+ int64_t decoded_value_2 = 0;
+ EXPECT_TRUE(property_converter->GetPropertyValueFromTransportValue(
+ transport_name, transport_value2, &decoded_value_2));
+ EXPECT_EQ(value_2, static_cast<T>(decoded_value_2));
}
} // namespace
@@ -99,37 +123,81 @@ TEST_F(PropertyConverterTest, PrimitiveProperties) {
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey0,
kTestPropertyServerKey0, value_0a, value_0b);
- const uint8_t value_1a = UINT8_MAX / 2, value_1b = UINT8_MAX / 3;
+ const bool value_1a = true, value_1b = false;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey1,
kTestPropertyServerKey1, value_1a, value_1b);
- const uint16_t value_2a = UINT16_MAX / 3, value_2b = UINT16_MAX / 4;
+ const uint8_t value_2a = UINT8_MAX / 2, value_2b = UINT8_MAX / 3;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey2,
kTestPropertyServerKey2, value_2a, value_2b);
- const uint32_t value_3a = UINT32_MAX / 4, value_3b = UINT32_MAX / 5;
+ const uint16_t value_3a = UINT16_MAX / 3, value_3b = UINT16_MAX / 4;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey3,
kTestPropertyServerKey3, value_3a, value_3b);
- const uint64_t value_4a = UINT64_MAX / 5, value_4b = UINT64_MAX / 6;
+ const uint32_t value_4a = UINT32_MAX / 4, value_4b = UINT32_MAX / 5;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey4,
kTestPropertyServerKey4, value_4a, value_4b);
- const int8_t value_5a = INT8_MIN / 2, value_5b = INT8_MIN / 3;
+ const uint64_t value_5a = UINT64_MAX / 5, value_5b = UINT64_MAX / 6;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey5,
kTestPropertyServerKey5, value_5a, value_5b);
- const int16_t value_6a = INT16_MIN / 3, value_6b = INT16_MIN / 4;
+ const int8_t value_6a = INT8_MIN / 2, value_6b = INT8_MIN / 3;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey6,
kTestPropertyServerKey6, value_6a, value_6b);
- const int32_t value_7a = INT32_MIN / 4, value_7b = INT32_MIN / 5;
+ const int16_t value_7a = INT16_MIN / 3, value_7b = INT16_MIN / 4;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey7,
kTestPropertyServerKey7, value_7a, value_7b);
- const int64_t value_8a = INT64_MIN / 5, value_8b = INT64_MIN / 6;
+ const int32_t value_8a = INT32_MIN / 4, value_8b = INT32_MIN / 5;
TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey8,
kTestPropertyServerKey8, value_8a, value_8b);
+
+ const int64_t value_9a = INT64_MIN / 5, value_9b = INT64_MIN / 6;
+ TestPrimitiveProperty(&property_converter, window.get(), kTestPropertyKey9,
+ kTestPropertyServerKey9, value_9a, value_9b);
+}
+
+// Verifies property setting behavior for a gfx::ImageSkia* property.
+TEST_F(PropertyConverterTest, ImageSkiaProperty) {
+ PropertyConverter property_converter;
+ property_converter.RegisterProperty(kTestImagePropertyKey,
+ kTestImagePropertyServerKey);
+ EXPECT_EQ(
+ kTestImagePropertyServerKey,
+ property_converter.GetTransportNameForPropertyKey(kTestImagePropertyKey));
+
+ SkBitmap bitmap_1;
+ bitmap_1.allocN32Pixels(16, 32);
+ bitmap_1.eraseARGB(255, 11, 22, 33);
+ gfx::ImageSkia value_1 = gfx::ImageSkia::CreateFrom1xBitmap(bitmap_1);
+ std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), nullptr));
+ window->SetProperty(kTestImagePropertyKey, new gfx::ImageSkia(value_1));
+ gfx::ImageSkia* image_out_1 = window->GetProperty(kTestImagePropertyKey);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap_1, *image_out_1->bitmap()));
+
+ std::string transport_name_out;
+ std::unique_ptr<std::vector<uint8_t>> transport_value_out;
+ EXPECT_TRUE(property_converter.ConvertPropertyForTransport(
+ window.get(), kTestImagePropertyKey, &transport_name_out,
+ &transport_value_out));
+ EXPECT_EQ(kTestImagePropertyServerKey, transport_name_out);
+ EXPECT_EQ(mojo::ConvertTo<std::vector<uint8_t>>(bitmap_1),
+ *transport_value_out.get());
+
+ SkBitmap bitmap_2;
+ bitmap_2.allocN32Pixels(16, 16);
+ bitmap_2.eraseARGB(255, 33, 22, 11);
+ EXPECT_FALSE(gfx::BitmapsAreEqual(bitmap_1, bitmap_2));
+ gfx::ImageSkia value_2 = gfx::ImageSkia::CreateFrom1xBitmap(bitmap_2);
+ std::vector<uint8_t> transport_value =
+ mojo::ConvertTo<std::vector<uint8_t>>(bitmap_2);
+ property_converter.SetPropertyFromTransportValue(
+ window.get(), kTestImagePropertyServerKey, &transport_value);
+ gfx::ImageSkia* image_out_2 = window->GetProperty(kTestImagePropertyKey);
+ EXPECT_TRUE(gfx::BitmapsAreEqual(bitmap_2, *image_out_2->bitmap()));
}
// Verifies property setting behavior for a gfx::Rect* property.
@@ -163,6 +231,37 @@ TEST_F(PropertyConverterTest, RectProperty) {
EXPECT_EQ(value_2, *window->GetProperty(kTestRectPropertyKey));
}
+// Verifies property setting behavior for a gfx::Size* property.
+TEST_F(PropertyConverterTest, SizeProperty) {
+ PropertyConverter property_converter;
+ property_converter.RegisterProperty(kTestSizePropertyKey,
+ kTestSizePropertyServerKey);
+ EXPECT_EQ(
+ kTestSizePropertyServerKey,
+ property_converter.GetTransportNameForPropertyKey(kTestSizePropertyKey));
+
+ gfx::Size value_1(1, 2);
+ std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), nullptr));
+ window->SetProperty(kTestSizePropertyKey, new gfx::Size(value_1));
+ EXPECT_EQ(value_1, *window->GetProperty(kTestSizePropertyKey));
+
+ std::string transport_name_out;
+ std::unique_ptr<std::vector<uint8_t>> transport_value_out;
+ EXPECT_TRUE(property_converter.ConvertPropertyForTransport(
+ window.get(), kTestSizePropertyKey, &transport_name_out,
+ &transport_value_out));
+ EXPECT_EQ(kTestSizePropertyServerKey, transport_name_out);
+ EXPECT_EQ(mojo::ConvertTo<std::vector<uint8_t>>(value_1),
+ *transport_value_out.get());
+
+ gfx::Size value_2(1, 3);
+ std::vector<uint8_t> transport_value =
+ mojo::ConvertTo<std::vector<uint8_t>>(value_2);
+ property_converter.SetPropertyFromTransportValue(
+ window.get(), kTestSizePropertyServerKey, &transport_value);
+ EXPECT_EQ(value_2, *window->GetProperty(kTestSizePropertyKey));
+}
+
// Verifies property setting behavior for a std::string* property.
TEST_F(PropertyConverterTest, StringProperty) {
PropertyConverter property_converter;
@@ -194,4 +293,35 @@ TEST_F(PropertyConverterTest, StringProperty) {
EXPECT_EQ(value_2, *window->GetProperty(kTestStringPropertyKey));
}
+// Verifies property setting behavior for a base::string16* property.
+TEST_F(PropertyConverterTest, String16Property) {
+ PropertyConverter property_converter;
+ property_converter.RegisterProperty(kTestString16PropertyKey,
+ kTestString16PropertyServerKey);
+ EXPECT_EQ(kTestString16PropertyServerKey,
+ property_converter.GetTransportNameForPropertyKey(
+ kTestString16PropertyKey));
+
+ base::string16 value_1 = base::ASCIIToUTF16("test value");
+ std::unique_ptr<Window> window(CreateNormalWindow(1, root_window(), nullptr));
+ window->SetProperty(kTestString16PropertyKey, new base::string16(value_1));
+ EXPECT_EQ(value_1, *window->GetProperty(kTestString16PropertyKey));
+
+ std::string transport_name_out;
+ std::unique_ptr<std::vector<uint8_t>> transport_value_out;
+ EXPECT_TRUE(property_converter.ConvertPropertyForTransport(
+ window.get(), kTestString16PropertyKey, &transport_name_out,
+ &transport_value_out));
+ EXPECT_EQ(kTestString16PropertyServerKey, transport_name_out);
+ EXPECT_EQ(mojo::ConvertTo<std::vector<uint8_t>>(value_1),
+ *transport_value_out.get());
+
+ base::string16 value_2 = base::ASCIIToUTF16("another test value");
+ std::vector<uint8_t> transport_value =
+ mojo::ConvertTo<std::vector<uint8_t>>(value_2);
+ property_converter.SetPropertyFromTransportValue(
+ window.get(), kTestString16PropertyServerKey, &transport_value);
+ EXPECT_EQ(value_2, *window->GetProperty(kTestString16PropertyKey));
+}
+
} // namespace aura
diff --git a/chromium/ui/aura/mus/property_utils.cc b/chromium/ui/aura/mus/property_utils.cc
new file mode 100644
index 00000000000..26a7bea6cca
--- /dev/null
+++ b/chromium/ui/aura/mus/property_utils.cc
@@ -0,0 +1,46 @@
+// 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/property_utils.h"
+
+#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
+#include "ui/wm/public/window_types.h"
+
+namespace aura {
+namespace {
+
+ui::wm::WindowType UiWindowTypeToWmWindowType(ui::mojom::WindowType type) {
+ switch (type) {
+ case ui::mojom::WindowType::WINDOW:
+ return ui::wm::WINDOW_TYPE_NORMAL;
+ case ui::mojom::WindowType::PANEL:
+ return ui::wm::WINDOW_TYPE_PANEL;
+ case ui::mojom::WindowType::CONTROL:
+ return ui::wm::WINDOW_TYPE_CONTROL;
+ case ui::mojom::WindowType::WINDOW_FRAMELESS:
+ case ui::mojom::WindowType::POPUP:
+ case ui::mojom::WindowType::BUBBLE:
+ case ui::mojom::WindowType::DRAG:
+ return ui::wm::WINDOW_TYPE_POPUP;
+ case ui::mojom::WindowType::MENU:
+ return ui::wm::WINDOW_TYPE_MENU;
+ case ui::mojom::WindowType::TOOLTIP:
+ return ui::wm::WINDOW_TYPE_TOOLTIP;
+ case ui::mojom::WindowType::UNKNOWN:
+ return ui::wm::WINDOW_TYPE_UNKNOWN;
+ }
+ NOTREACHED();
+ return ui::wm::WINDOW_TYPE_UNKNOWN;
+}
+
+} // namespace
+
+void SetWindowType(Window* window, ui::mojom::WindowType window_type) {
+ window->SetProperty(client::kWindowTypeKey, window_type);
+ window->SetType(UiWindowTypeToWmWindowType(window_type));
+}
+
+} // namespace aura
diff --git a/chromium/ui/aura/mus/property_utils.h b/chromium/ui/aura/mus/property_utils.h
new file mode 100644
index 00000000000..0106d966735
--- /dev/null
+++ b/chromium/ui/aura/mus/property_utils.h
@@ -0,0 +1,30 @@
+// 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.
+
+#ifndef UI_AURA_MUS_PROPERTY_UTILS_H_
+#define UI_AURA_MUS_PROPERTY_UTILS_H_
+
+#include <stdint.h>
+
+#include "ui/aura/aura_export.h"
+
+namespace ui {
+namespace mojom {
+enum class WindowType;
+}
+}
+
+namespace aura {
+
+class Window;
+
+// Configures the two window type properties on |window|. Specifically this
+// sets the property client::kWindowTypeKey as well as calling SetType().
+// This *must* be called before Init().
+AURA_EXPORT void SetWindowType(Window* window,
+ ui::mojom::WindowType window_type);
+
+} // namespace aura
+
+#endif // UI_AURA_MUS_PROPERTY_UTILS_H_
diff --git a/chromium/ui/aura/mus/surface_id_handler.h b/chromium/ui/aura/mus/surface_id_handler.h
deleted file mode 100644
index 01e4e64ad66..00000000000
--- a/chromium/ui/aura/mus/surface_id_handler.h
+++ /dev/null
@@ -1,40 +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.
-
-#ifndef UI_AURA_MUS_SURFACE_ID_HANDLER_H_
-#define UI_AURA_MUS_SURFACE_ID_HANDLER_H_
-
-#include "cc/surfaces/surface_id.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace aura {
-
-class Window;
-
-// Holds information about the current surface held by a Window.
-// |surface_id| uniquely identifies the surface in the display
-// compositor.
-// |frame_size| is the size of the frame held by the surface.
-// |device_scale_factor| is the scale factor that the frame was
-// renderered for.
-struct SurfaceInfo {
- cc::SurfaceId surface_id;
- gfx::Size frame_size;
- float device_scale_factor;
-};
-
-class SurfaceIdHandler {
- public:
- // Called when a child window allocates a new surface ID.
- // If the handler wishes to retain ownership of the |surface_info|,
- // it can move it. If a child's surface has been cleared then
- // |surface_info| will refer to a null pointer.
- virtual void OnChildWindowSurfaceChanged(
- Window* window,
- std::unique_ptr<SurfaceInfo>* surface_info) = 0;
-};
-
-} // namespace aura
-
-#endif // UI_AURA_MUS_SURFACE_ID_HANDLER_H_
diff --git a/chromium/ui/aura/mus/text_input_client_impl.cc b/chromium/ui/aura/mus/text_input_client_impl.cc
index 9e22764cb7b..782e8347afe 100644
--- a/chromium/ui/aura/mus/text_input_client_impl.cc
+++ b/chromium/ui/aura/mus/text_input_client_impl.cc
@@ -4,6 +4,7 @@
#include "ui/aura/mus/text_input_client_impl.h"
+#include "base/strings/utf_string_conversions.h"
#include "ui/aura/mus/input_method_mus.h"
#include "ui/base/ime/text_input_client.h"
@@ -18,29 +19,26 @@ ui::mojom::TextInputClientPtr TextInputClientImpl::CreateInterfacePtrAndBind() {
return binding_.CreateInterfacePtrAndBind();
}
-void TextInputClientImpl::OnCompositionEvent(
- ui::mojom::CompositionEventPtr event) {
- switch (event->type) {
- case ui::mojom::CompositionEventType::INSERT_CHAR: {
- DCHECK((*event->key_event)->IsKeyEvent());
- ui::KeyEvent* key_event = (*event->key_event)->AsKeyEvent();
- DCHECK(key_event->is_char());
- text_input_client_->InsertChar(*key_event);
- break;
- }
- case ui::mojom::CompositionEventType::CONFIRM:
- text_input_client_->ConfirmCompositionText();
- break;
- case ui::mojom::CompositionEventType::CLEAR:
- text_input_client_->ClearCompositionText();
- break;
- case ui::mojom::CompositionEventType::UPDATE:
- case ui::mojom::CompositionEventType::INSERT_TEXT:
- // TODO(moshayedi): crbug.com/631524. Implement these types of composition
- // events once we have the necessary fields in ui.mojom.CompositionEvent.
- NOTIMPLEMENTED();
- break;
- }
+void TextInputClientImpl::SetCompositionText(
+ const ui::CompositionText& composition) {
+ text_input_client_->SetCompositionText(composition);
+}
+
+void TextInputClientImpl::ConfirmCompositionText() {
+ text_input_client_->ConfirmCompositionText();
+}
+
+void TextInputClientImpl::ClearCompositionText() {
+ text_input_client_->ClearCompositionText();
+}
+
+void TextInputClientImpl::InsertText(const std::string& text) {
+ text_input_client_->InsertText(base::UTF8ToUTF16(text));
+}
+
+void TextInputClientImpl::InsertChar(std::unique_ptr<ui::Event> event) {
+ DCHECK(event->IsKeyEvent());
+ text_input_client_->InsertChar(*event->AsKeyEvent());
}
} // namespace aura
diff --git a/chromium/ui/aura/mus/text_input_client_impl.h b/chromium/ui/aura/mus/text_input_client_impl.h
index d8e2d966e84..e9222ec66c3 100644
--- a/chromium/ui/aura/mus/text_input_client_impl.h
+++ b/chromium/ui/aura/mus/text_input_client_impl.h
@@ -6,7 +6,8 @@
#define UI_AURA_MUS_TEXT_INPUT_CLIENT_IMPL_H_
#include "mojo/public/cpp/bindings/binding.h"
-#include "services/ui/public/interfaces/ime.mojom.h"
+#include "services/ui/public/interfaces/ime/ime.mojom.h"
+#include "ui/base/ime/composition_text.h"
namespace ui {
class TextInputClient;
@@ -25,7 +26,11 @@ class TextInputClientImpl : public ui::mojom::TextInputClient {
private:
// ui::mojom::TextInputClient:
- void OnCompositionEvent(ui::mojom::CompositionEventPtr event) override;
+ void SetCompositionText(const ui::CompositionText& composition) override;
+ void ConfirmCompositionText() override;
+ void ClearCompositionText() override;
+ void InsertText(const std::string& text) override;
+ void InsertChar(std::unique_ptr<ui::Event> event) override;
ui::TextInputClient* text_input_client_;
mojo::Binding<ui::mojom::TextInputClient> binding_;
diff --git a/chromium/ui/aura/mus/window_compositor_frame_sink.cc b/chromium/ui/aura/mus/window_compositor_frame_sink.cc
index 1490457984d..2f878a9803c 100644
--- a/chromium/ui/aura/mus/window_compositor_frame_sink.cc
+++ b/chromium/ui/aura/mus/window_compositor_frame_sink.cc
@@ -5,6 +5,7 @@
#include "ui/aura/mus/window_compositor_frame_sink.h"
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "cc/output/compositor_frame_sink_client.h"
#include "gpu/ipc/client/gpu_channel_host.h"
@@ -12,6 +13,7 @@ namespace aura {
// static
std::unique_ptr<WindowCompositorFrameSink> WindowCompositorFrameSink::Create(
+ const cc::FrameSinkId& frame_sink_id,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
std::unique_ptr<WindowCompositorFrameSinkBinding>*
@@ -20,13 +22,13 @@ std::unique_ptr<WindowCompositorFrameSink> WindowCompositorFrameSink::Create(
cc::mojom::MojoCompositorFrameSinkClientPtr compositor_frame_sink_client;
cc::mojom::MojoCompositorFrameSinkClientRequest
compositor_frame_sink_client_request =
- GetProxy(&compositor_frame_sink_client);
+ MakeRequest(&compositor_frame_sink_client);
compositor_frame_sink_binding->reset(new WindowCompositorFrameSinkBinding(
- GetProxy(&compositor_frame_sink),
+ MakeRequest(&compositor_frame_sink),
compositor_frame_sink_client.PassInterface()));
return base::WrapUnique(new WindowCompositorFrameSink(
- std::move(context_provider), gpu_memory_buffer_manager,
+ frame_sink_id, std::move(context_provider), gpu_memory_buffer_manager,
compositor_frame_sink.PassInterface(),
std::move(compositor_frame_sink_client_request)));
}
@@ -64,21 +66,32 @@ void WindowCompositorFrameSink::SubmitCompositorFrame(
DCHECK(thread_checker_->CalledOnValidThread());
if (!compositor_frame_sink_)
return;
- compositor_frame_sink_->SubmitCompositorFrame(std::move(frame));
+
+ gfx::Size frame_size = last_submitted_frame_size_;
+ if (!frame.render_pass_list.empty())
+ frame_size = frame.render_pass_list[0]->output_rect.size();
+ if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_)
+ local_frame_id_ = id_allocator_.GenerateId();
+
+ compositor_frame_sink_->SubmitCompositorFrame(local_frame_id_,
+ std::move(frame));
+
+ last_submitted_frame_size_ = frame_size;
}
WindowCompositorFrameSink::WindowCompositorFrameSink(
+ const cc::FrameSinkId& frame_sink_id,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
- mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink>
- compositor_frame_sink_info,
+ cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
cc::mojom::MojoCompositorFrameSinkClientRequest client_request)
: cc::CompositorFrameSink(std::move(context_provider),
nullptr,
gpu_memory_buffer_manager,
nullptr),
compositor_frame_sink_info_(std::move(compositor_frame_sink_info)),
- client_request_(std::move(client_request)) {}
+ client_request_(std::move(client_request)),
+ frame_sink_id_(frame_sink_id) {}
void WindowCompositorFrameSink::DidReceiveCompositorFrameAck() {
DCHECK(thread_checker_);
@@ -102,6 +115,10 @@ void WindowCompositorFrameSink::ReclaimResources(
client_->ReclaimResources(resources);
}
+void WindowCompositorFrameSink::WillDrawSurface() {
+ // TODO(fsamuel, staraz): Implement this.
+}
+
void WindowCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames);
}
diff --git a/chromium/ui/aura/mus/window_compositor_frame_sink.h b/chromium/ui/aura/mus/window_compositor_frame_sink.h
index 5ac53a3fbf0..d3550ea1e60 100644
--- a/chromium/ui/aura/mus/window_compositor_frame_sink.h
+++ b/chromium/ui/aura/mus/window_compositor_frame_sink.h
@@ -10,6 +10,7 @@
#include "cc/output/compositor_frame_sink.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/surface_id.h"
+#include "cc/surfaces/surface_id_allocator.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace aura {
@@ -23,6 +24,7 @@ class WindowCompositorFrameSink
public:
// static
static std::unique_ptr<WindowCompositorFrameSink> Create(
+ const cc::FrameSinkId& frame_sink_id,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
std::unique_ptr<WindowCompositorFrameSinkBinding>*
@@ -37,29 +39,32 @@ class WindowCompositorFrameSink
private:
WindowCompositorFrameSink(
+ const cc::FrameSinkId& frame_sink_id,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
- mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink>
- compositor_frame_sink_info,
+ cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info,
cc::mojom::MojoCompositorFrameSinkClientRequest client_request);
// cc::mojom::MojoCompositorFrameSinkClient implementation:
void DidReceiveCompositorFrameAck() override;
void OnBeginFrame(const cc::BeginFrameArgs& begin_frame_args) override;
void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
+ void WillDrawSurface() override;
// cc::ExternalBeginFrameSourceClient implementation.
void OnNeedsBeginFrames(bool needs_begin_frames) override;
+ gfx::Size last_submitted_frame_size_;
+ cc::LocalFrameId local_frame_id_;
+ cc::SurfaceIdAllocator id_allocator_;
std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_;
- mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSink>
- compositor_frame_sink_info_;
- mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSinkClient>
- client_request_;
+ cc::mojom::MojoCompositorFrameSinkPtrInfo compositor_frame_sink_info_;
+ cc::mojom::MojoCompositorFrameSinkClientRequest client_request_;
cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_;
std::unique_ptr<mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>>
client_binding_;
std::unique_ptr<base::ThreadChecker> thread_checker_;
+ const cc::FrameSinkId frame_sink_id_;
DISALLOW_COPY_AND_ASSIGN(WindowCompositorFrameSink);
};
diff --git a/chromium/ui/aura/mus/window_manager_delegate.h b/chromium/ui/aura/mus/window_manager_delegate.h
index 478ce90f574..87f907a3575 100644
--- a/chromium/ui/aura/mus/window_manager_delegate.h
+++ b/chromium/ui/aura/mus/window_manager_delegate.h
@@ -14,7 +14,7 @@
#include "base/callback_forward.h"
#include "services/ui/public/interfaces/cursor.mojom.h"
-#include "services/ui/public/interfaces/event_matcher.mojom.h"
+#include "services/ui/public/interfaces/window_manager.mojom.h"
#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/aura/aura_export.h"
@@ -48,9 +48,9 @@ class AURA_EXPORT WindowManagerClient {
virtual void SetNonClientCursor(Window* window,
ui::mojom::Cursor non_client_cursor) = 0;
- virtual void AddAccelerator(uint32_t id,
- ui::mojom::EventMatcherPtr event_matcher,
- const base::Callback<void(bool)>& callback) = 0;
+ virtual void AddAccelerators(
+ std::vector<ui::mojom::AcceleratorPtr> 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;
@@ -60,6 +60,11 @@ class AURA_EXPORT WindowManagerClient {
const gfx::Vector2d& offset,
const gfx::Insets& hit_area) = 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;
+
protected:
virtual ~WindowManagerClient() {}
};
@@ -94,8 +99,11 @@ class AURA_EXPORT WindowManagerDelegate {
// 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().
+ // 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
@@ -104,14 +112,21 @@ class AURA_EXPORT WindowManagerDelegate {
const std::set<Window*>& client_windows,
bool janky) = 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| is the root of the display.
- virtual void OnWmDisplayRemoved(Window* window) = 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;
@@ -127,6 +142,19 @@ class AURA_EXPORT WindowManagerDelegate {
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;
+
protected:
virtual ~WindowManagerDelegate() {}
};
diff --git a/chromium/ui/aura/mus/window_mus.h b/chromium/ui/aura/mus/window_mus.h
index c389eb3500d..f88d0422853 100644
--- a/chromium/ui/aura/mus/window_mus.h
+++ b/chromium/ui/aura/mus/window_mus.h
@@ -14,6 +14,10 @@
#include "ui/aura/aura_export.h"
#include "ui/aura/mus/mus_types.h"
+namespace cc {
+class SurfaceInfo;
+}
+
namespace gfx {
class Rect;
}
@@ -26,7 +30,6 @@ enum class OrderDirection;
namespace aura {
-struct SurfaceInfo;
class Window;
class WindowTreeClient;
@@ -79,8 +82,11 @@ class AURA_EXPORT WindowMus {
virtual void SetPredefinedCursorFromServer(ui::mojom::Cursor cursor) = 0;
virtual void SetPropertyFromServer(const std::string& property_name,
const std::vector<uint8_t>* data) = 0;
- virtual void SetSurfaceIdFromServer(
- std::unique_ptr<SurfaceInfo> surface_info) = 0;
+ virtual void SetSurfaceInfoFromServer(
+ const cc::SurfaceInfo& surface_info) = 0;
+ // The window was deleted on the server side. DestroyFromServer() should
+ // result in deleting |this|.
+ virtual void DestroyFromServer() = 0;
virtual void AddTransientChildFromServer(WindowMus* child) = 0;
virtual void RemoveTransientChildFromServer(WindowMus* child) = 0;
// Called when a window was added/removed as a transient child.
@@ -97,6 +103,16 @@ class AURA_EXPORT WindowMus {
virtual std::unique_ptr<WindowMusChangeData> PrepareForServerVisibilityChange(
bool value) = 0;
+ // Called when the window on the server has been destroyed and the client code
+ // is going to delete the window. The client may not immediately delete the
+ // window (as compared to DestroyFromServer()).
+ virtual void PrepareForDestroy() = 0;
+
+ // See TransientWindowClientObserver::OnWillRestackTransientChildAbove() for
+ // details on this and OnTransientRestackDone().
+ virtual void PrepareForTransientRestack(WindowMus* window) = 0;
+ virtual void OnTransientRestackDone(WindowMus* window) = 0;
+
virtual void NotifyEmbeddedAppDisconnected() = 0;
private:
diff --git a/chromium/ui/aura/mus/window_port_mus.cc b/chromium/ui/aura/mus/window_port_mus.cc
index f9be96b4993..9fd07109e72 100644
--- a/chromium/ui/aura/mus/window_port_mus.cc
+++ b/chromium/ui/aura/mus/window_port_mus.cc
@@ -4,10 +4,11 @@
#include "ui/aura/mus/window_port_mus.h"
+#include "base/memory/ptr_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h"
+#include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/mus/property_converter.h"
-#include "ui/aura/mus/surface_id_handler.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/mus/window_tree_client_delegate.h"
#include "ui/aura/window.h"
@@ -31,10 +32,16 @@ WindowPortMus::WindowPortMus(WindowTreeClient* client,
: WindowMus(window_mus_type), window_tree_client_(client) {}
WindowPortMus::~WindowPortMus() {
- if (surface_info_)
- SetSurfaceIdFromServer(nullptr);
+ if (surface_info_.id().is_valid())
+ SetSurfaceInfoFromServer(cc::SurfaceInfo());
- window_tree_client_->OnWindowMusDestroyed(this);
+ // DESTROY is only scheduled from DestroyFromServer(), meaning if DESTROY is
+ // present then the server originated the change.
+ const WindowTreeClient::Origin origin =
+ RemoveChangeByTypeAndData(ServerChangeType::DESTROY, ServerChangeData())
+ ? WindowTreeClient::Origin::SERVER
+ : WindowTreeClient::Origin::CLIENT;
+ window_tree_client_->OnWindowMusDestroyed(this, origin);
}
// static
@@ -52,31 +59,39 @@ void WindowPortMus::SetImeVisibility(bool visible,
}
void WindowPortMus::SetPredefinedCursor(ui::mojom::Cursor cursor_id) {
+ if (cursor_id == predefined_cursor_)
+ return;
+
window_tree_client_->SetPredefinedCursor(this, predefined_cursor_, cursor_id);
predefined_cursor_ = cursor_id;
}
+void WindowPortMus::Embed(
+ ui::mojom::WindowTreeClientPtr client,
+ uint32_t flags,
+ const ui::mojom::WindowTree::EmbedCallback& callback) {
+ window_tree_client_->Embed(window_, std::move(client), flags, callback);
+}
+
std::unique_ptr<WindowCompositorFrameSink>
WindowPortMus::RequestCompositorFrameSink(
- ui::mojom::CompositorFrameSinkType type,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
std::unique_ptr<WindowCompositorFrameSinkBinding>
compositor_frame_sink_binding;
std::unique_ptr<WindowCompositorFrameSink> compositor_frame_sink =
- WindowCompositorFrameSink::Create(std::move(context_provider),
- gpu_memory_buffer_manager,
- &compositor_frame_sink_binding);
- AttachCompositorFrameSink(type, std::move(compositor_frame_sink_binding));
+ WindowCompositorFrameSink::Create(
+ cc::FrameSinkId(server_id(), 0), std::move(context_provider),
+ gpu_memory_buffer_manager, &compositor_frame_sink_binding);
+ AttachCompositorFrameSink(std::move(compositor_frame_sink_binding));
return compositor_frame_sink;
}
void WindowPortMus::AttachCompositorFrameSink(
- ui::mojom::CompositorFrameSinkType type,
std::unique_ptr<WindowCompositorFrameSinkBinding>
compositor_frame_sink_binding) {
window_tree_client_->AttachCompositorFrameSink(
- server_id(), type,
+ server_id(),
std::move(compositor_frame_sink_binding->compositor_frame_sink_request_),
mojo::MakeProxy(std::move(
compositor_frame_sink_binding->compositor_frame_sink_client_)));
@@ -105,8 +120,18 @@ void WindowPortMus::RemoveChangeById(ServerChangeIdType change_id) {
bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type,
const ServerChangeData& data) {
- for (auto iter = server_changes_.begin(); iter != server_changes_.end();
- ++iter) {
+ auto iter = FindChangeByTypeAndData(type, data);
+ if (iter == server_changes_.end())
+ return false;
+ server_changes_.erase(iter);
+ return true;
+}
+
+WindowPortMus::ServerChanges::iterator WindowPortMus::FindChangeByTypeAndData(
+ const ServerChangeType type,
+ const ServerChangeData& data) {
+ auto iter = server_changes_.begin();
+ for (; iter != server_changes_.end(); ++iter) {
if (iter->type != type)
continue;
@@ -116,26 +141,28 @@ bool WindowPortMus::RemoveChangeByTypeAndData(const ServerChangeType type,
case ServerChangeType::REMOVE:
case ServerChangeType::REMOVE_TRANSIENT:
case ServerChangeType::REORDER:
+ case ServerChangeType::TRANSIENT_REORDER:
if (iter->data.child_id == data.child_id)
- break;
- continue;
+ return iter;
+ break;
case ServerChangeType::BOUNDS:
- if (iter->data.bounds == data.bounds)
- break;
- continue;
+ if (iter->data.bounds_in_dip == data.bounds_in_dip)
+ return iter;
+ break;
+ case ServerChangeType::DESTROY:
+ // No extra data for delete.
+ return iter;
case ServerChangeType::PROPERTY:
if (iter->data.property_name == data.property_name)
- break;
- continue;
+ return iter;
+ break;
case ServerChangeType::VISIBLE:
if (iter->data.visible == data.visible)
- break;
- continue;
+ return iter;
+ break;
}
- server_changes_.erase(iter);
- return true;
}
- return false;
+ return iter;
}
PropertyConverter* WindowPortMus::GetPropertyConverter() {
@@ -178,7 +205,7 @@ void WindowPortMus::ReorderFromServer(WindowMus* child,
void WindowPortMus::SetBoundsFromServer(const gfx::Rect& bounds) {
ServerChangeData data;
- data.bounds = bounds;
+ data.bounds_in_dip = bounds;
ScopedServerChange change(this, ServerChangeType::BOUNDS, data);
window_->SetBounds(bounds);
}
@@ -215,23 +242,44 @@ void WindowPortMus::SetPropertyFromServer(
property_data);
}
-void WindowPortMus::SetSurfaceIdFromServer(
- std::unique_ptr<SurfaceInfo> surface_info) {
- if (surface_info_) {
- const cc::SurfaceId& existing_surface_id = surface_info_->surface_id;
- cc::SurfaceId new_surface_id =
- surface_info ? surface_info->surface_id : cc::SurfaceId();
+void WindowPortMus::SetSurfaceInfoFromServer(
+ const cc::SurfaceInfo& surface_info) {
+ if (surface_info_.id().is_valid()) {
+ const cc::SurfaceId& existing_surface_id = surface_info_.id();
+ const cc::SurfaceId& new_surface_id = surface_info.id();
if (existing_surface_id.is_valid() &&
existing_surface_id != new_surface_id) {
// TODO(kylechar): Start return reference here?
}
}
- WindowPortMus* parent = Get(window_->parent());
- if (parent && parent->surface_id_handler_) {
- parent->surface_id_handler_->OnChildWindowSurfaceChanged(window_,
- &surface_info);
+
+ // The fact that SetSurfaceIdFromServer was called means that this window
+ // corresponds to an embedded client.
+ if (!client_surface_embedder && surface_info.id().is_valid())
+ client_surface_embedder = base::MakeUnique<ClientSurfaceEmbedder>(window_);
+
+ if (surface_info.id().is_valid())
+ client_surface_embedder->UpdateSurface(surface_info);
+ else
+ client_surface_embedder.reset();
+
+ surface_info_ = surface_info;
+}
+
+void WindowPortMus::DestroyFromServer() {
+ std::unique_ptr<ScopedServerChange> remove_from_parent_change;
+ if (window_->parent()) {
+ ServerChangeData data;
+ data.child_id = server_id();
+ WindowPortMus* parent = Get(window_->parent());
+ remove_from_parent_change = base::MakeUnique<ScopedServerChange>(
+ parent, ServerChangeType::REMOVE, data);
}
- surface_info_ = std::move(surface_info);
+ // NOTE: this can't use ScopedServerChange as |this| is destroyed before the
+ // function returns (ScopedServerChange would attempt to access |this| after
+ // destruction).
+ ScheduleChange(ServerChangeType::DESTROY, ServerChangeData());
+ delete window_;
}
void WindowPortMus::AddTransientChildFromServer(WindowMus* child) {
@@ -278,7 +326,7 @@ WindowPortMus::PrepareForServerBoundsChange(const gfx::Rect& bounds) {
std::unique_ptr<WindowMusChangeDataImpl> data(
base::MakeUnique<WindowMusChangeDataImpl>());
ServerChangeData change_data;
- change_data.bounds = bounds;
+ change_data.bounds_in_dip = bounds;
data->change = base::MakeUnique<ScopedServerChange>(
this, ServerChangeType::BOUNDS, change_data);
return std::move(data);
@@ -295,6 +343,24 @@ WindowPortMus::PrepareForServerVisibilityChange(bool value) {
return std::move(data);
}
+void WindowPortMus::PrepareForDestroy() {
+ ScheduleChange(ServerChangeType::DESTROY, ServerChangeData());
+}
+
+void WindowPortMus::PrepareForTransientRestack(WindowMus* window) {
+ ServerChangeData change_data;
+ change_data.child_id = window->server_id();
+ ScheduleChange(ServerChangeType::TRANSIENT_REORDER, change_data);
+}
+
+void WindowPortMus::OnTransientRestackDone(WindowMus* window) {
+ ServerChangeData change_data;
+ change_data.child_id = window->server_id();
+ const bool removed = RemoveChangeByTypeAndData(
+ ServerChangeType::TRANSIENT_REORDER, change_data);
+ DCHECK(removed);
+}
+
void WindowPortMus::NotifyEmbeddedAppDisconnected() {
for (WindowObserver& observer : *GetObservers(window_))
observer.OnEmbeddedAppDisconnected(window_);
@@ -327,8 +393,13 @@ void WindowPortMus::OnWillRemoveChild(Window* child) {
void WindowPortMus::OnWillMoveChild(size_t current_index, size_t dest_index) {
ServerChangeData change_data;
change_data.child_id = Get(window_->children()[current_index])->server_id();
- if (!RemoveChangeByTypeAndData(ServerChangeType::REORDER, change_data))
+ // See description of TRANSIENT_REORDER for details on why it isn't removed
+ // here.
+ if (!RemoveChangeByTypeAndData(ServerChangeType::REORDER, change_data) &&
+ FindChangeByTypeAndData(ServerChangeType::TRANSIENT_REORDER,
+ change_data) == server_changes_.end()) {
window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index);
+ }
}
void WindowPortMus::OnVisibilityChanged(bool visible) {
@@ -341,7 +412,7 @@ void WindowPortMus::OnVisibilityChanged(bool visible) {
void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
ServerChangeData change_data;
- change_data.bounds = new_bounds;
+ change_data.bounds_in_dip = new_bounds;
if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data))
window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds);
}
diff --git a/chromium/ui/aura/mus/window_port_mus.h b/chromium/ui/aura/mus/window_port_mus.h
index a4bbd525b4f..084e9d539b2 100644
--- a/chromium/ui/aura/mus/window_port_mus.h
+++ b/chromium/ui/aura/mus/window_port_mus.h
@@ -12,7 +12,9 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "cc/surfaces/surface_info.h"
#include "services/ui/public/interfaces/cursor.mojom.h"
+#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/mus/mus_types.h"
@@ -24,8 +26,8 @@
namespace aura {
+class ClientSurfaceEmbedder;
class PropertyConverter;
-class SurfaceIdHandler;
class Window;
class WindowPortMusTestApi;
class WindowTreeClient;
@@ -54,20 +56,20 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
ui::mojom::Cursor predefined_cursor() const { return predefined_cursor_; }
void SetPredefinedCursor(ui::mojom::Cursor cursor_id);
+ // Embeds a new client in this Window. See WindowTreeClient::Embed() for
+ // details on arguments.
+ void Embed(ui::mojom::WindowTreeClientPtr client,
+ uint32_t flags,
+ const ui::mojom::WindowTree::EmbedCallback& callback);
+
std::unique_ptr<WindowCompositorFrameSink> RequestCompositorFrameSink(
- ui::mojom::CompositorFrameSinkType type,
scoped_refptr<cc::ContextProvider> context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager);
void AttachCompositorFrameSink(
- ui::mojom::CompositorFrameSinkType type,
std::unique_ptr<WindowCompositorFrameSinkBinding>
compositor_frame_sink_binding);
- void set_surface_id_handler(SurfaceIdHandler* surface_id_handler) {
- surface_id_handler_ = surface_id_handler;
- }
-
private:
friend class WindowPortMusTestApi;
friend class WindowTreeClient;
@@ -108,19 +110,26 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
ADD,
ADD_TRANSIENT,
BOUNDS,
+ DESTROY,
PROPERTY,
REMOVE,
REMOVE_TRANSIENT,
REORDER,
+ // This is used when a REORDER *may* occur as the result of a transient
+ // child being added or removed. As there is no guarantee the move will
+ // actually happen (the window may be in place already) this change is not
+ // automatically removed. Instead the change is explicitly removed.
+ TRANSIENT_REORDER,
VISIBLE,
};
// Contains data needed to identify a change from the server.
struct ServerChangeData {
- // Applies to ADD, ADD_TRANSIENT, REMOVE, REMOVE_TRANSIENT and REORDER.
+ // Applies to ADD, ADD_TRANSIENT, REMOVE, REMOVE_TRANSIENT, REORDER and
+ // TRANSIENT_REORDER.
Id child_id;
- // Applies to BOUNDS.
- gfx::Rect bounds;
+ // Applies to BOUNDS. This should be in dip.
+ gfx::Rect bounds_in_dip;
// Applies to VISIBLE.
bool visible;
// Applies to PROPERTY.
@@ -136,6 +145,8 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
ServerChangeData data;
};
+ using ServerChanges = std::vector<ServerChange>;
+
// Convenience for adding/removing a ScopedChange.
class ScopedServerChange {
public:
@@ -174,6 +185,9 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
bool RemoveChangeByTypeAndData(const ServerChangeType type,
const ServerChangeData& data);
+ ServerChanges::iterator FindChangeByTypeAndData(const ServerChangeType type,
+ const ServerChangeData& data);
+
PropertyConverter* GetPropertyConverter();
// WindowMus:
@@ -190,8 +204,8 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
void SetPropertyFromServer(
const std::string& property_name,
const std::vector<uint8_t>* property_data) override;
- void SetSurfaceIdFromServer(
- std::unique_ptr<SurfaceInfo> surface_info) override;
+ void SetSurfaceInfoFromServer(const cc::SurfaceInfo& surface_info) override;
+ void DestroyFromServer() override;
void AddTransientChildFromServer(WindowMus* child) override;
void RemoveTransientChildFromServer(WindowMus* child) override;
ChangeSource OnTransientChildAdded(WindowMus* child) override;
@@ -200,6 +214,9 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
const gfx::Rect& bounds) override;
std::unique_ptr<WindowMusChangeData> PrepareForServerVisibilityChange(
bool value) override;
+ void PrepareForDestroy() override;
+ void PrepareForTransientRestack(WindowMus* window) override;
+ void OnTransientRestackDone(WindowMus* window) override;
void NotifyEmbeddedAppDisconnected() override;
// WindowPort:
@@ -220,11 +237,13 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
Window* window_ = nullptr;
+ // Used when this window is embedding a client.
+ std::unique_ptr<ClientSurfaceEmbedder> client_surface_embedder;
+
ServerChangeIdType next_server_change_id_ = 0;
- std::vector<ServerChange> server_changes_;
+ ServerChanges server_changes_;
- SurfaceIdHandler* surface_id_handler_;
- std::unique_ptr<SurfaceInfo> surface_info_;
+ cc::SurfaceInfo surface_info_;
ui::mojom::Cursor predefined_cursor_ = ui::mojom::Cursor::CURSOR_NULL;
diff --git a/chromium/ui/aura/mus/window_tree_client.cc b/chromium/ui/aura/mus/window_tree_client.cc
index 9fbd03f3146..13660c96943 100644
--- a/chromium/ui/aura/mus/window_tree_client.cc
+++ b/chromium/ui/aura/mus/window_tree_client.cc
@@ -13,8 +13,12 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/memory/ptr_util.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/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 "ui/aura/client/aura_constants.h"
#include "ui/aura/client/drag_drop_client.h"
@@ -25,7 +29,7 @@
#include "ui/aura/mus/in_flight_change.h"
#include "ui/aura/mus/input_method_mus.h"
#include "ui/aura/mus/property_converter.h"
-#include "ui/aura/mus/surface_id_handler.h"
+#include "ui/aura/mus/property_utils.h"
#include "ui/aura/mus/window_manager_delegate.h"
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/mus/window_port_mus.h"
@@ -61,10 +65,6 @@ inline uint16_t HiWord(uint32_t id) {
return static_cast<uint16_t>((id >> 16) & 0xFFFF);
}
-inline uint16_t LoWord(uint32_t id) {
- return static_cast<uint16_t>(id & 0xFFFF);
-}
-
struct WindowPortPropertyDataMus : public WindowPortPropertyData {
std::string transport_name;
std::unique_ptr<std::vector<uint8_t>> transport_value;
@@ -119,11 +119,23 @@ bool IsInternalProperty(const void* key) {
return key == client::kModalKey;
}
+void SetWindowTypeFromProperties(
+ Window* window,
+ const std::unordered_map<std::string, std::vector<uint8_t>>& properties) {
+ auto type_iter =
+ properties.find(ui::mojom::WindowManager::kWindowType_InitProperty);
+ if (type_iter == properties.end())
+ return;
+
+ // TODO: need to validate type! http://crbug.com/654924.
+ ui::mojom::WindowType window_type = static_cast<ui::mojom::WindowType>(
+ mojo::ConvertTo<int32_t>(type_iter->second));
+ SetWindowType(window, window_type);
+}
+
// Helper function to get the device_scale_factor() of the display::Display
-// with |display_id|.
+// nearest to |window|.
float ScaleFactorForDisplay(Window* window) {
- // TODO(riajiang): Change to use display::GetDisplayWithDisplayId() after
- // https://codereview.chromium.org/2361283002/ is landed.
return display::Screen::GetScreen()
->GetDisplayNearestWindow(window)
.device_scale_factor();
@@ -132,10 +144,12 @@ float ScaleFactorForDisplay(Window* window) {
} // namespace
WindowTreeClient::WindowTreeClient(
+ service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
WindowManagerDelegate* window_manager_delegate,
mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request)
- : client_id_(0),
+ : connector_(connector),
+ client_id_(0),
next_window_id_(1),
next_change_id_(1),
delegate_(delegate),
@@ -186,58 +200,31 @@ WindowTreeClient::~WindowTreeClient() {
client::GetTransientWindowClient()->RemoveObserver(this);
}
-void WindowTreeClient::ConnectViaWindowTreeFactory(
- service_manager::Connector* connector) {
+void WindowTreeClient::ConnectViaWindowTreeFactory() {
// The client id doesn't really matter, we use 101 purely for debugging.
client_id_ = 101;
ui::mojom::WindowTreeFactoryPtr factory;
- connector->ConnectToInterface(ui::mojom::kServiceName, &factory);
+ connector_->BindInterface(ui::mojom::kServiceName, &factory);
ui::mojom::WindowTreePtr window_tree;
- factory->CreateWindowTree(GetProxy(&window_tree),
+ factory->CreateWindowTree(MakeRequest(&window_tree),
binding_.CreateInterfacePtrAndBind());
SetWindowTree(std::move(window_tree));
}
-void WindowTreeClient::ConnectAsWindowManager(
- service_manager::Connector* connector) {
+void WindowTreeClient::ConnectAsWindowManager() {
DCHECK(window_manager_delegate_);
ui::mojom::WindowManagerWindowTreeFactoryPtr factory;
- connector->ConnectToInterface(ui::mojom::kServiceName, &factory);
+ connector_->BindInterface(ui::mojom::kServiceName, &factory);
ui::mojom::WindowTreePtr window_tree;
- factory->CreateWindowTree(GetProxy(&window_tree),
+ factory->CreateWindowTree(MakeRequest(&window_tree),
binding_.CreateInterfacePtrAndBind());
SetWindowTree(std::move(window_tree));
}
-void WindowTreeClient::SetClientArea(
- Window* window,
- const gfx::Insets& client_area,
- const std::vector<gfx::Rect>& additional_client_areas) {
- DCHECK(tree_);
- float device_scale_factor = ScaleFactorForDisplay(window);
- std::vector<gfx::Rect> additional_client_areas_in_pixel;
- for (const gfx::Rect& area : additional_client_areas) {
- additional_client_areas_in_pixel.push_back(
- gfx::ConvertRectToPixel(device_scale_factor, area));
- }
- tree_->SetClientArea(
- WindowMus::Get(window)->server_id(),
- gfx::ConvertInsetsToPixel(device_scale_factor, client_area),
- additional_client_areas_in_pixel);
-}
-
-void WindowTreeClient::SetHitTestMask(Window* window, const gfx::Rect& mask) {
- DCHECK(tree_);
- tree_->SetHitTestMask(
- WindowMus::Get(window)->server_id(),
- gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), mask));
-}
-
-void WindowTreeClient::ClearHitTestMask(Window* window) {
- DCHECK(tree_);
- tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), base::nullopt);
+client::CaptureClient* WindowTreeClient::GetCaptureClient() {
+ return delegate_->GetCaptureClient();
}
void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) {
@@ -270,29 +257,33 @@ void WindowTreeClient::SetImeVisibility(WindowMus* window,
}
void WindowTreeClient::Embed(
- Id window_id,
+ Window* window,
ui::mojom::WindowTreeClientPtr client,
uint32_t flags,
const ui::mojom::WindowTree::EmbedCallback& callback) {
DCHECK(tree_);
- tree_->Embed(window_id, std::move(client), flags, callback);
-}
+ // Window::Init() must be called before Embed() (otherwise the server hasn't
+ // been told about the window).
+ DCHECK(window->layer());
+ if (!window->children().empty()) {
+ // The window server removes all children before embedding. In other words,
+ // it's generally an error to Embed() with existing children. So, fail
+ // early.
+ callback.Run(false);
+ return;
+ }
-void WindowTreeClient::RequestClose(Window* window) {
- DCHECK(window);
- if (window_manager_internal_client_)
- window_manager_internal_client_->WmRequestClose(
- WindowMus::Get(window)->server_id());
+ tree_->Embed(WindowMus::Get(window)->server_id(), std::move(client), flags,
+ callback);
}
void WindowTreeClient::AttachCompositorFrameSink(
Id window_id,
- ui::mojom::CompositorFrameSinkType type,
cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink,
cc::mojom::MojoCompositorFrameSinkClientPtr client) {
DCHECK(tree_);
- tree_->AttachCompositorFrameSink(
- window_id, type, std::move(compositor_frame_sink), std::move(client));
+ tree_->AttachCompositorFrameSink(window_id, std::move(compositor_frame_sink),
+ std::move(client));
}
void WindowTreeClient::RegisterWindowMus(WindowMus* window) {
@@ -305,11 +296,9 @@ WindowMus* WindowTreeClient::GetWindowByServerId(Id id) {
return it != windows_.end() ? it->second : nullptr;
}
-bool WindowTreeClient::WasCreatedByThisClient(const WindowMus* window) const {
- // Windows created via CreateTopLevelWindow() are not owned by us, but have
- // our client id. const_cast is required by set.
- return HiWord(window->server_id()) == client_id_ &&
- roots_.count(const_cast<WindowMus*>(window)) == 0;
+bool WindowTreeClient::IsWindowKnown(aura::Window* window) {
+ WindowMus* window_mus = WindowMus::Get(window);
+ return windows_.count(window_mus->server_id()) > 0;
}
InFlightChange* WindowTreeClient::GetOldestInFlightChangeMatching(
@@ -344,45 +333,65 @@ bool WindowTreeClient::ApplyServerChangeToExistingInFlightChange(
}
void WindowTreeClient::BuildWindowTree(
- const mojo::Array<ui::mojom::WindowDataPtr>& windows) {
- for (const auto& window_data : windows) {
- WindowMus* parent = window_data->parent_id == kInvalidServerId
- ? nullptr
- : GetWindowByServerId(window_data->parent_id);
- WindowMus* existing_window = GetWindowByServerId(window_data->window_id);
- if (!existing_window)
- NewWindowFromWindowData(parent, window_data);
- else if (parent)
- parent->AddChildFromServer(existing_window);
+ const std::vector<ui::mojom::WindowDataPtr>& windows) {
+ for (const auto& window_data : windows)
+ CreateOrUpdateWindowFromWindowData(*window_data);
+}
+
+void WindowTreeClient::CreateOrUpdateWindowFromWindowData(
+ const ui::mojom::WindowData& window_data) {
+ WindowMus* parent = window_data.parent_id == kInvalidServerId
+ ? nullptr
+ : GetWindowByServerId(window_data.parent_id);
+ WindowMus* window = GetWindowByServerId(window_data.window_id);
+ if (!window)
+ window = NewWindowFromWindowData(parent, window_data);
+ else if (parent)
+ parent->AddChildFromServer(window);
+
+ if (window_data.transient_parent_id == kInvalidServerId)
+ return;
+
+ // Adjust the transient parent if necessary.
+ client::TransientWindowClient* transient_window_client =
+ client::GetTransientWindowClient();
+ Window* existing_transient_parent =
+ transient_window_client->GetTransientParent(window->GetWindow());
+ WindowMus* new_transient_parent =
+ GetWindowByServerId(window_data.transient_parent_id);
+ if (!new_transient_parent && existing_transient_parent) {
+ WindowMus::Get(existing_transient_parent)
+ ->RemoveTransientChildFromServer(window);
+ } else if (new_transient_parent &&
+ new_transient_parent->GetWindow() != existing_transient_parent) {
+ if (existing_transient_parent) {
+ WindowMus::Get(existing_transient_parent)
+ ->RemoveTransientChildFromServer(window);
+ }
+ new_transient_parent->AddTransientChildFromServer(window);
}
}
std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortMus(
- const ui::mojom::WindowDataPtr& window_data,
+ const ui::mojom::WindowData& window_data,
WindowMusType window_mus_type) {
std::unique_ptr<WindowPortMus> window_port_mus(
base::MakeUnique<WindowPortMus>(this, window_mus_type));
- window_port_mus->set_server_id(window_data->window_id);
+ window_port_mus->set_server_id(window_data.window_id);
RegisterWindowMus(window_port_mus.get());
return window_port_mus;
}
void WindowTreeClient::SetLocalPropertiesFromServerProperties(
WindowMus* window,
- const ui::mojom::WindowDataPtr& window_data) {
- for (auto& pair : window_data->properties) {
- if (pair.second.is_null()) {
- window->SetPropertyFromServer(pair.first, nullptr);
- } else {
- std::vector<uint8_t> stl_value = pair.second.To<std::vector<uint8_t>>();
- window->SetPropertyFromServer(pair.first, &stl_value);
- }
- }
+ const ui::mojom::WindowData& window_data) {
+ for (auto& pair : window_data.properties)
+ window->SetPropertyFromServer(pair.first, &pair.second);
}
std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
WindowMusType window_mus_type,
- const ui::mojom::WindowDataPtr& window_data,
+ const ui::mojom::WindowData& window_data,
int64_t display_id) {
std::unique_ptr<WindowPortMus> window_port =
CreateWindowPortMus(window_data, window_mus_type);
@@ -390,28 +399,35 @@ std::unique_ptr<WindowTreeHostMus> WindowTreeClient::CreateWindowTreeHost(
std::unique_ptr<WindowTreeHostMus> window_tree_host =
base::MakeUnique<WindowTreeHostMus>(std::move(window_port), this,
display_id);
- if (!window_data.is_null()) {
- SetLocalPropertiesFromServerProperties(
- WindowMus::Get(window_tree_host->window()), window_data);
+ window_tree_host->InitHost();
+ SetLocalPropertiesFromServerProperties(
+ WindowMus::Get(window_tree_host->window()), window_data);
+ if (window_data.visible) {
+ SetWindowVisibleFromServer(WindowMus::Get(window_tree_host->window()),
+ true);
}
+ SetWindowBoundsFromServer(WindowMus::Get(window_tree_host->window()),
+ window_data.bounds);
return window_tree_host;
}
WindowMus* WindowTreeClient::NewWindowFromWindowData(
WindowMus* parent,
- const ui::mojom::WindowDataPtr& window_data) {
+ const ui::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));
WindowPortMus* window_port_mus_ptr = window_port_mus.get();
Window* window = new Window(nullptr, std::move(window_port_mus));
WindowMus* window_mus = window_port_mus_ptr;
+ SetWindowTypeFromProperties(window, window_data.properties);
window->Init(ui::LAYER_NOT_DRAWN);
SetLocalPropertiesFromServerProperties(window_mus, window_data);
- window_mus->SetBoundsFromServer(window_data->bounds);
+ window_mus->SetBoundsFromServer(
+ gfx::ConvertRectToDIP(ScaleFactorForDisplay(window), window_data.bounds));
if (parent)
parent->AddChildFromServer(window_port_mus_ptr);
- if (window_data->visible)
+ if (window_data.visible)
window_mus->SetVisibleFromServer(true);
return window_port_mus_ptr;
}
@@ -427,8 +443,8 @@ void WindowTreeClient::SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr) {
&WindowTreeClient::OnConnectionLost, weak_factory_.GetWeakPtr()));
if (window_manager_delegate_) {
- tree_ptr_->GetWindowManagerClient(GetProxy(&window_manager_internal_client_,
- tree_ptr_.associated_group()));
+ tree_ptr_->GetWindowManagerClient(MakeRequest(
+ &window_manager_internal_client_, tree_ptr_.associated_group()));
}
}
@@ -437,8 +453,8 @@ void WindowTreeClient::WindowTreeConnectionEstablished(
tree_ = window_tree;
drag_drop_controller_ = base::MakeUnique<DragDropControllerMus>(this, tree_);
- capture_synchronizer_ = base::MakeUnique<CaptureSynchronizer>(
- this, tree_, delegate_->GetCaptureClient());
+ capture_synchronizer_ =
+ base::MakeUnique<CaptureSynchronizer>(this, tree_, GetCaptureClient());
focus_synchronizer_ = base::MakeUnique<FocusSynchronizer>(this, tree_);
}
@@ -479,7 +495,7 @@ void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree,
DCHECK(roots_.empty());
std::unique_ptr<WindowTreeHostMus> window_tree_host =
- CreateWindowTreeHost(WindowMusType::EMBED, root_data, display_id);
+ CreateWindowTreeHost(WindowMusType::EMBED, *root_data, display_id);
focus_synchronizer_->SetFocusFromServer(
GetWindowByServerId(focused_window_id));
@@ -487,16 +503,18 @@ void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree,
delegate_->OnEmbed(std::move(window_tree_host));
}
-WindowTreeHost* WindowTreeClient::WmNewDisplayAddedImpl(
+WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
const display::Display& display,
ui::mojom::WindowDataPtr root_data,
bool parent_drawn) {
DCHECK(window_manager_delegate_);
+ window_manager_delegate_->OnWmWillCreateDisplay(display);
+
std::unique_ptr<WindowTreeHostMus> window_tree_host =
- CreateWindowTreeHost(WindowMusType::DISPLAY, root_data, display.id());
+ CreateWindowTreeHost(WindowMusType::DISPLAY, *root_data, display.id());
- WindowTreeHost* window_tree_host_ptr = window_tree_host.get();
+ WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
display);
return window_tree_host_ptr;
@@ -517,13 +535,15 @@ void WindowTreeClient::OnReceivedCursorLocationMemory(
void WindowTreeClient::SetWindowBoundsFromServer(
WindowMus* window,
- const gfx::Rect& revert_bounds) {
+ const gfx::Rect& revert_bounds_in_pixels) {
if (IsRoot(window)) {
- GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds);
+ // WindowTreeHost expects bounds to be in pixels.
+ GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels);
return;
}
- window->SetBoundsFromServer(revert_bounds);
+ window->SetBoundsFromServer(gfx::ConvertRectToDIP(
+ ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels));
}
void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window,
@@ -558,9 +578,9 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
window->set_server_id(MakeTransportId(client_id_, next_window_id_++));
RegisterWindowMus(window);
- const bool create_top_level = !window_manager_delegate_ && IsRoot(window);
+ DCHECK(window_manager_delegate_ || !IsRoot(window));
- mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties;
+ std::unordered_map<std::string, std::vector<uint8_t>> transport_properties;
std::set<const void*> property_keys =
window->GetWindow()->GetAllPropertKeys();
PropertyConverter* property_converter = delegate_->GetPropertyConverter();
@@ -572,32 +592,25 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
continue;
}
if (!transport_value) {
- transport_properties[transport_name] = mojo::Array<uint8_t>(nullptr);
+ transport_properties[transport_name] = std::vector<uint8_t>();
} else {
- transport_properties[transport_name] =
- mojo::Array<uint8_t>::From(*transport_value);
+ transport_properties[transport_name] = std::move(*transport_value);
}
}
- const uint32_t change_id =
- ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
- window, create_top_level ? ChangeType::NEW_TOP_LEVEL_WINDOW
- : ChangeType::NEW_WINDOW));
- if (create_top_level) {
- tree_->NewTopLevelWindow(change_id, window->server_id(),
- std::move(transport_properties));
- } else {
- tree_->NewWindow(change_id, window->server_id(),
- std::move(transport_properties));
- }
+ const uint32_t change_id = ScheduleInFlightChange(
+ base::MakeUnique<CrashInFlightChange>(window, ChangeType::NEW_WINDOW));
+ tree_->NewWindow(change_id, window->server_id(),
+ std::move(transport_properties));
}
-void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window) {
+void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
if (focus_synchronizer_->focused_window() == window)
focus_synchronizer_->OnFocusedWindowDestroyed();
// TODO: decide how to deal with windows not owned by this client.
- if (WasCreatedByThisClient(window) || IsRoot(window)) {
+ if (origin == Origin::CLIENT &&
+ (WasCreatedByThisClient(window) || IsRoot(window))) {
const uint32_t change_id =
ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
window, ChangeType::DELETE_WINDOW));
@@ -623,9 +636,7 @@ void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window) {
for (auto change_id : in_flight_change_ids_to_remove)
in_flight_map_.erase(change_id);
- const bool was_root = roots_.erase(window) > 0;
- if (!in_destructor_ && was_root && roots_.empty() && is_from_embed_)
- delegate_->OnEmbedRootDestroyed(window->GetWindow());
+ roots_.erase(window);
}
void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
@@ -637,7 +648,10 @@ void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
if (IsRoot(window))
return;
- ScheduleInFlightBoundsChange(window, old_bounds, new_bounds);
+ float device_scale_factor = ScaleFactorForDisplay(window->GetWindow());
+ ScheduleInFlightBoundsChange(
+ window, gfx::ConvertRectToPixel(device_scale_factor, old_bounds),
+ gfx::ConvertRectToPixel(device_scale_factor, new_bounds));
}
void WindowTreeClient::OnWindowMusAddChild(WindowMus* parent,
@@ -721,20 +735,15 @@ void WindowTreeClient::OnWindowMusPropertyChanged(
}
DCHECK_EQ(transport_name, data_mus->transport_name);
- mojo::Array<uint8_t> transport_value_mojo(nullptr);
- if (transport_value) {
- transport_value_mojo.resize(transport_value->size());
- if (transport_value->size()) {
- memcpy(&transport_value_mojo.front(), &(transport_value->front()),
- transport_value->size());
- }
- }
+ base::Optional<std::vector<uint8_t>> transport_value_mojo;
+ if (transport_value)
+ transport_value_mojo.emplace(std::move(*transport_value));
+
const uint32_t change_id =
ScheduleInFlightChange(base::MakeUnique<InFlightPropertyChange>(
window, transport_name, std::move(data_mus->transport_value)));
- tree_->SetWindowProperty(change_id, window->server_id(),
- mojo::String(transport_name),
- std::move(transport_value_mojo));
+ tree_->SetWindowProperty(change_id, window->server_id(), transport_name,
+ transport_value_mojo);
}
void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id,
@@ -748,9 +757,6 @@ void WindowTreeClient::OnWmMoveLoopCompleted(uint32_t change_id,
}
}
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeClient, WindowTreeClient implementation:
-
std::set<Window*> WindowTreeClient::GetRoots() {
std::set<Window*> roots;
for (WindowMus* window : roots_)
@@ -758,6 +764,13 @@ std::set<Window*> WindowTreeClient::GetRoots() {
return roots;
}
+bool WindowTreeClient::WasCreatedByThisClient(const WindowMus* window) const {
+ // Windows created via CreateTopLevelWindow() are not owned by us, but have
+ // our client id. const_cast is required by set.
+ return HiWord(window->server_id()) == client_id_ &&
+ roots_.count(const_cast<WindowMus*>(window)) == 0;
+}
+
gfx::Point WindowTreeClient::GetCursorScreenPoint() {
// We raced initialization. Return (0, 0).
if (!cursor_location_memory())
@@ -802,9 +815,6 @@ void WindowTreeClient::CancelWindowMove(Window* window) {
tree_->CancelWindowMove(WindowMus::Get(window)->server_id());
}
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeClient, WindowTreeClient implementation:
-
void WindowTreeClient::AddObserver(WindowTreeClientObserver* observer) {
observers_.AddObserver(observer);
}
@@ -836,8 +846,8 @@ void WindowTreeClient::OnEmbed(ClientSpecificId client_id,
is_from_embed_ = true;
if (window_manager_delegate_) {
- tree_ptr_->GetWindowManagerClient(GetProxy(&window_manager_internal_client_,
- tree_ptr_.associated_group()));
+ tree_ptr_->GetWindowManagerClient(MakeRequest(
+ &window_manager_internal_client_, tree_ptr_.associated_group()));
}
OnEmbedImpl(tree_ptr_.get(), client_id, std::move(root_data), display_id,
@@ -918,15 +928,14 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id,
GetOldestInFlightChangeMatching(bounds_change);
if (current_change)
current_change->SetRevertValueFrom(bounds_change);
- else if (window->GetWindow()->bounds() != bounds)
+ else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()),
+ window->GetWindow()->bounds()) != bounds)
SetWindowBoundsFromServer(window, bounds);
}
// There is currently no API to bulk set properties, so we iterate over each
// property individually.
- std::map<std::string, std::vector<uint8_t>> properties =
- data->properties.To<std::map<std::string, std::vector<uint8_t>>>();
- for (const auto& pair : properties) {
+ for (const auto& pair : data->properties) {
std::unique_ptr<std::vector<uint8_t>> revert_value(
base::MakeUnique<std::vector<uint8_t>>(pair.second));
InFlightPropertyChange property_change(window, pair.first,
@@ -961,17 +970,21 @@ void WindowTreeClient::OnWindowBoundsChanged(Id window_id,
void WindowTreeClient::OnClientAreaChanged(
uint32_t window_id,
const gfx::Insets& new_client_area,
- mojo::Array<gfx::Rect> new_additional_client_areas) {
- // TODO: client area.
- // TODO(riajiang): Convert from pixel to DIP. (http://crbug.com/600815)
- /*
- Window* window = GetWindowByServerId(window_id);
- if (window) {
- WindowPrivate(window).LocalSetClientArea(
- new_client_area,
- new_additional_client_areas.To<std::vector<gfx::Rect>>());
+ const std::vector<gfx::Rect>& new_additional_client_areas) {
+ WindowMus* window = GetWindowByServerId(window_id);
+ if (!window)
+ return;
+
+ float device_scale_factor = ScaleFactorForDisplay(window->GetWindow());
+ 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(uint32_t window_id,
@@ -998,7 +1011,7 @@ void WindowTreeClient::OnWindowHierarchyChanged(
Id window_id,
Id old_parent_id,
Id new_parent_id,
- mojo::Array<ui::mojom::WindowDataPtr> windows) {
+ std::vector<ui::mojom::WindowDataPtr> windows) {
const bool was_window_known = GetWindowByServerId(window_id) != nullptr;
BuildWindowTree(windows);
@@ -1030,9 +1043,21 @@ void WindowTreeClient::OnWindowReordered(Id window_id,
}
void WindowTreeClient::OnWindowDeleted(Id window_id) {
- // TODO(sky): decide how best to deal with this. It seems we should let the
- // delegate do the actualy deletion.
- delete GetWindowByServerId(window_id)->GetWindow();
+ WindowMus* window = GetWindowByServerId(window_id);
+ if (!window)
+ return;
+
+ if (roots_.count(window)) {
+ // Roots are associated with WindowTreeHosts. The WindowTreeHost owns the
+ // root, so we have to delete the WindowTreeHost to indirectly delete the
+ // Window. Additionally clients may want to do extra processing before the
+ // delete, so call to the delegate to handle it. Let the window know it is
+ // going to be deleted so we don't callback to the server.
+ window->PrepareForDestroy();
+ delegate_->OnEmbedRootDestroyed(GetWindowTreeHostMus(window));
+ } else {
+ window->DestroyFromServer();
+ }
}
void WindowTreeClient::OnWindowVisibilityChanged(Id window_id, bool visible) {
@@ -1073,26 +1098,22 @@ void WindowTreeClient::OnWindowParentDrawnStateChanged(Id window_id,
void WindowTreeClient::OnWindowSharedPropertyChanged(
Id window_id,
- const mojo::String& name,
- mojo::Array<uint8_t> transport_data) {
+ const std::string& name,
+ const base::Optional<std::vector<uint8_t>>& transport_data) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
std::unique_ptr<std::vector<uint8_t>> data;
- if (!transport_data.is_null()) {
- data = base::MakeUnique<std::vector<uint8_t>>(
- transport_data.To<std::vector<uint8_t>>());
- }
+ if (transport_data.has_value())
+ data = base::MakeUnique<std::vector<uint8_t>>(transport_data.value());
+
InFlightPropertyChange new_change(window, name, std::move(data));
if (ApplyServerChangeToExistingInFlightChange(new_change))
return;
- if (!transport_data.is_null()) {
- data = base::MakeUnique<std::vector<uint8_t>>(
- transport_data.To<std::vector<uint8_t>>());
- }
- window->SetPropertyFromServer(name, data.get());
+ window->SetPropertyFromServer(
+ name, transport_data.has_value() ? &transport_data.value() : nullptr);
}
void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
@@ -1129,8 +1150,19 @@ void WindowTreeClient::OnWindowInputEvent(uint32_t event_id,
return;
}
- EventAckHandler ack_handler(CreateEventResultCallback(event_id));
WindowTreeHostMus* host = GetWindowTreeHostMus(window);
+ DCHECK(host);
+
+ // The location of the event is relative to |window|. As the event is handed
+ // to WindowTreeHost we need it to be relative to WindowTreeHost.
+ if (event->IsLocatedEvent()) {
+ gfx::Point host_location = event->AsLocatedEvent()->location();
+ aura::Window::ConvertPointToTarget(window->GetWindow(), host->window(),
+ &host_location);
+ event->AsLocatedEvent()->set_location(host_location);
+ }
+
+ EventAckHandler ack_handler(CreateEventResultCallback(event_id));
// TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or
// ui::TouchEvent once we have proper support for pointer events.
if (event->IsMousePointerEvent()) {
@@ -1189,23 +1221,16 @@ void WindowTreeClient::OnWindowPredefinedCursorChanged(
void WindowTreeClient::OnWindowSurfaceChanged(
Id window_id,
- const cc::SurfaceId& surface_id,
- const gfx::Size& frame_size,
- float device_scale_factor) {
+ const cc::SurfaceInfo& surface_info) {
WindowMus* window = GetWindowByServerId(window_id);
if (!window)
return;
- std::unique_ptr<SurfaceInfo> surface_info(base::MakeUnique<SurfaceInfo>());
- surface_info->surface_id = surface_id;
- surface_info->frame_size = frame_size;
- surface_info->device_scale_factor = device_scale_factor;
- window->SetSurfaceIdFromServer(std::move(surface_info));
+ window->SetSurfaceInfoFromServer(surface_info);
}
void WindowTreeClient::OnDragDropStart(
- mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) {
- drag_drop_controller_->OnDragDropStart(
- mime_data.To<std::map<std::string, std::vector<uint8_t>>>());
+ const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data) {
+ drag_drop_controller_->OnDragDropStart(mojo::UnorderedMapToMap(mime_data));
}
void WindowTreeClient::OnDragEnter(Id window_id,
@@ -1288,7 +1313,9 @@ void WindowTreeClient::RequestClose(uint32_t window_id) {
if (!window || !IsRoot(window))
return;
- window->GetWindow()->delegate()->OnRequestClose();
+ // Since the window is the root window, we send close request to the entire
+ // WindowTreeHost.
+ GetWindowTreeHostMus(window->GetWindow())->OnCloseRequest();
}
void WindowTreeClient::OnConnect(ClientSpecificId client_id) {
@@ -1303,15 +1330,15 @@ void WindowTreeClient::WmNewDisplayAdded(const display::Display& display,
void WindowTreeClient::WmDisplayRemoved(int64_t display_id) {
DCHECK(window_manager_delegate_);
- // TODO: route to WindowTreeHost.
- /*
- for (Window* root : roots_) {
- if (root->display_id() == display_id) {
- window_manager_delegate_->OnWmDisplayRemoved(root);
+ 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) {
@@ -1320,43 +1347,44 @@ void WindowTreeClient::WmDisplayModified(const display::Display& display) {
window_manager_delegate_->OnWmDisplayModified(display);
}
-// TODO(riajiang): Convert between pixel and DIP for window bounds properly.
-// (http://crbug.com/646942)
void WindowTreeClient::WmSetBounds(uint32_t change_id,
Id window_id,
- const gfx::Rect& transit_bounds) {
+ const gfx::Rect& transit_bounds_in_pixels) {
WindowMus* window = GetWindowByServerId(window_id);
bool result = false;
if (window) {
+ float device_scale_factor = ScaleFactorForDisplay(window->GetWindow());
DCHECK(window_manager_delegate_);
- gfx::Rect bounds = transit_bounds;
+ gfx::Rect transit_bounds_in_dip =
+ gfx::ConvertRectToDIP(device_scale_factor, transit_bounds_in_pixels);
+ gfx::Rect bounds_in_dip = transit_bounds_in_dip;
// TODO: this needs to trigger scheduling a bounds change on |window|.
- result =
- window_manager_delegate_->OnWmSetBounds(window->GetWindow(), &bounds);
+ result = window_manager_delegate_->OnWmSetBounds(window->GetWindow(),
+ &bounds_in_dip);
if (result) {
// If the resulting bounds differ return false. Returning false ensures
// the client applies the bounds we set below.
- result = bounds == transit_bounds;
- window->SetBoundsFromServer(bounds);
+ result = bounds_in_dip == transit_bounds_in_dip;
+ window->SetBoundsFromServer(bounds_in_dip);
}
}
if (window_manager_internal_client_)
window_manager_internal_client_->WmResponse(change_id, result);
}
-void WindowTreeClient::WmSetProperty(uint32_t change_id,
- Id window_id,
- const mojo::String& name,
- mojo::Array<uint8_t> transit_data) {
+void WindowTreeClient::WmSetProperty(
+ uint32_t change_id,
+ 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.is_null()) {
- data.reset(
- new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>()));
- }
+ 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) {
@@ -1371,11 +1399,25 @@ void WindowTreeClient::WmSetProperty(uint32_t change_id,
void WindowTreeClient::WmCreateTopLevelWindow(
uint32_t change_id,
ClientSpecificId requesting_client_id,
- mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
+ const std::unordered_map<std::string, std::vector<uint8_t>>&
+ transport_properties) {
std::map<std::string, std::vector<uint8_t>> properties =
- transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
- Window* window =
- window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
+ mojo::UnorderedMapToMap(transport_properties);
+ ui::mojom::WindowType window_type = ui::mojom::WindowType::UNKNOWN;
+ auto type_iter =
+ properties.find(ui::mojom::WindowManager::kWindowType_InitProperty);
+ if (type_iter != properties.end()) {
+ // TODO: validation! http://crbug.com/654924.
+ window_type = static_cast<ui::mojom::WindowType>(
+ mojo::ConvertTo<int32_t>(type_iter->second));
+ }
+ Window* window = window_manager_delegate_->OnWmCreateTopLevelWindow(
+ window_type, &properties);
+ if (!window) {
+ window_manager_internal_client_->OnWmCreatedTopLevelWindow(
+ change_id, kInvalidServerId);
+ return;
+ }
embedded_windows_[requesting_client_id].insert(window);
if (window_manager_internal_client_) {
window_manager_internal_client_->OnWmCreatedTopLevelWindow(
@@ -1424,6 +1466,24 @@ void WindowTreeClient::WmCancelMoveLoop(uint32_t change_id) {
window_manager_delegate_->OnWmCancelMoveLoop(window->GetWindow());
}
+void WindowTreeClient::WmDeactivateWindow(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::OnAccelerator(uint32_t ack_id,
uint32_t accelerator_id,
std::unique_ptr<ui::Event> event) {
@@ -1448,13 +1508,12 @@ void WindowTreeClient::SetNonClientCursor(Window* window,
WindowMus::Get(window)->server_id(), cursor_id);
}
-void WindowTreeClient::AddAccelerator(
- uint32_t id,
- ui::mojom::EventMatcherPtr event_matcher,
+void WindowTreeClient::AddAccelerators(
+ std::vector<ui::mojom::AcceleratorPtr> accelerators,
const base::Callback<void(bool)>& callback) {
if (window_manager_internal_client_) {
- window_manager_internal_client_->AddAccelerator(
- id, std::move(event_matcher), callback);
+ window_manager_internal_client_->AddAccelerators(std::move(accelerators),
+ callback);
}
}
@@ -1488,25 +1547,89 @@ void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea(
const gfx::Vector2d& offset,
const gfx::Insets& hit_area) {
if (window_manager_internal_client_) {
- // TODO(riajiang): Figure out if |offset| needs to be converted.
- // (http://crbugs.com/646932)
+ float device_scale_factor = ScaleFactorForDisplay(window);
+ gfx::Vector2dF offset_in_pixels =
+ gfx::ScaleVector2d(offset, device_scale_factor);
window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea(
- WindowMus::Get(window)->server_id(), offset.x(), offset.y(),
- gfx::ConvertInsetsToDIP(ScaleFactorForDisplay(window), hit_area));
+ WindowMus::Get(window)->server_id(), offset_in_pixels.x(),
+ offset_in_pixels.y(),
+ gfx::ConvertInsetsToPixel(device_scale_factor, hit_area));
}
}
+void WindowTreeClient::RequestClose(Window* window) {
+ DCHECK(window);
+ if (window_manager_internal_client_)
+ window_manager_internal_client_->WmRequestClose(
+ WindowMus::Get(window)->server_id());
+}
+
void WindowTreeClient::OnWindowTreeHostBoundsWillChange(
WindowTreeHostMus* window_tree_host,
const gfx::Rect& bounds) {
ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()),
- window_tree_host->GetBounds(), bounds);
+ window_tree_host->GetBoundsInPixels(), bounds);
}
-std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() {
+void WindowTreeClient::OnWindowTreeHostClientAreaWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const gfx::Insets& client_area,
+ const std::vector<gfx::Rect>& additional_client_areas) {
+ DCHECK(tree_);
+ Window* window = window_tree_host->window();
+ float device_scale_factor = ScaleFactorForDisplay(window);
+ std::vector<gfx::Rect> additional_client_areas_in_pixel;
+ for (const gfx::Rect& area : additional_client_areas) {
+ additional_client_areas_in_pixel.push_back(
+ gfx::ConvertRectToPixel(device_scale_factor, area));
+ }
+ tree_->SetClientArea(
+ WindowMus::Get(window)->server_id(),
+ gfx::ConvertInsetsToPixel(device_scale_factor, client_area),
+ additional_client_areas_in_pixel);
+}
+
+void WindowTreeClient::OnWindowTreeHostHitTestMaskWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const base::Optional<gfx::Rect>& mask_rect) {
+ Window* window = window_tree_host->window();
+
+ base::Optional<gfx::Rect> out_rect = base::nullopt;
+ if (mask_rect) {
+ out_rect = gfx::ConvertRectToPixel(ScaleFactorForDisplay(window),
+ mask_rect.value());
+ }
+
+ tree_->SetHitTestMask(WindowMus::Get(window_tree_host->window())->server_id(),
+ out_rect);
+}
+
+void WindowTreeClient::OnWindowTreeHostDeactivateWindow(
+ WindowTreeHostMus* window_tree_host) {
+ tree_->DeactivateWindow(
+ WindowMus::Get(window_tree_host->window())->server_id());
+}
+
+std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel(
+ const std::map<std::string, std::vector<uint8_t>>* properties) {
std::unique_ptr<WindowPortMus> window_port =
base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL);
roots_.insert(window_port.get());
+
+ window_port->set_server_id(MakeTransportId(client_id_, next_window_id_++));
+ RegisterWindowMus(window_port.get());
+
+ std::unordered_map<std::string, std::vector<uint8_t>> transport_properties;
+ if (properties) {
+ for (const auto& property_pair : *properties)
+ transport_properties[property_pair.first] = property_pair.second;
+ }
+
+ const uint32_t change_id =
+ ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>(
+ window_port.get(), ChangeType::NEW_TOP_LEVEL_WINDOW));
+ tree_->NewTopLevelWindow(change_id, window_port->server_id(),
+ transport_properties);
return window_port;
}
@@ -1520,10 +1643,17 @@ void WindowTreeClient::OnWindowTreeHostCreated(
void WindowTreeClient::OnTransientChildWindowAdded(Window* parent,
Window* transient_child) {
+ // TransientWindowClient is a singleton and we allow multiple
+ // WindowTreeClients. Ignore changes to windows we don't know about (assume
+ // they came from another connection).
+ if (!IsWindowKnown(parent) || !IsWindowKnown(transient_child))
+ return;
+
if (WindowMus::Get(parent)->OnTransientChildAdded(
WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
return;
}
+
// The change originated from client code and needs to be sent to the server.
DCHECK(tree_);
WindowMus* parent_mus = WindowMus::Get(parent);
@@ -1536,6 +1666,10 @@ void WindowTreeClient::OnTransientChildWindowAdded(Window* parent,
void WindowTreeClient::OnTransientChildWindowRemoved(Window* parent,
Window* transient_child) {
+ // See comments in OnTransientChildWindowAdded() for details on early return.
+ if (!IsWindowKnown(parent) || !IsWindowKnown(transient_child))
+ return;
+
if (WindowMus::Get(parent)->OnTransientChildRemoved(
WindowMus::Get(transient_child)) == WindowMus::ChangeSource::SERVER) {
return;
@@ -1549,6 +1683,31 @@ void WindowTreeClient::OnTransientChildWindowRemoved(Window* parent,
tree_->RemoveTransientWindowFromParent(change_id, child_mus->server_id());
}
+void WindowTreeClient::OnWillRestackTransientChildAbove(
+ Window* parent,
+ Window* transient_child) {
+ DCHECK(parent->parent());
+ // See comments in OnTransientChildWindowAdded() for details on early return.
+ if (!IsWindowKnown(parent->parent()))
+ return;
+
+ DCHECK_EQ(parent->parent(), transient_child->parent());
+ WindowMus::Get(parent->parent())
+ ->PrepareForTransientRestack(WindowMus::Get(transient_child));
+}
+
+void WindowTreeClient::OnDidRestackTransientChildAbove(
+ Window* parent,
+ Window* transient_child) {
+ DCHECK(parent->parent());
+ // See comments in OnTransientChildWindowAdded() for details on early return.
+ if (!IsWindowKnown(parent->parent()))
+ return;
+ DCHECK_EQ(parent->parent(), transient_child->parent());
+ WindowMus::Get(parent->parent())
+ ->OnTransientRestackDone(WindowMus::Get(transient_child));
+}
+
uint32_t WindowTreeClient::CreateChangeIdForDrag(WindowMus* window) {
return ScheduleInFlightChange(
base::MakeUnique<InFlightDragChange>(window, ChangeType::DRAG_LOOP));
diff --git a/chromium/ui/aura/mus/window_tree_client.h b/chromium/ui/aura/mus/window_tree_client.h
index f9835fe486d..7c89cf1f89e 100644
--- a/chromium/ui/aura/mus/window_tree_client.h
+++ b/chromium/ui/aura/mus/window_tree_client.h
@@ -57,9 +57,12 @@ struct WindowPortPropertyData;
class WindowTreeClientDelegate;
class WindowTreeClientPrivate;
class WindowTreeClientObserver;
-class WindowTreeHost;
class WindowTreeHostMus;
+namespace client {
+class CaptureClient;
+}
+
using EventResultCallback = base::Callback<void(ui::mojom::EventResult)>;
// Manages the connection with mus.
@@ -81,25 +84,25 @@ class AURA_EXPORT WindowTreeClient
public client::TransientWindowClientObserver {
public:
explicit WindowTreeClient(
+ service_manager::Connector* connector,
WindowTreeClientDelegate* delegate,
WindowManagerDelegate* window_manager_delegate = nullptr,
ui::mojom::WindowTreeClientRequest request = nullptr);
~WindowTreeClient() override;
// Establishes the connection by way of the WindowTreeFactory.
- void ConnectViaWindowTreeFactory(service_manager::Connector* connector);
+ void ConnectViaWindowTreeFactory();
// Establishes the connection by way of WindowManagerWindowTreeFactory.
- void ConnectAsWindowManager(service_manager::Connector* connector);
+ void ConnectAsWindowManager();
+
+ service_manager::Connector* connector() { return connector_; }
bool connected() const { return tree_ != nullptr; }
ClientSpecificId client_id() const { return client_id_; }
- void SetClientArea(Window* window,
- const gfx::Insets& client_area,
- const std::vector<gfx::Rect>& additional_client_areas);
- void SetHitTestMask(Window* window, const gfx::Rect& mask);
- void ClearHitTestMask(Window* window);
+ client::CaptureClient* GetCaptureClient();
+
void SetCanFocus(Window* window, bool can_focus);
void SetCanAcceptDrops(Id window_id, bool can_accept_drops);
void SetCanAcceptEvents(Id window_id, bool can_accept_events);
@@ -112,18 +115,17 @@ class AURA_EXPORT WindowTreeClient
bool visible,
mojo::TextInputStatePtr state);
- // TODO: this should take a window, not an id.
- void Embed(Id window_id,
+ // Embeds a new client in |window|. |flags| is a bitmask of the values defined
+ // by kEmbedFlag*; 0 gives default behavior. |callback| is called to indicate
+ // 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,
uint32_t flags,
const ui::mojom::WindowTree::EmbedCallback& callback);
- // TODO: this should move to WindowManager.
- void RequestClose(Window* window);
-
void AttachCompositorFrameSink(
Id window_id,
- ui::mojom::CompositorFrameSinkType type,
cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink,
cc::mojom::MojoCompositorFrameSinkClientPtr client);
@@ -132,6 +134,9 @@ class AURA_EXPORT WindowTreeClient
// Returns the root of this connection.
std::set<Window*> GetRoots();
+ // Returns true if the specified window was created by this client.
+ bool WasCreatedByThisClient(const WindowMus* window) const;
+
// Returns the current location of the mouse on screen. Note: this method may
// race the asynchronous initialization; but in that case we return (0, 0).
gfx::Point GetCursorScreenPoint();
@@ -164,6 +169,11 @@ class AURA_EXPORT WindowTreeClient
friend class WindowPortMus;
friend class WindowTreeClientPrivate;
+ enum class Origin {
+ CLIENT,
+ SERVER,
+ };
+
using IdToWindowMap = std::map<Id, WindowMus*>;
// TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
@@ -173,8 +183,7 @@ class AURA_EXPORT WindowTreeClient
WindowMus* GetWindowByServerId(Id id);
- // Returns true if the specified window was created by this client.
- bool WasCreatedByThisClient(const WindowMus* window) const;
+ bool IsWindowKnown(aura::Window* window);
// Returns the oldest InFlightChange that matches |change|.
InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change);
@@ -188,27 +197,31 @@ class AURA_EXPORT WindowTreeClient
// See InFlightChange for details on how InFlightChanges are used.
bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change);
- void BuildWindowTree(const mojo::Array<ui::mojom::WindowDataPtr>& windows);
+ void BuildWindowTree(const std::vector<ui::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);
// Creates a WindowPortMus from the server side data.
std::unique_ptr<WindowPortMus> CreateWindowPortMus(
- const ui::mojom::WindowDataPtr& window_data,
+ const ui::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::WindowDataPtr& window_data);
+ const ui::mojom::WindowData& window_data);
// Creates a new WindowTreeHostMus.
std::unique_ptr<WindowTreeHostMus> CreateWindowTreeHost(
WindowMusType window_mus_type,
- const ui::mojom::WindowDataPtr& window_data,
+ const ui::mojom::WindowData& window_data,
int64_t display_id);
- WindowMus* NewWindowFromWindowData(
- WindowMus* parent,
- const ui::mojom::WindowDataPtr& window_data);
+ WindowMus* NewWindowFromWindowData(WindowMus* parent,
+ const ui::mojom::WindowData& window_data);
// Sets the ui::mojom::WindowTree implementation.
void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr);
@@ -232,9 +245,9 @@ class AURA_EXPORT WindowTreeClient
bool drawn);
// Called by WmNewDisplayAdded().
- WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display,
- ui::mojom::WindowDataPtr root_data,
- bool parent_drawn);
+ WindowTreeHostMus* WmNewDisplayAddedImpl(const display::Display& display,
+ ui::mojom::WindowDataPtr root_data,
+ bool parent_drawn);
std::unique_ptr<EventResultCallback> CreateEventResultCallback(
int32_t event_id);
@@ -244,7 +257,7 @@ class AURA_EXPORT WindowTreeClient
// Called when a property needs to change as the result of a change in the
// server, or the server failing to accept a change.
void SetWindowBoundsFromServer(WindowMus* window,
- const gfx::Rect& revert_bounds);
+ const gfx::Rect& revert_bounds_in_pixels);
void SetWindowVisibleFromServer(WindowMus* window, bool visible);
// Called from OnWindowMusBoundsChanged() and SetRootWindowBounds().
@@ -254,7 +267,7 @@ class AURA_EXPORT WindowTreeClient
// Following are called from WindowMus.
void OnWindowMusCreated(WindowMus* window);
- void OnWindowMusDestroyed(WindowMus* window);
+ void OnWindowMusDestroyed(WindowMus* window, Origin origin);
void OnWindowMusBoundsChanged(WindowMus* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds);
@@ -295,7 +308,7 @@ class AURA_EXPORT WindowTreeClient
void OnClientAreaChanged(
uint32_t window_id,
const gfx::Insets& new_client_area,
- mojo::Array<gfx::Rect> new_additional_client_areas) override;
+ const std::vector<gfx::Rect>& new_additional_client_areas) override;
void OnTransientWindowAdded(uint32_t window_id,
uint32_t transient_window_id) override;
void OnTransientWindowRemoved(uint32_t window_id,
@@ -304,7 +317,7 @@ class AURA_EXPORT WindowTreeClient
Id window_id,
Id old_parent_id,
Id new_parent_id,
- mojo::Array<ui::mojom::WindowDataPtr> windows) override;
+ std::vector<ui::mojom::WindowDataPtr> windows) override;
void OnWindowReordered(Id window_id,
Id relative_window_id,
ui::mojom::OrderDirection direction) override;
@@ -316,8 +329,8 @@ class AURA_EXPORT WindowTreeClient
void OnWindowParentDrawnStateChanged(Id window_id, bool drawn) override;
void OnWindowSharedPropertyChanged(
Id window_id,
- const mojo::String& name,
- mojo::Array<uint8_t> transport_data) override;
+ const std::string& name,
+ const base::Optional<std::vector<uint8_t>>& transport_data) override;
void OnWindowInputEvent(uint32_t event_id,
Id window_id,
std::unique_ptr<ui::Event> event,
@@ -328,11 +341,10 @@ class AURA_EXPORT WindowTreeClient
void OnWindowPredefinedCursorChanged(Id window_id,
ui::mojom::Cursor cursor) override;
void OnWindowSurfaceChanged(Id window_id,
- const cc::SurfaceId& surface_id,
- const gfx::Size& frame_size,
- float device_scale_factor) override;
+ const cc::SurfaceInfo& surface_info) override;
void OnDragDropStart(
- mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override;
+ const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data)
+ override;
void OnDragEnter(Id window_id,
uint32_t event_flags,
const gfx::Point& position,
@@ -367,15 +379,17 @@ class AURA_EXPORT WindowTreeClient
void WmDisplayModified(const display::Display& display) override;
void WmSetBounds(uint32_t change_id,
Id window_id,
- const gfx::Rect& transit_bounds) override;
- void WmSetProperty(uint32_t change_id,
- Id window_id,
- const mojo::String& name,
- mojo::Array<uint8_t> transit_data) override;
- void WmCreateTopLevelWindow(uint32_t change_id,
- ClientSpecificId requesting_client_id,
- mojo::Map<mojo::String, mojo::Array<uint8_t>>
- transport_properties) override;
+ const gfx::Rect& transit_bounds_in_pixels) override;
+ void WmSetProperty(
+ uint32_t change_id,
+ Id window_id,
+ const std::string& name,
+ const base::Optional<std::vector<uint8_t>>& transit_data) override;
+ void WmCreateTopLevelWindow(
+ uint32_t change_id,
+ ClientSpecificId requesting_client_id,
+ const std::unordered_map<std::string, std::vector<uint8_t>>&
+ transport_properties) override;
void WmClientJankinessChanged(ClientSpecificId client_id,
bool janky) override;
void WmPerformMoveLoop(uint32_t change_id,
@@ -383,6 +397,7 @@ class AURA_EXPORT WindowTreeClient
ui::mojom::MoveLoopSource source,
const gfx::Point& cursor_location) override;
void WmCancelMoveLoop(uint32_t window_id) override;
+ void WmDeactivateWindow(Id window_id) override;
void OnAccelerator(uint32_t ack_id,
uint32_t accelerator_id,
std::unique_ptr<ui::Event> event) override;
@@ -391,9 +406,8 @@ class AURA_EXPORT WindowTreeClient
void SetFrameDecorationValues(
ui::mojom::FrameDecorationValuesPtr values) override;
void SetNonClientCursor(Window* window, ui::mojom::Cursor cursor_id) override;
- void AddAccelerator(uint32_t id,
- ui::mojom::EventMatcherPtr event_matcher,
- const base::Callback<void(bool)>& callback) override;
+ void AddAccelerators(std::vector<ui::mojom::AcceleratorPtr> accelerators,
+ const base::Callback<void(bool)>& callback) override;
void RemoveAccelerator(uint32_t id) override;
void AddActivationParent(Window* window) override;
void RemoveActivationParent(Window* window) override;
@@ -402,11 +416,22 @@ class AURA_EXPORT WindowTreeClient
Window* window,
const gfx::Vector2d& offset,
const gfx::Insets& hit_area) override;
+ void RequestClose(Window* window) override;
// Overriden from WindowTreeHostMusDelegate:
void OnWindowTreeHostBoundsWillChange(WindowTreeHostMus* window_tree_host,
const gfx::Rect& bounds) override;
- std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel() override;
+ void OnWindowTreeHostClientAreaWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const gfx::Insets& client_area,
+ const std::vector<gfx::Rect>& additional_client_areas) override;
+ void OnWindowTreeHostHitTestMaskWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const base::Optional<gfx::Rect>& mask_rect) override;
+ void OnWindowTreeHostDeactivateWindow(
+ WindowTreeHostMus* window_tree_host) override;
+ std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel(
+ const std::map<std::string, std::vector<uint8_t>>* properties) override;
void OnWindowTreeHostCreated(WindowTreeHostMus* window_tree_host) override;
// Override from client::TransientWindowClientObserver:
@@ -414,6 +439,10 @@ class AURA_EXPORT WindowTreeClient
Window* transient_child) override;
void OnTransientChildWindowRemoved(Window* parent,
Window* transient_child) override;
+ void OnWillRestackTransientChildAbove(Window* parent,
+ Window* transient_child) override;
+ void OnDidRestackTransientChildAbove(Window* parent,
+ Window* transient_child) override;
// Overriden from DragDropControllerHost:
uint32_t CreateChangeIdForDrag(WindowMus* window) override;
@@ -431,6 +460,9 @@ class AURA_EXPORT WindowTreeClient
cursor_location_mapping_.get());
}
+ // This may be null in tests.
+ service_manager::Connector* connector_;
+
// This is set once and only once when we get OnEmbed(). It gives the unique
// id for this client.
ClientSpecificId client_id_;
diff --git a/chromium/ui/aura/mus/window_tree_client_delegate.h b/chromium/ui/aura/mus/window_tree_client_delegate.h
index dca30464266..609a0578585 100644
--- a/chromium/ui/aura/mus/window_tree_client_delegate.h
+++ b/chromium/ui/aura/mus/window_tree_client_delegate.h
@@ -38,10 +38,17 @@ class AURA_EXPORT WindowTreeClientDelegate {
virtual void OnUnembed(Window* root);
// Called when the embed root has been destroyed on the server side (or
- // another client was embedded in the same window). This is only called if the
- // WindowTreeClient was created from an InterfaceRequest. Generally when this
- // is called the delegate should delete the WindowTreeClient.
- virtual void OnEmbedRootDestroyed(Window* root) = 0;
+ // another client was embedded in the same window). This is called in two
+ // distinct cases:
+ // . If the WindowTreeClient was created from an InterfaceRequest. In this
+ // case the WindowTreeClient associated with the WindowTreeHost is no
+ // longer in a usable state and should be deleted (after deleting
+ // |window_tree_host|).
+ // . When the window associated with a top level window (one created by way of
+ // directly creating a WindowTreeHostMus) is destroyed on the server side.
+ // In this case the |window_tree_host| should be destroyed, but the
+ // WindowTreeClient is still usable.
+ virtual void OnEmbedRootDestroyed(WindowTreeHostMus* window_tree_host) = 0;
// Called when the connection to the window server has been lost. After this
// call the windows are still valid, and you can still do things, but they
diff --git a/chromium/ui/aura/mus/window_tree_client_unittest.cc b/chromium/ui/aura/mus/window_tree_client_unittest.cc
index e6ed1c1fdf9..66fa7d876a5 100644
--- a/chromium/ui/aura/mus/window_tree_client_unittest.cc
+++ b/chromium/ui/aura/mus/window_tree_client_unittest.cc
@@ -6,11 +6,14 @@
#include <stdint.h>
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "mojo/common/common_type_converters.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 "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
@@ -29,7 +32,9 @@
#include "ui/aura/window.h"
#include "ui/aura/window_property.h"
#include "ui/aura/window_tracker.h"
+#include "ui/aura/window_tree_host_observer.h"
#include "ui/compositor/compositor.h"
+#include "ui/display/display_switches.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/geometry/rect.h"
@@ -57,10 +62,6 @@ void SetWindowVisibility(Window* window, bool visible) {
window->Hide();
}
-Window* GetFirstRoot(WindowTreeClient* client) {
- return client->GetRoots().empty() ? nullptr : *client->GetRoots().begin();
-}
-
bool IsWindowHostVisible(Window* window) {
return window->GetRootWindow()->GetHost()->compositor()->IsVisible();
}
@@ -74,8 +75,8 @@ void RegisterTestProperties(PropertyConverter* converter) {
// Convert a primitive aura property value to a mus transport value.
// Note that this implicitly casts arguments to the aura storage type, int64_t.
-mojo::Array<uint8_t> ConvertToPropertyTransportValue(int64_t value) {
- return mojo::Array<uint8_t>(mojo::ConvertTo<std::vector<uint8_t>>(value));
+std::vector<uint8_t> ConvertToPropertyTransportValue(int64_t value) {
+ return mojo::ConvertTo<std::vector<uint8_t>>(value);
}
} // namespace
@@ -83,6 +84,40 @@ mojo::Array<uint8_t> ConvertToPropertyTransportValue(int64_t value) {
using WindowTreeClientWmTest = test::AuraMusWmTestBase;
using WindowTreeClientClientTest = test::AuraMusClientTestBase;
+// WindowTreeClientWmTest with --force-device-scale-factor=2.
+class WindowTreeClientWmTestHighDPI : public WindowTreeClientWmTest {
+ 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 {}
+
+ // WindowTreeClientClientTest:
+ void SetUp() override {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kForceDeviceScaleFactor, "2");
+ WindowTreeClientClientTest::SetUp();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeClientClientTestHighDPI);
+};
+
// Verifies bounds are reverted if the server replied that the change failed.
TEST_F(WindowTreeClientWmTest, SetBoundsFailed) {
Window window(nullptr);
@@ -106,7 +141,7 @@ TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) {
data->window_id = child_window_id;
data->bounds = gfx::Rect(1, 2, 3, 4);
data->visible = false;
- mojo::Array<ui::mojom::WindowDataPtr> data_array(1);
+ std::vector<ui::mojom::WindowDataPtr> data_array(1);
data_array[0] = std::move(data);
ASSERT_TRUE(root_window()->children().empty());
window_tree_client()->OnWindowHierarchyChanged(
@@ -128,9 +163,9 @@ TEST_F(WindowTreeClientWmTest, ReparentFromServerDoesntAddAgain) {
window_tree()->AckAllChanges();
// 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), nullptr);
+ window_tree_client()->OnWindowHierarchyChanged(
+ server_id(&window1), server_id(root_window()), server_id(&window2),
+ std::vector<ui::mojom::WindowDataPtr>());
ASSERT_FALSE(window_tree()->has_change());
EXPECT_EQ(&window2, window1.parent());
EXPECT_EQ(root_window(), window2.parent());
@@ -147,11 +182,14 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
const uint8_t server_test_property1_value = 91;
data->properties[kTestPropertyServerKey1] =
ConvertToPropertyTransportValue(server_test_property1_value);
+ data->properties[ui::mojom::WindowManager::kWindowType_InitProperty] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ static_cast<int32_t>(ui::mojom::WindowType::BUBBLE));
data->parent_id = server_id(root_window());
data->window_id = child_window_id;
data->bounds = gfx::Rect(1, 2, 3, 4);
data->visible = false;
- mojo::Array<ui::mojom::WindowDataPtr> data_array(1);
+ std::vector<ui::mojom::WindowDataPtr> data_array(1);
data_array[0] = std::move(data);
ASSERT_TRUE(root_window()->children().empty());
window_tree_client()->OnWindowHierarchyChanged(
@@ -161,6 +199,9 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithProperties) {
Window* child = root_window()->children()[0];
EXPECT_FALSE(child->TargetVisibility());
EXPECT_EQ(server_test_property1_value, child->GetProperty(kTestPropertyKey1));
+ EXPECT_EQ(child->type(), ui::wm::WINDOW_TYPE_POPUP);
+ EXPECT_EQ(ui::mojom::WindowType::BUBBLE,
+ child->GetProperty(client::kWindowTypeKey));
}
// Verifies a move from the server doesn't attempt signal the server.
@@ -257,11 +298,12 @@ TEST_F(WindowTreeClientWmTest, SetPropertySucceeded) {
ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
root_window()->SetProperty(client::kAlwaysOnTopKey, true);
EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
- mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue();
- ASSERT_FALSE(value.is_null());
+ base::Optional<std::vector<uint8_t>> value =
+ window_tree()->GetLastPropertyValue();
+ ASSERT_TRUE(value.has_value());
// PropertyConverter uses int64_t values, even for smaller types, like bool.
- ASSERT_EQ(8u, value.size());
- EXPECT_EQ(1, mojo::ConvertTo<int64_t>(value.PassStorage()));
+ ASSERT_EQ(8u, value->size());
+ EXPECT_EQ(1, mojo::ConvertTo<int64_t>(*value));
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
WindowTreeChangeType::PROPERTY, true));
EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
@@ -273,11 +315,12 @@ TEST_F(WindowTreeClientWmTest, SetPropertyFailed) {
ASSERT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
root_window()->SetProperty(client::kAlwaysOnTopKey, true);
EXPECT_TRUE(root_window()->GetProperty(client::kAlwaysOnTopKey));
- mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue();
- ASSERT_FALSE(value.is_null());
+ base::Optional<std::vector<uint8_t>> value =
+ window_tree()->GetLastPropertyValue();
+ ASSERT_TRUE(value.has_value());
// PropertyConverter uses int64_t values, even for smaller types, like bool.
- ASSERT_EQ(8u, value.size());
- EXPECT_EQ(1, mojo::ConvertTo<int64_t>(value.PassStorage()));
+ ASSERT_EQ(8u, value->size());
+ EXPECT_EQ(1, mojo::ConvertTo<int64_t>(*value));
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
WindowTreeChangeType::PROPERTY, false));
EXPECT_FALSE(root_window()->GetProperty(client::kAlwaysOnTopKey));
@@ -357,9 +400,10 @@ TEST_F(WindowTreeClientWmTest, SetRectProperty) {
ASSERT_EQ(nullptr, root_window()->GetProperty(client::kRestoreBoundsKey));
root_window()->SetProperty(client::kRestoreBoundsKey, new gfx::Rect(example));
EXPECT_TRUE(root_window()->GetProperty(client::kRestoreBoundsKey));
- mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue();
- ASSERT_FALSE(value.is_null());
- EXPECT_EQ(example, mojo::ConvertTo<gfx::Rect>(value.PassStorage()));
+ base::Optional<std::vector<uint8_t>> value =
+ window_tree()->GetLastPropertyValue();
+ ASSERT_TRUE(value.has_value());
+ EXPECT_EQ(example, mojo::ConvertTo<gfx::Rect>(*value));
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
WindowTreeChangeType::PROPERTY, true));
EXPECT_EQ(example, *root_window()->GetProperty(client::kRestoreBoundsKey));
@@ -378,9 +422,10 @@ TEST_F(WindowTreeClientWmTest, SetStringProperty) {
ASSERT_EQ(nullptr, root_window()->GetProperty(client::kAppIdKey));
root_window()->SetProperty(client::kAppIdKey, new std::string(example));
EXPECT_TRUE(root_window()->GetProperty(client::kAppIdKey));
- mojo::Array<uint8_t> value = window_tree()->GetLastPropertyValue();
- ASSERT_FALSE(value.is_null());
- EXPECT_EQ(example, mojo::ConvertTo<std::string>(value.PassStorage()));
+ base::Optional<std::vector<uint8_t>> value =
+ window_tree()->GetLastPropertyValue();
+ ASSERT_TRUE(value.has_value());
+ EXPECT_EQ(example, mojo::ConvertTo<std::string>(*value));
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
WindowTreeChangeType::PROPERTY, true));
EXPECT_EQ(example, *root_window()->GetProperty(client::kAppIdKey));
@@ -430,22 +475,6 @@ TEST_F(WindowTreeClientWmTest, SetVisibleFailedWithPendingChange) {
EXPECT_EQ(original_visible, root_window()->TargetVisibility());
}
-/*
-// Verifies |is_modal| is reverted if the server replied that the change failed.
-TEST_F(WindowTreeClientWmTest, SetModalFailed) {
- WindowTreeSetup setup;
- Window* root = GetFirstRoot();
- ASSERT_TRUE(root);
- EXPECT_FALSE(root->is_modal());
- root->SetModal();
- uint32_t change_id;
- ASSERT_TRUE(window_tree()->GetAndClearChangeId(&change_id));
- EXPECT_TRUE(root->is_modal());
- window_tree_client()->OnChangeCompleted(change_id, false);
- EXPECT_FALSE(root->is_modal());
-}
-*/
-
namespace {
class InputEventBasicTestWindowDelegate : public test::TestWindowDelegate {
@@ -458,18 +487,22 @@ class InputEventBasicTestWindowDelegate : public test::TestWindowDelegate {
bool got_move() const { return got_move_; }
bool was_acked() const { return was_acked_; }
+ const gfx::Point& last_event_location() const { return last_event_location_; }
// TestWindowDelegate::
void OnMouseEvent(ui::MouseEvent* event) override {
was_acked_ = test_window_tree_->WasEventAcked(kEventId);
if (event->type() == ui::ET_MOUSE_MOVED)
got_move_ = true;
+ last_event_location_ = event->location();
+ event->SetHandled();
}
private:
TestWindowTree* test_window_tree_;
bool was_acked_ = false;
bool got_move_ = false;
+ gfx::Point last_event_location_;
DISALLOW_COPY_AND_ASSIGN(InputEventBasicTestWindowDelegate);
};
@@ -481,26 +514,33 @@ TEST_F(WindowTreeClientClientTest, InputEventBasic) {
WindowTreeHostMus window_tree_host(window_tree_client_impl());
Window* top_level = window_tree_host.window();
const gfx::Rect bounds(0, 0, 100, 100);
- window_tree_host.SetBounds(bounds);
+ window_tree_host.SetBoundsInPixels(bounds);
+ window_tree_host.InitHost();
window_tree_host.Show();
EXPECT_EQ(bounds, top_level->bounds());
- EXPECT_EQ(bounds, window_tree_host.GetBounds());
+ EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
Window child(&window_delegate);
child.Init(ui::LAYER_NOT_DRAWN);
top_level->AddChild(&child);
- child.SetBounds(gfx::Rect(0, 0, 100, 100));
+ child.SetBounds(gfx::Rect(10, 10, 100, 100));
child.Show();
EXPECT_FALSE(window_delegate.got_move());
EXPECT_FALSE(window_delegate.was_acked());
+ const gfx::Point event_location_in_child(2, 3);
std::unique_ptr<ui::Event> ui_event(
- new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
- ui::EventTimeForNow(), ui::EF_NONE, 0));
+ new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child,
+ gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
window_tree_client()->OnWindowInputEvent(
- InputEventBasicTestWindowDelegate::kEventId, server_id(top_level),
+ InputEventBasicTestWindowDelegate::kEventId, server_id(&child),
ui::Event::Clone(*ui_event.get()), 0);
- EXPECT_TRUE(window_tree()->WasEventAcked(1));
+ EXPECT_TRUE(window_tree()->WasEventAcked(
+ InputEventBasicTestWindowDelegate::kEventId));
+ EXPECT_EQ(ui::mojom::EventResult::HANDLED,
+ window_tree()->GetEventResult(
+ InputEventBasicTestWindowDelegate::kEventId));
EXPECT_TRUE(window_delegate.got_move());
EXPECT_FALSE(window_delegate.was_acked());
+ EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
}
class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
@@ -712,9 +752,9 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
window_tree_client_impl()->GetRoots().size();
std::unique_ptr<WindowTreeHostMus> window_tree_host =
base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
+ window_tree_host->InitHost();
+ EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
aura::Window* top_level = window_tree_host->window();
- // TODO: need to check WindowTreeHost visibility.
- // EXPECT_TRUE(WindowPrivate(root2).parent_drawn());
EXPECT_NE(server_id(top_level), server_id(root_window()));
EXPECT_EQ(initial_root_count + 1,
window_tree_client_impl()->GetRoots().size());
@@ -732,8 +772,7 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindow) {
window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
display_id, false);
- // TODO: need to check WindowTreeHost visibility.
- // EXPECT_FALSE(WindowPrivate(root2).parent_drawn());
+ EXPECT_FALSE(window_tree_host->window()->TargetVisibility());
// Should not be able to add a top level as a child of another window.
// TODO(sky): decide how to handle this.
@@ -756,6 +795,9 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
EXPECT_FALSE(IsWindowHostVisible(top_level));
EXPECT_FALSE(top_level->TargetVisibility());
+ window_tree_host.InitHost();
+ EXPECT_FALSE(window_tree_host.window()->TargetVisibility());
+
// Ack the request to the windowtree to create the new window.
EXPECT_EQ(window_tree()->window_id(), server_id(top_level));
@@ -775,10 +817,9 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsPropertiesFromData) {
// Make sure all the properties took.
EXPECT_TRUE(IsWindowHostVisible(top_level));
EXPECT_TRUE(top_level->TargetVisibility());
- // TODO: check display_id.
EXPECT_EQ(display_id, window_tree_host.display_id());
EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
- EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBounds());
+ EXPECT_EQ(gfx::Rect(1, 2, 3, 4), top_level->GetHost()->GetBoundsInPixels());
}
TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
@@ -786,15 +827,16 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
WindowTreeHostMus window_tree_host(window_tree_client_impl());
Window* top_level = window_tree_host.window();
-
EXPECT_FALSE(top_level->TargetVisibility());
+ window_tree_host.InitHost();
+
// Make visibility go from false->true->false. Don't ack immediately.
top_level->Show();
top_level->Hide();
// Change bounds to 5, 6, 7, 8.
- window_tree_host.SetBounds(gfx::Rect(5, 6, 7, 8));
+ window_tree_host.SetBoundsInPixels(gfx::Rect(5, 6, 7, 8));
EXPECT_EQ(gfx::Rect(0, 0, 7, 8), window_tree_host.window()->bounds());
const uint8_t explicitly_set_test_property1_value = 2;
@@ -824,7 +866,7 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
// The only value that should take effect is the property for 'yy' as it was
// not in flight.
EXPECT_FALSE(top_level->TargetVisibility());
- EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBounds());
+ EXPECT_EQ(gfx::Rect(5, 6, 7, 8), window_tree_host.GetBoundsInPixels());
EXPECT_EQ(gfx::Rect(0, 0, 7, 8), top_level->bounds());
EXPECT_EQ(explicitly_set_test_property1_value,
top_level->GetProperty(kTestPropertyKey1));
@@ -844,9 +886,8 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsAllChangesInFlight) {
EXPECT_EQ(gfx::Rect(bounds_from_server.size()), top_level->bounds());
// But the bounds of the WindowTreeHost is display relative.
EXPECT_EQ(bounds_from_server,
- top_level->GetRootWindow()->GetHost()->GetBounds());
- ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
- WindowTreeChangeType::PROPERTY, false));
+ top_level->GetRootWindow()->GetHost()->GetBoundsInPixels());
+ window_tree()->AckAllChangesOfType(WindowTreeChangeType::PROPERTY, false);
EXPECT_EQ(server_test_property1_value,
top_level->GetProperty(kTestPropertyKey1));
EXPECT_EQ(server_test_property2_value,
@@ -859,11 +900,11 @@ TEST_F(WindowTreeClientClientTest, NewWindowGetsProperties) {
const uint8_t explicitly_set_test_property1_value = 29;
window.SetProperty(kTestPropertyKey1, explicitly_set_test_property1_value);
window.Init(ui::LAYER_NOT_DRAWN);
- mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties =
- window_tree()->GetLastNewWindowProperties();
- ASSERT_FALSE(transport_properties.is_null());
+ base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>
+ transport_properties = window_tree()->GetLastNewWindowProperties();
+ ASSERT_TRUE(transport_properties.has_value());
std::map<std::string, std::vector<uint8_t>> properties =
- transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
+ mojo::UnorderedMapToMap(*transport_properties);
ASSERT_EQ(1u, properties.count(kTestPropertyServerKey1));
// PropertyConverter uses int64_t values, even for smaller types like uint8_t.
ASSERT_EQ(8u, properties[kTestPropertyServerKey1].size());
@@ -907,12 +948,124 @@ TEST_F(WindowTreeClientClientTest, Transients) {
EXPECT_EQ(server_id(&transient), window_tree()->transient_data().child_id);
}
+// Verifies adding/removing a transient child doesn't notify the server of the
+// restack when the change originates from the server.
+TEST_F(WindowTreeClientClientTest,
+ TransientChildServerMutateDoesntNotifyOfRestack) {
+ Window* w1 = new Window(nullptr);
+ w1->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w1);
+ Window* w2 = new Window(nullptr);
+ w2->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w2);
+ Window* w3 = new Window(nullptr);
+ w3->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w3);
+ // Three children of root: |w1|, |w2| and |w3| (in that order). Make |w1| a
+ // transient child of |w2|. Should trigger moving |w1| on top of |w2|, but not
+ // notify the server of the reorder.
+ window_tree()->AckAllChanges();
+ window_tree_client()->OnTransientWindowAdded(server_id(w2), server_id(w1));
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w1, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ // No changes should be scheduled.
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Make |w3| also a transient child of |w2|. Order shouldn't change.
+ window_tree_client()->OnTransientWindowAdded(server_id(w2), server_id(w3));
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w1, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Remove |w1| as a transient child, this should move |w3| on top of |w2|.
+ window_tree_client()->OnTransientWindowRemoved(server_id(w2), server_id(w1));
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w3, root_window()->children()[1]);
+ EXPECT_EQ(w1, root_window()->children()[2]);
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+}
+
+// Verifies adding/removing a transient child doesn't notify the server of the
+// restack when the change originates from the client.
+TEST_F(WindowTreeClientClientTest,
+ TransientChildClientMutateDoesntNotifyOfRestack) {
+ client::TransientWindowClient* transient_client =
+ client::GetTransientWindowClient();
+ Window* w1 = new Window(nullptr);
+ w1->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w1);
+ Window* w2 = new Window(nullptr);
+ w2->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w2);
+ Window* w3 = new Window(nullptr);
+ w3->Init(ui::LAYER_NOT_DRAWN);
+ root_window()->AddChild(w3);
+ // Three children of root: |w1|, |w2| and |w3| (in that order). Make |w1| a
+ // transient child of |w2|. Should trigger moving |w1| on top of |w2|, but not
+ // notify the server of the reorder.
+ window_tree()->AckAllChanges();
+ transient_client->AddTransientChild(w2, w1);
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w1, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ // Only a single add transient change should be added.
+ EXPECT_TRUE(window_tree()->AckSingleChangeOfType(
+ WindowTreeChangeType::ADD_TRANSIENT, true));
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Make |w3| also a transient child of |w2|. Order shouldn't change.
+ transient_client->AddTransientChild(w2, w3);
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w1, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ EXPECT_TRUE(window_tree()->AckSingleChangeOfType(
+ WindowTreeChangeType::ADD_TRANSIENT, true));
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Remove |w1| as a transient child, this should move |w3| on top of |w2|.
+ transient_client->RemoveTransientChild(w2, w1);
+ EXPECT_EQ(w2, root_window()->children()[0]);
+ EXPECT_EQ(w3, root_window()->children()[1]);
+ EXPECT_EQ(w1, root_window()->children()[2]);
+ EXPECT_TRUE(window_tree()->AckSingleChangeOfType(
+ WindowTreeChangeType::REMOVE_TRANSIENT, true));
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Make |w1| the first child and ensure a REORDER was scheduled.
+ root_window()->StackChildAtBottom(w1);
+ EXPECT_EQ(w1, root_window()->children()[0]);
+ EXPECT_EQ(w2, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ EXPECT_TRUE(window_tree()->AckSingleChangeOfType(
+ WindowTreeChangeType::REORDER, true));
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+
+ // Try stacking |w2| above |w3|. This should be disallowed as that would
+ // result in placing |w2| above its transient child.
+ root_window()->StackChildAbove(w2, w3);
+ EXPECT_EQ(w1, root_window()->children()[0]);
+ EXPECT_EQ(w2, root_window()->children()[1]);
+ EXPECT_EQ(w3, root_window()->children()[2]);
+ // NOTE: even though the order didn't change, internally the order was
+ // changed and then changed back. That is the StackChildAbove() call really
+ // succeeded, but then TransientWindowManager reordered the windows back to
+ // a valid configuration. We expect only one REORDER here as the second
+ // results from TransientWindowManager and we assume the server applied it as
+ // well.
+ EXPECT_EQ(1u, window_tree()->number_of_changes());
+ window_tree()->AckAllChangesOfType(WindowTreeChangeType::REORDER, true);
+ EXPECT_EQ(0u, window_tree()->number_of_changes());
+}
+
TEST_F(WindowTreeClientClientTest,
TopLevelWindowDestroyedBeforeCreateComplete) {
const size_t initial_root_count =
window_tree_client_impl()->GetRoots().size();
std::unique_ptr<WindowTreeHostMus> window_tree_host =
base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
+ window_tree_host->InitHost();
EXPECT_EQ(initial_root_count + 1,
window_tree_client_impl()->GetRoots().size());
@@ -941,9 +1094,16 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
std::map<std::string, std::vector<uint8_t>> properties;
properties[kTestPropertyServerKey1] =
ConvertToPropertyTransportValue(property_value);
+ const char kUnknownPropertyKey[] = "unknown-property";
+ using UnknownPropertyType = int32_t;
+ const UnknownPropertyType kUnknownPropertyValue = 101;
+ properties[kUnknownPropertyKey] =
+ mojo::ConvertTo<std::vector<uint8_t>>(kUnknownPropertyValue);
std::unique_ptr<WindowTreeHostMus> window_tree_host =
base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl(),
&properties);
+ window_tree_host->InitHost();
+ window_tree_host->window()->Show();
// Verify the property made it to the window.
EXPECT_EQ(property_value,
window_tree_host->window()->GetProperty(kTestPropertyKey1));
@@ -953,17 +1113,59 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
- // Verify the property was sent to the server.
- mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties =
- window_tree()->GetLastNewWindowProperties();
- ASSERT_FALSE(transport_properties.is_null());
+ // Verify the properties were sent to the server.
+ base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>
+ transport_properties = window_tree()->GetLastNewWindowProperties();
+ ASSERT_TRUE(transport_properties.has_value());
std::map<std::string, std::vector<uint8_t>> properties2 =
- transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
+ mojo::UnorderedMapToMap(*transport_properties);
ASSERT_EQ(1u, properties2.count(kTestPropertyServerKey1));
// PropertyConverter uses int64_t values, even for smaller types like uint8_t.
ASSERT_EQ(8u, properties2[kTestPropertyServerKey1].size());
EXPECT_EQ(static_cast<int64_t>(property_value),
mojo::ConvertTo<int64_t>(properties2[kTestPropertyServerKey1]));
+
+ ASSERT_EQ(1u, properties2.count(kUnknownPropertyKey));
+ ASSERT_EQ(sizeof(UnknownPropertyType),
+ properties2[kUnknownPropertyKey].size());
+ EXPECT_EQ(kUnknownPropertyValue, mojo::ConvertTo<UnknownPropertyType>(
+ properties2[kUnknownPropertyKey]));
+}
+
+namespace {
+
+class CloseWindowWindowTreeHostObserver : public aura::WindowTreeHostObserver {
+ public:
+ CloseWindowWindowTreeHostObserver() {}
+ ~CloseWindowWindowTreeHostObserver() override {}
+
+ bool root_destroyed() const { return root_destroyed_; }
+
+ // aura::WindowTreeHostObserver::
+ void OnHostCloseRequested(const aura::WindowTreeHost* host) override {
+ root_destroyed_ = true;
+ }
+
+ private:
+ bool root_destroyed_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver);
+};
+
+} // namespace
+
+TEST_F(WindowTreeClientClientTest, CloseWindow) {
+ WindowTreeHostMus window_tree_host(window_tree_client_impl());
+ window_tree_host.InitHost();
+ CloseWindowWindowTreeHostObserver observer;
+ window_tree_host.AddObserver(&observer);
+ Window* top_level = window_tree_host.window();
+
+ // Close a root window should send close request to the observer of its
+ // WindowTreeHost.
+ EXPECT_FALSE(observer.root_destroyed());
+ window_tree_client()->RequestClose(server_id(top_level));
+ EXPECT_TRUE(observer.root_destroyed());
}
// Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
@@ -1211,7 +1413,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);
- mojo::Array<ui::mojom::WindowDataPtr> data_array(3);
+ std::vector<ui::mojom::WindowDataPtr> data_array(3);
data_array[0] = std::move(data1);
data_array[1] = std::move(data2);
data_array[2] = std::move(data3);
@@ -1227,4 +1429,76 @@ TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) {
EXPECT_EQ(window2, server_window->children()[1]);
}
+// Ensures when WindowTreeClient::OnWindowDeleted() is called nothing is
+// scheduled on the server side.
+TEST_F(WindowTreeClientClientTest, OnWindowDeletedDoesntNotifyServer) {
+ Window window1(nullptr);
+ window1.Init(ui::LAYER_NOT_DRAWN);
+ Window* window2 = new Window(nullptr);
+ window2->Init(ui::LAYER_NOT_DRAWN);
+ window1.AddChild(window2);
+ window_tree()->AckAllChanges();
+ window_tree_client()->OnWindowDeleted(server_id(window2));
+ 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(WindowTreeClientWmTestHighDPI, 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.
+ 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);
+ EXPECT_EQ(new_bounds, root_window()->bounds());
+}
+
+TEST_F(WindowTreeClientClientTestHighDPI, NewTopLevelWindowBounds) {
+ WindowTreeHostMus window_tree_host(window_tree_client_impl());
+ Window* top_level = window_tree_host.window();
+ window_tree_host.InitHost();
+
+ ui::mojom::WindowDataPtr data = ui::mojom::WindowData::New();
+ data->window_id = server_id(top_level);
+ data->bounds.SetRect(2, 4, 6, 8);
+ const int64_t display_id = 10;
+ uint32_t change_id;
+ ASSERT_TRUE(window_tree()->GetAndRemoveFirstChangeOfType(
+ WindowTreeChangeType::NEW_TOP_LEVEL, &change_id));
+ window_tree_client()->OnTopLevelCreated(change_id, std::move(data),
+ display_id, true);
+
+ // aura::Window should operate in DIP and aura::WindowTreeHost should operate
+ // in pixels.
+ EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds());
+ EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels());
+}
+
} // 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 e458fd2be02..ca5d986aad4 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus.cc
+++ b/chromium/ui/aura/mus/window_tree_host_mus.cc
@@ -33,12 +33,12 @@ bool IsUsingTestContext() {
WindowTreeHostMus::WindowTreeHostMus(
std::unique_ptr<WindowPortMus> window_port,
- WindowTreeHostMusDelegate* delegate,
+ WindowTreeClient* window_tree_client,
int64_t display_id,
const std::map<std::string, std::vector<uint8_t>>* properties)
: WindowTreeHostPlatform(std::move(window_port)),
display_id_(display_id),
- delegate_(delegate) {
+ delegate_(window_tree_client) {
// TODO(sky): find a cleaner way to set this! Better solution is to likely
// have constructor take aura::Window.
WindowPortMus::Get(window())->window_ = window();
@@ -49,7 +49,10 @@ WindowTreeHostMus::WindowTreeHostMus(
for (auto& pair : *properties)
window_mus->SetPropertyFromServer(pair.first, &pair.second);
}
- CreateCompositor();
+ Id server_id = WindowMus::Get(window())->server_id();
+ cc::FrameSinkId frame_sink_id(server_id, 0);
+ DCHECK(frame_sink_id.is_valid());
+ CreateCompositor(frame_sink_id);
gfx::AcceleratedWidget accelerated_widget;
if (IsUsingTestContext()) {
accelerated_widget = gfx::kNullAcceleratedWidget;
@@ -65,8 +68,8 @@ WindowTreeHostMus::WindowTreeHostMus(
static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
#endif
}
- // TODO(markdittmer): Use correct device-scale-factor from |window|.
- OnAcceleratedWidgetAvailable(accelerated_widget, 1.f);
+ OnAcceleratedWidgetAvailable(accelerated_widget,
+ GetDisplay().device_scale_factor());
delegate_->OnWindowTreeHostCreated(this);
@@ -75,6 +78,8 @@ WindowTreeHostMus::WindowTreeHostMus(
false)); // Do not advertise accelerated widget; already set manually.
input_method_ = base::MakeUnique<InputMethodMus>(this, window());
+ input_method_->Init(window_tree_client->connector());
+ SetSharedInputMethod(input_method_.get());
compositor()->SetHostHasTransparentBackground(true);
@@ -82,12 +87,16 @@ WindowTreeHostMus::WindowTreeHostMus(
compositor()->SetVisible(false);
}
+// Pass |properties| to CreateWindowPortForTopLevel() so that |properties|
+// are passed to the server *and* pass |properties| to the WindowTreeHostMus
+// constructor (above) which applies the properties to the Window. Some of the
+// properties may be server specific and not applied to the Window.
WindowTreeHostMus::WindowTreeHostMus(
WindowTreeClient* window_tree_client,
const std::map<std::string, std::vector<uint8_t>>* properties)
: WindowTreeHostMus(
static_cast<WindowTreeHostMusDelegate*>(window_tree_client)
- ->CreateWindowPortForTopLevel(),
+ ->CreateWindowPortForTopLevel(properties),
window_tree_client,
display::Screen::GetScreen()->GetPrimaryDisplay().id(),
properties) {}
@@ -97,23 +106,30 @@ WindowTreeHostMus::~WindowTreeHostMus() {
DestroyDispatcher();
}
-void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) {
+void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds_in_pixels) {
base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true);
- SetBounds(bounds);
+ SetBoundsInPixels(bounds_in_pixels);
}
-display::Display WindowTreeHostMus::GetDisplay() const {
- for (const display::Display& display :
- display::Screen::GetScreen()->GetAllDisplays()) {
- if (display.id() == display_id_)
- return display;
- }
- return display::Display();
+void WindowTreeHostMus::SetClientArea(
+ const gfx::Insets& insets,
+ const std::vector<gfx::Rect>& additional_client_area) {
+ delegate_->OnWindowTreeHostClientAreaWillChange(this, insets,
+ additional_client_area);
+}
+
+void WindowTreeHostMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) {
+ delegate_->OnWindowTreeHostHitTestMaskWillChange(this, rect);
+}
+
+void WindowTreeHostMus::DeactivateWindow() {
+ delegate_->OnWindowTreeHostDeactivateWindow(this);
}
-void WindowTreeHostMus::ShowImpl() {
- WindowTreeHostPlatform::ShowImpl();
- window()->Show();
+display::Display WindowTreeHostMus::GetDisplay() const {
+ display::Display display;
+ display::Screen::GetScreen()->GetDisplayWithDisplayId(display_id_, &display);
+ return display;
}
void WindowTreeHostMus::HideImpl() {
@@ -121,10 +137,10 @@ void WindowTreeHostMus::HideImpl() {
window()->Hide();
}
-void WindowTreeHostMus::SetBounds(const gfx::Rect& bounds) {
+void WindowTreeHostMus::SetBoundsInPixels(const gfx::Rect& bounds) {
if (!in_set_bounds_from_server_)
delegate_->OnWindowTreeHostBoundsWillChange(this, bounds);
- WindowTreeHostPlatform::SetBounds(bounds);
+ WindowTreeHostPlatform::SetBoundsInPixels(bounds);
}
void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
diff --git a/chromium/ui/aura/mus/window_tree_host_mus.h b/chromium/ui/aura/mus/window_tree_host_mus.h
index 9209f60facd..0855369f1ea 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus.h
+++ b/chromium/ui/aura/mus/window_tree_host_mus.h
@@ -30,19 +30,29 @@ class WindowTreeHostMusDelegate;
class AURA_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
public:
+ // |properties| are applied to the window created by this class (using
+ // PropertyConverter).
+ // TODO: this should take an unordered_map, see http://crbug.com/670515.
WindowTreeHostMus(
std::unique_ptr<WindowPortMus> window_port,
- WindowTreeHostMusDelegate* delegate,
+ WindowTreeClient* window_tree_client,
int64_t display_id,
const std::map<std::string, std::vector<uint8_t>>* properties = nullptr);
- WindowTreeHostMus(
+
+ // This constructor is intended for creating top level windows in
+ // non-window-manager code. |properties| are properties passed verbatim to
+ // the server, that is, no conversion is done before sending |properties| to
+ // the server. Additionally |properties| are passed to PropertyConverter and
+ // any known properties are set on the Window created by this class.
+ // TODO: this should take an unordered_map, see http://crbug.com/670515.
+ explicit WindowTreeHostMus(
WindowTreeClient* window_tree_client,
const std::map<std::string, std::vector<uint8_t>>* properties = nullptr);
~WindowTreeHostMus() override;
- // Sets the bounds in dips.
- void SetBoundsFromServer(const gfx::Rect& bounds);
+ // Sets the bounds in pixels.
+ void SetBoundsFromServer(const gfx::Rect& bounds_in_pixels);
ui::EventDispatchDetails SendEventToProcessor(ui::Event* event) {
return aura::WindowTreeHostPlatform::SendEventToProcessor(event);
@@ -50,15 +60,25 @@ class AURA_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
InputMethodMus* input_method() { return input_method_.get(); }
+ // Sets the client area on the underlying mus window.
+ void SetClientArea(const gfx::Insets& insets,
+ const std::vector<gfx::Rect>& additional_client_area);
+
+ // Sets the hit test mask on the underlying mus window. Pass base::nullopt to
+ // clear.
+ void SetHitTestMask(const base::Optional<gfx::Rect>& rect);
+
+ // Requests that the window manager change the activation to the next window.
+ void DeactivateWindow();
+
// 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;
// aura::WindowTreeHostPlatform:
- void ShowImpl() override;
void HideImpl() override;
- void SetBounds(const gfx::Rect& bounds) override;
+ void SetBoundsInPixels(const gfx::Rect& bounds) override;
void DispatchEvent(ui::Event* event) override;
void OnClosed() override;
void OnActivationChanged(bool active) override;
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 e93dcfcaa91..edd844b282b 100644
--- a/chromium/ui/aura/mus/window_tree_host_mus_delegate.h
+++ b/chromium/ui/aura/mus/window_tree_host_mus_delegate.h
@@ -5,6 +5,12 @@
#ifndef UI_AURA_MUS_WINDOW_TREE_HOST_MUS_DELEGATE_H_
#define UI_AURA_MUS_WINDOW_TREE_HOST_MUS_DELEGATE_H_
+#include <stdint.h>
+
+#include <map>
+#include <string>
+#include <vector>
+
#include "ui/aura/aura_export.h"
namespace gfx {
@@ -25,8 +31,25 @@ class AURA_EXPORT WindowTreeHostMusDelegate {
WindowTreeHostMus* window_tree_host,
const gfx::Rect& bounds) = 0;
+ // Called when the client area of a WindowTreeHostMus is about to change.
+ virtual void OnWindowTreeHostClientAreaWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const gfx::Insets& client_area,
+ const std::vector<gfx::Rect>& additional_client_areas) = 0;
+
+ // Called when the hit test mask is about to be cleared.
+ virtual void OnWindowTreeHostHitTestMaskWillChange(
+ WindowTreeHostMus* window_tree_host,
+ const base::Optional<gfx::Rect>& mask_rect) = 0;
+
+ // Called to clear the focus of the current window.
+ virtual void OnWindowTreeHostDeactivateWindow(
+ WindowTreeHostMus* window_tree_host) = 0;
+
// Called when a WindowTreeHostMus is created without a WindowPort.
- virtual std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel() = 0;
+ // TODO: this should take an unordered_map, see http://crbug.com/670515.
+ virtual std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel(
+ const std::map<std::string, std::vector<uint8_t>>* properties) = 0;
// Called from WindowTreeHostMus's constructor once the Window has been
// created.
diff --git a/chromium/ui/aura/mus/window_tree_host_mus_unittest.cc b/chromium/ui/aura/mus/window_tree_host_mus_unittest.cc
new file mode 100644
index 00000000000..ef119bf4d0d
--- /dev/null
+++ b/chromium/ui/aura/mus/window_tree_host_mus_unittest.cc
@@ -0,0 +1,38 @@
+// 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_tree_host_mus.h"
+
+#include "base/memory/ptr_util.h"
+#include "ui/aura/test/aura_mus_test_base.h"
+#include "ui/aura/test/mus/test_window_tree.h"
+
+namespace aura {
+
+using WindowTreeHostMusTest = aura::test::AuraMusClientTestBase;
+
+TEST_F(WindowTreeHostMusTest, UpdateClientArea) {
+ std::unique_ptr<WindowTreeHostMus> window_tree_host_mus =
+ base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
+
+ gfx::Insets new_insets(10, 11, 12, 13);
+ window_tree_host_mus->SetClientArea(new_insets, std::vector<gfx::Rect>());
+ EXPECT_EQ(new_insets, window_tree()->last_client_area());
+}
+
+TEST_F(WindowTreeHostMusTest, SetHitTestMask) {
+ std::unique_ptr<WindowTreeHostMus> window_tree_host_mus =
+ base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
+
+ EXPECT_FALSE(window_tree()->last_hit_test_mask().has_value());
+ gfx::Rect mask(10, 10, 10, 10);
+ window_tree_host_mus->SetHitTestMask(mask);
+ ASSERT_TRUE(window_tree()->last_hit_test_mask().has_value());
+ EXPECT_EQ(mask, window_tree()->last_hit_test_mask());
+
+ window_tree_host_mus->SetHitTestMask(base::nullopt);
+ ASSERT_FALSE(window_tree()->last_hit_test_mask().has_value());
+}
+
+} // namespace aura
diff --git a/chromium/ui/aura/test/ui_controls_factory_ozone.cc b/chromium/ui/aura/test/ui_controls_factory_ozone.cc
index 30f6bae8db0..6eb27bd9e76 100644
--- a/chromium/ui/aura/test/ui_controls_factory_ozone.cc
+++ b/chromium/ui/aura/test/ui_controls_factory_ozone.cc
@@ -107,7 +107,7 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
}
gfx::Point host_location = root_location;
- host_->ConvertPointToHost(&host_location);
+ host_->ConvertDIPToPixels(&host_location);
ui::EventType event_type;
@@ -137,7 +137,7 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
}
gfx::Point host_location = root_location;
- host_->ConvertPointToHost(&host_location);
+ host_->ConvertDIPToPixels(&host_location);
int flag = 0;
diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc
index 67fd26292ac..e12dd7dbe79 100644
--- a/chromium/ui/aura/window.cc
+++ b/chromium/ui/aura/window.cc
@@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
@@ -58,7 +59,6 @@ Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port)
visible_(false),
id_(kInitialId),
transparent_(false),
- user_data_(nullptr),
ignore_events_(false),
// Don't notify newly added observers during notification. This causes
// problems for code that adds an observer as part of an observer
@@ -158,16 +158,28 @@ void Window::SetType(ui::wm::WindowType type) {
type_ = type;
}
+const std::string& Window::GetName() const {
+ std::string* name = GetProperty(client::kNameKey);
+ return name ? *name : base::EmptyString();
+}
+
void Window::SetName(const std::string& name) {
- name_ = name;
+ if (name == GetName())
+ return;
+ SetProperty(client::kNameKey, new std::string(name));
if (layer())
UpdateLayerName();
}
+const base::string16& Window::GetTitle() const {
+ base::string16* title = GetProperty(client::kTitleKey);
+ return title ? *title : base::EmptyString16();
+}
+
void Window::SetTitle(const base::string16& title) {
- if (title == title_)
+ if (title == GetTitle())
return;
- title_ = title;
+ SetProperty(client::kTitleKey, new base::string16(title));
for (WindowObserver& observer : observers_)
observer.OnWindowTitleChanged(this);
}
@@ -451,7 +463,7 @@ void Window::MoveCursorTo(const gfx::Point& point_in_window) {
DCHECK(root_window);
gfx::Point point_in_root(point_in_window);
ConvertPointToTarget(this, root_window, &point_in_root);
- root_window->GetHost()->MoveCursorTo(point_in_root);
+ root_window->GetHost()->MoveCursorToLocationInDIP(point_in_root);
}
gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const {
@@ -609,12 +621,12 @@ void Window::OnDeviceScaleFactorChanged(float device_scale_factor) {
std::string Window::GetDebugInfo() const {
return base::StringPrintf(
"%s<%d> bounds(%d, %d, %d, %d) %s %s opacity=%.1f",
- name().empty() ? "Unknown" : name().c_str(), id(),
- bounds().x(), bounds().y(), bounds().width(), bounds().height(),
+ GetName().empty() ? "Unknown" : GetName().c_str(), id(), bounds().x(),
+ bounds().y(), bounds().width(), bounds().height(),
visible_ ? "WindowVisible" : "WindowHidden",
- layer() ?
- (layer()->GetTargetVisibility() ? "LayerVisible" : "LayerHidden") :
- "NoLayer",
+ layer()
+ ? (layer()->GetTargetVisibility() ? "LayerVisible" : "LayerHidden")
+ : "NoLayer",
layer() ? layer()->opacity() : 1.0f);
}
@@ -1081,7 +1093,7 @@ ui::EventTarget* Window::GetParentTarget() {
}
std::unique_ptr<ui::EventTargetIterator> Window::GetChildIterator() const {
- return base::MakeUnique<ui::EventTargetIteratorImpl<Window>>(children());
+ return base::MakeUnique<ui::EventTargetIteratorPtrImpl<Window>>(children());
}
ui::EventTargeter* Window::GetEventTargeter() {
@@ -1098,7 +1110,7 @@ void Window::UpdateLayerName() {
#if !defined(NDEBUG)
DCHECK(layer());
- std::string layer_name(name_);
+ std::string layer_name(GetName());
if (layer_name.empty())
layer_name = "Unnamed Window";
diff --git a/chromium/ui/aura/window.h b/chromium/ui/aura/window.h
index 68408041f11..80770c17b4d 100644
--- a/chromium/ui/aura/window.h
+++ b/chromium/ui/aura/window.h
@@ -103,10 +103,10 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
int id() const { return id_; }
void set_id(int id) { id_ = id; }
- const std::string& name() const { return name_; }
+ const std::string& GetName() const;
void SetName(const std::string& name);
- const base::string16 title() const { return title_; }
+ const base::string16& GetTitle() const;
void SetTitle(const base::string16& title);
bool transparent() const { return transparent_; }
@@ -135,10 +135,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void set_host(WindowTreeHost* host) { host_ = host; }
bool IsRootWindow() const { return !!host_; }
- // The Window does not own this object.
- void set_user_data(void* user_data) { user_data_ = user_data; }
- void* user_data() const { return user_data_; }
-
// Changes the visibility of the window.
void Show();
void Hide();
@@ -500,9 +496,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
bool visible_;
int id_;
- std::string name_;
-
- base::string16 title_;
// Whether layer is initialized as non-opaque.
bool transparent_;
@@ -510,8 +503,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
std::unique_ptr<LayoutManager> layout_manager_;
std::unique_ptr<ui::EventTargeter> targeter_;
- void* user_data_;
-
// Makes the window pass all events through to any windows behind it.
bool ignore_events_;
diff --git a/chromium/ui/aura/window_delegate.cc b/chromium/ui/aura/window_delegate.cc
deleted file mode 100644
index c3503d82764..00000000000
--- a/chromium/ui/aura/window_delegate.cc
+++ /dev/null
@@ -1,11 +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/window_delegate.h"
-
-namespace aura {
-
-void WindowDelegate::OnRequestClose() {}
-
-} // namespace aura
diff --git a/chromium/ui/aura/window_delegate.h b/chromium/ui/aura/window_delegate.h
index 434dcad5036..644c0cee287 100644
--- a/chromium/ui/aura/window_delegate.h
+++ b/chromium/ui/aura/window_delegate.h
@@ -94,9 +94,6 @@ class AURA_EXPORT WindowDelegate : public ui::EventHandler {
// above returns true.
virtual void GetHitTestMask(gfx::Path* mask) const = 0;
- // Sent when the server requests the window to close.
- virtual void OnRequestClose();
-
protected:
~WindowDelegate() override {}
};
diff --git a/chromium/ui/aura/window_event_dispatcher.cc b/chromium/ui/aura/window_event_dispatcher.cc
index f5fe099778d..4ccccb4cb7c 100644
--- a/chromium/ui/aura/window_event_dispatcher.cc
+++ b/chromium/ui/aura/window_event_dispatcher.cc
@@ -158,10 +158,10 @@ DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint(
void WindowEventDispatcher::ProcessedTouchEvent(uint32_t unique_event_id,
Window* window,
ui::EventResult result) {
- std::unique_ptr<ui::GestureRecognizer::Gestures> gestures(
+ ui::GestureRecognizer::Gestures gestures =
ui::GestureRecognizer::Get()->AckTouchEvent(unique_event_id, result,
- window));
- DispatchDetails details = ProcessGestures(window, gestures.get());
+ window);
+ DispatchDetails details = ProcessGestures(window, std::move(gestures));
if (details.dispatcher_destroyed)
return;
}
@@ -275,9 +275,9 @@ ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit(
ui::EventDispatchDetails WindowEventDispatcher::ProcessGestures(
Window* target,
- ui::GestureRecognizer::Gestures* gestures) {
+ ui::GestureRecognizer::Gestures gestures) {
DispatchDetails details;
- if (!gestures || gestures->empty())
+ if (gestures.empty())
return details;
// If a window has been hidden between the touch event and now, the associated
@@ -285,10 +285,9 @@ ui::EventDispatchDetails WindowEventDispatcher::ProcessGestures(
if (!target)
return details;
- for (size_t i = 0; i < gestures->size(); ++i) {
- ui::GestureEvent* event = gestures->get().at(i);
+ for (const auto& event : gestures) {
event->ConvertLocationToTarget(window(), target);
- details = DispatchEvent(target, event);
+ details = DispatchEvent(target, event.get());
if (details.dispatcher_destroyed || details.target_destroyed)
break;
}
@@ -486,13 +485,12 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent(
const ui::TouchEvent& touchevent = *event.AsTouchEvent();
if (!touchevent.synchronous_handling_disabled()) {
- std::unique_ptr<ui::GestureRecognizer::Gestures> gestures;
-
Window* window = static_cast<Window*>(target);
- gestures.reset(ui::GestureRecognizer::Get()->AckTouchEvent(
- touchevent.unique_event_id(), event.result(), window));
+ ui::GestureRecognizer::Gestures gestures =
+ ui::GestureRecognizer::Get()->AckTouchEvent(
+ touchevent.unique_event_id(), event.result(), window);
- return ProcessGestures(window, gestures.get());
+ return ProcessGestures(window, std::move(gestures));
}
}
}
@@ -714,7 +712,7 @@ ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() {
if (!window()->bounds().Contains(root_mouse_location))
return details;
gfx::Point host_mouse_location = root_mouse_location;
- host_->ConvertPointToHost(&host_mouse_location);
+ host_->ConvertDIPToPixels(&host_mouse_location);
ui::MouseEvent event(ui::ET_MOUSE_MOVED, host_mouse_location,
host_mouse_location, ui::EventTimeForNow(),
ui::EF_IS_SYNTHESIZED, 0);
diff --git a/chromium/ui/aura/window_event_dispatcher.h b/chromium/ui/aura/window_event_dispatcher.h
index b4cfb13ea8c..219037c7938 100644
--- a/chromium/ui/aura/window_event_dispatcher.h
+++ b/chromium/ui/aura/window_event_dispatcher.h
@@ -154,7 +154,7 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor,
WARN_UNUSED_RESULT;
ui::EventDispatchDetails ProcessGestures(
Window* target,
- ui::GestureRecognizer::Gestures* gestures) WARN_UNUSED_RESULT;
+ ui::GestureRecognizer::Gestures gestures) WARN_UNUSED_RESULT;
// Called when a window becomes invisible, either by being removed
// from root window hierarchy, via SetVisible(false) or being destroyed.
diff --git a/chromium/ui/aura/window_event_dispatcher_unittest.cc b/chromium/ui/aura/window_event_dispatcher_unittest.cc
index be370e510fa..ebec238f29d 100644
--- a/chromium/ui/aura/window_event_dispatcher_unittest.cc
+++ b/chromium/ui/aura/window_event_dispatcher_unittest.cc
@@ -1623,6 +1623,7 @@ TEST_P(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) {
// on.
WindowTreeHost* host = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100));
host->InitHost();
+ host->window()->Show();
// Create two windows.
Window* w1 = CreateNormalWindow(1, host->window(), nullptr);
@@ -1700,6 +1701,7 @@ TEST_P(WindowEventDispatcherTest, ValidRootDuringDestruction) {
std::unique_ptr<WindowTreeHost> host(
WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)));
host->InitHost();
+ host->window()->Show();
// Owned by WindowEventDispatcher.
Window* w1 = CreateNormalWindow(1, host->window(), NULL);
w1->AddObserver(&observer);
@@ -1806,6 +1808,7 @@ TEST_P(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) {
// Should be deleted by |delegate|.
WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100));
h2->InitHost();
+ h2->window()->Show();
DeleteHostFromHeldMouseEventDelegate delegate(h2);
// Owned by |h2|.
Window* w1 = CreateNormalWindow(1, h2->window(), &delegate);
@@ -2397,6 +2400,7 @@ TEST_P(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) {
std::unique_ptr<WindowTreeHost> second_host(
WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
second_host->InitHost();
+ second_host->window()->Show();
Window* second_root = second_host->window();
// Create two windows parented to |root_window()|.
@@ -2459,6 +2463,7 @@ TEST_P(WindowEventDispatcherTest,
std::unique_ptr<WindowTreeHost> second_host(
WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
second_host->InitHost();
+ second_host->window()->Show();
WindowEventDispatcher* second_dispatcher = second_host->dispatcher();
// Install an InputStateLookup on the Env that always claims that a
@@ -2499,6 +2504,7 @@ TEST_P(WindowEventDispatcherTest,
std::unique_ptr<WindowTreeHost> second_host(
WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
second_host->InitHost();
+ second_host->window()->Show();
client::SetCaptureClient(second_host->window(),
client::GetCaptureClient(root_window()));
diff --git a/chromium/ui/aura/window_tree_host.cc b/chromium/ui/aura/window_tree_host.cc
index ef626257d73..039ec6daece 100644
--- a/chromium/ui/aura/window_tree_host.cc
+++ b/chromium/ui/aura/window_tree_host.cc
@@ -61,17 +61,8 @@ WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
void WindowTreeHost::InitHost() {
InitCompositor();
- UpdateRootWindowSize(GetBounds().size());
+ UpdateRootWindowSizeInPixels(GetBoundsInPixels().size());
Env::GetInstance()->NotifyHostInitialized(this);
- window()->Show();
-}
-
-void WindowTreeHost::InitCompositor() {
- compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
- GetBounds().size());
- compositor_->SetRootLayer(window()->layer());
- compositor_->SetDisplayColorSpace(
- GetICCProfileForCurrentDisplay().GetColorSpace());
}
void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) {
@@ -96,7 +87,7 @@ gfx::Transform WindowTreeHost::GetRootTransform() const {
void WindowTreeHost::SetRootTransform(const gfx::Transform& transform) {
window()->SetTransform(transform);
- UpdateRootWindowSize(GetBounds().size());
+ UpdateRootWindowSizeInPixels(GetBoundsInPixels().size());
}
gfx::Transform WindowTreeHost::GetInverseRootTransform() const {
@@ -107,18 +98,20 @@ gfx::Transform WindowTreeHost::GetInverseRootTransform() const {
return invert;
}
-void WindowTreeHost::SetOutputSurfacePadding(const gfx::Insets& padding) {
- if (output_surface_padding_ == padding)
+void WindowTreeHost::SetOutputSurfacePaddingInPixels(
+ const gfx::Insets& padding_in_pixels) {
+ if (output_surface_padding_in_pixels_ == padding_in_pixels)
return;
- output_surface_padding_ = padding;
- OnHostResized(GetBounds().size());
+ output_surface_padding_in_pixels_ = padding_in_pixels;
+ OnHostResizedInPixels(GetBoundsInPixels().size());
}
-void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) {
- gfx::Rect bounds(output_surface_padding_.left(),
- output_surface_padding_.top(), host_size.width(),
- host_size.height());
+void WindowTreeHost::UpdateRootWindowSizeInPixels(
+ const gfx::Size& host_size_in_pixels) {
+ gfx::Rect bounds(output_surface_padding_in_pixels_.left(),
+ output_surface_padding_in_pixels_.top(),
+ host_size_in_pixels.width(), host_size_in_pixels.height());
float scale_factor = ui::GetDeviceScaleFactor(window()->layer());
gfx::RectF new_bounds =
gfx::ScaleRect(gfx::RectF(bounds), 1.0f / scale_factor);
@@ -126,25 +119,25 @@ void WindowTreeHost::UpdateRootWindowSize(const gfx::Size& host_size) {
window()->SetBounds(gfx::ToEnclosingRect(new_bounds));
}
-void WindowTreeHost::ConvertPointToNativeScreen(gfx::Point* point) const {
- ConvertPointToHost(point);
- gfx::Point location = GetLocationOnNativeScreen();
+void WindowTreeHost::ConvertDIPToScreenInPixels(gfx::Point* point) const {
+ ConvertDIPToPixels(point);
+ gfx::Point location = GetLocationOnScreenInPixels();
point->Offset(location.x(), location.y());
}
-void WindowTreeHost::ConvertPointFromNativeScreen(gfx::Point* point) const {
- gfx::Point location = GetLocationOnNativeScreen();
+void WindowTreeHost::ConvertScreenInPixelsToDIP(gfx::Point* point) const {
+ gfx::Point location = GetLocationOnScreenInPixels();
point->Offset(-location.x(), -location.y());
- ConvertPointFromHost(point);
+ ConvertPixelsToDIP(point);
}
-void WindowTreeHost::ConvertPointToHost(gfx::Point* point) const {
+void WindowTreeHost::ConvertDIPToPixels(gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
GetRootTransform().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
-void WindowTreeHost::ConvertPointFromHost(gfx::Point* point) const {
+void WindowTreeHost::ConvertPixelsToDIP(gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
GetInverseRootTransform().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
@@ -172,16 +165,18 @@ void WindowTreeHost::OnCursorVisibilityChanged(bool show) {
OnCursorVisibilityChangedNative(show);
}
-void WindowTreeHost::MoveCursorTo(const gfx::Point& location_in_dip) {
+void WindowTreeHost::MoveCursorToLocationInDIP(
+ const gfx::Point& location_in_dip) {
gfx::Point host_location(location_in_dip);
- ConvertPointToHost(&host_location);
+ ConvertDIPToPixels(&host_location);
MoveCursorToInternal(location_in_dip, host_location);
}
-void WindowTreeHost::MoveCursorToHostLocation(const gfx::Point& host_location) {
- gfx::Point root_location(host_location);
- ConvertPointFromHost(&root_location);
- MoveCursorToInternal(root_location, host_location);
+void WindowTreeHost::MoveCursorToLocationInPixels(
+ const gfx::Point& location_in_pixels) {
+ gfx::Point root_location(location_in_pixels);
+ ConvertPixelsToDIP(&root_location);
+ MoveCursorToInternal(root_location, location_in_pixels);
}
ui::InputMethod* WindowTreeHost::GetInputMethod() {
@@ -205,9 +200,13 @@ ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME(
}
void WindowTreeHost::Show() {
- if (compositor())
- compositor()->SetVisible(true);
+ // Ensure that compositor has been properly initialized, see InitCompositor()
+ // and InitHost().
+ DCHECK(compositor());
+ DCHECK_EQ(compositor()->root_layer(), window()->layer());
+ compositor()->SetVisible(true);
ShowImpl();
+ window()->Show();
}
void WindowTreeHost::Hide() {
@@ -246,12 +245,17 @@ void WindowTreeHost::DestroyDispatcher() {
//window()->RemoveOrDestroyChildren();
}
-void WindowTreeHost::CreateCompositor() {
+void WindowTreeHost::CreateCompositor(const cc::FrameSinkId& frame_sink_id) {
DCHECK(Env::GetInstance());
ui::ContextFactory* context_factory = Env::GetInstance()->context_factory();
DCHECK(context_factory);
- compositor_.reset(
- new ui::Compositor(context_factory, base::ThreadTaskRunnerHandle::Get()));
+ ui::ContextFactoryPrivate* context_factory_private =
+ Env::GetInstance()->context_factory_private();
+ compositor_.reset(new ui::Compositor(
+ frame_sink_id.is_valid() ? frame_sink_id
+ : context_factory_private->AllocateFrameSinkId(),
+ context_factory, context_factory_private,
+ base::ThreadTaskRunnerHandle::Get()));
if (!dispatcher()) {
window()->Init(ui::LAYER_NOT_DRAWN);
window()->set_host(this);
@@ -262,33 +266,43 @@ void WindowTreeHost::CreateCompositor() {
}
}
+void WindowTreeHost::InitCompositor() {
+ compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
+ GetBoundsInPixels().size());
+ compositor_->SetRootLayer(window()->layer());
+ compositor_->SetDisplayColorSpace(
+ GetICCProfileForCurrentDisplay().GetColorSpace());
+}
+
void WindowTreeHost::OnAcceleratedWidgetAvailable() {
compositor_->SetAcceleratedWidget(GetAcceleratedWidget());
prop_.reset(new ui::ViewProp(GetAcceleratedWidget(),
kWindowTreeHostForAcceleratedWidget, this));
}
-void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
- TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved",
- "origin", new_location.ToString());
+void WindowTreeHost::OnHostMovedInPixels(
+ const gfx::Point& new_location_in_pixels) {
+ TRACE_EVENT1("ui", "WindowTreeHost::OnHostMovedInPixels", "origin",
+ new_location_in_pixels.ToString());
for (WindowTreeHostObserver& observer : observers_)
- observer.OnHostMoved(this, new_location);
+ observer.OnHostMovedInPixels(this, new_location_in_pixels);
}
-void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
- gfx::Size adjusted_size(new_size);
- adjusted_size.Enlarge(output_surface_padding_.width(),
- output_surface_padding_.height());
+void WindowTreeHost::OnHostResizedInPixels(
+ const gfx::Size& new_size_in_pixels) {
+ gfx::Size adjusted_size(new_size_in_pixels);
+ adjusted_size.Enlarge(output_surface_padding_in_pixels_.width(),
+ output_surface_padding_in_pixels_.height());
// The compositor should have the same size as the native root window host.
// Get the latest scale from display because it might have been changed.
compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
adjusted_size);
- gfx::Size layer_size = GetBounds().size();
+ gfx::Size layer_size = GetBoundsInPixels().size();
// The layer, and the observers should be notified of the
// transformed size of the root window.
- UpdateRootWindowSize(layer_size);
+ UpdateRootWindowSizeInPixels(layer_size);
for (WindowTreeHostObserver& observer : observers_)
observer.OnHostResized(this);
}
@@ -329,7 +343,7 @@ ui::EventProcessor* WindowTreeHost::GetEventProcessor() {
void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location) {
last_cursor_request_position_in_host_ = host_location;
- MoveCursorToNative(host_location);
+ MoveCursorToScreenLocationInPixels(host_location);
client::CursorClient* cursor_client = client::GetCursorClient(window());
if (cursor_client) {
const display::Display& display =
diff --git a/chromium/ui/aura/window_tree_host.h b/chromium/ui/aura/window_tree_host.h
index fcbcbd82516..60928f86cdf 100644
--- a/chromium/ui/aura/window_tree_host.h
+++ b/chromium/ui/aura/window_tree_host.h
@@ -11,6 +11,7 @@
#include "base/event_types.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
+#include "cc/surfaces/frame_sink_id.h"
#include "ui/aura/aura_export.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/ime/input_method_delegate.h"
@@ -52,7 +53,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
~WindowTreeHost() override;
// Creates a new WindowTreeHost. The caller owns the returned value.
- static WindowTreeHost* Create(const gfx::Rect& bounds);
+ static WindowTreeHost* Create(const gfx::Rect& bounds_in_pixels);
// Returns the WindowTreeHost for the specified accelerated widget, or NULL
// if there is none associated.
@@ -60,8 +61,6 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
void InitHost();
- void InitCompositor();
-
void AddObserver(WindowTreeHostObserver* observer);
void RemoveObserver(WindowTreeHostObserver* observer);
@@ -85,33 +84,34 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// Sets padding applied to the output surface. The output surface is sized to
// to the size of the host plus output surface padding. |window()| is offset
- // by |padding|, that is, |window|'s origin is set to padding.left(),
- // padding.top().
+ // by |padding_in_pixels|, that is, |window|'s origin is set to
+ // padding_in_pixels.left(), padding_in_pixels.top().
// This does not impact the bounds as returned from GetBounds(), only the
// output surface size and location of window(). Additionally window() is
// sized to the size set by bounds (more specifically the size passed to
- // OnHostResized()), but the location of window() is set to that of
- // |padding|.
- void SetOutputSurfacePadding(const gfx::Insets& padding);
+ // OnHostResizedInPixels()), but the location of window() is set to that of
+ // |padding_in_pixels|.
+ void SetOutputSurfacePaddingInPixels(const gfx::Insets& padding_in_pixels);
- // Updates the root window's size using |host_size|, current
+ // Updates the root window's size using |host_size_in_pixels|, current
// transform and outsets.
- virtual void UpdateRootWindowSize(const gfx::Size& host_size);
+ virtual void UpdateRootWindowSizeInPixels(
+ const gfx::Size& host_size_in_pixels);
// Converts |point| from the root window's coordinate system to native
// screen's.
- void ConvertPointToNativeScreen(gfx::Point* point) const;
+ void ConvertDIPToScreenInPixels(gfx::Point* point) const;
// Converts |point| from native screen coordinate system to the root window's.
- void ConvertPointFromNativeScreen(gfx::Point* point) const;
+ void ConvertScreenInPixelsToDIP(gfx::Point* point) const;
// Converts |point| from the root window's coordinate system to the
// host window's.
- void ConvertPointToHost(gfx::Point* point) const;
+ void ConvertDIPToPixels(gfx::Point* point) const;
// Converts |point| from the host window's coordinate system to the
// root window's.
- void ConvertPointFromHost(gfx::Point* point) const;
+ void ConvertPixelsToDIP(gfx::Point* point) const;
// Cursor.
// Sets the currently-displayed cursor. If the cursor was previously hidden
@@ -124,10 +124,10 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
void OnCursorVisibilityChanged(bool visible);
// Moves the cursor to the specified location relative to the root window.
- void MoveCursorTo(const gfx::Point& location);
+ void MoveCursorToLocationInDIP(const gfx::Point& location_in_dip);
- // Moves the cursor to the |host_location| given in host coordinates.
- void MoveCursorToHostLocation(const gfx::Point& host_location);
+ // Moves the cursor to the |location_in_pixels| given in host coordinates.
+ void MoveCursorToLocationInPixels(const gfx::Point& location_in_pixels);
gfx::NativeCursor last_cursor() const { return last_cursor_; }
@@ -173,8 +173,8 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
void Hide();
// Gets/Sets the size of the WindowTreeHost (in pixels).
- virtual gfx::Rect GetBounds() const = 0;
- virtual void SetBounds(const gfx::Rect& bounds_in_pixels) = 0;
+ virtual gfx::Rect GetBoundsInPixels() const = 0;
+ virtual void SetBoundsInPixels(const gfx::Rect& bounds_in_pixels) = 0;
// Sets the OS capture to the root window.
virtual void SetCapture() = 0;
@@ -191,14 +191,19 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
void DestroyCompositor();
void DestroyDispatcher();
- void CreateCompositor();
+ // If frame_sink_id is not passed in, one will be grabbed from
+ // ContextFactoryPrivate.
+ void CreateCompositor(
+ const cc::FrameSinkId& frame_sink_id = cc::FrameSinkId());
+
+ void InitCompositor();
void OnAcceleratedWidgetAvailable();
// Returns the location of the RootWindow on native screen.
- virtual gfx::Point GetLocationOnNativeScreen() const = 0;
+ virtual gfx::Point GetLocationOnScreenInPixels() const = 0;
- void OnHostMoved(const gfx::Point& new_location);
- void OnHostResized(const gfx::Size& new_size);
+ void OnHostMovedInPixels(const gfx::Point& new_location_in_pixels);
+ void OnHostResizedInPixels(const gfx::Size& new_size_in_pixels);
void OnHostWorkspaceChanged();
void OnHostCloseRequested();
void OnHostActivated();
@@ -208,7 +213,8 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
virtual void SetCursorNative(gfx::NativeCursor cursor) = 0;
// Moves the cursor to the specified location relative to the root window.
- virtual void MoveCursorToNative(const gfx::Point& location) = 0;
+ virtual void MoveCursorToScreenLocationInPixels(
+ const gfx::Point& location_in_pixels) = 0;
// kCalled when the cursor visibility has changed.
virtual void OnCursorVisibilityChangedNative(bool show) = 0;
@@ -228,7 +234,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
friend class test::WindowTreeHostTestApi;
// Moves the cursor to the specified location. This method is internally used
- // by MoveCursorTo() and MoveCursorToHostLocation().
+ // by MoveCursorToLocationInDIP() and MoveCursorToLocationInPixels().
void MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location);
@@ -258,7 +264,7 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
// Whether the InputMethod instance is owned by this WindowTreeHost.
bool owned_input_method_;
- gfx::Insets output_surface_padding_;
+ gfx::Insets output_surface_padding_in_pixels_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHost);
};
diff --git a/chromium/ui/aura/window_tree_host_observer.h b/chromium/ui/aura/window_tree_host_observer.h
index 620cc885ade..f5c112ad8df 100644
--- a/chromium/ui/aura/window_tree_host_observer.h
+++ b/chromium/ui/aura/window_tree_host_observer.h
@@ -20,8 +20,8 @@ class AURA_EXPORT WindowTreeHostObserver {
virtual void OnHostResized(const WindowTreeHost* host) {}
// Called when the host is moved on screen.
- virtual void OnHostMoved(const WindowTreeHost* host,
- const gfx::Point& new_origin) {}
+ virtual void OnHostMovedInPixels(const WindowTreeHost* host,
+ const gfx::Point& new_origin_in_pixels) {}
// Called when the host is moved to a different workspace.
virtual void OnHostWorkspaceChanged(const WindowTreeHost* host) {}
diff --git a/chromium/ui/aura/window_tree_host_platform.cc b/chromium/ui/aura/window_tree_host_platform.cc
index e9ecea9e091..84cb47739e5 100644
--- a/chromium/ui/aura/window_tree_host_platform.cc
+++ b/chromium/ui/aura/window_tree_host_platform.cc
@@ -90,15 +90,15 @@ void WindowTreeHostPlatform::HideImpl() {
window_->Hide();
}
-gfx::Rect WindowTreeHostPlatform::GetBounds() const {
+gfx::Rect WindowTreeHostPlatform::GetBoundsInPixels() const {
return window_ ? window_->GetBounds() : gfx::Rect();
}
-void WindowTreeHostPlatform::SetBounds(const gfx::Rect& bounds) {
+void WindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) {
window_->SetBounds(bounds);
}
-gfx::Point WindowTreeHostPlatform::GetLocationOnNativeScreen() const {
+gfx::Point WindowTreeHostPlatform::GetLocationOnScreenInPixels() const {
return window_->GetBounds().origin();
}
@@ -123,8 +123,9 @@ void WindowTreeHostPlatform::SetCursorNative(gfx::NativeCursor cursor) {
window_->SetCursor(cursor.platform());
}
-void WindowTreeHostPlatform::MoveCursorToNative(const gfx::Point& location) {
- window_->MoveCursorTo(location);
+void WindowTreeHostPlatform::MoveCursorToScreenLocationInPixels(
+ const gfx::Point& location_in_pixels) {
+ window_->MoveCursorTo(location_in_pixels);
}
void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) {
@@ -139,10 +140,10 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
gfx::Rect old_bounds = bounds_;
bounds_ = new_bounds;
if (bounds_.origin() != old_bounds.origin()) {
- OnHostMoved(bounds_.origin());
+ OnHostMovedInPixels(bounds_.origin());
}
if (bounds_.size() != old_bounds.size() || current_scale != new_scale) {
- OnHostResized(bounds_.size());
+ OnHostResizedInPixels(bounds_.size());
}
}
diff --git a/chromium/ui/aura/window_tree_host_platform.h b/chromium/ui/aura/window_tree_host_platform.h
index 773d9f49efa..7cc90a524fe 100644
--- a/chromium/ui/aura/window_tree_host_platform.h
+++ b/chromium/ui/aura/window_tree_host_platform.h
@@ -33,13 +33,14 @@ class AURA_EXPORT WindowTreeHostPlatform
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void ShowImpl() override;
void HideImpl() override;
- gfx::Rect GetBounds() const override;
- void SetBounds(const gfx::Rect& bounds) override;
- gfx::Point GetLocationOnNativeScreen() const override;
+ gfx::Rect GetBoundsInPixels() const override;
+ void SetBoundsInPixels(const gfx::Rect& bounds) override;
+ gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
void SetCursorNative(gfx::NativeCursor cursor) override;
- void MoveCursorToNative(const gfx::Point& location) override;
+ void MoveCursorToScreenLocationInPixels(
+ const gfx::Point& location_in_pixels) override;
void OnCursorVisibilityChangedNative(bool show) override;
protected:
diff --git a/chromium/ui/aura/window_tree_host_unittest.cc b/chromium/ui/aura/window_tree_host_unittest.cc
index 3ba26cec00a..e4ce37c0412 100644
--- a/chromium/ui/aura/window_tree_host_unittest.cc
+++ b/chromium/ui/aura/window_tree_host_unittest.cc
@@ -14,11 +14,11 @@ using WindowTreeHostTest = test::AuraTestBase;
TEST_F(WindowTreeHostTest, DPIWindowSize) {
gfx::Rect starting_bounds(0, 0, 800, 600);
EXPECT_EQ(starting_bounds.size(), host()->compositor()->size());
- EXPECT_EQ(starting_bounds, host()->GetBounds());
+ EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(starting_bounds, root_window()->bounds());
test_screen()->SetDeviceScaleFactor(1.5f);
- EXPECT_EQ(starting_bounds, host()->GetBounds());
+ EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
// Size should be rounded up after scaling.
EXPECT_EQ(gfx::Rect(0, 0, 534, 400), root_window()->bounds());
@@ -29,11 +29,11 @@ TEST_F(WindowTreeHostTest, DPIWindowSize) {
gfx::Insets padding(1, 2, 3, 4);
// Padding is in physical pixels.
- host()->SetOutputSurfacePadding(padding);
+ host()->SetOutputSurfacePaddingInPixels(padding);
gfx::Rect padded_rect = starting_bounds;
padded_rect.Inset(-padding);
EXPECT_EQ(padded_rect.size(), host()->compositor()->size());
- EXPECT_EQ(starting_bounds, host()->GetBounds());
+ EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(gfx::Rect(1, 1, 534, 401), root_window()->bounds());
EXPECT_EQ(gfx::Vector2dF(0, 0),
host()->compositor()->root_layer()->subpixel_position_offset());
diff --git a/chromium/ui/aura/window_tree_host_x11.cc b/chromium/ui/aura/window_tree_host_x11.cc
index c618a1ced10..9f669ad7451 100644
--- a/chromium/ui/aura/window_tree_host_x11.cc
+++ b/chromium/ui/aura/window_tree_host_x11.cc
@@ -312,9 +312,9 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
bounds_ = bounds;
OnConfigureNotify();
if (size_changed)
- OnHostResized(bounds.size());
+ OnHostResizedInPixels(bounds.size());
if (origin_changed)
- OnHostMoved(bounds_.origin());
+ OnHostMovedInPixels(bounds_.origin());
break;
}
case GenericEvent:
@@ -396,11 +396,11 @@ void WindowTreeHostX11::HideImpl() {
}
}
-gfx::Rect WindowTreeHostX11::GetBounds() const {
+gfx::Rect WindowTreeHostX11::GetBoundsInPixels() const {
return bounds_;
}
-void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
+void WindowTreeHostX11::SetBoundsInPixels(const gfx::Rect& bounds) {
// Even if the host window's size doesn't change, aura's root window
// size, which is in DIP, changes when the scale changes.
float current_scale = compositor()->device_scale_factor();
@@ -433,15 +433,15 @@ void WindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
// |bounds_| later.
bounds_ = bounds;
if (origin_changed)
- OnHostMoved(bounds.origin());
+ OnHostMovedInPixels(bounds.origin());
if (size_changed || current_scale != new_scale) {
- OnHostResized(bounds.size());
+ OnHostResizedInPixels(bounds.size());
} else {
window()->SchedulePaintInRect(window()->bounds());
}
}
-gfx::Point WindowTreeHostX11::GetLocationOnNativeScreen() const {
+gfx::Point WindowTreeHostX11::GetLocationOnScreenInPixels() const {
return bounds_.origin();
}
@@ -465,10 +465,11 @@ void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) {
SetCursorInternal(cursor);
}
-void WindowTreeHostX11::MoveCursorToNative(const gfx::Point& location) {
+void WindowTreeHostX11::MoveCursorToScreenLocationInPixels(
+ const gfx::Point& location_in_pixels) {
XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0,
- bounds_.x() + location.x(),
- bounds_.y() + location.y());
+ bounds_.x() + location_in_pixels.x(),
+ bounds_.y() + location_in_pixels.y());
}
void WindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
@@ -570,8 +571,8 @@ void WindowTreeHostX11::TranslateAndDispatchLocatedEvent(
}
// static
-WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
- return new WindowTreeHostX11(bounds);
+WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds_in_pixels) {
+ return new WindowTreeHostX11(bounds_in_pixels);
}
namespace test {
diff --git a/chromium/ui/aura/window_tree_host_x11.h b/chromium/ui/aura/window_tree_host_x11.h
index dead24f750f..7cea1643c06 100644
--- a/chromium/ui/aura/window_tree_host_x11.h
+++ b/chromium/ui/aura/window_tree_host_x11.h
@@ -43,13 +43,14 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void ShowImpl() override;
void HideImpl() override;
- gfx::Rect GetBounds() const override;
- void SetBounds(const gfx::Rect& bounds) override;
- gfx::Point GetLocationOnNativeScreen() const override;
+ gfx::Rect GetBoundsInPixels() const override;
+ void SetBoundsInPixels(const gfx::Rect& bounds) override;
+ gfx::Point GetLocationOnScreenInPixels() const override;
void SetCapture() override;
void ReleaseCapture() override;
void SetCursorNative(gfx::NativeCursor cursor_type) override;
- void MoveCursorToNative(const gfx::Point& location) override;
+ void MoveCursorToScreenLocationInPixels(
+ const gfx::Point& location_in_pixels) override;
void OnCursorVisibilityChangedNative(bool show) override;
// Deselects mouse and keyboard events on |xwindow_|.
diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc
index 90972c780ad..6d5cf838e1a 100644
--- a/chromium/ui/aura/window_unittest.cc
+++ b/chromium/ui/aura/window_unittest.cc
@@ -441,7 +441,7 @@ TEST_P(WindowTest, MoveCursorToWithTransformRootWindow) {
transform.Rotate(90.0);
transform.Scale(2.0, 5.0);
host()->SetRootTransform(transform);
- host()->MoveCursorTo(gfx::Point(10, 10));
+ host()->MoveCursorToLocationInDIP(gfx::Point(10, 10));
#if !defined(OS_WIN)
// TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD
EXPECT_EQ("50,120", QueryLatestMousePositionRequestInHost(host()).ToString());
@@ -1610,7 +1610,7 @@ TEST_P(WindowTest, IgnoreEventsTest) {
// Tests transformation on the root window.
TEST_P(WindowTest, Transform) {
- gfx::Size size = host()->GetBounds().size();
+ gfx::Size size = host()->GetBoundsInPixels().size();
EXPECT_EQ(gfx::Rect(size), display::Screen::GetScreen()
->GetDisplayNearestPoint(gfx::Point())
.bounds());
@@ -1632,11 +1632,11 @@ TEST_P(WindowTest, Transform) {
.ToString());
// Host size shouldn't change.
- EXPECT_EQ(size.ToString(), host()->GetBounds().size().ToString());
+ EXPECT_EQ(size.ToString(), host()->GetBoundsInPixels().size().ToString());
}
TEST_P(WindowTest, TransformGesture) {
- gfx::Size size = host()->GetBounds().size();
+ gfx::Size size = host()->GetBoundsInPixels().size();
std::unique_ptr<GestureTrackPositionDelegate> delegate(
new GestureTrackPositionDelegate);