mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
decorations: refactor view_set_decorations
This commit is contained in:
parent
a8f98cb90b
commit
38ac6c59d6
8 changed files with 78 additions and 49 deletions
|
|
@ -65,7 +65,7 @@ void ssd_set_active(struct ssd *ssd, bool active);
|
|||
void ssd_update_title(struct ssd *ssd);
|
||||
void ssd_update_geometry(struct ssd *ssd);
|
||||
void ssd_destroy(struct ssd *ssd);
|
||||
void ssd_titlebar_hide(struct ssd *ssd);
|
||||
void ssd_set_titlebar(struct ssd *ssd, bool enabled);
|
||||
|
||||
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
|
||||
void ssd_enable_shade(struct ssd *ssd, bool enable);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@ enum ssd_preference {
|
|||
LAB_SSD_PREF_SERVER,
|
||||
};
|
||||
|
||||
enum ssd_mode {
|
||||
LAB_SSD_MODE_NONE,
|
||||
LAB_SSD_MODE_BORDER,
|
||||
LAB_SSD_MODE_FULL
|
||||
};
|
||||
|
||||
/**
|
||||
* Directions in which a view can be maximized. "None" is used
|
||||
* internally to mean "not maximized" but is not valid in rc.xml.
|
||||
|
|
@ -452,7 +458,7 @@ void view_toggle_visible_on_all_workspaces(struct view *view);
|
|||
bool view_is_tiled(struct view *view);
|
||||
bool view_is_floating(struct view *view);
|
||||
void view_move_to_workspace(struct view *view, struct workspace *workspace);
|
||||
void view_set_decorations(struct view *view, bool decorations);
|
||||
void view_set_decorations(struct view *view, enum ssd_mode mode);
|
||||
void view_toggle_fullscreen(struct view *view);
|
||||
void view_invalidate_last_layout_geometry(struct view *view);
|
||||
void view_adjust_for_layout_change(struct view *view);
|
||||
|
|
|
|||
|
|
@ -52,8 +52,11 @@ handle_mode(struct wl_listener *listener, void *data)
|
|||
"requested: %u", client_mode);
|
||||
}
|
||||
|
||||
view_set_decorations(kde_deco->view,
|
||||
kde_deco->view->ssd_preference == LAB_SSD_PREF_SERVER);
|
||||
if (kde_deco->view->ssd_preference == LAB_SSD_PREF_SERVER) {
|
||||
view_set_decorations(kde_deco->view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(kde_deco->view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -48,8 +48,11 @@ xdg_deco_request_mode(struct wl_listener *listener, void *data)
|
|||
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_xdg_decoration,
|
||||
client_mode);
|
||||
view_set_decorations(xdg_deco->view,
|
||||
client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
if (client_mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) {
|
||||
view_set_decorations(xdg_deco->view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(xdg_deco->view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ ssd_create(struct view *view, bool active)
|
|||
ssd_titlebar_create(ssd);
|
||||
if (view->ssd_titlebar_hidden) {
|
||||
/* Ensure we keep the old state on Reconfigure or when exiting fullscreen */
|
||||
ssd_titlebar_hide(ssd);
|
||||
ssd_set_titlebar(ssd, false);
|
||||
}
|
||||
ssd->margin = ssd_thickness(view);
|
||||
ssd_set_active(ssd, active);
|
||||
|
|
@ -254,13 +254,13 @@ ssd_update_geometry(struct ssd *ssd)
|
|||
}
|
||||
|
||||
void
|
||||
ssd_titlebar_hide(struct ssd *ssd)
|
||||
ssd_set_titlebar(struct ssd *ssd, bool enabled)
|
||||
{
|
||||
if (!ssd || !ssd->titlebar.tree->node.enabled) {
|
||||
if (!ssd || ssd->titlebar.tree->node.enabled == enabled) {
|
||||
return;
|
||||
}
|
||||
wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, false);
|
||||
ssd->titlebar.height = 0;
|
||||
wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, enabled);
|
||||
ssd->titlebar.height = enabled ? ssd->view->server->theme->title_height : 0;
|
||||
ssd_border_update(ssd);
|
||||
ssd_extents_update(ssd);
|
||||
ssd->margin = ssd_thickness(ssd->view);
|
||||
|
|
|
|||
68
src/view.c
68
src/view.c
|
|
@ -1198,25 +1198,14 @@ view_toggle_decorations(struct view *view)
|
|||
{
|
||||
assert(view);
|
||||
|
||||
/* Reject decoration toggles when shaded */
|
||||
if (view->shaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rc.ssd_keep_border && view->ssd_enabled && view->ssd
|
||||
if (rc.ssd_keep_border && view->ssd_enabled
|
||||
&& !view->ssd_titlebar_hidden) {
|
||||
/*
|
||||
* ssd_titlebar_hidden has to be set before calling
|
||||
* ssd_titlebar_hide() to make ssd_thickness() happy.
|
||||
*/
|
||||
view->ssd_titlebar_hidden = true;
|
||||
ssd_titlebar_hide(view->ssd);
|
||||
if (!view_is_floating(view)) {
|
||||
view_apply_special_geometry(view);
|
||||
}
|
||||
return;
|
||||
view_set_decorations(view, LAB_SSD_MODE_BORDER);
|
||||
} else if (view->ssd_enabled) {
|
||||
view_set_decorations(view, LAB_SSD_MODE_NONE);
|
||||
} else {
|
||||
view_set_decorations(view, LAB_SSD_MODE_FULL);
|
||||
}
|
||||
view_set_decorations(view, !view->ssd_enabled);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1299,25 +1288,38 @@ undecorate(struct view *view)
|
|||
}
|
||||
|
||||
void
|
||||
view_set_decorations(struct view *view, bool decorations)
|
||||
view_set_decorations(struct view *view, enum ssd_mode mode)
|
||||
{
|
||||
assert(view);
|
||||
|
||||
if (view->ssd_enabled != decorations && !view->fullscreen) {
|
||||
/*
|
||||
* Set view->ssd_enabled first since it is referenced
|
||||
* within the call tree of ssd_create()
|
||||
*/
|
||||
view->ssd_enabled = decorations;
|
||||
if (decorations) {
|
||||
decorate(view);
|
||||
} else {
|
||||
undecorate(view);
|
||||
view->ssd_titlebar_hidden = false;
|
||||
}
|
||||
if (!view_is_floating(view)) {
|
||||
view_apply_special_geometry(view);
|
||||
}
|
||||
if (view->shaded || view->fullscreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ssd_enabled = mode != LAB_SSD_MODE_NONE;
|
||||
bool titlebar_hidden = mode != LAB_SSD_MODE_FULL;
|
||||
|
||||
if (view->ssd_enabled == ssd_enabled
|
||||
&& view->ssd_titlebar_hidden == titlebar_hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set these first since they are referenced
|
||||
* within the call tree of ssd_create() and ssd_thickness()
|
||||
*/
|
||||
view->ssd_enabled = ssd_enabled;
|
||||
view->ssd_titlebar_hidden = titlebar_hidden;
|
||||
|
||||
if (ssd_enabled) {
|
||||
decorate(view);
|
||||
ssd_set_titlebar(view->ssd, !titlebar_hidden);
|
||||
} else {
|
||||
undecorate(view);
|
||||
}
|
||||
|
||||
if (!view_is_floating(view)) {
|
||||
view_apply_special_geometry(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -577,7 +577,11 @@ xdg_toplevel_view_map(struct view *view)
|
|||
|
||||
init_foreign_toplevel(view);
|
||||
|
||||
view_set_decorations(view, has_ssd(view));
|
||||
if (has_ssd(view)) {
|
||||
view_set_decorations(view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set initial "pending" dimensions (may be modified by
|
||||
|
|
|
|||
|
|
@ -420,8 +420,11 @@ handle_request_maximize(struct wl_listener *listener, void *data)
|
|||
* Set decorations early to avoid changing geometry
|
||||
* after maximize (reduces visual glitches).
|
||||
*/
|
||||
view_set_decorations(view,
|
||||
want_deco(xwayland_surface_from_view(view)));
|
||||
if (want_deco(xwayland_surface_from_view(view))) {
|
||||
view_set_decorations(view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
}
|
||||
view_toggle_maximize(view, VIEW_AXIS_BOTH);
|
||||
}
|
||||
|
|
@ -493,7 +496,11 @@ handle_set_decorations(struct wl_listener *listener, void *data)
|
|||
wl_container_of(listener, xwayland_view, set_decorations);
|
||||
struct view *view = &xwayland_view->base;
|
||||
|
||||
view_set_decorations(view, want_deco(xwayland_view->xwayland_surface));
|
||||
if (want_deco(xwayland_view->xwayland_surface)) {
|
||||
view_set_decorations(view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -643,7 +650,11 @@ xwayland_view_map(struct view *view)
|
|||
*/
|
||||
view_set_fullscreen(view, xwayland_surface->fullscreen);
|
||||
if (!view->been_mapped) {
|
||||
view_set_decorations(view, want_deco(xwayland_surface));
|
||||
if (want_deco(xwayland_surface)) {
|
||||
view_set_decorations(view, LAB_SSD_MODE_FULL);
|
||||
} else {
|
||||
view_set_decorations(view, LAB_SSD_MODE_NONE);
|
||||
}
|
||||
}
|
||||
enum view_axis axis = VIEW_AXIS_NONE;
|
||||
if (xwayland_surface->maximized_horz) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue