2022-02-21 03:18:38 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
2023-08-23 01:04:40 +02:00
|
|
|
#include <assert.h>
|
2025-07-28 01:22:10 -04:00
|
|
|
#include <wlr/types/wlr_scene.h>
|
2026-03-23 20:43:26 -07:00
|
|
|
#include "buffer.h"
|
2025-08-13 21:00:11 +09:00
|
|
|
#include "common/macros.h"
|
2026-03-23 20:43:26 -07:00
|
|
|
#include "common/mem.h"
|
2026-02-23 16:34:36 -05:00
|
|
|
#include "common/scene-helpers.h"
|
2026-03-21 22:47:22 -04:00
|
|
|
#include "config/rcxml.h"
|
2025-09-03 05:08:52 -04:00
|
|
|
#include "ssd.h"
|
2022-11-26 16:53:35 -05:00
|
|
|
#include "ssd-internal.h"
|
2022-02-21 03:18:38 +01:00
|
|
|
#include "theme.h"
|
2022-11-21 10:10:39 -05:00
|
|
|
#include "view.h"
|
2026-03-23 21:12:20 -07:00
|
|
|
|
2026-03-25 19:58:00 -07:00
|
|
|
#define PIXEL(x,y) (bw * y + x)
|
|
|
|
|
|
2022-02-21 03:18:38 +01:00
|
|
|
void
|
2022-11-26 16:06:22 -05:00
|
|
|
ssd_border_create(struct ssd *ssd)
|
2022-02-21 03:18:38 +01:00
|
|
|
{
|
2023-08-23 01:04:40 +02:00
|
|
|
assert(ssd);
|
|
|
|
|
assert(!ssd->border.tree);
|
|
|
|
|
|
2022-11-26 16:46:28 -05:00
|
|
|
struct view *view = ssd->view;
|
2026-03-21 22:47:22 -04:00
|
|
|
struct theme *theme = rc.theme;
|
2026-03-23 20:43:26 -07:00
|
|
|
int bw = theme->border_width;
|
2023-02-08 23:19:14 -05:00
|
|
|
int width = view->current.width;
|
2023-08-08 03:39:35 +02:00
|
|
|
int height = view_effective_height(view, /* use_pending */ false);
|
2022-02-21 03:18:38 +01:00
|
|
|
int full_width = width + 2 * theme->border_width;
|
2024-09-09 17:43:38 +02:00
|
|
|
int corner_width = ssd_get_corner_width();
|
2022-02-21 03:18:38 +01:00
|
|
|
|
2026-02-23 16:34:36 -05:00
|
|
|
ssd->border.tree = lab_wlr_scene_tree_create(ssd->tree);
|
2023-08-23 01:04:40 +02:00
|
|
|
wlr_scene_node_set_position(&ssd->border.tree->node, -theme->border_width, 0);
|
|
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
enum ssd_active_state active;
|
|
|
|
|
FOR_EACH_ACTIVE_STATE(active) {
|
|
|
|
|
struct ssd_border_subtree *subtree = &ssd->border.subtrees[active];
|
2026-02-23 16:34:36 -05:00
|
|
|
subtree->tree = lab_wlr_scene_tree_create(ssd->border.tree);
|
2025-08-13 21:00:11 +09:00
|
|
|
struct wlr_scene_tree *parent = subtree->tree;
|
2024-11-12 10:54:59 +09:00
|
|
|
wlr_scene_node_set_enabled(&parent->node, active);
|
2025-08-13 21:00:11 +09:00
|
|
|
float *color = theme->window[active].border_color;
|
2024-11-12 10:54:59 +09:00
|
|
|
|
2026-03-23 20:43:26 -07:00
|
|
|
|
2026-02-23 16:34:36 -05:00
|
|
|
subtree->left = lab_wlr_scene_rect_create(parent,
|
2025-08-13 21:00:11 +09:00
|
|
|
theme->border_width, height, color);
|
2026-03-23 21:12:20 -07:00
|
|
|
|
2026-02-23 16:34:36 -05:00
|
|
|
subtree->right = lab_wlr_scene_rect_create(parent,
|
2025-08-13 21:00:11 +09:00
|
|
|
theme->border_width, height, color);
|
2026-03-23 21:12:20 -07:00
|
|
|
|
2026-02-23 16:34:36 -05:00
|
|
|
subtree->bottom = lab_wlr_scene_rect_create(parent,
|
2025-08-13 21:00:11 +09:00
|
|
|
full_width, theme->border_width, color);
|
2026-03-23 21:12:20 -07:00
|
|
|
|
2026-02-23 16:34:36 -05:00
|
|
|
subtree->top = lab_wlr_scene_rect_create(parent,
|
2025-08-13 21:00:11 +09:00
|
|
|
MAX(width - 2 * corner_width, 0), theme->border_width, color);
|
2026-03-23 22:14:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (theme->beveled_border) {
|
2026-03-25 19:58:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int bevelSize = 2; // TODO: configurable
|
|
|
|
|
|
2026-03-23 22:14:28 -07:00
|
|
|
/* From Pull request 3382 */
|
|
|
|
|
uint8_t r = color[0] * 255;
|
|
|
|
|
uint8_t g = color[1] * 255;
|
|
|
|
|
uint8_t b = color[2] * 255;
|
|
|
|
|
uint8_t a = color[3] * 255;
|
|
|
|
|
|
|
|
|
|
/* highlight */
|
|
|
|
|
uint8_t r1 = MIN(r * 5 / 4, a);
|
|
|
|
|
uint8_t g1 = MIN(g * 5 / 4, a);
|
|
|
|
|
uint8_t b1 = MIN(b * 5 / 4, a);
|
|
|
|
|
|
|
|
|
|
/* darker outline */
|
|
|
|
|
uint8_t r0 = r / 2;
|
|
|
|
|
uint8_t g0 = g / 2;
|
|
|
|
|
uint8_t b0 = b / 2;
|
|
|
|
|
|
|
|
|
|
uint32_t col = ((uint32_t)a << 24) | ((uint32_t)r << 16)
|
|
|
|
|
| ((uint32_t)g << 8) | b;
|
|
|
|
|
uint32_t col0 = ((uint32_t)a << 24) | ((uint32_t)r0 << 16)
|
|
|
|
|
| ((uint32_t)g0 << 8) | b0;
|
|
|
|
|
uint32_t col1 = ((uint32_t)a << 24) | ((uint32_t)r1 << 16)
|
|
|
|
|
| ((uint32_t)g1 << 8) | b1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t *left_data = znew_n(uint32_t, bw);
|
|
|
|
|
uint32_t *top_data = znew_n(uint32_t, bw);
|
2026-03-25 19:58:00 -07:00
|
|
|
uint32_t *right_data = znew_n(uint32_t, theme->border_width);
|
|
|
|
|
uint32_t *bottom_data = znew_n(uint32_t, theme->border_width);
|
2026-03-23 22:14:28 -07:00
|
|
|
|
2026-03-25 19:58:00 -07:00
|
|
|
for (int i = 0; i < bw; i++) {
|
|
|
|
|
if (i<bevelSize) {
|
|
|
|
|
left_data[i] = col1;
|
|
|
|
|
top_data[i] = col1;
|
|
|
|
|
right_data[i] = col1;
|
|
|
|
|
bottom_data[i] = col1;
|
|
|
|
|
|
|
|
|
|
} else if (i > (bw-bevelSize-1)) {
|
|
|
|
|
left_data[i] = col0;
|
|
|
|
|
top_data[i] = col0;
|
|
|
|
|
right_data[i] = col0;
|
|
|
|
|
bottom_data[i] = col0;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
left_data[i] = col;
|
|
|
|
|
top_data[i] = col;
|
|
|
|
|
right_data[i] = col;
|
|
|
|
|
bottom_data[i] = col;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-23 22:14:28 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t *tl_data = znew_n(uint32_t, bw*bw);
|
|
|
|
|
uint32_t *tr_data = znew_n(uint32_t, bw*bw);
|
|
|
|
|
uint32_t *bl_data = znew_n(uint32_t, bw*bw);
|
|
|
|
|
uint32_t *br_data = znew_n(uint32_t, bw*bw);
|
2026-03-25 19:58:00 -07:00
|
|
|
// Fill with solid
|
2026-03-23 22:14:28 -07:00
|
|
|
for (int i=0; i<bw;i++) {
|
|
|
|
|
for (int j=0; j<bw;j++) {
|
2026-03-25 19:58:00 -07:00
|
|
|
tl_data[PIXEL(i, j)] = col;
|
|
|
|
|
tr_data[PIXEL(i, j)] = col;
|
|
|
|
|
bl_data[PIXEL(i, j)] = col;
|
|
|
|
|
br_data[PIXEL(i, j)] = col;
|
2026-03-23 22:14:28 -07:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-25 19:58:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Main Corners
|
|
|
|
|
for (int i=0; i < bevelSize; i++) {
|
|
|
|
|
|
|
|
|
|
// Solid bar parts
|
|
|
|
|
for (int j=0; j<bw; j++) {
|
|
|
|
|
// Top left corner: Entire "bevel size" top rows are highlighted
|
|
|
|
|
tl_data[PIXEL(j, i)] = col1;
|
|
|
|
|
// First "bevel size" top columns are highlighted
|
|
|
|
|
tl_data[PIXEL(i, j)] = col1;
|
|
|
|
|
|
|
|
|
|
// Bottom Right corner: Entire "bevel size" last rows are lowlight
|
|
|
|
|
br_data[PIXEL(j, (bw-1-i))] = col0;
|
|
|
|
|
// Last "bevel size" columns are lowlight
|
|
|
|
|
br_data[PIXEL((bw-1-i), j)] = col0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bottom left corner: Entire "bevel size" last rows are lowlight
|
|
|
|
|
bl_data[PIXEL(j, (bw-1-i))] = col0;
|
|
|
|
|
// First "bevel size" columns are highlight, except for the bottom right corner
|
|
|
|
|
bl_data[PIXEL(i, j)] = col1;
|
|
|
|
|
|
|
|
|
|
// Top Right corner: Entire "bevel size" first rows are highlight
|
|
|
|
|
tr_data[PIXEL(j, i)] = col1;
|
|
|
|
|
// Last "bevel size" columns are lowlight, except for the top left
|
|
|
|
|
tr_data[PIXEL((bw-1-i), j)] = col0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Beveled Corner Parts
|
|
|
|
|
for (int i=0; i < bevelSize; i++) {
|
|
|
|
|
|
|
|
|
|
for (int j=0; j<bevelSize; j++) {
|
|
|
|
|
// Outer Corners
|
|
|
|
|
// Bottom left corner:
|
|
|
|
|
// First "bevel size" columns are highlight, except for the bottom right corner
|
|
|
|
|
bl_data[PIXEL(i, (bw - 1 - j))] = (j >= i) ? col1 : col0;
|
|
|
|
|
|
|
|
|
|
// Top Right corner:
|
|
|
|
|
// Last "bevel size" columns are lowlight, except for the top left
|
|
|
|
|
tr_data[PIXEL((bw-1-i), j)] = (j > i) ? col0 : col1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Inner Corners
|
|
|
|
|
// Top left corner: Bottom right is all dark
|
|
|
|
|
tl_data[PIXEL((bw-1-i), (bw - 1 - j))] = col0;
|
|
|
|
|
|
|
|
|
|
// Bottom Right corner: Top left is all light
|
|
|
|
|
br_data[PIXEL(i, j)] = col1;
|
|
|
|
|
|
|
|
|
|
// Top Right corner:
|
|
|
|
|
// Interior bottom left is dark on top, light on bottom
|
|
|
|
|
tr_data[PIXEL(i, (bw-1-j))] = (i > j) ? col1 : col0;
|
|
|
|
|
|
|
|
|
|
// Bottom Left corner:
|
|
|
|
|
// Interior top right is dark on top, light on bottom
|
|
|
|
|
bl_data[PIXEL((bw-1-i), j)] = (i > j) ? col0 : col1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-23 22:14:28 -07:00
|
|
|
tl_data[bw*bw -1] = col0;
|
|
|
|
|
tl_data[bw*bw -2] = col0;
|
|
|
|
|
tl_data[(bw-1)*bw -1] = col0;
|
|
|
|
|
tl_data[(bw-1)*bw -2] = col0;
|
|
|
|
|
tr_data[(bw-1)*bw + (0)] = col0;
|
2026-03-25 19:58:00 -07:00
|
|
|
tr_data[(bw-1)*bw + (1)] = col1;
|
2026-03-23 22:14:28 -07:00
|
|
|
tr_data[(bw-2)*bw + (0)] = col0;
|
|
|
|
|
tr_data[(bw-2)*bw + (1)] = col0;
|
2026-03-25 19:58:00 -07:00
|
|
|
bl_data[(0)*bw + (bw-1)] = col0;
|
|
|
|
|
bl_data[(0)*bw + (bw-2)] = col0;
|
2026-03-23 22:14:28 -07:00
|
|
|
bl_data[(1)*bw + (bw-1)] = col1;
|
2026-03-25 19:58:00 -07:00
|
|
|
bl_data[(1)*bw + (bw-2)] = col0;
|
2026-03-23 22:14:28 -07:00
|
|
|
br_data[(0)*bw + (0)] = col1;
|
|
|
|
|
br_data[(0)*bw + (1)] = col1;
|
|
|
|
|
br_data[(1)*bw + (0)] = col1;
|
|
|
|
|
br_data[(1)*bw + (1)] = col1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *ttexture_buffer =
|
|
|
|
|
buffer_create_from_data(top_data, 1,theme->border_width,
|
|
|
|
|
4);
|
|
|
|
|
subtree->ttexture = wlr_scene_buffer_create(parent, &ttexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&ttexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *btexture_buffer =
|
|
|
|
|
buffer_create_from_data(bottom_data, 1,theme->border_width,
|
|
|
|
|
4);
|
|
|
|
|
subtree->btexture = wlr_scene_buffer_create(parent, &btexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&btexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *ltexture_buffer =
|
|
|
|
|
buffer_create_from_data(left_data, theme->border_width, 1,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->ltexture = wlr_scene_buffer_create(parent, <exture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(<exture_buffer->base);
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *rtexture_buffer =
|
|
|
|
|
buffer_create_from_data(right_data, theme->border_width, 1,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->rtexture = wlr_scene_buffer_create(parent, &rtexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&rtexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *tltexture_buffer =
|
|
|
|
|
buffer_create_from_data(tl_data, theme->border_width, theme->border_width,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->tlcorner = wlr_scene_buffer_create(parent, &tltexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&tltexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *trtexture_buffer =
|
|
|
|
|
buffer_create_from_data(tr_data, theme->border_width, theme->border_width,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->trcorner = wlr_scene_buffer_create(parent, &trtexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&trtexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *bltexture_buffer =
|
|
|
|
|
buffer_create_from_data(bl_data, theme->border_width, theme->border_width,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->blcorner = wlr_scene_buffer_create(parent, &bltexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&bltexture_buffer->base);
|
|
|
|
|
|
|
|
|
|
struct lab_data_buffer *brtexture_buffer =
|
|
|
|
|
buffer_create_from_data(br_data, theme->border_width, theme->border_width,
|
|
|
|
|
4*theme->border_width);
|
|
|
|
|
subtree->brcorner = wlr_scene_buffer_create(parent, &brtexture_buffer->base);
|
|
|
|
|
wlr_buffer_drop(&brtexture_buffer->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!theme->beveled_border) {
|
|
|
|
|
wlr_scene_node_set_position(&subtree->left->node, 0, 0);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->right->node,
|
|
|
|
|
theme->border_width + width, 0);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->bottom->node,
|
|
|
|
|
0, height);
|
2026-03-23 20:43:26 -07:00
|
|
|
|
2026-03-23 22:14:28 -07:00
|
|
|
wlr_scene_node_set_position(&subtree->top->node,
|
|
|
|
|
theme->border_width + corner_width,
|
|
|
|
|
-(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
}
|
2026-03-23 20:43:26 -07:00
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
}
|
2026-03-23 20:43:26 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-25 15:37:28 +02:00
|
|
|
|
view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.
Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).
Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.
Internally, I've taken the following approach:
- SSD code decorates the view as "maximized" (i.e. hiding borders) only
if maximized in both directions.
- Layout code (interactive move/resize, tiling, etc.) generally treats
the view as "maximized" (with the restrictions that entails) if
maximized in either direction. For example, moving a vertically-
maximized view first restores the natural geometry (this differs from
Openbox, which instead allows the view to move only horizontally.)
v2: use enum view_axis for view->maximized
v3:
- update docs
- allow resizing if partly maximized
- add TODOs & corrections noted by Consolatis
2023-10-26 00:38:29 -04:00
|
|
|
if (view->maximized == VIEW_AXIS_BOTH) {
|
2023-08-25 15:37:28 +02:00
|
|
|
wlr_scene_node_set_enabled(&ssd->border.tree->node, false);
|
|
|
|
|
}
|
2024-07-19 21:45:24 +02:00
|
|
|
|
|
|
|
|
if (view->current.width > 0 && view->current.height > 0) {
|
|
|
|
|
/*
|
|
|
|
|
* The SSD is recreated by a Reconfigure request
|
|
|
|
|
* thus we may need to handle squared corners.
|
|
|
|
|
*/
|
|
|
|
|
ssd_border_update(ssd);
|
|
|
|
|
}
|
2022-02-21 03:18:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2022-11-26 16:06:22 -05:00
|
|
|
ssd_border_update(struct ssd *ssd)
|
2022-02-21 03:18:38 +01:00
|
|
|
{
|
2023-08-23 01:04:40 +02:00
|
|
|
assert(ssd);
|
|
|
|
|
assert(ssd->border.tree);
|
|
|
|
|
|
2022-11-26 16:46:28 -05:00
|
|
|
struct view *view = ssd->view;
|
view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.
Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).
Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.
Internally, I've taken the following approach:
- SSD code decorates the view as "maximized" (i.e. hiding borders) only
if maximized in both directions.
- Layout code (interactive move/resize, tiling, etc.) generally treats
the view as "maximized" (with the restrictions that entails) if
maximized in either direction. For example, moving a vertically-
maximized view first restores the natural geometry (this differs from
Openbox, which instead allows the view to move only horizontally.)
v2: use enum view_axis for view->maximized
v3:
- update docs
- allow resizing if partly maximized
- add TODOs & corrections noted by Consolatis
2023-10-26 00:38:29 -04:00
|
|
|
if (view->maximized == VIEW_AXIS_BOTH
|
|
|
|
|
&& ssd->border.tree->node.enabled) {
|
2023-08-23 01:04:40 +02:00
|
|
|
/* Disable borders on maximize */
|
|
|
|
|
wlr_scene_node_set_enabled(&ssd->border.tree->node, false);
|
|
|
|
|
ssd->margin = ssd_thickness(ssd->view);
|
|
|
|
|
}
|
|
|
|
|
|
view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.
Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).
Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.
Internally, I've taken the following approach:
- SSD code decorates the view as "maximized" (i.e. hiding borders) only
if maximized in both directions.
- Layout code (interactive move/resize, tiling, etc.) generally treats
the view as "maximized" (with the restrictions that entails) if
maximized in either direction. For example, moving a vertically-
maximized view first restores the natural geometry (this differs from
Openbox, which instead allows the view to move only horizontally.)
v2: use enum view_axis for view->maximized
v3:
- update docs
- allow resizing if partly maximized
- add TODOs & corrections noted by Consolatis
2023-10-26 00:38:29 -04:00
|
|
|
if (view->maximized == VIEW_AXIS_BOTH) {
|
2023-08-23 01:04:40 +02:00
|
|
|
return;
|
|
|
|
|
} else if (!ssd->border.tree->node.enabled) {
|
|
|
|
|
/* And re-enabled them when unmaximized */
|
|
|
|
|
wlr_scene_node_set_enabled(&ssd->border.tree->node, true);
|
|
|
|
|
ssd->margin = ssd_thickness(ssd->view);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 22:47:22 -04:00
|
|
|
struct theme *theme = rc.theme;
|
2022-02-21 03:18:38 +01:00
|
|
|
|
2023-02-08 23:19:14 -05:00
|
|
|
int width = view->current.width;
|
2023-08-08 03:39:35 +02:00
|
|
|
int height = view_effective_height(view, /* use_pending */ false);
|
2022-02-21 03:18:38 +01:00
|
|
|
int full_width = width + 2 * theme->border_width;
|
2024-09-09 17:43:38 +02:00
|
|
|
int corner_width = ssd_get_corner_width();
|
2022-02-21 03:18:38 +01:00
|
|
|
|
2024-06-22 23:27:37 +02:00
|
|
|
/*
|
|
|
|
|
* From here on we have to cover the following border scenarios:
|
|
|
|
|
* Non-tiled (partial border, rounded corners):
|
|
|
|
|
* _____________
|
|
|
|
|
* o oox
|
|
|
|
|
* |---------------|
|
|
|
|
|
* |_______________|
|
|
|
|
|
*
|
|
|
|
|
* Tiled (full border, squared corners):
|
|
|
|
|
* _______________
|
|
|
|
|
* |o oox|
|
|
|
|
|
* |---------------|
|
|
|
|
|
* |_______________|
|
|
|
|
|
*
|
|
|
|
|
* Tiled or non-tiled with zero title height (full boarder, no title):
|
|
|
|
|
* _______________
|
|
|
|
|
* |_______________|
|
|
|
|
|
*/
|
|
|
|
|
|
2024-08-25 16:33:41 +09:00
|
|
|
int side_height = ssd->state.was_squared
|
2024-06-22 23:27:37 +02:00
|
|
|
? height + ssd->titlebar.height
|
|
|
|
|
: height;
|
2024-08-25 16:33:41 +09:00
|
|
|
int side_y = ssd->state.was_squared
|
2024-06-22 23:27:37 +02:00
|
|
|
? -ssd->titlebar.height
|
|
|
|
|
: 0;
|
2024-08-25 16:33:41 +09:00
|
|
|
int top_width = ssd->titlebar.height <= 0 || ssd->state.was_squared
|
2024-06-22 23:27:37 +02:00
|
|
|
? full_width
|
2025-05-04 22:33:12 +09:00
|
|
|
: MAX(width - 2 * corner_width, 0);
|
2024-08-25 16:33:41 +09:00
|
|
|
int top_x = ssd->titlebar.height <= 0 || ssd->state.was_squared
|
2024-06-22 23:27:37 +02:00
|
|
|
? 0
|
2024-09-09 17:43:38 +02:00
|
|
|
: theme->border_width + corner_width;
|
2024-06-22 23:27:37 +02:00
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
enum ssd_active_state active;
|
|
|
|
|
FOR_EACH_ACTIVE_STATE(active) {
|
|
|
|
|
struct ssd_border_subtree *subtree = &ssd->border.subtrees[active];
|
2026-03-23 20:43:26 -07:00
|
|
|
|
|
|
|
|
|
2026-03-23 22:14:28 -07:00
|
|
|
if (theme->beveled_border) {
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->ttexture,
|
|
|
|
|
full_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->ttexture->node,
|
|
|
|
|
0, -(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->rtexture,
|
|
|
|
|
theme->border_width, side_height+(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
wlr_scene_node_set_position(&subtree->rtexture->node,
|
|
|
|
|
theme->border_width + width, -(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->btexture,
|
|
|
|
|
full_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->btexture->node,
|
|
|
|
|
0, height);
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->ltexture,
|
|
|
|
|
theme->border_width, side_height+(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
wlr_scene_node_set_position(&subtree->ltexture->node,
|
|
|
|
|
0, -(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->tlcorner,
|
|
|
|
|
theme->border_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->tlcorner->node,
|
|
|
|
|
0, -(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->trcorner,
|
|
|
|
|
theme->border_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->trcorner->node,
|
|
|
|
|
theme->border_width + width, -(ssd->titlebar.height + theme->border_width));
|
2026-03-23 20:43:26 -07:00
|
|
|
|
|
|
|
|
|
2026-03-23 22:14:28 -07:00
|
|
|
wlr_scene_buffer_set_dest_size(subtree->brcorner,
|
|
|
|
|
theme->border_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->brcorner->node,
|
|
|
|
|
theme->border_width + width, height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_scene_buffer_set_dest_size(subtree->blcorner,
|
|
|
|
|
theme->border_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->blcorner->node,
|
|
|
|
|
0, height);
|
|
|
|
|
} else {
|
|
|
|
|
wlr_scene_rect_set_size(subtree->left,
|
|
|
|
|
theme->border_width, side_height);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->left->node,
|
|
|
|
|
0, side_y);
|
|
|
|
|
wlr_scene_rect_set_size(subtree->right,
|
|
|
|
|
theme->border_width, side_height);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->right->node,
|
|
|
|
|
theme->border_width + width, side_y);
|
|
|
|
|
wlr_scene_rect_set_size(subtree->bottom,
|
|
|
|
|
full_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->bottom->node,
|
|
|
|
|
0, height);
|
|
|
|
|
wlr_scene_rect_set_size(subtree->top,
|
|
|
|
|
top_width, theme->border_width);
|
|
|
|
|
wlr_scene_node_set_position(&subtree->top->node,
|
|
|
|
|
top_x, -(ssd->titlebar.height + theme->border_width));
|
|
|
|
|
}
|
2025-08-13 21:00:11 +09:00
|
|
|
}
|
2022-02-21 03:18:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2022-11-26 16:06:22 -05:00
|
|
|
ssd_border_destroy(struct ssd *ssd)
|
2022-02-21 03:18:38 +01:00
|
|
|
{
|
2023-08-23 01:04:40 +02:00
|
|
|
assert(ssd);
|
|
|
|
|
assert(ssd->border.tree);
|
2022-02-21 03:18:38 +01:00
|
|
|
|
2023-08-23 01:04:40 +02:00
|
|
|
wlr_scene_node_destroy(&ssd->border.tree->node);
|
2025-08-13 21:00:11 +09:00
|
|
|
ssd->border = (struct ssd_border_scene){0};
|
2022-02-21 03:18:38 +01:00
|
|
|
}
|