Commit fb80a99b authored by Mikolaj Walczak's avatar Mikolaj Walczak Committed by Commit Bot

Wayland event for dpi scaling change

Send a wayland event to Android when user requests
a density change (CTRL +/CTRL -/CTRL 0) on ARC++
application.
BUG=b:142100473
TEST=`adb shell logcat -s libwayland-client:*'

Change-Id: I550557eeb017fb24eef83cc09a7b0d809462d7b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846629
Commit-Queue: Mikolaj Walczak <walczakm@google.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704993}
parent 42594432
...@@ -626,7 +626,8 @@ void ClientControlledShellSurface::OnBoundsChangeEvent( ...@@ -626,7 +626,8 @@ void ClientControlledShellSurface::OnBoundsChangeEvent(
} }
void ClientControlledShellSurface::ChangeZoomLevel(ZoomChange change) { void ClientControlledShellSurface::ChangeZoomLevel(ZoomChange change) {
// TODO(walczakm): Send wayland event. if (change_zoom_level_callback_)
change_zoom_level_callback_.Run(change);
} }
void ClientControlledShellSurface::OnDragStarted(int component) { void ClientControlledShellSurface::OnDragStarted(int component) {
......
...@@ -122,6 +122,12 @@ class ClientControlledShellSurface : public ShellSurfaceBase, ...@@ -122,6 +122,12 @@ class ClientControlledShellSurface : public ShellSurfaceBase,
drag_finished_callback_ = callback; drag_finished_callback_ = callback;
} }
// Set callback to run when user requests to change a zoom level.
using ChangeZoomLevelCallback = base::RepeatingCallback<void(ZoomChange)>;
void set_change_zoom_level_callback(const ChangeZoomLevelCallback& callback) {
change_zoom_level_callback_ = callback;
}
// Returns true if this shell surface is currently being dragged. // Returns true if this shell surface is currently being dragged.
bool IsDragging(); bool IsDragging();
...@@ -298,6 +304,7 @@ class ClientControlledShellSurface : public ShellSurfaceBase, ...@@ -298,6 +304,7 @@ class ClientControlledShellSurface : public ShellSurfaceBase,
BoundsChangedCallback bounds_changed_callback_; BoundsChangedCallback bounds_changed_callback_;
DragStartedCallback drag_started_callback_; DragStartedCallback drag_started_callback_;
DragFinishedCallback drag_finished_callback_; DragFinishedCallback drag_finished_callback_;
ChangeZoomLevelCallback change_zoom_level_callback_;
// TODO(reveman): Use configure callbacks for orientation. crbug.com/765954 // TODO(reveman): Use configure callbacks for orientation. crbug.com/765954
Orientation pending_orientation_ = Orientation::LANDSCAPE; Orientation pending_orientation_ = Orientation::LANDSCAPE;
......
...@@ -689,6 +689,13 @@ class WaylandRemoteShell : public ash::TabletModeObserver, ...@@ -689,6 +689,13 @@ class WaylandRemoteShell : public ash::TabletModeObserver,
weak_ptr_factory_.GetWeakPtr(), base::Unretained(resource)); weak_ptr_factory_.GetWeakPtr(), base::Unretained(resource));
} }
ClientControlledShellSurface::ChangeZoomLevelCallback
CreateChangeZoomLevelCallback(wl_resource* resource) {
return base::BindRepeating(
&WaylandRemoteShell::HandleRemoteSurfaceChangeZoomLevelCallback,
weak_ptr_factory_.GetWeakPtr(), base::Unretained(resource));
}
ClientControlledShellSurface::StateChangedCallback CreateStateChangedCallback( ClientControlledShellSurface::StateChangedCallback CreateStateChangedCallback(
wl_resource* resource) { wl_resource* resource) {
return base::BindRepeating( return base::BindRepeating(
...@@ -1019,6 +1026,23 @@ class WaylandRemoteShell : public ash::TabletModeObserver, ...@@ -1019,6 +1026,23 @@ class WaylandRemoteShell : public ash::TabletModeObserver,
wl_client_flush(wl_resource_get_client(resource)); wl_client_flush(wl_resource_get_client(resource));
} }
void HandleRemoteSurfaceChangeZoomLevelCallback(wl_resource* resource,
ZoomChange change) {
int32_t value = 0;
switch (change) {
case ZoomChange::IN:
value = ZCR_REMOTE_SURFACE_V1_ZOOM_CHANGE_IN;
break;
case ZoomChange::OUT:
value = ZCR_REMOTE_SURFACE_V1_ZOOM_CHANGE_OUT;
break;
case ZoomChange::RESET:
value = ZCR_REMOTE_SURFACE_V1_ZOOM_CHANGE_RESET;
break;
}
zcr_remote_surface_v1_send_change_zoom_level(resource, value);
}
void HandleRemoteSurfaceGeometryChangedCallback(wl_resource* resource, void HandleRemoteSurfaceGeometryChangedCallback(wl_resource* resource,
const gfx::Rect& geometry) { const gfx::Rect& geometry) {
LOG_IF(ERROR, pending_bounds_changes_.count(resource) > 0) LOG_IF(ERROR, pending_bounds_changes_.count(resource) > 0)
...@@ -1139,6 +1163,10 @@ void remote_shell_get_remote_surface(wl_client* client, ...@@ -1139,6 +1163,10 @@ void remote_shell_get_remote_surface(wl_client* client,
base::BindRepeating(&HandleRemoteSurfaceDragFinishedCallback, base::BindRepeating(&HandleRemoteSurfaceDragFinishedCallback,
base::Unretained(remote_surface_resource))); base::Unretained(remote_surface_resource)));
DCHECK(wl_resource_get_version(remote_surface_resource) >= 23);
shell_surface->set_change_zoom_level_callback(
shell->CreateChangeZoomLevelCallback(remote_surface_resource));
SetImplementation(remote_surface_resource, &remote_surface_implementation, SetImplementation(remote_surface_resource, &remote_surface_implementation,
std::move(shell_surface)); std::move(shell_surface));
} }
......
...@@ -22,7 +22,7 @@ class Display; ...@@ -22,7 +22,7 @@ class Display;
namespace exo { namespace exo {
namespace wayland { namespace wayland {
constexpr uint32_t kZcrRemoteShellVersion = 22; constexpr uint32_t kZcrRemoteShellVersion = 23;
void bind_remote_shell(wl_client* client, void bind_remote_shell(wl_client* client,
void* data, void* data,
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
reset. reset.
</description> </description>
<interface name="zcr_remote_shell_v1" version="22"> <interface name="zcr_remote_shell_v1" version="23">
<description summary="remote_shell"> <description summary="remote_shell">
The global interface that allows clients to turn a wl_surface into a The global interface that allows clients to turn a wl_surface into a
"real window" which is remotely managed but can be stacked, activated "real window" which is remotely managed but can be stacked, activated
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
</interface> </interface>
<interface name="zcr_remote_surface_v1" version="20"> <interface name="zcr_remote_surface_v1" version="23">
<description summary="A desktop window"> <description summary="A desktop window">
An interface that may be implemented by a wl_surface, for An interface that may be implemented by a wl_surface, for
implementations that provide a desktop-style user interface implementations that provide a desktop-style user interface
...@@ -1016,6 +1016,23 @@ ...@@ -1016,6 +1016,23 @@
description of set_ime_blocked for detail. description of set_ime_blocked for detail.
</description> </description>
</request> </request>
<!-- Version 23 additions -->
<enum name="zoom_change">
<description summary="zoom level change">
Zoom level change.
</description>
<entry name="in" value="0" summary="zoom in"/>
<entry name="out" value="1" summary="zoom out"/>
<entry name="reset" value="2" summary="reset zoom level"/>
</enum>
<event name="change_zoom_level" since="23">
<description summary="change zoom level">
Request application zoom level change.
</description>
<arg name="change" type="int" summary="zoom_change"/>
</event>
</interface> </interface>
<interface name="zcr_notification_surface_v1" version="16"> <interface name="zcr_notification_surface_v1" version="16">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment