decorations: make has_ssd public

This commit is contained in:
Tobias Bengfort 2024-04-19 13:35:16 +02:00
parent 7761d11dae
commit d5f39c2ea0
3 changed files with 33 additions and 31 deletions

View file

@ -87,6 +87,7 @@ bool ssd_is_button(enum ssd_part_type type);
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
/* TODO: clean up / update */
bool has_ssd(struct view *view);
struct border ssd_thickness(struct view *view);
struct wlr_box ssd_max_extents(struct view *view);

View file

@ -13,6 +13,38 @@
#include "ssd-internal.h"
#include "theme.h"
#include "view.h"
#include "window-rules.h"
bool
has_ssd(struct view *view)
{
/* Window-rules take priority if they exist for this view */
switch (window_rules_get_property(view, "serverDecoration")) {
case LAB_PROP_TRUE:
return true;
case LAB_PROP_FALSE:
return false;
default:
break;
}
/*
* view->ssd_preference may be set by the decoration implementation
* e.g. src/decorations/xdg-deco.c or src/decorations/kde-deco.c.
*/
switch (view->ssd_preference) {
case LAB_SSD_PREF_SERVER:
return true;
case LAB_SSD_PREF_CLIENT:
return false;
default:
/*
* We don't know anything about the client preference
* so fall back to core.decoration settings in rc.xml
*/
return rc.xdg_shell_server_side_deco;
}
}
struct border
ssd_thickness(struct view *view)

View file

@ -53,37 +53,6 @@ handle_new_popup(struct wl_listener *listener, void *data)
xdg_popup_create(view, wlr_popup);
}
static bool
has_ssd(struct view *view)
{
/* Window-rules take priority if they exist for this view */
switch (window_rules_get_property(view, "serverDecoration")) {
case LAB_PROP_TRUE:
return true;
case LAB_PROP_FALSE:
return false;
default:
break;
}
/*
* view->ssd_preference may be set by the decoration implementation
* e.g. src/decorations/xdg-deco.c or src/decorations/kde-deco.c.
*/
switch (view->ssd_preference) {
case LAB_SSD_PREF_SERVER:
return true;
case LAB_SSD_PREF_CLIENT:
return false;
default:
/*
* We don't know anything about the client preference
* so fall back to core.decoration settings in rc.xml
*/
return rc.xdg_shell_server_side_deco;
}
}
static void
handle_commit(struct wl_listener *listener, void *data)
{