From 3cd3490fd1f8f94388353c357d881500fd74589a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 22 Jan 2019 17:20:19 +0100 Subject: [PATCH] Fixed initialization of window decorations. --- uwac/libuwac/uwac-window.c | 43 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index d4daa3095..74356901c 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -384,6 +384,30 @@ UwacBuffer* UwacWindowFindFreeBuffer(UwacWindow* w) return &w->buffers[i]; } +static UwacReturnCode UwacWindowSetDecorations(UwacWindow *w) +{ + if (!w || !w->display) + return UWAC_ERROR_INTERNAL; + + if (w->display->deco_manager) { + w->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( + w->display->deco_manager, w->xdg_toplevel); + if (!w->deco) { + uwacErrorHandler(w->display, UWAC_NOT_FOUND, "Current window manager does not allow decorating with SSD"); + } + else + zxdg_toplevel_decoration_v1_set_mode(w->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + } + else if (w->display->kde_deco_manager) { + w->kde_deco = org_kde_kwin_server_decoration_manager_create(w->display->kde_deco_manager, w->surface); + if (!w->kde_deco) { + uwacErrorHandler(w->display, UWAC_NOT_FOUND, "Current window manager does not allow decorating with SSD"); + } + else + org_kde_kwin_server_decoration_request_mode(w->kde_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); + } + return UWAC_SUCCESS; +} UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t height, enum wl_shm_format format) @@ -447,24 +471,6 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h goto out_error_shell; } - if (w->display->deco_manager) { - w->deco = zxdg_decoration_manager_v1_get_toplevel_decoration( - w->display->deco_manager, w->xdg_toplevel); - if (!w->deco) { - uwacErrorHandler(w->display, UWAC_NOT_FOUND, "Current window manager does not allow decorating with SSD"); - } - else - zxdg_toplevel_decoration_v1_set_mode(w->deco, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - } - else if (w->display->kde_deco_manager) { - w->kde_deco = org_kde_kwin_server_decoration_manager_create(w->display->kde_deco_manager, w->surface); - if (!w->kde_deco) { - uwacErrorHandler(w->display, UWAC_NOT_FOUND, "Current window manager does not allow decorating with SSD"); - } - else - org_kde_kwin_server_decoration_request_mode(w->kde_deco, ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER); - } - assert(w->xdg_surface); xdg_toplevel_add_listener(w->xdg_toplevel, &xdg_toplevel_listener, w); } @@ -493,6 +499,7 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h wl_list_insert(display->windows.prev, &w->link); display->last_error = UWAC_SUCCESS; + UwacWindowSetDecorations(w); return w; out_error_shell: wl_surface_destroy(w->surface);