Skip to content

Commit 527b698

Browse files
committed
GPU Wayland Display: Use server side decoration, now that they are more widely available
1 parent 8966232 commit 527b698

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
279279
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
280280
mSeat = (wl_seat*)wl_registry_bind(registry, name, &wl_seat_interface, 1);
281281
wl_seat_add_listener(mSeat, &seat_listener, &seat_capabilities_c);
282-
} else if (strcmp(interface, zxdg_toplevel_decoration_v1_interface.name) == 0) {
283-
mDecManager = (zxdg_decoration_manager_v1*)wl_registry_bind(registry, name, &zxdg_toplevel_decoration_v1_interface, 1);
282+
} else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
283+
mDecManager = (zxdg_decoration_manager_v1*)wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1);
284284
}
285285
};
286286

@@ -321,7 +321,7 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
321321
if (me->mDisplayRunning) {
322322
me->ResizeScene(me->mWidthRequested, me->mHeightRequested); // Swapchain is recreated by the backend, Vulkan WSI commits the new buffer
323323
} else {
324-
me->mDisplayWidth = me->mWidthRequested; // Initial size, used by InitDisplay via getSize()
324+
me->mDisplayWidth = me->mWidthRequested;
325325
me->mDisplayHeight = me->mHeightRequested;
326326
}
327327
}
@@ -349,8 +349,11 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
349349

350350
xdg_toplevel_set_title(mXdgToplevel, DISPLAY_WINDOW_NAME);
351351

352-
if (mDecManager) {
353-
printf("Enabling decoration\n");
352+
if (mDecManager) { // Must be requested before the first commit. Without the protocol (e.g. GNOME), the window has no decorations
353+
mXdgDecoration = zxdg_decoration_manager_v1_get_toplevel_decoration(mDecManager, mXdgToplevel);
354+
zxdg_toplevel_decoration_v1_set_mode(mXdgDecoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
355+
} else if (mDisplay->GetProcessingSettings().debugLevel >= 0) {
356+
GPUInfo("Wayland compositor does not support server-side decorations");
354357
}
355358

356359
wl_surface_commit(mSurface); // Initial commit without buffer, the compositor answers with the first configure
@@ -406,9 +409,17 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
406409
wl_keyboard_release(mKeyboard);
407410
mKeyboard = nullptr;
408411
}
412+
if (mXdgDecoration) {
413+
zxdg_toplevel_decoration_v1_destroy(mXdgDecoration);
414+
mXdgDecoration = nullptr;
415+
}
409416
xdg_toplevel_destroy(mXdgToplevel);
410417
xdg_surface_destroy(mXdgSurface);
411418
wl_surface_destroy(mSurface);
419+
if (mDecManager) {
420+
zxdg_decoration_manager_v1_destroy(mDecManager);
421+
mDecManager = nullptr;
422+
}
412423
wl_registry_destroy(mRegistry);
413424
wl_display_disconnect(mWayland);
414425

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend
6666

6767
wl_output* mOutput = nullptr;
6868

69-
7069
xkb_context* mXKBcontext = nullptr;
7170
xkb_keymap* mXKBkeymap = nullptr;
7271
xkb_state* mXKBstate = nullptr;
7372

7473
zxdg_decoration_manager_v1* mDecManager = nullptr;
75-
// zxdg_toplevel_decoration_v1* mXdgDecoration = nullptr;
74+
zxdg_toplevel_decoration_v1* mXdgDecoration = nullptr;
7675

7776
int32_t mWidthRequested = 0;
7877
int32_t mHeightRequested = 0;

0 commit comments

Comments
 (0)