This second MR in the Wayland series adds display configuration related enhancements, including providing more display information (like a proper/consistent name and position) to Wine and implementing GetCurrentDisplaySettings.
To get additional information from the Wayland compositor we need to use a protocol from the wayland-protocols collection, so we introduce support in the build system for protocol .xml files. These changes are introduced on their own in the first commit in the series, but we can squash it with the next commit, where the functionality is first used, if preferred.
To be able to provide a consistent view of the display settings across all processes, this MR adds a shared memory region containing an authoritative version of the Wayland output information (see the "winewayland.drv: Implement GetCurrentDisplaySettings." commit for more details).
Thanks!
-- v2: winewayland.drv: Update desktop window size on display changes. winewayland.drv: Update registry settings after monitor changes. winewayland.drv: Infer and report Windows monitor positions. winewayland.drv: Handle wl_output objects only in the desktop process. winewayland.drv: Implement GetCurrentDisplaySettings. winewayland.drv: Use the output name reported by the compositor. tools: Support building Wayland protocol source files.
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Wayland protocol descriptions are distributed as source XML files that need to be transformed to C source and header files with a version of the wayland-scanner tool compatible with the used libwayland library.
This commit enhances the makedep build tool to support building such Wayland protocol XML files. Components can use the WAYLAND_PROTOCOL_SRCS build variable to add protocol XML files to their build.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- tools/makedep.c | 57 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index 49a7514c9f0..10ddebc0df9 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -100,6 +100,7 @@ struct incl_file #define FLAG_C_IMPLIB 0x040000 /* file is part of an import library */ #define FLAG_C_UNIX 0x080000 /* file is part of a Unix library */ #define FLAG_SFD_FONTS 0x100000 /* sfd file generated bitmap fonts */ +#define FLAG_WAYLAND_PROTO 0x200000 /* generates wayland protocol .c/.h files */
static const struct { @@ -157,6 +158,7 @@ static const char *icotool; static const char *msgfmt; static const char *ln_s; static const char *sed_cmd; +static const char *wayland_scanner; /* per-architecture global variables */ static const char *arch_dirs[MAX_ARCHS]; static const char *arch_pe_dirs[MAX_ARCHS]; @@ -470,7 +472,6 @@ static char *replace_filename( const char *path, const char *name ) return ret; }
- /******************************************************************* * replace_substr */ @@ -1176,6 +1177,25 @@ static void parse_sfd_file( struct file *source, FILE *file ) }
+/******************************************************************* + * parse_xml_file + */ +static void parse_xml_file( struct file *source, FILE *file ) +{ + char *buffer; + + input_line = 0; + while ((buffer = get_line( file ))) + { + if (strstr( buffer, "<protocol name=" )) + { + source->flags |= FLAG_WAYLAND_PROTO; + break; + } + } +} + + static const struct { const char *ext; @@ -1193,7 +1213,8 @@ static const struct { ".idl", parse_idl_file }, { ".rc", parse_rc_file }, { ".in", parse_in_file }, - { ".sfd", parse_sfd_file } + { ".sfd", parse_sfd_file }, + { ".xml", parse_xml_file } };
/******************************************************************* @@ -1389,7 +1410,6 @@ static struct file *open_src_file( const struct makefile *make, struct incl_file return file; }
- /******************************************************************* * find_importlib_module */ @@ -1428,6 +1448,7 @@ static struct file *open_include_file( const struct makefile *make, struct incl_ if ((file = open_local_generated_file( make, pFile, ".cur", ".svg" ))) return file; if ((file = open_local_generated_file( make, pFile, ".ico", ".svg" ))) return file; } + if ((file = open_local_generated_file( make, pFile, "-client-protocol.h", ".xml" ))) return file;
/* check for extra targets */ if (strarray_exists( &make->extra_targets, pFile->name )) @@ -1802,7 +1823,6 @@ static struct makefile *parse_makefile( const char *path ) return make; }
- /******************************************************************* * add_generated_sources */ @@ -1915,6 +1935,21 @@ static void add_generated_sources( struct makefile *make ) strarray_addall_uniq( &make->extra_imports, get_expanded_file_local_var( make, obj, "IMPORTS" )); } + if (source->file->flags & FLAG_WAYLAND_PROTO) + { + char *code_name = replace_extension ( source->name , ".xml", "-protocol.c" ); + char *header_name = replace_extension ( source->name , ".xml", "-client-protocol.h" ); + + file = add_generated_source( make, code_name, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + file = add_generated_source( make, header_name, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + + free( code_name ); + free( header_name ); + } } if (make->testdll) { @@ -3101,6 +3136,16 @@ static void output_source_spec( struct makefile *make, struct incl_file *source, } }
+static void output_source_xml( struct makefile *make, struct incl_file *source, const char *obj ) +{ + if ((source->file->flags & FLAG_WAYLAND_PROTO) && wayland_scanner) + { + output( "%s-protocol.c: %s\n", obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s private-code $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner ); + output( "%s-client-protocol.h: %s\n", obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s client-header $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner); + } +}
/******************************************************************* * output_source_one_arch @@ -3240,6 +3285,7 @@ static const struct { "in", output_source_in }, { "x", output_source_x }, { "spec", output_source_spec }, + { "xml", output_source_xml }, { NULL, output_source_default } };
@@ -4054,6 +4100,7 @@ static void output_silent_rules(void) "MSG", "SED", "TEST", + "WAYLAND_SCANNER", "WIDL", "WMC", "WRC" @@ -4153,6 +4200,7 @@ static void load_sources( struct makefile *make ) "IN_SRCS", "PO_SRCS", "MANPAGES", + "WAYLAND_PROTOCOL_SRCS", NULL }; const char **var; @@ -4383,6 +4431,7 @@ int main( int argc, char *argv[] ) msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" ); sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" ); ln_s = get_expanded_make_variable( top_makefile, "LN_S" ); + wayland_scanner = get_expanded_make_variable( top_makefile, "WAYLAND_SCANNER" );
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL; if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;
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>
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Implement the GetCurrentDisplaySettings driver callback by reading display device information from a memory region shared between all processes.
The desktop window process is responsible for maintaining the information in this region, thus providing an authoritative version of display device information, which is also in sync with the Windows configuration, for all other processes to use.
Wayland doesn't provide a mechanism to get the latest output information in a cross-process consistent form from some central point, instead relying on events from which each client builds its own view of the current configuration. Without some single source of truth like the one provided by this shared memory region, it's challenging to maintain consistency between processes in terms of current configuration and mappings from wl_outputs to to Windows monitors.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/Makefile.in | 2 +- dlls/winewayland.drv/display.c | 198 +++++++++++++++++++++++-- dlls/winewayland.drv/waylanddrv.h | 3 + dlls/winewayland.drv/waylanddrv_main.c | 2 + 4 files changed, 188 insertions(+), 17 deletions(-)
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index 326a9d765c8..faa6186db21 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -1,7 +1,7 @@ MODULE = winewayland.drv UNIXLIB = winewayland.so UNIX_CFLAGS = $(WAYLAND_CLIENT_CFLAGS) -UNIX_LIBS = -lwin32u $(WAYLAND_CLIENT_LIBS) +UNIX_LIBS = -lwin32u $(WAYLAND_CLIENT_LIBS) $(PTHREAD_LIBS)
C_SRCS = \ display.c \ diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index e72b26a9da0..640829142c1 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -30,10 +30,77 @@
#include "ntuser.h"
+#include <pthread.h> + WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
static BOOL force_display_devices_refresh;
+struct output_info +{ + char name[128]; + struct wayland_output_mode modes[128]; + int num_modes; + int current_mode; +}; + +struct display_devices +{ + struct output_info outputs[16]; + int num_outputs; + pthread_mutex_t mutex; +}; + +static HANDLE display_devices_handle; +static struct display_devices *display_devices; + +BOOL wayland_display_devices_process_init(void) +{ + OBJECT_ATTRIBUTES attr; + LARGE_INTEGER size; + SIZE_T count = 0; + WCHAR name[] = {'\','?','?','\','W','a','y','l','a','n','d', + 'D','i','s','p','l','a','y','D','e','v','i','c','e','s'}; + UNICODE_STRING nameW = {sizeof(name), sizeof(name), name}; + NTSTATUS status; + + size.QuadPart = sizeof(*display_devices); + InitializeObjectAttributes(&attr, &nameW, OBJ_OPENIF, NULL, NULL); + status = NtCreateSection(&display_devices_handle, + SECTION_MAP_READ | SECTION_MAP_WRITE, + &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0); + if (status != 0 && !(status & ERROR_SEVERITY_INFORMATIONAL)) + { + ERR("Failed to create or open WaylandDisplayDevices shared memory\n"); + return FALSE; + } + + if (NtMapViewOfSection(display_devices_handle, GetCurrentProcess(), + (PVOID)&display_devices, 0, 0, + NULL, &count, ViewShare, 0, PAGE_READWRITE)) + { + ERR("Failed to map WaylandDisplayDevices shared memory\n"); + return FALSE; + } + + /* Initialize the shared memory contents if we just created it. */ + if (status == 0) + { + pthread_mutexattr_t mutexattr; + + pthread_mutexattr_init(&mutexattr); + pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_DEFAULT); + pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED); + pthread_mutex_init(&display_devices->mutex, &mutexattr); + pthread_mutexattr_destroy(&mutexattr); + } + + TRACE("status=0x%lx handle=%p map=%p\n", + (long)status, display_devices_handle, display_devices); + + return TRUE; +} + static void wayland_refresh_display_devices(void) { UINT32 num_path, num_mode; @@ -85,13 +152,12 @@ static void wayland_add_device_adapter(const struct gdi_device_manager *device_m }
static void wayland_add_device_monitor(const struct gdi_device_manager *device_manager, - void *param, struct wayland_output *output) + void *param, struct output_info *output_info) { struct gdi_monitor monitor = {0}; + struct wayland_output_mode *mode = &output_info->modes[output_info->current_mode];
- SetRect(&monitor.rc_monitor, 0, 0, - output->current_mode->width, - output->current_mode->height); + SetRect(&monitor.rc_monitor, 0, 0, mode->width, mode->height);
/* We don't have a direct way to get the work area in Wayland. */ monitor.rc_work = monitor.rc_monitor; @@ -99,7 +165,7 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m monitor.state_flags = DISPLAY_DEVICE_ATTACHED | DISPLAY_DEVICE_ACTIVE;
TRACE("name=%s rc_monitor=rc_work=%s state_flags=0x%x\n", - output->name, wine_dbgstr_rect(&monitor.rc_monitor), + output_info->name, wine_dbgstr_rect(&monitor.rc_monitor), (UINT)monitor.state_flags);
device_manager->add_monitor(&monitor, param); @@ -118,26 +184,52 @@ static void populate_devmode(struct wayland_output_mode *output_mode, DEVMODEW * }
static void wayland_add_device_modes(const struct gdi_device_manager *device_manager, - void *param, struct wayland_output *output) + void *param, struct output_info *output_info) { - struct wayland_output_mode *output_mode; + int i;
- RB_FOR_EACH_ENTRY(output_mode, &output->modes, struct wayland_output_mode, entry) + for (i = 0; i < output_info->num_modes; i++) { DEVMODEW mode; - populate_devmode(output_mode, &mode); + populate_devmode(&output_info->modes[i], &mode); device_manager->add_mode(&mode, param); } }
+static void display_devices_update_output(struct output_info *output_info, + struct wayland_output *output) +{ + struct wayland_output_mode *mode; + int mode_i = 0; + + lstrcpynA(output_info->name, output->name, sizeof(output_info->name)); + if (strlen(output_info->name) != strlen(output->name)) + WARN("wayland output name %s is too long, truncating\n", output->name); + + RB_FOR_EACH_ENTRY(mode, &output->modes, struct wayland_output_mode, entry) + { + if (mode_i >= ARRAYSIZE(output_info->modes)) + { + WARN("wayland reported too many modes for %s, ignoring\n", + output->name); + continue; + } + output_info->modes[mode_i] = *mode; + if (mode == output->current_mode) output_info->current_mode = mode_i; + mode_i++; + } + + output_info->num_modes = mode_i; +} + /*********************************************************************** * UpdateDisplayDevices (WAYLAND.@) */ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param) { - struct wayland_output *output; - INT output_id = 0; + INT output_id; + BOOL update_from_wayland = force_display_devices_refresh;
if (!force && !force_display_devices_refresh) return TRUE;
@@ -147,14 +239,88 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
wayland_add_device_gpu(device_manager, param);
- wl_list_for_each(output, &process_wayland->output_list, link) + pthread_mutex_lock(&display_devices->mutex); + + /* Update shared display device information from Wayland information. + * This should only happen from the desktop window process. */ + if (update_from_wayland) { - if (!output->current_mode) continue; + struct wayland_output *output; + + output_id = 0; + + wl_list_for_each(output, &process_wayland->output_list, link) + { + if (!output->current_mode) continue; + if (output_id >= ARRAYSIZE(display_devices->outputs)) + { + WARN("wayland reported too many outputs, ignoring %s\n", + output->name); + continue; + } + display_devices_update_output(&display_devices->outputs[output_id], + output); + output_id++; + } + + display_devices->num_outputs = output_id; + } + + /* Update gdi devices from shared display device information. */ + for (output_id = 0; output_id < display_devices->num_outputs; output_id++) + { + struct output_info *output_info = &display_devices->outputs[output_id]; wayland_add_device_adapter(device_manager, param, output_id); - wayland_add_device_monitor(device_manager, param, output); - wayland_add_device_modes(device_manager, param, output); - output_id++; + wayland_add_device_monitor(device_manager, param, output_info); + wayland_add_device_modes(device_manager, param, output_info); }
+ pthread_mutex_unlock(&display_devices->mutex); + + return TRUE; +} + +/*********************************************************************** + * GetCurrentDisplaySettings (WAYLAND.@) + * + */ +BOOL WAYLAND_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode) +{ + int display_index; + WCHAR *end; + struct output_info *output_info; + + TRACE("(%s,%p)\n", debugstr_w(name), devmode); + + display_index = wcstol(name + 11, &end, 10) - 1; + if (*end) + { + ERR("Failed to parse display device name %s\n", wine_dbgstr_w(name)); + return FALSE; + } + + pthread_mutex_lock(&display_devices->mutex); + + if (display_index >= display_devices->num_outputs) + { + pthread_mutex_unlock(&display_devices->mutex); + ERR("Failed to get information for %s\n", wine_dbgstr_w(name)); + return FALSE; + } + + output_info = &display_devices->outputs[display_index]; + populate_devmode(&output_info->modes[output_info->current_mode], devmode); + + pthread_mutex_unlock(&display_devices->mutex); + + devmode->dmFields |= DM_POSITION; + devmode->dmPosition.x = 0; + devmode->dmPosition.y = 0; + + TRACE("=> %d,%d+%ux%u@%u %ubpp\n", + (int)devmode->dmPosition.x, (int)devmode->dmPosition.y, + (UINT)devmode->dmPelsWidth, (UINT)devmode->dmPelsHeight, + (UINT)devmode->dmDisplayFrequency, (UINT)devmode->dmBitsPerPel); + return TRUE; } diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index da0fccecda9..794cff2b0dd 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -78,6 +78,7 @@ struct wayland_output */
BOOL wayland_process_init(void) DECLSPEC_HIDDEN; +BOOL wayland_display_devices_process_init(void) DECLSPEC_HIDDEN; void wayland_init_display_devices(void) DECLSPEC_HIDDEN;
/********************************************************************** @@ -92,6 +93,8 @@ void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HI * USER driver functions */
+BOOL WAYLAND_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, + LPDEVMODEW devmode) DECLSPEC_HIDDEN; BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param) DECLSPEC_HIDDEN;
diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index a9297edc500..d83314cd74f 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -31,6 +31,7 @@
static const struct user_driver_funcs waylanddrv_funcs = { + .pGetCurrentDisplaySettings = WAYLAND_GetCurrentDisplaySettings, .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, };
@@ -40,6 +41,7 @@ static NTSTATUS waylanddrv_unix_init(void *arg) * our initialization. We clear them on error. */ __wine_set_user_driver(&waylanddrv_funcs, WINE_GDI_DRIVER_VERSION);
+ if (!wayland_display_devices_process_init()) goto err; if (!wayland_process_init()) goto err;
return 0;
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Since non-desktop processes rely on the shared memory region to get display information, they don't need to access wl_output objects themselves for now.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/display.c | 11 +---------- dlls/winewayland.drv/wayland.c | 3 +++ dlls/winewayland.drv/waylanddrv.h | 6 ++++++ dlls/winewayland.drv/waylanddrv_main.c | 25 +++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 640829142c1..354e10162ca 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -111,16 +111,7 @@ static void wayland_refresh_display_devices(void)
void wayland_init_display_devices(void) { - struct ntuser_thread_info *thread_info = NtUserGetThreadInfo(); - DWORD current_pid = GetCurrentProcessId(); - HWND desktop_hwnd = UlongToHandle(thread_info->top_window); - DWORD desktop_pid = 0; - - if (desktop_hwnd) NtUserGetWindowThread(desktop_hwnd, &desktop_pid); - - /* Refresh devices only from the desktop window process. */ - if (!desktop_pid || current_pid == desktop_pid) - wayland_refresh_display_devices(); + wayland_refresh_display_devices(); }
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 30ef22df52d..2eb58fb7139 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -45,6 +45,9 @@ static void registry_handle_global(void *data, struct wl_registry *registry, { TRACE("interface=%s version=%u id=%u\n", interface, version, id);
+ /* For now only the desktop process needs wl_output objects. */ + if (GetCurrentProcessId() != get_desktop_process_id()) return; + if (strcmp(interface, "wl_output") == 0) { if (!wayland_output_create(id, version)) diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 794cff2b0dd..2f1a83ee542 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -89,6 +89,12 @@ 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;
+/********************************************************************** + * USER32 helpers + */ + +DWORD get_desktop_process_id(void) DECLSPEC_HIDDEN; + /********************************************************************** * USER driver functions */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index d83314cd74f..cb9702c4564 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -27,8 +27,33 @@ #include "ntstatus.h" #define WIN32_NO_STATUS
+#include "wine/server.h" + #include "waylanddrv.h"
+DWORD get_desktop_process_id(void) +{ + struct ntuser_thread_info *thread_info = NtUserGetThreadInfo(); + HWND desktop_hwnd = UlongToHandle(thread_info->top_window); + DWORD desktop_pid; + + /* The thread information may not have been updated yet, so also query + * the server directly to be certain. */ + if (!desktop_hwnd) + { + SERVER_START_REQ(get_desktop_window) + { + req->force = 0; + if (!wine_server_call(req)) + desktop_hwnd = UlongToHandle(reply->top_window); + } + SERVER_END_REQ; + } + + return NtUserGetWindowThread(desktop_hwnd, &desktop_pid) ? + desktop_pid : GetCurrentProcessId(); +} + static const struct user_driver_funcs waylanddrv_funcs = { .pGetCurrentDisplaySettings = WAYLAND_GetCurrentDisplaySettings,
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Use the xdg-output-unstable-v1 protocol to get the position and size of the Wayland outputs in the compositor logical space, and use this information to infer the physical (i.e., native pixel) coordinates of the monitors.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/display.c | 40 +++++++-- dlls/winewayland.drv/wayland_output.c | 125 +++++++++++++++++++++++++- dlls/winewayland.drv/waylanddrv.h | 3 + 3 files changed, 160 insertions(+), 8 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 354e10162ca..e9fac1dad47 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -42,6 +42,7 @@ struct output_info struct wayland_output_mode modes[128]; int num_modes; int current_mode; + int x, y; };
struct display_devices @@ -101,6 +102,19 @@ BOOL wayland_display_devices_process_init(void) return TRUE; }
+static struct wayland_output *wayland_get_primary_output(void) +{ + struct wayland_output *output; + + wl_list_for_each(output, &process_wayland->output_list, link) + { + if (output->current_mode && output->x == 0 && output->y == 0) + return output; + } + + return NULL; +} + static void wayland_refresh_display_devices(void) { UINT32 num_path, num_mode; @@ -148,7 +162,8 @@ static void wayland_add_device_monitor(const struct gdi_device_manager *device_m struct gdi_monitor monitor = {0}; struct wayland_output_mode *mode = &output_info->modes[output_info->current_mode];
- SetRect(&monitor.rc_monitor, 0, 0, mode->width, mode->height); + SetRect(&monitor.rc_monitor, output_info->x, output_info->y, + output_info->x + mode->width, output_info->y + mode->height);
/* We don't have a direct way to get the work area in Wayland. */ monitor.rc_work = monitor.rc_monitor; @@ -211,6 +226,9 @@ static void display_devices_update_output(struct output_info *output_info, }
output_info->num_modes = mode_i; + + output_info->x = output->x; + output_info->y = output->y; }
/*********************************************************************** @@ -236,13 +254,21 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage * This should only happen from the desktop window process. */ if (update_from_wayland) { - struct wayland_output *output; + struct wayland_output *output, *primary;
output_id = 0;
+ /* Add the primary output (i.e., positioned at 0,0) first. */ + if ((primary = wayland_get_primary_output())) + { + display_devices_update_output(&display_devices->outputs[output_id], + primary); + output_id++; + } + wl_list_for_each(output, &process_wayland->output_list, link) { - if (!output->current_mode) continue; + if (!output->current_mode || output == primary) continue; if (output_id >= ARRAYSIZE(display_devices->outputs)) { WARN("wayland reported too many outputs, ignoring %s\n", @@ -302,11 +328,11 @@ BOOL WAYLAND_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW output_info = &display_devices->outputs[display_index]; populate_devmode(&output_info->modes[output_info->current_mode], devmode);
- pthread_mutex_unlock(&display_devices->mutex); - devmode->dmFields |= DM_POSITION; - devmode->dmPosition.x = 0; - devmode->dmPosition.y = 0; + devmode->dmPosition.x = output_info->x; + devmode->dmPosition.y = output_info->y; + + pthread_mutex_unlock(&display_devices->mutex);
TRACE("=> %d,%d+%ux%u@%u %ubpp\n", (int)devmode->dmPosition.x, (int)devmode->dmPosition.y, diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c index 8eb24fe97f3..717341d678e 100644 --- a/dlls/winewayland.drv/wayland_output.c +++ b/dlls/winewayland.drv/wayland_output.c @@ -97,11 +97,126 @@ static void wayland_output_add_mode(struct wayland_output *output, if (current) output->current_mode = mode; }
+static int wayland_output_cmp_x(const void *va, const void *vb) +{ + const struct wayland_output *a = va; + const struct wayland_output *b = vb; + + if (a->logical_x < b->logical_x) return -1; + if (a->logical_x > b->logical_x) return 1; + if (a->logical_y < b->logical_y) return -1; + if (a->logical_y > b->logical_y) return 1; + return 0; +} + +static int wayland_output_cmp_y(const void *va, const void *vb) +{ + const struct wayland_output *a = va; + const struct wayland_output *b = vb; + + if (a->logical_y < b->logical_y) return -1; + if (a->logical_y > b->logical_y) return 1; + if (a->logical_x < b->logical_x) return -1; + if (a->logical_x > b->logical_x) return 1; + return 0; +} + +static struct wayland_output** wayland_output_list_sorted(struct wl_list *output_list, + int (*cmp)(const void *, const void *)) +{ + int num_outputs = wl_list_length(output_list); + struct wayland_output **sorted; + struct wayland_output *o; + int i = 0; + + sorted = malloc(sizeof(*sorted) * (num_outputs + 1)); + if (!sorted) + { + ERR("Couldn't allocate space for sorted outputs\n"); + return NULL; + } + + wl_list_for_each(o, output_list, link) sorted[i++] = o; + + qsort(sorted, num_outputs, sizeof(*sorted), cmp); + + sorted[num_outputs] = NULL; + return sorted; +} + +static void wayland_output_list_update_physical_coords(struct wl_list *output_list) +{ + struct wayland_output **sorted_x, **sorted_y; + struct wayland_output **cur_p, **prev_p; + struct wayland_output *cur, *prev; + + /* Set default physical coordinates. */ + wl_list_for_each(cur, output_list, link) + { + cur->x = cur->logical_x; + cur->y = cur->logical_y; + } + + /* Sort and process the outputs from left to right. */ + cur_p = sorted_x = wayland_output_list_sorted(output_list, wayland_output_cmp_x); + if (!sorted_x) return; + + while ((cur = *cur_p)) + { + /* Update output->x based on other outputs that are to to the left. */ + prev_p = sorted_x; + while ((prev = *prev_p) != cur) + { + if (cur->logical_x == prev->logical_x + prev->logical_w && + prev->current_mode) + { + int new_x = prev->x + prev->current_mode->width; + if (new_x > cur->x) cur->x = new_x; + } + prev_p++; + } + + cur_p++; + } + + free(sorted_x); + + /* Now sort and process the outputs from top to bottom. */ + cur_p = sorted_y = wayland_output_list_sorted(output_list, wayland_output_cmp_y); + if (!sorted_y) return; + + while ((cur = *cur_p)) + { + /* Update output->y based on other outputs that are above. */ + prev_p = sorted_y; + while ((prev = *prev_p) != cur) + { + if (cur->logical_y == prev->logical_y + prev->logical_h && + prev->current_mode) + { + int new_y = prev->y + prev->current_mode->height; + if (new_y > cur->y) cur->y = new_y; + } + prev_p++; + } + + cur_p++; + } + + free(sorted_y); +} + static void wayland_output_done(struct wayland_output *output) { struct wayland_output_mode *mode;
- TRACE("name=%s\n", output->name); + TRACE("name=%s logical=%d,%d+%dx%d physical=%d,%d+%dx%d\n", + output->name, output->logical_x, output->logical_y, + output->logical_w, output->logical_h, + output->x, output->y, + output->current_mode->width, output->current_mode->height); + + wayland_output_list_update_physical_coords(&process_wayland->output_list);
RB_FOR_EACH_ENTRY(mode, &output->modes, struct wayland_output_mode, entry) { @@ -163,6 +278,10 @@ static void zxdg_output_v1_handle_logical_position(void *data, int32_t x, int32_t y) { + struct wayland_output *output = data; + TRACE("logical_x=%d logical_y=%d\n", x, y); + output->logical_x = x; + output->logical_y = y; }
static void zxdg_output_v1_handle_logical_size(void *data, @@ -170,6 +289,10 @@ static void zxdg_output_v1_handle_logical_size(void *data, int32_t width, int32_t height) { + struct wayland_output *output = data; + TRACE("logical_w=%d logical_h=%d\n", width, height); + output->logical_w = width; + output->logical_h = height; }
static void zxdg_output_v1_handle_done(void *data, diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 2f1a83ee542..492976a5070 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -70,6 +70,9 @@ struct wayland_output struct rb_tree modes; struct wayland_output_mode *current_mode; char *name; + int logical_x, logical_y; /* logical position */ + int logical_w, logical_h; /* logical size */ + int x, y; /* position in physical pixel coordinate space */ uint32_t global_id; };
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/display.c | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index e9fac1dad47..8c637e35442 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -123,9 +123,48 @@ static void wayland_refresh_display_devices(void) NtUserGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path, &num_mode); }
+/* Initialize registry display settings when new display devices are added */ +static void wayland_init_registry_display_settings(void) +{ + DEVMODEW dm = {.dmSize = sizeof(dm)}; + DISPLAY_DEVICEW dd = {sizeof(dd)}; + UNICODE_STRING device_name; + DWORD i = 0; + int ret; + + while (!NtUserEnumDisplayDevices(NULL, i++, &dd, 0)) + { + RtlInitUnicodeString(&device_name, dd.DeviceName); + + /* Skip if the device already has registry display settings */ + if (NtUserEnumDisplaySettings(&device_name, ENUM_REGISTRY_SETTINGS, &dm, 0)) + continue; + + if (!NtUserEnumDisplaySettings(&device_name, ENUM_CURRENT_SETTINGS, &dm, 0)) + { + ERR("Failed to query current display settings for %s.\n", wine_dbgstr_w(dd.DeviceName)); + continue; + } + + TRACE("Device %s current display mode %ux%u %ubits %uHz at %d,%d.\n", + wine_dbgstr_w(dd.DeviceName), (UINT)dm.dmPelsWidth, (UINT)dm.dmPelsHeight, + (UINT)dm.dmBitsPerPel, (UINT)dm.dmDisplayFrequency, (int)dm.dmPosition.x, + (int)dm.dmPosition.y); + + ret = NtUserChangeDisplaySettings(&device_name, &dm, NULL, + CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, NULL); + if (ret != DISP_CHANGE_SUCCESSFUL) + { + ERR("Failed to save registry display settings for %s, returned %d.\n", + wine_dbgstr_w(dd.DeviceName), ret); + } + } +} + void wayland_init_display_devices(void) { wayland_refresh_display_devices(); + wayland_init_registry_display_settings(); }
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager,
From: Alexandros Frantzis alexandros.frantzis@collabora.com
Update the desktop window size to match the current virtual screen rect.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- dlls/winewayland.drv/Makefile.in | 3 +- dlls/winewayland.drv/display.c | 3 ++ dlls/winewayland.drv/waylanddrv.h | 15 +++++++- dlls/winewayland.drv/waylanddrv_main.c | 7 ++-- dlls/winewayland.drv/window.c | 50 ++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 dlls/winewayland.drv/window.c
diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index faa6186db21..013d0ca9c87 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -8,7 +8,8 @@ C_SRCS = \ dllmain.c \ wayland.c \ wayland_output.c \ - waylanddrv_main.c + waylanddrv_main.c \ + window.c
WAYLAND_PROTOCOL_SRCS = \ xdg-output-unstable-v1.xml diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 8c637e35442..aa75cc25057 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -163,8 +163,11 @@ static void wayland_init_registry_display_settings(void)
void wayland_init_display_devices(void) { + HWND desktop_hwnd = get_desktop_window(); + wayland_refresh_display_devices(); wayland_init_registry_display_settings(); + if (desktop_hwnd) send_message(desktop_hwnd, WM_DISPLAYCHANGE, 0, 0); }
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 492976a5070..38501b470e7 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -96,12 +96,25 @@ void wayland_output_use_xdg_extension(struct wayland_output *output) DECLSPEC_HI * USER32 helpers */
-DWORD get_desktop_process_id(void) DECLSPEC_HIDDEN; +HWND get_desktop_window(void) DECLSPEC_HIDDEN; + +static inline DWORD get_desktop_process_id(void) +{ + DWORD desktop_pid; + return NtUserGetWindowThread(get_desktop_window(), &desktop_pid) ? + desktop_pid : GetCurrentProcessId(); +} + +static inline LRESULT send_message(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + return NtUserMessageCall(hwnd, msg, wparam, lparam, NULL, NtUserSendDriverMessage, FALSE); +}
/********************************************************************** * USER driver functions */
+LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN; BOOL WAYLAND_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode) DECLSPEC_HIDDEN; BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index cb9702c4564..d267e43068c 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -31,11 +31,10 @@
#include "waylanddrv.h"
-DWORD get_desktop_process_id(void) +HWND get_desktop_window(void) { struct ntuser_thread_info *thread_info = NtUserGetThreadInfo(); HWND desktop_hwnd = UlongToHandle(thread_info->top_window); - DWORD desktop_pid;
/* The thread information may not have been updated yet, so also query * the server directly to be certain. */ @@ -50,12 +49,12 @@ DWORD get_desktop_process_id(void) SERVER_END_REQ; }
- return NtUserGetWindowThread(desktop_hwnd, &desktop_pid) ? - desktop_pid : GetCurrentProcessId(); + return desktop_hwnd; }
static const struct user_driver_funcs waylanddrv_funcs = { + .pDesktopWindowProc = WAYLAND_DesktopWindowProc, .pGetCurrentDisplaySettings = WAYLAND_GetCurrentDisplaySettings, .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, }; diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c new file mode 100644 index 00000000000..7d56d9b3b02 --- /dev/null +++ b/dlls/winewayland.drv/window.c @@ -0,0 +1,50 @@ +/* + * Window related functions + * + * Copyright 2020 Alexandros Frantzis for Collabora Ltd + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "config.h" + +#include "waylanddrv.h" + +#include "ntuser.h" + +/********************************************************************** + * WAYLAND_DesktopWindowProc + */ +LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + switch (msg) + { + case WM_DISPLAYCHANGE: + { + RECT virtual_rect = NtUserGetVirtualScreenRect(); + NtUserSetWindowPos(hwnd, 0, virtual_rect.left, virtual_rect.top, + virtual_rect.right - virtual_rect.left, + virtual_rect.bottom - virtual_rect.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); + } + break; + } + + return NtUserMessageCall(hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE); +}
On Thu Mar 23 15:26:28 2023 +0000, Alexandros Frantzis wrote:
The problem is that if we stick to using an old version of the
protocols, we will not be able to use new protocols that fills the gaps Wine may need to functions properly without resorting to using any weird workaround that work half of the time. If there is an updated protocol version (or a new protocol), we would need to take explicit action, both to use it in the code and also to ensure we can access the updated protocol sources. If we use wayland-protocols we would need to depend on a newer package version that ships the files we need. If we vendor the protocol .xml file we would need to manually copy the new file to the driver sources. In both cases the process is straightforward, so I am not really concerned either way. Note that Wayland protocols have strong backward compatibility guarantees, so bringing in an updated (minor) version of a protocol .xml still allows us to use all older features.
If using a vendor protocol .xml with the latest protocols and it can
generate backward compatible code with the unmodified outdated wayland-scanner version this would be the best solution, but even in this situation compatibility can be an issue. At the moment at least, all (non-ancient) versions of wayland-scanner can generate .c/.h code for all current protocols. In the unlikely case that this changes and there is a protocol that requires a particular wayland-scanner version, and we absolutely need to have it, we will just have to introduce a minimum libwayland/wayland-scanner dependency. For now, the only dependency we have to deal with is that the .c/.h protocol code generated by a wayland-scanner version is only guaranteed to work with the matching libwayland or newer. Vendoring (or not) is completely orthogonal to all of the above, it's just a matter of where one gets the protocol .xml files from.
@julliard I have updated the MR to use vendored Wayland protocol .xml files (while still generating .c/.h at build time). Let me know what you think. Thanks!
From what I understand of the summary, the GetCurrentDisplaySettings implementation can be inconsistent and relies on figuring out everything the compositor supports by guessing.
Perhaps I am misunderstanding your concern, but the current implementation of `GetCurrentDisplaySettings` (which uses the shared memory region) does provides consistent and real output information across all Wine processes, there is no guesswork involved.
Since the Wayland output state of different clients/processes can be (transiently) out of sync, we effectively treat the Wayland output state of the desktop window process as the authoritative one, and all other processes use that state (through that shared memory region) when reporting back information, in order to be consistent both among them **and** with the Wine monitor information.
There are some other benefits to the shared memory approach, which will become important in the future. For example, the ability to consistently apply/simulate application initiated mode changes (i.e., `ChangeDisplaySettings`) across all processes (since Wayland doesn't allow normal clients to actually change the compositor mode).
Have you bugged the Wayland devs about adding some protocols to support viewing the display specifications?
This might go against their design choices, but it's not much of a danger since applications can't self position or control other windows, it would just be asking the compositor what displays are available and what modes they support.
All the information is already provided through the wl_output (and xdg_output) events, it's just that each client is responsible for tracking these events and maintaining the total output state on its own. That's absolutely fine for the overwhelming majority of clients, so I don't expect upstream to be interested at all in providing another way to get the full output state (plus there is a roundabout way to achieve this, by creating a new wl_registry and synchronously waiting for initial wl_output events). In the end I don't think that it would be enough on its own anyway, because although it would help with some aspects of the problem, there would still be cases where the Wayland output state of some process and the the Wine monitor information could become desynchronized.
Maybe on top of that you could allow choosing a display to output to (rather than exact positioning, it's just a general "I want to be on this display") which would work well for games, as they tend to have display settings there to see what they can do.
This is already supported by the xdg-shell protocol for fullscreen surfaces, which is the main use case for gaming needs, and the Wayland driver will make use of this feature (the full series already uses that).
I hope all the above help clarify the design decisions a bit more.
Since the Wayland output state of different clients/processes can be (transiently) out of sync, we effectively treat the Wayland output state of the desktop window process as the authoritative one, and all other processes use that state (through that shared memory region) when reporting back information, in order to be consistent both among them **and** with the Wine monitor information.
There are some other benefits to the shared memory approach, which will become important in the future. For example, the ability to consistently apply/simulate application initiated mode changes (i.e., `ChangeDisplaySettings`) across all processes (since Wayland doesn't allow normal clients to actually change the compositor mode).
I should note that using shared memory that way is not allowed in Wine. It's not considered acceptable that one crashing app can take down the entire session. Shared state has to be stored in the Wine server.
On Fri Mar 24 16:01:45 2023 +0000, Alexandre Julliard wrote:
Since the Wayland output state of different clients/processes can be
(transiently) out of sync, we effectively treat the Wayland output state of the desktop window process as the authoritative one, and all other processes use that state (through that shared memory region) when reporting back information, in order to be consistent both among them **and** with the Wine monitor information.
There are some other benefits to the shared memory approach, which
will become important in the future. For example, the ability to consistently apply/simulate application initiated mode changes (i.e., `ChangeDisplaySettings`) across all processes (since Wayland doesn't allow normal clients to actually change the compositor mode). I should note that using shared memory that way is not allowed in Wine. It's not considered acceptable that one crashing app can take down the entire session. Shared state has to be stored in the Wine server.
Fwiw regarding display settings, the default (nulldrv) implementation should already be able to share current display settings and display changes across all processes through the registry. It's currently guarded by `ChangeDisplaySettings` returning `E_NOTIMPL`, but could perhaps be done unconditionally.
Of course that's not necessarily in sync with the host settings, and needs to be updated on external changes.
On Fri Mar 24 16:01:45 2023 +0000, Rémi Bernon wrote:
Fwiw regarding display settings, the default (nulldrv) implementation should already be able to share current display settings and display changes across all processes through the registry. It's currently guarded by `ChangeDisplaySettings` returning `E_NOTIMPL`, but could perhaps be done unconditionally. Of course that's not necessarily in sync with the host settings, and needs to be updated on external changes.
@julliard
I should note that using shared memory that way is not allowed in Wine. It's not considered acceptable that one crashing app can take down the entire session. Shared state has to be stored in the Wine server.
I was under the impression that the `NtCreateSection("\??\WaylandDisplayDevices", file=0)` call I am using is doing effectively that, i.e., it creates a server-owned shared memory region, that stays alive as long as there are handles to it.
It's unclear to me how an app crashing would take the session down in this case. Could you elaborate? Is there some other server provided mechanism that would be preferable to use?
It's unclear to me how an app crashing would take the session down in this case. Could you elaborate?
The most obvious example would be the debugger attaching to a thread that's holding the shared mutex.
Is there some other server provided mechanism that would be preferable to use?
The registry, as mentioned by @bernon, is the easiest one. We could also store more of that information directly in server objects. This would most likely be handled in the generic code so that all drivers benefit.
On Fri Mar 24 17:09:03 2023 +0000, Alexandros Frantzis wrote:
@julliard
I should note that using shared memory that way is not allowed in
Wine. It's not considered acceptable that one crashing app can take down the entire session. Shared state has to be stored in the Wine server. I was under the impression that the `NtCreateSection("\??\WaylandDisplayDevices", file=0)` call I am using is doing effectively that, i.e., it creates a server-owned shared memory region, that stays alive as long as there are handles to it. It's unclear to me how an app crashing would take the session down in this case. Could you elaborate? Is there some other server provided mechanism that would be preferable to use?
@rbernon
The shared memory approach in this MR is effectively trying to establish a shared truth for the host settings (so a kind of driver built-in xrandr). So, I guess the suggestion is to use CURRENT_SETTINGS as that shared truth instead, correct?
I will need to think about (and experiment with) this a bit more, but at the very least I think I would need to be able to attach (and be able to retrieve from any process) some driver-specific display device properties (the Wayland output name it corresponds to, the compositor scale and native mode etc).
Thanks!
On Fri Mar 24 18:16:27 2023 +0000, Alexandre Julliard wrote:
It's unclear to me how an app crashing would take the session down in
this case. Could you elaborate? The most obvious example would be the debugger attaching to a thread that's holding the shared mutex.
Is there some other server provided mechanism that would be preferable
to use? The registry, as mentioned by @bernon, is the easiest one. We could also store more of that information directly in server objects. This would most likely be handled in the generic code so that all drivers benefit.
@julliard Thanks! I give the registry approach a try (see above), and hopefully it will be enough (but also happy to move in the direction of making more generic code improvements if preferred).
I will need to think about (and experiment with) this a bit more, but at the very least I think I would need to be able to attach (and be able to retrieve from any process) some driver-specific display device properties (the Wayland output name it corresponds to, the compositor scale and native mode etc).
Any suggestions about how to achieve the above, without manually digging into the registry from the driver? Would some kind of small API exported from win32u.so for driver use be an acceptable option, so I can reuse some of the registry code from there? For example, something along the lines of {set|get}_display_device_private_data(device) to store/retrieve some blob of data from the proper registry key?
On Fri Mar 24 18:20:18 2023 +0000, Alexandros Frantzis wrote:
I will need to think about (and experiment with) this a bit more, but
at the very least I think I would need to be able to attach (and be able to retrieve from any process) some driver-specific display device properties (the Wayland output name it corresponds to, the compositor scale and native mode etc). Any suggestions about how to achieve the above, without manually digging into the registry from the driver? Would some kind of small API exported from win32u.so for driver use be an acceptable option, so I can reuse some of the registry code from there? For example, something along the lines of {set|get}_display_device_private_data(device) to store/retrieve some blob of data from the proper registry key?
I don't really know what you need to keep with each mode, I think `winex11` currently simply looks the mode again in its host mode list, caching it to avoid unnecessary enumeration. A simple solution would be to do the same.
Otherwise, each `DEVMODEW` can also carry private driver data after it, and there's a `dmDriverExtra` field that indicates its size.
Assuming the driver data is portable (which isn't the case with every `winex11` modes currently) across architectures and processes, the private data could be saved into the registry when enumerating and caching available modes, and passed back to the driver when applying display settings on display settings change.
Note that this is not currently implemented and driver extra data isn't saved, but I think it should be easy to add.
I don't really know what you need to keep with each mode
The (portable) properties I would like to be able to store and retrieve are per device rather than per mode, hence the idea for some new win32u API to set/get per device private data which would be stored in the registry (the set part could actually be part of the `struct gdi_adapter` setup). The other requirement is that I would need to access the data from arbitrary points in the driver, not just from within a display settings change context.
I guess I could store the per-device properties in DEVMODEW driver extra data (and retrieve it by getting any mode, e.g., the current), although this seems to be a somewhat roundabout way to deal with per device properties. On the other hand, this would be just a driver implementation detail, and would avoid any extra APIs, so perhaps it's not too bad. One (theoretical) problem would be how to deal with a device doesn't have any modes (e.g., not connected), but that can never happen in the Wayland driver, since only connected outputs are advertised by the compositor and exposed to Wine. Thoughts?
Note that per device private data will not be needed until a later MR, but I would like to ensure there is a reasonable/acceptable way to implement this, so that I don't paint myself into a (design) corner.
Concerning storing CURRENT_SETTINGS in the registry:
Of course that's not necessarily in sync with the host settings, and needs to be updated on external changes.
I have been experimenting with a way to set CURRENT_SETTINGS from within the driver for the initial display device configuration (and on host settings change).
Initially I tried to use a `NtUserChangeDisplaySettings()` call (like we do in `init_registry_display_settings`), combined with returning E_NOTIMPL from WAYLAND_ChangeDisplaySettings, but this has proved problematic since the initial device configuration may occur at (desktop) process startup. At that time it seems it's not possible to invoke `GetDesktopWindow()` and `send_message(WM_DISPLAYCHANGE)` which the `NtUserChangeDisplaySettings()` implementation in win32u tries to do.
An alternative idea I have been toying with is to enhance `gdi_device_manager.add_mode()` to also take a flag denoting whether to use this is as the registry and/or current mode. The win32u implementation would consult this flag to set the REGISTRY_SETTINGS (if not already set) and/or the CURRENT_SETTINGS. This would also allow us to remove the `init_registry_display_settings` code which is currently duplicated across many drivers. How does that sound? Any other suggestions?
Thanks!
An alternative idea I have been toying with is to enhance `gdi_device_manager.add_mode()` to also take a flag denoting whether to use this is as the registry and/or current mode. The win32u implementation would consult this flag to set the REGISTRY_SETTINGS (if not already set) and/or the CURRENT_SETTINGS. This would also allow us to remove the `init_registry_display_settings` code which is currently duplicated across many drivers. How does that sound? Any other suggestions?
Sounds like a good idea to me.
I hope all the above help clarify the design decisions a bit more.
It did, and taught me a bit more about Wayland and how it works. Thanks.