From: Alexandros Frantzis alexandros.frantzis@collabora.com
Use the xdg-output-unstable-v1 protocol to get a unique, cross-process consistent name for the outputs.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- configure | 50 +++- configure.ac | 4 +- dlls/winewayland.drv/Makefile.in | 3 + dlls/winewayland.drv/wayland.c | 12 + dlls/winewayland.drv/wayland_output.c | 111 ++++++++- dlls/winewayland.drv/waylanddrv.h | 6 +- .../xdg-output-unstable-v1.xml | 220 ++++++++++++++++++ 7 files changed, 392 insertions(+), 14 deletions(-) create mode 100644 dlls/winewayland.drv/xdg-output-unstable-v1.xml
diff --git a/configure b/configure index 647a1237469..39da5cca1f5 100755 --- a/configure +++ b/configure @@ -702,6 +702,7 @@ INOTIFY_LIBS INOTIFY_CFLAGS PCSCLITE_LIBS PCAP_LIBS +WAYLAND_SCANNER WAYLAND_CLIENT_LIBS WAYLAND_CLIENT_CFLAGS X_EXTRA_LIBS @@ -15640,8 +15641,54 @@ fi
CPPFLAGS=$ac_save_CPPFLAGS
+ # Extract the first word of "wayland-scanner", so it can be a program name with args. +set dummy wayland-scanner; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_WAYLAND_SCANNER+y} +then : + printf %s "(cached) " >&6 +else $as_nop + case $WAYLAND_SCANNER in + [\/]* | ?:[\/]*) + ac_cv_path_WAYLAND_SCANNER="$WAYLAND_SCANNER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_WAYLAND_SCANNER="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_WAYLAND_SCANNER" && ac_cv_path_WAYLAND_SCANNER="`test -n "$PKG_CONFIG" && $PKG_CONFIG --variable=wayland_scanner wayland-scanner`" + ;; +esac +fi +WAYLAND_SCANNER=$ac_cv_path_WAYLAND_SCANNER +if test -n "$WAYLAND_SCANNER"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WAYLAND_SCANNER" >&5 +printf "%s\n" "$WAYLAND_SCANNER" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + fi -if test -z "$WAYLAND_CLIENT_LIBS" +if test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" then : case "x$with_wayland" in x) as_fn_append wine_notices "|Wayland ${notice_platform}development files not found, the Wayland driver won't be supported." ;; @@ -23147,6 +23194,7 @@ X_LIBS = $X_LIBS X_EXTRA_LIBS = $X_EXTRA_LIBS WAYLAND_CLIENT_CFLAGS = $WAYLAND_CLIENT_CFLAGS WAYLAND_CLIENT_LIBS = $WAYLAND_CLIENT_LIBS +WAYLAND_SCANNER = $WAYLAND_SCANNER PCAP_LIBS = $PCAP_LIBS PCSCLITE_LIBS = $PCSCLITE_LIBS INOTIFY_CFLAGS = $INOTIFY_CFLAGS diff --git a/configure.ac b/configure.ac index 5ff1bb093f4..8a1c62ddb15 100644 --- a/configure.ac +++ b/configure.ac @@ -1342,8 +1342,10 @@ then [AC_CHECK_HEADERS([wayland-client.h]) AC_CHECK_LIB(wayland-client,wl_display_connect,[:], [WAYLAND_CLIENT_LIBS=""],[$WAYLAND_CLIENT_LIBS])]) + AC_PATH_PROG(WAYLAND_SCANNER,wayland-scanner, + [`test -n "$PKG_CONFIG" && $PKG_CONFIG --variable=wayland_scanner wayland-scanner`]) fi -WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS"], +WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER"], [Wayland ${notice_platform}development files not found, the Wayland driver won't be supported.], [enable_winewayland_drv])
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index d86b51a519f..326a9d765c8 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -10,4 +10,7 @@ C_SRCS = \ wayland_output.c \ waylanddrv_main.c
+WAYLAND_PROTOCOL_SRCS = \ + xdg-output-unstable-v1.xml + RC_SRCS = version.rc diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 104a091ea80..30ef22df52d 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -50,6 +50,18 @@ static void registry_handle_global(void *data, struct wl_registry *registry, if (!wayland_output_create(id, version)) ERR("Failed to create wayland_output for global id=%u\n", id); } + else if (strcmp(interface, "zxdg_output_manager_v1") == 0) + { + struct wayland_output *output; + + process_wayland->zxdg_output_manager_v1 = + wl_registry_bind(registry, id, &zxdg_output_manager_v1_interface, + version < 3 ? version : 3); + + /* Add zxdg_output_v1 to existing outputs. */ + wl_list_for_each(output, &process_wayland->output_list, link) + wayland_output_use_xdg_extension(output); + } }
static void registry_handle_global_remove(void *data, struct wl_registry *registry, diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c index be9ea32bd72..8eb24fe97f3 100644 --- a/dlls/winewayland.drv/wayland_output.c +++ b/dlls/winewayland.drv/wayland_output.c @@ -97,6 +97,22 @@ static void wayland_output_add_mode(struct wayland_output *output, if (current) output->current_mode = mode; }
+static void wayland_output_done(struct wayland_output *output) +{ + struct wayland_output_mode *mode; + + TRACE("name=%s\n", output->name); + + RB_FOR_EACH_ENTRY(mode, &output->modes, struct wayland_output_mode, entry) + { + TRACE("mode %dx%d @ %d %s\n", + mode->width, mode->height, mode->refresh, + output->current_mode == mode ? "*" : ""); + } + + wayland_init_display_devices(); +} + static void output_handle_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t physical_width, int32_t physical_height, @@ -122,18 +138,12 @@ static void output_handle_mode(void *data, struct wl_output *wl_output, static void output_handle_done(void *data, struct wl_output *wl_output) { struct wayland_output *output = data; - struct wayland_output_mode *mode; - - TRACE("name=%s\n", output->name);
- RB_FOR_EACH_ENTRY(mode, &output->modes, struct wayland_output_mode, entry) + if (!output->zxdg_output_v1 || + zxdg_output_v1_get_version(output->zxdg_output_v1) >= 3) { - TRACE("mode %dx%d @ %d %s\n", - mode->width, mode->height, mode->refresh, - output->current_mode == mode ? "*" : ""); + wayland_output_done(output); } - - wayland_init_display_devices(); }
static void output_handle_scale(void *data, struct wl_output *wl_output, @@ -148,6 +158,54 @@ static const struct wl_output_listener output_listener = { output_handle_scale };
+static void zxdg_output_v1_handle_logical_position(void *data, + struct zxdg_output_v1 *zxdg_output_v1, + int32_t x, + int32_t y) +{ +} + +static void zxdg_output_v1_handle_logical_size(void *data, + struct zxdg_output_v1 *zxdg_output_v1, + int32_t width, + int32_t height) +{ +} + +static void zxdg_output_v1_handle_done(void *data, + struct zxdg_output_v1 *zxdg_output_v1) +{ + if (zxdg_output_v1_get_version(zxdg_output_v1) < 3) + { + struct wayland_output *output = data; + wayland_output_done(output); + } +} + +static void zxdg_output_v1_handle_name(void *data, + struct zxdg_output_v1 *zxdg_output_v1, + const char *name) +{ + struct wayland_output *output = data; + + free(output->name); + output->name = strdup(name); +} + +static void zxdg_output_v1_handle_description(void *data, + struct zxdg_output_v1 *zxdg_output_v1, + const char *description) +{ +} + +static const struct zxdg_output_v1_listener zxdg_output_v1_listener = { + zxdg_output_v1_handle_logical_position, + zxdg_output_v1_handle_logical_size, + zxdg_output_v1_handle_done, + zxdg_output_v1_handle_name, + zxdg_output_v1_handle_description, +}; + /********************************************************************** * wayland_output_create * @@ -156,6 +214,7 @@ static const struct wl_output_listener output_listener = { BOOL wayland_output_create(uint32_t id, uint32_t version) { struct wayland_output *output = calloc(1, sizeof(*output)); + int name_len;
if (!output) { @@ -172,8 +231,21 @@ BOOL wayland_output_create(uint32_t id, uint32_t version) wl_list_init(&output->link); rb_init(&output->modes, wayland_output_mode_cmp_rb);
- snprintf(output->name, sizeof(output->name), "WaylandOutput%d", - next_output_id++); + /* Have a fallback while we don't have compositor given name. */ + name_len = snprintf(NULL, 0, "WaylandOutput%d", next_output_id); + output->name = malloc(name_len + 1); + if (output->name) + { + snprintf(output->name, name_len + 1, "WaylandOutput%d", next_output_id++); + } + else + { + ERR("Couldn't allocate space for output name\n"); + goto err; + } + + if (process_wayland->zxdg_output_manager_v1) + wayland_output_use_xdg_extension(output);
wl_list_insert(process_wayland->output_list.prev, &output->link);
@@ -198,6 +270,23 @@ void wayland_output_destroy(struct wayland_output *output) { rb_destroy(&output->modes, wayland_output_mode_free_rb, NULL); wl_list_remove(&output->link); + if (output->zxdg_output_v1) + zxdg_output_v1_destroy(output->zxdg_output_v1); wl_output_destroy(output->wl_output); + free(output->name); free(output); } + +/********************************************************************** + * wayland_output_use_xdg_extension + * + * Use the zxdg_output_v1 extension to get output information. + */ +void wayland_output_use_xdg_extension(struct wayland_output *output) +{ + output->zxdg_output_v1 = + zxdg_output_manager_v1_get_xdg_output(process_wayland->zxdg_output_manager_v1, + output->wl_output); + zxdg_output_v1_add_listener(output->zxdg_output_v1, &zxdg_output_v1_listener, + output); +} diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 8458ed17df2..da0fccecda9 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -26,6 +26,7 @@ #endif
#include <wayland-client.h> +#include "xdg-output-unstable-v1-client-protocol.h"
#include "windef.h" #include "winbase.h" @@ -49,6 +50,7 @@ struct wayland { struct wl_event_queue *wl_event_queue; struct wl_registry *wl_registry; + struct zxdg_output_manager_v1 *zxdg_output_manager_v1; struct wl_list output_list; };
@@ -64,9 +66,10 @@ struct wayland_output { struct wl_list link; struct wl_output *wl_output; + struct zxdg_output_v1 *zxdg_output_v1; struct rb_tree modes; struct wayland_output_mode *current_mode; - char name[20]; + char *name; uint32_t global_id; };
@@ -83,6 +86,7 @@ void wayland_init_display_devices(void) DECLSPEC_HIDDEN;
BOOL wayland_output_create(uint32_t id, uint32_t version) DECLSPEC_HIDDEN; void wayland_output_destroy(struct wayland_output *output) DECLSPEC_HIDDEN; +void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HIDDEN;
/********************************************************************** * USER driver functions diff --git a/dlls/winewayland.drv/xdg-output-unstable-v1.xml b/dlls/winewayland.drv/xdg-output-unstable-v1.xml new file mode 100644 index 00000000000..9a5b7900097 --- /dev/null +++ b/dlls/winewayland.drv/xdg-output-unstable-v1.xml @@ -0,0 +1,220 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="xdg_output_unstable_v1"> + + <copyright> + Copyright © 2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + </copyright> + + <description summary="Protocol to describe output regions"> + This protocol aims at describing outputs in a way which is more in line + with the concept of an output on desktop oriented systems. + + Some information are more specific to the concept of an output for + a desktop oriented system and may not make sense in other applications, + such as IVI systems for example. + + Typically, the global compositor space on a desktop system is made of + a contiguous or overlapping set of rectangular regions. + + Some of the information provided in this protocol might be identical + to their counterparts already available from wl_output, in which case + the information provided by this protocol should be preferred to their + equivalent in wl_output. The goal is to move the desktop specific + concepts (such as output location within the global compositor space, + the connector name and types, etc.) out of the core wl_output protocol. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible + changes may be added together with the corresponding interface + version bump. + Backward incompatible changes are done by bumping the version + number in the protocol and interface names and resetting the + interface version. Once the protocol is to be declared stable, + the 'z' prefix and the version number in the protocol and + interface names are removed and the interface version number is + reset. + </description> + + <interface name="zxdg_output_manager_v1" version="3"> + <description summary="manage xdg_output objects"> + A global factory interface for xdg_output objects. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_output_manager object"> + Using this request a client can tell the server that it is not + going to use the xdg_output_manager object anymore. + + Any objects already created through this instance are not affected. + </description> + </request> + + <request name="get_xdg_output"> + <description summary="create an xdg output from a wl_output"> + This creates a new xdg_output object for the given wl_output. + </description> + <arg name="id" type="new_id" interface="zxdg_output_v1"/> + <arg name="output" type="object" interface="wl_output"/> + </request> + </interface> + + <interface name="zxdg_output_v1" version="3"> + <description summary="compositor logical output region"> + An xdg_output describes part of the compositor geometry. + + This typically corresponds to a monitor that displays part of the + compositor space. + + For objects version 3 onwards, after all xdg_output properties have been + sent (when the object is created and when properties are updated), a + wl_output.done event is sent. This allows changes to the output + properties to be seen as atomic, even if they happen via multiple events. + </description> + + <request name="destroy" type="destructor"> + <description summary="destroy the xdg_output object"> + Using this request a client can tell the server that it is not + going to use the xdg_output object anymore. + </description> + </request> + + <event name="logical_position"> + <description summary="position of the output within the global compositor space"> + The position event describes the location of the wl_output within + the global compositor space. + + The logical_position event is sent after creating an xdg_output + (see xdg_output_manager.get_xdg_output) and whenever the location + of the output changes within the global compositor space. + </description> + <arg name="x" type="int" + summary="x position within the global compositor space"/> + <arg name="y" type="int" + summary="y position within the global compositor space"/> + </event> + + <event name="logical_size"> + <description summary="size of the output in the global compositor space"> + The logical_size event describes the size of the output in the + global compositor space. + + For example, a surface without any buffer scale, transformation + nor rotation set, with the size matching the logical_size will + have the same size as the corresponding output when displayed. + + Most regular Wayland clients should not pay attention to the + logical size and would rather rely on xdg_shell interfaces. + + Some clients such as Xwayland, however, need this to configure + their surfaces in the global compositor space as the compositor + may apply a different scale from what is advertised by the output + scaling property (to achieve fractional scaling, for example). + + For example, for a wl_output mode 3840×2160 and a scale factor 2: + + - A compositor not scaling the surface buffers will advertise a + logical size of 3840×2160, + + - A compositor automatically scaling the surface buffers will + advertise a logical size of 1920×1080, + + - A compositor using a fractional scale of 1.5 will advertise a + logical size of 2560×1440. + + For example, for a wl_output mode 1920×1080 and a 90 degree rotation, + the compositor will advertise a logical size of 1080x1920. + + The logical_size event is sent after creating an xdg_output + (see xdg_output_manager.get_xdg_output) and whenever the logical + size of the output changes, either as a result of a change in the + applied scale or because of a change in the corresponding output + mode(see wl_output.mode) or transform (see wl_output.transform). + </description> + <arg name="width" type="int" + summary="width in global compositor space"/> + <arg name="height" type="int" + summary="height in global compositor space"/> + </event> + + <event name="done"> + <description summary="all information about the output have been sent"> + This event is sent after all other properties of an xdg_output + have been sent. + + This allows changes to the xdg_output properties to be seen as + atomic, even if they happen via multiple events. + + For objects version 3 onwards, this event is deprecated. Compositors + are not required to send it anymore and must send wl_output.done + instead. + </description> + </event> + + <!-- Version 2 additions --> + + <event name="name" since="2"> + <description summary="name of this output"> + Many compositors will assign names to their outputs, show them to the + user, allow them to be configured by name, etc. The client may wish to + know this name as well to offer the user similar behaviors. + + The naming convention is compositor defined, but limited to + alphanumeric characters and dashes (-). Each name is unique among all + wl_output globals, but if a wl_output global is destroyed the same name + may be reused later. The names will also remain consistent across + sessions with the same hardware and software configuration. + + Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do + not assume that the name is a reflection of an underlying DRM + connector, X11 connection, etc. + + The name event is sent after creating an xdg_output (see + xdg_output_manager.get_xdg_output). This event is only sent once per + xdg_output, and the name does not change over the lifetime of the + wl_output global. + </description> + <arg name="name" type="string" summary="output name"/> + </event> + + <event name="description" since="2"> + <description summary="human-readable description of this output"> + Many compositors can produce human-readable descriptions of their + outputs. The client may wish to know this description as well, to + communicate the user for various purposes. + + The description is a UTF-8 string with no convention defined for its + contents. Examples might include 'Foocorp 11" Display' or 'Virtual X11 + output via :1'. + + The description event is sent after creating an xdg_output (see + xdg_output_manager.get_xdg_output) and whenever the description + changes. The description is optional, and may not be sent at all. + + For objects of version 2 and lower, this event is only sent once per + xdg_output, and the description does not change over the lifetime of + the wl_output global. + </description> + <arg name="description" type="string" summary="output description"/> + </event> + + </interface> +</protocol>