Decorations: respect earlier client side decoration negotion result

Before this patch, it was impossible to differentiate between negotiations
resulting in client side decorations and no negotiations at all.

By adding an enum we are now able to differentiate between the two states.
This commit is contained in:
Consolatis 2023-03-22 19:53:17 +01:00 committed by Johan Malm
parent 082dc79555
commit 35e71ada82
3 changed files with 26 additions and 3 deletions

View file

@ -20,6 +20,12 @@ enum view_type {
#endif
};
enum ssd_preference {
LAB_SSD_PREF_UNSPEC = 0,
LAB_SSD_PREF_CLIENT,
LAB_SSD_PREF_SERVER,
};
struct view;
struct view_impl {
void (*configure)(struct view *view, struct wlr_box geo);
@ -63,6 +69,7 @@ struct view {
bool mapped;
bool been_mapped;
bool ssd_enabled;
enum ssd_preference ssd_preference;
bool minimized;
bool maximized;
bool fullscreen;

View file

@ -28,10 +28,22 @@ xdg_deco_request_mode(struct wl_listener *listener, void *data)
enum wlr_xdg_toplevel_decoration_v1_mode client_mode =
xdg_deco->wlr_decoration->requested_mode;
if (client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE) {
switch (client_mode) {
case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE:
xdg_deco->view->ssd_preference = LAB_SSD_PREF_SERVER;
break;
case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE:
xdg_deco->view->ssd_preference = LAB_SSD_PREF_CLIENT;
break;
case WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE:
xdg_deco->view->ssd_preference = LAB_SSD_PREF_UNSPEC;
client_mode = rc.xdg_shell_server_side_deco
? WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
: WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
break;
default:
wlr_log(WLR_ERROR, "Unspecified decoration variant requested: %u",
client_mode);
}
wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_decoration, client_mode);

View file

@ -48,9 +48,13 @@ handle_new_xdg_popup(struct wl_listener *listener, void *data)
static bool
has_ssd(struct view *view)
{
if (view->ssd_enabled) {
/* View prefers server side decorations */
switch (view->ssd_preference) {
case LAB_SSD_PREF_SERVER:
return true;
case LAB_SSD_PREF_CLIENT:
return false;
default:
break;
}
if (!rc.xdg_shell_server_side_deco) {