exo: Implement version 5 of aura shell.
This adds two new events to aura_output interface that makes it
easier for clients to calculate an ideal contents scale.
This also adds a new request that can be used to set a unique
application ID for a surface. The application ID identifies the
general class of applications to which the surface belongs. The
compositor can use this to group multiple surfaces together.
For example, "org.chromium.FooViewer".
Note that the application ID set here takes precedence over the
app id set through XDG shell interface. To keep it simple, we
just remove the implementation of xdg surface set_app_id. If
that turns out to be useful in the future, then we can always
re-implement that and make it available as an alternative ID.
Bug: 824449, 791672
Test: wayland_client_info
Change-Id: I3219cedbd7d9ce65e73ca33127ea976acc8c4163
Reviewed-on: https://chromium-review.googlesource.com/1008664
Reviewed-by: Daniele Castagna <[email protected]>
Commit-Queue: David Reveman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#550038}
diff --git a/components/exo/shell_surface_base.cc b/components/exo/shell_surface_base.cc
index 88a3b40..1bdf5f4 100644
--- a/components/exo/shell_surface_base.cc
+++ b/components/exo/shell_surface_base.cc
@@ -822,6 +822,10 @@
SetStartupId(startup_id);
}
+void ShellSurfaceBase::OnSetApplicationId(const char* application_id) {
+ SetApplicationId(application_id);
+}
+
////////////////////////////////////////////////////////////////////////////////
// SurfaceObserver overrides:
diff --git a/components/exo/shell_surface_base.h b/components/exo/shell_surface_base.h
index 4c936e1..6fdb49c 100644
--- a/components/exo/shell_surface_base.h
+++ b/components/exo/shell_surface_base.h
@@ -174,6 +174,7 @@
void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override;
void OnSetParent(Surface* parent, const gfx::Point& position) override;
void OnSetStartupId(const char* startup_id) override;
+ void OnSetApplicationId(const char* application_id) override;
// Overridden from SurfaceObserver:
void OnSurfaceDestroying(Surface* surface) override;
diff --git a/components/exo/sub_surface.h b/components/exo/sub_surface.h
index cb55462..59a201c 100644
--- a/components/exo/sub_surface.h
+++ b/components/exo/sub_surface.h
@@ -57,6 +57,7 @@
}
void OnSetParent(Surface* parent, const gfx::Point& position) override {}
void OnSetStartupId(const char* startup_id) override {}
+ void OnSetApplicationId(const char* application_id) override {}
// Overridden from SurfaceObserver:
void OnSurfaceDestroying(Surface* surface) override;
diff --git a/components/exo/surface.cc b/components/exo/surface.cc
index 5b197534..560c716 100644
--- a/components/exo/surface.cc
+++ b/components/exo/surface.cc
@@ -454,6 +454,14 @@
delegate_->OnSetStartupId(startup_id);
}
+void Surface::SetApplicationId(const char* application_id) {
+ TRACE_EVENT1("exo", "Surface::SetApplicationId", "application_id",
+ application_id);
+
+ if (delegate_)
+ delegate_->OnSetApplicationId(application_id);
+}
+
void Surface::SetParent(Surface* parent, const gfx::Point& position) {
TRACE_EVENT2("exo", "Surface::SetParent", "parent", !!parent, "position",
position.ToString());
diff --git a/components/exo/surface.h b/components/exo/surface.h
index a3610ac..d0874a9 100644
--- a/components/exo/surface.h
+++ b/components/exo/surface.h
@@ -145,9 +145,12 @@
// Request that surface should use a specific set of frame colors.
void SetFrameColors(SkColor active_color, SkColor inactive_color);
- // Request that surface should have a specific startup_id string.
+ // Request that surface should have a specific startup ID string.
void SetStartupId(const char* startup_id);
+ // Request that surface should have a specific application ID string.
+ void SetApplicationId(const char* application_id);
+
// Request "parent" for surface.
void SetParent(Surface* parent, const gfx::Point& position);
diff --git a/components/exo/surface_delegate.h b/components/exo/surface_delegate.h
index 1f1658d1..0a5dded 100644
--- a/components/exo/surface_delegate.h
+++ b/components/exo/surface_delegate.h
@@ -41,6 +41,9 @@
// Called when surface was requested to set a specific startup ID label.
virtual void OnSetStartupId(const char* startup_id) = 0;
+ // Called when surface was requested to set a specific application ID label.
+ virtual void OnSetApplicationId(const char* application_id) = 0;
+
protected:
virtual ~SurfaceDelegate() {}
};
diff --git a/components/exo/surface_tree_host.h b/components/exo/surface_tree_host.h
index 65fe76d..08719ac 100644
--- a/components/exo/surface_tree_host.h
+++ b/components/exo/surface_tree_host.h
@@ -92,6 +92,7 @@
}
void OnSetParent(Surface* parent, const gfx::Point& position) override {}
void OnSetStartupId(const char* startup_id) override {}
+ void OnSetApplicationId(const char* application_id) override {}
// Overridden from cc::BeginFrameObserverBase:
bool OnBeginFrameDerivedImpl(const viz::BeginFrameArgs& args) override;
diff --git a/components/exo/wayland/clients/client_base.cc b/components/exo/wayland/clients/client_base.cc
index 5e3afd30..4dc5557e 100644
--- a/components/exo/wayland/clients/client_base.cc
+++ b/components/exo/wayland/clients/client_base.cc
@@ -104,7 +104,7 @@
wl_registry_bind(registry, id, &wp_presentation_interface, 1)));
} else if (strcmp(interface, "zaura_shell") == 0) {
globals->aura_shell.reset(static_cast<zaura_shell*>(
- wl_registry_bind(registry, id, &zaura_shell_interface, 1)));
+ wl_registry_bind(registry, id, &zaura_shell_interface, 5)));
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
globals->linux_dmabuf.reset(static_cast<zwp_linux_dmabuf_v1*>(
wl_registry_bind(registry, id, &zwp_linux_dmabuf_v1_interface, 2)));
diff --git a/components/exo/wayland/clients/info.cc b/components/exo/wayland/clients/info.cc
index ac772d690..d508a548 100644
--- a/components/exo/wayland/clients/info.cc
+++ b/components/exo/wayland/clients/info.cc
@@ -17,9 +17,11 @@
namespace {
-// This struct contains globals and all the fields that will be set by
+// This struct contains all the fields that will be set by output
// interface listener callbacks.
struct Info {
+ int32_t connection;
+ int32_t device_scale_factor;
struct {
int32_t x, y;
int32_t physical_width, physical_height;
@@ -35,7 +37,6 @@
};
// |next_modes| are swapped with |modes| after receiving output done event.
std::vector<Mode> modes, next_modes;
- int32_t device_scale_factor;
struct Scale {
uint32_t flags;
int32_t scale;
@@ -43,8 +44,13 @@
// |next_scales| are swapped with |scales| after receiving output done event.
std::vector<Scale> scales, next_scales;
std::unique_ptr<wl_output> output;
+ std::unique_ptr<zaura_output> aura_output;
+};
+
+// This struct contains globals and all outputs.
+struct Globals {
std::unique_ptr<zaura_shell> aura_shell;
- wl_output_listener output_listener;
+ std::vector<Info> outputs;
};
void RegistryHandler(void* data,
@@ -52,16 +58,22 @@
uint32_t id,
const char* interface,
uint32_t version) {
- Info* info = static_cast<Info*>(data);
+ Globals* globals = static_cast<Globals*>(data);
if (strcmp(interface, "wl_output") == 0) {
- info->output.reset(static_cast<wl_output*>(
+ globals->outputs.push_back(
+ {.connection = ZAURA_OUTPUT_CONNECTION_TYPE_UNKNOWN,
+ .device_scale_factor = ZAURA_OUTPUT_SCALE_FACTOR_1000,
+ .geometry = {.subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN,
+ .make = "unknown",
+ .model = "unknown",
+ .transform = WL_OUTPUT_TRANSFORM_NORMAL}});
+ globals->outputs.back().output.reset(static_cast<wl_output*>(
wl_registry_bind(registry, id, &wl_output_interface, 2)));
- wl_output_add_listener(info->output.get(), &info->output_listener, info);
} else if (strcmp(interface, "zaura_shell") == 0) {
if (version >= 2) {
- info->aura_shell.reset(static_cast<zaura_shell*>(
- wl_registry_bind(registry, id, &zaura_shell_interface, 2)));
+ globals->aura_shell.reset(static_cast<zaura_shell*>(
+ wl_registry_bind(registry, id, &zaura_shell_interface, 5)));
}
}
}
@@ -115,7 +127,7 @@
void OutputScale(void* data, wl_output* output, int32_t scale) {
Info* info = static_cast<Info*>(data);
- info->device_scale_factor = scale;
+ info->device_scale_factor = scale * 1000;
}
void AuraOutputScale(void* data,
@@ -127,6 +139,22 @@
info->next_scales.push_back({flags, scale});
}
+void AuraOutputConnection(void* data,
+ zaura_output* output,
+ uint32_t connection) {
+ Info* info = static_cast<Info*>(data);
+
+ info->connection = connection;
+}
+
+void AuraOutputDeviceScaleFactor(void* data,
+ zaura_output* output,
+ uint32_t device_scale_factor) {
+ Info* info = static_cast<Info*>(data);
+
+ info->device_scale_factor = device_scale_factor;
+}
+
std::string OutputSubpixelToString(int32_t subpixel) {
switch (subpixel) {
case WL_OUTPUT_SUBPIXEL_UNKNOWN:
@@ -209,6 +237,17 @@
}
}
+std::string AuraOutputConnectionToString(uint32_t connection_type) {
+ switch (connection_type) {
+ case ZAURA_OUTPUT_CONNECTION_TYPE_UNKNOWN:
+ return "unknown";
+ case ZAURA_OUTPUT_CONNECTION_TYPE_INTERNAL:
+ return "internal";
+ default:
+ return "invalid";
+ }
+}
+
} // namespace
int main(int argc, char* argv[]) {
@@ -218,61 +257,73 @@
return 1;
}
- Info info = {
- .geometry = {.subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN,
- .make = "unknown",
- .model = "unknown",
- .transform = WL_OUTPUT_TRANSFORM_NORMAL},
- .output_listener = {OutputGeometry, OutputMode, OutputDone, OutputScale}};
+ Globals globals;
wl_registry_listener registry_listener = {RegistryHandler, RegistryRemover};
wl_registry* registry = wl_display_get_registry(display.get());
- wl_registry_add_listener(registry, ®istry_listener, &info);
+ wl_registry_add_listener(registry, ®istry_listener, &globals);
wl_display_roundtrip(display.get());
- std::unique_ptr<zaura_output> aura_output;
- zaura_output_listener aura_output_listener = {AuraOutputScale};
- if (info.output && info.aura_shell) {
- aura_output.reset(static_cast<zaura_output*>(
- zaura_shell_get_aura_output(info.aura_shell.get(), info.output.get())));
- zaura_output_add_listener(aura_output.get(), &aura_output_listener, &info);
+ wl_output_listener output_listener = {OutputGeometry, OutputMode, OutputDone,
+ OutputScale};
+
+ zaura_output_listener aura_output_listener = {
+ AuraOutputScale, AuraOutputConnection, AuraOutputDeviceScaleFactor};
+ for (auto& info : globals.outputs) {
+ wl_output_add_listener(info.output.get(), &output_listener, &info);
+ if (globals.aura_shell) {
+ info.aura_output.reset(
+ static_cast<zaura_output*>(zaura_shell_get_aura_output(
+ globals.aura_shell.get(), info.output.get())));
+ zaura_output_add_listener(info.aura_output.get(), &aura_output_listener,
+ &info);
+ }
}
wl_display_roundtrip(display.get());
- std::cout << "geometry:" << std::endl
- << " x: " << info.geometry.x << std::endl
- << " y: " << info.geometry.y << std::endl
- << " physical width: " << info.geometry.physical_width << " mm"
- << std::endl
- << " physical height: " << info.geometry.physical_height
- << " mm" << std::endl
- << " subpixel: "
- << OutputSubpixelToString(info.geometry.subpixel) << std::endl
- << " make: " << info.geometry.make << std::endl
- << " model: " << info.geometry.model << std::endl
- << " transform: "
- << OutputTransformToString(info.geometry.transform) << std::endl
- << std::endl;
- std::cout << "modes:" << std::endl;
- for (auto& mode : info.modes) {
- std::cout << " " << std::left << std::setw(19)
- << base::StringPrintf("%dx%d:", mode.width, mode.height)
- << std::left << std::setw(14)
- << base::StringPrintf("%.2f Hz", mode.refresh / 1000.0)
- << OutputModeFlagsToString(mode.flags) << std::endl;
- }
- std::cout << std::endl;
- std::cout << "device scale factor: " << info.device_scale_factor
- << std::endl;
- if (!info.scales.empty()) {
- std::cout << std::endl;
- std::cout << "scales:" << std::endl;
- for (auto& scale : info.scales) {
- std::cout << " " << std::left << std::setw(19)
- << (AuraOutputScaleFactorToString(scale.scale) + ":")
- << AuraOutputScaleFlagsToString(scale.flags) << std::endl;
+ for (auto& info : globals.outputs) {
+ int id = &info - &globals.outputs[0];
+ if (id)
+ std::cout << std::endl;
+ std::cout << "OUTPUT" << id << ":" << std::endl << std::endl;
+ std::cout << " connection: "
+ << AuraOutputConnectionToString(info.connection) << std::endl;
+ std::cout << " device scale factor: "
+ << AuraOutputScaleFactorToString(info.device_scale_factor)
+ << std::endl
+ << std::endl;
+ std::cout << " geometry:" << std::endl
+ << " x: " << info.geometry.x << std::endl
+ << " y: " << info.geometry.y << std::endl
+ << " physical width: " << info.geometry.physical_width
+ << " mm" << std::endl
+ << " physical height: " << info.geometry.physical_height
+ << " mm" << std::endl
+ << " subpixel: "
+ << OutputSubpixelToString(info.geometry.subpixel) << std::endl
+ << " make: " << info.geometry.make << std::endl
+ << " model: " << info.geometry.model << std::endl
+ << " transform: "
+ << OutputTransformToString(info.geometry.transform) << std::endl
+ << std::endl;
+ std::cout << " modes:" << std::endl;
+ for (auto& mode : info.modes) {
+ std::cout << " " << std::left << std::setw(19)
+ << base::StringPrintf("%dx%d:", mode.width, mode.height)
+ << std::left << std::setw(14)
+ << base::StringPrintf("%.2f Hz", mode.refresh / 1000.0)
+ << OutputModeFlagsToString(mode.flags) << std::endl;
+ }
+ if (!info.scales.empty()) {
+ std::cout << std::endl;
+ std::cout << " scales:" << std::endl;
+ for (auto& scale : info.scales) {
+ std::cout << " " << std::left << std::setw(19)
+ << (AuraOutputScaleFactorToString(scale.scale) + ":")
+ << AuraOutputScaleFlagsToString(scale.flags) << std::endl;
+ }
}
}
diff --git a/components/exo/wayland/protocol/aura-shell.xml b/components/exo/wayland/protocol/aura-shell.xml
index f947fff..02d45aa6 100644
--- a/components/exo/wayland/protocol/aura-shell.xml
+++ b/components/exo/wayland/protocol/aura-shell.xml
@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="zaura_shell" version="4">
+ <interface name="zaura_shell" version="5">
<description summary="aura_shell">
The global interface exposing aura shell capabilities is used to
instantiate an interface extension for a wl_surface object.
@@ -68,7 +68,7 @@
</request>
</interface>
- <interface name="zaura_surface" version="4">
+ <interface name="zaura_surface" version="5">
<description summary="aura shell interface to a wl_surface">
An additional interface to a wl_surface object, which allows the
client to access aura shell specific functionality for surface.
@@ -120,9 +120,18 @@
</description>
<arg name="startup_id" type="string" allow-null="true"/>
</request>
+
+ <!-- Version 5 additions -->
+
+ <request name="set_application_id" since="5">
+ <description summary="set the application ID of this surface">
+ Set the application ID.
+ </description>
+ <arg name="application_id" type="string" allow-null="true"/>
+ </request>
</interface>
- <interface name="zaura_output" version="2">
+ <interface name="zaura_output" version="5">
<description summary="aura shell interface to a wl_output">
An additional interface to a wl_output object, which allows the
client to access aura shell specific functionality for output.
@@ -156,7 +165,7 @@
<entry name="2000" value="2000"/>
</enum>
- <event name="scale">
+ <event name="scale" since="2">
<description summary="advertise available scales for the output">
The scale event describes an available scale for the output.
@@ -169,6 +178,37 @@
<arg name="flags" type="uint" enum="scale_property" summary="bitfield of scale flags"/>
<arg name="scale" type="uint" enum="scale_factor" summary="output scale"/>
</event>
+
+ <!-- Version 5 additions -->
+
+ <enum name="connection_type">
+ <entry name="unknown" value="0"/>
+ <entry name="internal" value="1"/>
+ </enum>
+
+ <event name="connection" since="5">
+ <description summary="advertise connection for the output">
+ The connection event describes how the output is connected.
+
+ The event is sent when binding to the output object.
+ </description>
+ <arg name="connection" type="uint" enum="connection_type" summary="output connection"/>
+ </event>
+
+ <event name="device_scale_factor" since="5">
+ <description summary="advertise device scale factor for the output">
+ This event describes the device specific scale factor for the output.
+
+ The device specific scale factor is not expected the change during
+ the lifetime of the output. And it is not limited to an integer value
+ like the scale factor provided by wl_output interface. The exact
+ contents scale used by the compositor can be determined by combining
+ this device scale factor with the current output scale.
+
+ The event is sent when binding to the output object.
+ </description>
+ <arg name="scale" type="uint" enum="scale_factor" summary="output device scale factor"/>
+ </event>
</interface>
</protocol>
diff --git a/components/exo/wayland/public/aura-shell-client-protocol.h b/components/exo/wayland/public/aura-shell-client-protocol.h
index cd8dbf4..18e7da7 100644
--- a/components/exo/wayland/public/aura-shell-client-protocol.h
+++ b/components/exo/wayland/public/aura-shell-client-protocol.h
@@ -219,6 +219,8 @@
#define ZAURA_SURFACE_SET_PARENT 1
#define ZAURA_SURFACE_SET_FRAME_COLORS 2
#define ZAURA_SURFACE_SET_STARTUP_ID 3
+#define ZAURA_SURFACE_SET_APPLICATION_ID 4
+
/**
* @ingroup iface_zaura_surface
@@ -236,6 +238,10 @@
* @ingroup iface_zaura_surface
*/
#define ZAURA_SURFACE_SET_STARTUP_ID_SINCE_VERSION 4
+/**
+ * @ingroup iface_zaura_surface
+ */
+#define ZAURA_SURFACE_SET_APPLICATION_ID_SINCE_VERSION 5
/** @ingroup iface_zaura_surface */
static inline void
@@ -306,11 +312,23 @@
*
* Set the startup ID.
*/
-static inline void zaura_surface_set_startup_id(
- struct zaura_surface* zaura_surface,
- const char* startup_id) {
- wl_proxy_marshal((struct wl_proxy*)zaura_surface,
- ZAURA_SURFACE_SET_STARTUP_ID, startup_id);
+static inline void
+zaura_surface_set_startup_id(struct zaura_surface *zaura_surface, const char *startup_id)
+{
+ wl_proxy_marshal((struct wl_proxy *) zaura_surface,
+ ZAURA_SURFACE_SET_STARTUP_ID, startup_id);
+}
+
+/**
+ * @ingroup iface_zaura_surface
+ *
+ * Set the application ID.
+ */
+static inline void
+zaura_surface_set_application_id(struct zaura_surface *zaura_surface, const char *application_id)
+{
+ wl_proxy_marshal((struct wl_proxy *) zaura_surface,
+ ZAURA_SURFACE_SET_APPLICATION_ID, application_id);
}
#ifndef ZAURA_OUTPUT_SCALE_PROPERTY_ENUM
@@ -352,6 +370,14 @@
};
#endif /* ZAURA_OUTPUT_SCALE_FACTOR_ENUM */
+#ifndef ZAURA_OUTPUT_CONNECTION_TYPE_ENUM
+#define ZAURA_OUTPUT_CONNECTION_TYPE_ENUM
+enum zaura_output_connection_type {
+ ZAURA_OUTPUT_CONNECTION_TYPE_UNKNOWN = 0,
+ ZAURA_OUTPUT_CONNECTION_TYPE_INTERNAL = 1,
+};
+#endif /* ZAURA_OUTPUT_CONNECTION_TYPE_ENUM */
+
/**
* @ingroup iface_zaura_output
* @struct zaura_output_listener
@@ -369,11 +395,44 @@
* scale that was received with the current flag set.
* @param flags bitfield of scale flags
* @param scale output scale
+ * @since 2
*/
void (*scale)(void *data,
struct zaura_output *zaura_output,
uint32_t flags,
uint32_t scale);
+ /**
+ * advertise connection for the output
+ *
+ * The connection event describes how the output is connected.
+ *
+ * The event is sent when binding to the output object.
+ * @param connection output connection
+ * @since 5
+ */
+ void (*connection)(void *data,
+ struct zaura_output *zaura_output,
+ uint32_t connection);
+ /**
+ * advertise device scale factor for the output
+ *
+ * This event describes the device specific scale factor for the
+ * output.
+ *
+ * The device specific scale factor is not expected the change
+ * during the lifetime of the output. And it is not limited to an
+ * integer value like the scale factor provided by wl_output
+ * interface. The exact contents scale used by the compositor can
+ * be determined by combining this device scale factor with the
+ * current output scale.
+ *
+ * The event is sent when binding to the output object.
+ * @param scale output device scale factor
+ * @since 5
+ */
+ void (*device_scale_factor)(void *data,
+ struct zaura_output *zaura_output,
+ uint32_t scale);
};
/**
@@ -390,7 +449,15 @@
/**
* @ingroup iface_zaura_output
*/
-#define ZAURA_OUTPUT_SCALE_SINCE_VERSION 1
+#define ZAURA_OUTPUT_SCALE_SINCE_VERSION 2
+/**
+ * @ingroup iface_zaura_output
+ */
+#define ZAURA_OUTPUT_CONNECTION_SINCE_VERSION 5
+/**
+ * @ingroup iface_zaura_output
+ */
+#define ZAURA_OUTPUT_DEVICE_SCALE_FACTOR_SINCE_VERSION 5
/** @ingroup iface_zaura_output */
diff --git a/components/exo/wayland/public/aura-shell-protocol.c b/components/exo/wayland/public/aura-shell-protocol.c
index 894f282..214ac7b1 100644
--- a/components/exo/wayland/public/aura-shell-protocol.c
+++ b/components/exo/wayland/public/aura-shell-protocol.c
@@ -50,7 +50,7 @@
};
WL_EXPORT const struct wl_interface zaura_shell_interface = {
- "zaura_shell", 4,
+ "zaura_shell", 5,
2, zaura_shell_requests,
0, NULL,
};
@@ -60,21 +60,24 @@
{ "set_parent", "2?oii", types + 6 },
{ "set_frame_colors", "3uu", types + 0 },
{ "set_startup_id", "4?s", types + 0 },
+ { "set_application_id", "5?s", types + 0 },
};
WL_EXPORT const struct wl_interface zaura_surface_interface = {
- "zaura_surface", 4,
- 4, zaura_surface_requests,
+ "zaura_surface", 5,
+ 5, zaura_surface_requests,
0, NULL,
};
static const struct wl_message zaura_output_events[] = {
- { "scale", "uu", types + 0 },
+ { "scale", "2uu", types + 0 },
+ { "connection", "5u", types + 0 },
+ { "device_scale_factor", "5u", types + 0 },
};
WL_EXPORT const struct wl_interface zaura_output_interface = {
- "zaura_output", 2,
+ "zaura_output", 5,
0, NULL,
- 1, zaura_output_events,
+ 3, zaura_output_events,
};
diff --git a/components/exo/wayland/public/aura-shell-server-protocol.h b/components/exo/wayland/public/aura-shell-server-protocol.h
index 1a128634..6029f5c3 100644
--- a/components/exo/wayland/public/aura-shell-server-protocol.h
+++ b/components/exo/wayland/public/aura-shell-server-protocol.h
@@ -224,15 +224,24 @@
struct wl_resource *resource,
uint32_t active_color,
uint32_t inactive_color);
- /**
- * set the startup ID of this surface
- *
- * Set the startup ID.
- * @since 4
- */
- void (*set_startup_id)(struct wl_client* client,
- struct wl_resource* resource,
- const char* startup_id);
+ /**
+ * set the startup ID of this surface
+ *
+ * Set the startup ID.
+ * @since 4
+ */
+ void (*set_startup_id)(struct wl_client *client,
+ struct wl_resource *resource,
+ const char *startup_id);
+ /**
+ * set the application ID of this surface
+ *
+ * Set the application ID.
+ * @since 5
+ */
+ void (*set_application_id)(struct wl_client *client,
+ struct wl_resource *resource,
+ const char *application_id);
};
@@ -252,6 +261,10 @@
* @ingroup iface_zaura_surface
*/
#define ZAURA_SURFACE_SET_STARTUP_ID_SINCE_VERSION 4
+/**
+ * @ingroup iface_zaura_surface
+ */
+#define ZAURA_SURFACE_SET_APPLICATION_ID_SINCE_VERSION 5
#ifndef ZAURA_OUTPUT_SCALE_PROPERTY_ENUM
#define ZAURA_OUTPUT_SCALE_PROPERTY_ENUM
@@ -292,12 +305,30 @@
};
#endif /* ZAURA_OUTPUT_SCALE_FACTOR_ENUM */
+#ifndef ZAURA_OUTPUT_CONNECTION_TYPE_ENUM
+#define ZAURA_OUTPUT_CONNECTION_TYPE_ENUM
+enum zaura_output_connection_type {
+ ZAURA_OUTPUT_CONNECTION_TYPE_UNKNOWN = 0,
+ ZAURA_OUTPUT_CONNECTION_TYPE_INTERNAL = 1,
+};
+#endif /* ZAURA_OUTPUT_CONNECTION_TYPE_ENUM */
+
#define ZAURA_OUTPUT_SCALE 0
+#define ZAURA_OUTPUT_CONNECTION 1
+#define ZAURA_OUTPUT_DEVICE_SCALE_FACTOR 2
/**
* @ingroup iface_zaura_output
*/
-#define ZAURA_OUTPUT_SCALE_SINCE_VERSION 1
+#define ZAURA_OUTPUT_SCALE_SINCE_VERSION 2
+/**
+ * @ingroup iface_zaura_output
+ */
+#define ZAURA_OUTPUT_CONNECTION_SINCE_VERSION 5
+/**
+ * @ingroup iface_zaura_output
+ */
+#define ZAURA_OUTPUT_DEVICE_SCALE_FACTOR_SINCE_VERSION 5
/**
@@ -313,6 +344,30 @@
wl_resource_post_event(resource_, ZAURA_OUTPUT_SCALE, flags, scale);
}
+/**
+ * @ingroup iface_zaura_output
+ * Sends an connection event to the client owning the resource.
+ * @param resource_ The client's resource
+ * @param connection output connection
+ */
+static inline void
+zaura_output_send_connection(struct wl_resource *resource_, uint32_t connection)
+{
+ wl_resource_post_event(resource_, ZAURA_OUTPUT_CONNECTION, connection);
+}
+
+/**
+ * @ingroup iface_zaura_output
+ * Sends an device_scale_factor event to the client owning the resource.
+ * @param resource_ The client's resource
+ * @param scale output device scale factor
+ */
+static inline void
+zaura_output_send_device_scale_factor(struct wl_resource *resource_, uint32_t scale)
+{
+ wl_resource_post_event(resource_, ZAURA_OUTPUT_DEVICE_SCALE_FACTOR, scale);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
index 4524d23..3daa2682 100644
--- a/components/exo/wayland/server.cc
+++ b/components/exo/wayland/server.cc
@@ -1706,7 +1706,7 @@
void xdg_toplevel_v6_set_app_id(wl_client* client,
wl_resource* resource,
const char* app_id) {
- GetUserDataAs<WaylandToplevel>(resource)->SetApplicationId(app_id);
+ NOTIMPLEMENTED();
}
void xdg_toplevel_v6_show_window_menu(wl_client* client,
@@ -2776,6 +2776,11 @@
surface_->SetStartupId(startup_id);
}
+ void SetApplicationId(const char* application_id) {
+ if (surface_)
+ surface_->SetApplicationId(application_id);
+ }
+
// Overridden from SurfaceObserver:
void OnSurfaceDestroying(Surface* surface) override {
surface->RemoveSurfaceObserver(this);
@@ -2831,9 +2836,16 @@
GetUserDataAs<AuraSurface>(resource)->SetStartupId(startup_id);
}
+void aura_surface_set_application_id(wl_client* client,
+ wl_resource* resource,
+ const char* application_id) {
+ GetUserDataAs<AuraSurface>(resource)->SetApplicationId(application_id);
+}
+
const struct zaura_surface_interface aura_surface_implementation = {
aura_surface_set_frame, aura_surface_set_parent,
- aura_surface_set_frame_colors, aura_surface_set_startup_id};
+ aura_surface_set_frame_colors, aura_surface_set_startup_id,
+ aura_surface_set_application_id};
////////////////////////////////////////////////////////////////////////////////
// aura_output_interface:
@@ -2845,28 +2857,47 @@
// Overridden from WaylandDisplayObserver::ScaleObserver:
void OnDisplayScalesChanged(const display::Display& display) override {
display::DisplayManager* display_manager =
- ash::Shell::Get()->display_manager();
- if (display_manager->GetDisplayIdForUIScaling() == display.id()) {
- display::ManagedDisplayMode active_mode;
- bool rv = display_manager->GetActiveModeForDisplayId(display.id(),
- &active_mode);
- DCHECK(rv);
- const display::ManagedDisplayInfo& display_info =
+ ash::Shell::Get()->display_manager();
+ const display::ManagedDisplayInfo& display_info =
display_manager->GetDisplayInfo(display.id());
- for (auto& mode : display_info.display_modes()) {
- uint32_t flags = 0;
- if (mode.is_default())
- flags |= ZAURA_OUTPUT_SCALE_PROPERTY_PREFERRED;
- if (active_mode.IsEquivalent(mode))
- flags |= ZAURA_OUTPUT_SCALE_PROPERTY_CURRENT;
- zaura_output_send_scale(resource_, flags, mode.ui_scale() * 1000);
+ if (wl_resource_get_version(resource_) >=
+ ZAURA_OUTPUT_SCALE_SINCE_VERSION) {
+ if (display_manager->GetDisplayIdForUIScaling() == display.id()) {
+ display::ManagedDisplayMode active_mode;
+ bool rv = display_manager->GetActiveModeForDisplayId(display.id(),
+ &active_mode);
+ DCHECK(rv);
+ for (auto& mode : display_info.display_modes()) {
+ uint32_t flags = 0;
+ if (mode.is_default())
+ flags |= ZAURA_OUTPUT_SCALE_PROPERTY_PREFERRED;
+ if (active_mode.IsEquivalent(mode))
+ flags |= ZAURA_OUTPUT_SCALE_PROPERTY_CURRENT;
+
+ zaura_output_send_scale(resource_, flags, mode.ui_scale() * 1000);
+ }
+ } else {
+ zaura_output_send_scale(resource_,
+ ZAURA_OUTPUT_SCALE_PROPERTY_CURRENT |
+ ZAURA_OUTPUT_SCALE_PROPERTY_PREFERRED,
+ ZAURA_OUTPUT_SCALE_FACTOR_1000);
}
- } else {
- zaura_output_send_scale(resource_,
- ZAURA_OUTPUT_SCALE_PROPERTY_CURRENT |
- ZAURA_OUTPUT_SCALE_PROPERTY_PREFERRED,
- ZAURA_OUTPUT_SCALE_FACTOR_1000);
+ }
+
+ if (wl_resource_get_version(resource_) >=
+ ZAURA_OUTPUT_CONNECTION_SINCE_VERSION) {
+ zaura_output_send_connection(resource_,
+ display.IsInternal()
+ ? ZAURA_OUTPUT_CONNECTION_TYPE_INTERNAL
+ : ZAURA_OUTPUT_CONNECTION_TYPE_UNKNOWN);
+ }
+
+ if (wl_resource_get_version(resource_) >=
+ ZAURA_OUTPUT_DEVICE_SCALE_FACTOR_SINCE_VERSION) {
+ zaura_output_send_device_scale_factor(resource_,
+ display_info.device_scale_factor() *
+ 1000);
}
}
@@ -2924,7 +2955,7 @@
const struct zaura_shell_interface aura_shell_implementation = {
aura_shell_get_aura_surface, aura_shell_get_aura_output};
-const uint32_t aura_shell_version = 4;
+const uint32_t aura_shell_version = 5;
void bind_aura_shell(wl_client* client,
void* data,