diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index 9f3ad584f4f..39c3976cdfd 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -24,6 +24,7 @@ #include "config.h" +#include #include #include @@ -902,3 +903,29 @@ void wayland_surface_ensure_contents(struct wayland_surface *surface) if (damage) NtGdiDeleteObjectApp(damage); } + +/********************************************************************** + * wayland_surface_set_title + */ +void wayland_surface_set_title(struct wayland_surface *surface, LPCWSTR text) +{ + DWORD text_len; + DWORD utf8_count; + char *utf8 = NULL; + + assert(surface->xdg_toplevel); + + TRACE("surface=%p hwnd=%p text='%s'\n", + surface, surface->hwnd, wine_dbgstr_w(text)); + + text_len = (lstrlenW(text) + 1) * sizeof(WCHAR); + + if (!RtlUnicodeToUTF8N(NULL, 0, &utf8_count, text, text_len) && + (utf8 = malloc(utf8_count))) + { + RtlUnicodeToUTF8N(utf8, utf8_count, &utf8_count, text, text_len); + xdg_toplevel_set_title(surface->xdg_toplevel, utf8); + } + + free(utf8); +} diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 613aae18b22..3301ce05f82 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -258,6 +258,7 @@ void wayland_surface_coords_to_window(struct wayland_surface *surface, struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface *surface); BOOL wayland_client_surface_release(struct wayland_client_surface *client); void wayland_surface_ensure_contents(struct wayland_surface *surface); +void wayland_surface_set_title(struct wayland_surface *surface, LPCWSTR title); /********************************************************************** * Wayland SHM buffer @@ -329,6 +330,7 @@ BOOL WAYLAND_ClipCursor(const RECT *clip, BOOL reset); LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); void WAYLAND_DestroyWindow(HWND hwnd); void WAYLAND_SetCursor(HWND hwnd, HCURSOR hcursor); +void WAYLAND_SetWindowText(HWND hwnd, LPCWSTR text); LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam); BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param); diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index 6bddbb509b6..61e7df16f14 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -41,6 +41,7 @@ static const struct user_driver_funcs waylanddrv_funcs = .pKbdLayerDescriptor = WAYLAND_KbdLayerDescriptor, .pReleaseKbdTables = WAYLAND_ReleaseKbdTables, .pSetCursor = WAYLAND_SetCursor, + .pSetWindowText = WAYLAND_SetWindowText, .pSysCommand = WAYLAND_SysCommand, .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, .pWindowMessage = WAYLAND_WindowMessage, diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index a02363411ea..3c41c57b7b5 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -195,6 +195,7 @@ static void wayland_win_data_update_wayland_surface(struct wayland_win_data *dat HWND parent = NtUserGetAncestor(data->hwnd, GA_PARENT); BOOL visible, xdg_visible; RECT clip; + WCHAR text[1024]; TRACE("hwnd=%p\n", data->hwnd); @@ -223,7 +224,16 @@ static void wayland_win_data_update_wayland_surface(struct wayland_win_data *dat /* If the window is a visible toplevel make it a wayland * xdg_toplevel. Otherwise keep it role-less to avoid polluting the * compositor with empty xdg_toplevels. */ - if (visible) wayland_surface_make_toplevel(surface); + if (visible) + { + wayland_surface_make_toplevel(surface); + if (surface->xdg_toplevel) + { + if (!NtUserInternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) + text[0] = 0; + wayland_surface_set_title(surface, text); + } + } } wayland_win_data_get_config(data, &surface->window); @@ -669,6 +679,22 @@ static enum xdg_toplevel_resize_edge hittest_to_resize_edge(WPARAM hittest) } } +/***************************************************************** + * WAYLAND_SetWindowText + */ +void WAYLAND_SetWindowText(HWND hwnd, LPCWSTR text) +{ + struct wayland_surface *surface = wayland_surface_lock_hwnd(hwnd); + + TRACE("hwnd=%p text=%s\n", hwnd, wine_dbgstr_w(text)); + + if (surface) + { + if (surface->xdg_toplevel) wayland_surface_set_title(surface, text); + pthread_mutex_unlock(&surface->mutex); + } +} + /*********************************************************************** * WAYLAND_SysCommand */