Module: wine Branch: master Commit: e352fa19fae8f36f09970e3d2aa930570251c0dc URL: https://gitlab.winehq.org/wine/wine/-/commit/e352fa19fae8f36f09970e3d2aa9305...
Author: Alexandros Frantzis alexandros.frantzis@collabora.com Date: Tue May 2 11:34:49 2023 +0300
winewayland.drv: Allocate process_wayland statically.
There is currently no benefit to dynamic allocation, and static allocation allows us to simplify some aspects of initialization.
---
dlls/winewayland.drv/display.c | 2 +- dlls/winewayland.drv/wayland.c | 41 +++++++++++++++-------------------- dlls/winewayland.drv/wayland_output.c | 8 +++---- dlls/winewayland.drv/waylanddrv.h | 4 ++-- 4 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 5234a1f03aa..d822a785898 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -290,7 +290,7 @@ BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
wl_array_init(&output_info_array);
- wl_list_for_each(output, &process_wayland->output_list, link) + wl_list_for_each(output, &process_wayland.output_list, link) { if (!output->current_mode) continue; output_info = wl_array_add(&output_info_array, sizeof(*output_info)); diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 22a7a8cc63f..dab23a555a2 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -32,8 +32,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
-struct wl_display *process_wl_display = NULL; -struct wayland *process_wayland = NULL; +struct wayland process_wayland = +{ + .output_list = {&process_wayland.output_list, &process_wayland.output_list} +};
/********************************************************************** * Registry handling @@ -54,12 +56,12 @@ static void registry_handle_global(void *data, struct wl_registry *registry, { struct wayland_output *output;
- process_wayland->zxdg_output_manager_v1 = + 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) + wl_list_for_each(output, &process_wayland.output_list, link) wayland_output_use_xdg_extension(output); } } @@ -71,7 +73,7 @@ static void registry_handle_global_remove(void *data, struct wl_registry *regist
TRACE("id=%u\n", id);
- wl_list_for_each_safe(output, tmp, &process_wayland->output_list, link) + wl_list_for_each_safe(output, tmp, &process_wayland.output_list, link) { if (output->global_id == id) { @@ -97,48 +99,41 @@ BOOL wayland_process_init(void) { struct wl_display *wl_display_wrapper;
- process_wl_display = wl_display_connect(NULL); - if (!process_wl_display) + process_wayland.wl_display = wl_display_connect(NULL); + if (!process_wayland.wl_display) return FALSE;
- process_wayland = calloc(1, sizeof(*process_wayland)); - if (!process_wayland) - return FALSE; + TRACE("wl_display=%p\n", process_wayland.wl_display);
- TRACE("process_wayland=%p wl_display=%p\n", process_wayland, process_wl_display); - - if (!(process_wayland->wl_event_queue = wl_display_create_queue(process_wl_display))) + if (!(process_wayland.wl_event_queue = wl_display_create_queue(process_wayland.wl_display))) { ERR("Failed to create event queue\n"); return FALSE; }
- if (!(wl_display_wrapper = wl_proxy_create_wrapper(process_wl_display))) + if (!(wl_display_wrapper = wl_proxy_create_wrapper(process_wayland.wl_display))) { ERR("Failed to create proxy wrapper for wl_display\n"); return FALSE; } wl_proxy_set_queue((struct wl_proxy *) wl_display_wrapper, - process_wayland->wl_event_queue); + process_wayland.wl_event_queue);
- process_wayland->wl_registry = wl_display_get_registry(wl_display_wrapper); + process_wayland.wl_registry = wl_display_get_registry(wl_display_wrapper); wl_proxy_wrapper_destroy(wl_display_wrapper); - if (!process_wayland->wl_registry) + if (!process_wayland.wl_registry) { ERR("Failed to get to wayland registry\n"); return FALSE; }
- wl_list_init(&process_wayland->output_list); - /* Populate registry */ - wl_registry_add_listener(process_wayland->wl_registry, ®istry_listener, - process_wayland); + wl_registry_add_listener(process_wayland.wl_registry, ®istry_listener, NULL);
/* We need two roundtrips. One to get and bind globals, one to handle all * initial events produced from registering the globals. */ - wl_display_roundtrip_queue(process_wl_display, process_wayland->wl_event_queue); - wl_display_roundtrip_queue(process_wl_display, process_wayland->wl_event_queue); + wl_display_roundtrip_queue(process_wayland.wl_display, process_wayland.wl_event_queue); + wl_display_roundtrip_queue(process_wayland.wl_display, process_wayland.wl_event_queue);
wayland_init_display_devices();
diff --git a/dlls/winewayland.drv/wayland_output.c b/dlls/winewayland.drv/wayland_output.c index 5cd6e74f24a..5c93e16f3e1 100644 --- a/dlls/winewayland.drv/wayland_output.c +++ b/dlls/winewayland.drv/wayland_output.c @@ -230,7 +230,7 @@ BOOL wayland_output_create(uint32_t id, uint32_t version) goto err; }
- output->wl_output = wl_registry_bind(process_wayland->wl_registry, id, + output->wl_output = wl_registry_bind(process_wayland.wl_registry, id, &wl_output_interface, version < 2 ? version : 2); output->global_id = id; @@ -252,10 +252,10 @@ BOOL wayland_output_create(uint32_t id, uint32_t version) goto err; }
- if (process_wayland->zxdg_output_manager_v1) + if (process_wayland.zxdg_output_manager_v1) wayland_output_use_xdg_extension(output);
- wl_list_insert(process_wayland->output_list.prev, &output->link); + wl_list_insert(process_wayland.output_list.prev, &output->link);
return TRUE;
@@ -293,7 +293,7 @@ void wayland_output_destroy(struct wayland_output *output) 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, + 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 e1ea66f3b33..d5cbb47bf9e 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -39,8 +39,7 @@ * Globals */
-extern struct wl_display *process_wl_display DECLSPEC_HIDDEN; -extern struct wayland *process_wayland DECLSPEC_HIDDEN; +extern struct wayland process_wayland DECLSPEC_HIDDEN;
/********************************************************************** * Definitions for wayland types @@ -48,6 +47,7 @@ extern struct wayland *process_wayland DECLSPEC_HIDDEN;
struct wayland { + struct wl_display *wl_display; struct wl_event_queue *wl_event_queue; struct wl_registry *wl_registry; struct zxdg_output_manager_v1 *zxdg_output_manager_v1;