Skip to content

Commit 40c2cd6

Browse files
committed
Make SSD borders lighter than SSD titlebars
1 parent 8b633ad commit 40c2cd6

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/decorations/ssd.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
constexpr uint8_t TITLEBAR_HEIGHT = 24;
77
constexpr uint32_t TITLEBAR_COLOR = 0x303030;
8+
constexpr uint8_t BORDER_WIDTH = 1;
9+
constexpr uint32_t BORDER_COLOR = 0x505050;
810

911
static consteval std::array<float, 4> rrggbb_to_floats(uint32_t rrggbb) {
1012
return std::array<float, 4>(
@@ -17,14 +19,18 @@ Ssd::Ssd(View& parent) noexcept : view(parent) {
1719
wlr_scene_node_set_position(&scene_tree->node, 0, 0);
1820
wlr_scene_node_set_enabled(&scene_tree->node, true);
1921

20-
auto color = rrggbb_to_floats(TITLEBAR_COLOR);
21-
titlebar_rect = wlr_scene_rect_create(
22-
scene_tree, parent.surface_current.width + get_extra_width(), get_titlebar_height(), color.data());
22+
auto titlebar_color = rrggbb_to_floats(TITLEBAR_COLOR);
23+
auto view_geo = view.get_surface_geometry();
24+
titlebar_rect = wlr_scene_rect_create(scene_tree, view_geo.width, TITLEBAR_HEIGHT, titlebar_color.data());
25+
wlr_scene_node_set_position(&titlebar_rect->node, BORDER_WIDTH, BORDER_WIDTH);
26+
wlr_scene_node_lower_to_bottom(&titlebar_rect->node);
2327
wlr_scene_node_set_enabled(&titlebar_rect->node, true);
2428

25-
border_rect = wlr_scene_rect_create(scene_tree, parent.surface_current.width + get_extra_width(),
26-
parent.surface_current.height + get_border_width(), color.data());
27-
wlr_scene_node_set_position(&border_rect->node, 0, TITLEBAR_HEIGHT);
29+
auto border_color = rrggbb_to_floats(BORDER_COLOR);
30+
border_rect = wlr_scene_rect_create(
31+
scene_tree, view_geo.width + get_extra_width(), view_geo.height + get_extra_height(), border_color.data());
32+
wlr_scene_node_set_position(&border_rect->node, 0, 0);
33+
wlr_scene_node_lower_to_bottom(&border_rect->node);
2834
wlr_scene_node_set_enabled(&border_rect->node, true);
2935
}
3036

@@ -34,30 +40,30 @@ Ssd::~Ssd() {
3440

3541
void Ssd::update() const {
3642
auto view_geo = view.get_surface_geometry();
37-
wlr_scene_rect_set_size(titlebar_rect, view_geo.width + 2, TITLEBAR_HEIGHT);
38-
wlr_scene_rect_set_size(border_rect, view_geo.width + 2, view_geo.height + 1);
43+
wlr_scene_rect_set_size(titlebar_rect, view_geo.width, TITLEBAR_HEIGHT);
44+
wlr_scene_rect_set_size(border_rect, view_geo.width + get_extra_width(), view_geo.height + get_extra_height());
3945
}
4046

4147
wlr_box Ssd::get_geometry() const {
4248
auto view_geo = view.get_surface_geometry();
43-
return {.x = view_geo.x - get_border_width(),
44-
.y = view_geo.y - get_titlebar_height(),
49+
return {.x = view_geo.x - get_horizontal_offset(),
50+
.y = view_geo.y - get_vertical_offset(),
4551
.width = view_geo.width + get_extra_width(),
4652
.height = view_geo.height + get_extra_height()};
4753
}
4854

49-
uint8_t Ssd::get_titlebar_height() const {
50-
return TITLEBAR_HEIGHT;
55+
uint8_t Ssd::get_vertical_offset() const {
56+
return TITLEBAR_HEIGHT + BORDER_WIDTH;
5157
}
5258

53-
uint8_t Ssd::get_border_width() const {
54-
return 1;
59+
uint8_t Ssd::get_horizontal_offset() const {
60+
return BORDER_WIDTH;
5561
}
5662

5763
int32_t Ssd::get_extra_width() const {
58-
return get_border_width() * 2;
64+
return BORDER_WIDTH * 2;
5965
}
6066

6167
int32_t Ssd::get_extra_height() const {
62-
return get_titlebar_height() + get_border_width();
68+
return TITLEBAR_HEIGHT + BORDER_WIDTH * 2;
6369
}

src/decorations/ssd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class Ssd final : public std::enable_shared_from_this<Ssd> {
2222
void update() const;
2323
wlr_box get_geometry() const;
2424

25-
uint8_t get_titlebar_height() const;
26-
uint8_t get_border_width() const;
25+
uint8_t get_vertical_offset() const;
26+
uint8_t get_horizontal_offset() const;
2727
int32_t get_extra_width() const;
2828
int32_t get_extra_height() const;
2929
};

src/surface/view.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int32_t View::find_surface_min_y() const {
9898

9999
min_y = min_y == INT32_MAX ? 0 : min_y;
100100
if (ssd.has_value()) {
101-
return min_y + ssd->get_titlebar_height();
101+
return min_y + ssd->get_vertical_offset();
102102
} else {
103103
return min_y;
104104
}
@@ -151,8 +151,8 @@ void View::set_geometry(const int32_t x, const int32_t y, const int32_t width, c
151151

152152
if (scene_tree != nullptr) {
153153
if (ssd.has_value()) {
154-
wlr_scene_node_set_position(
155-
&scene_tree->node, surface_current.x - ssd->get_border_width(), surface_current.y - ssd->get_titlebar_height());
154+
wlr_scene_node_set_position(&scene_tree->node, surface_current.x - ssd->get_horizontal_offset(),
155+
surface_current.y - ssd->get_vertical_offset());
156156
} else {
157157
wlr_scene_node_set_position(&scene_tree->node, surface_current.x, surface_current.y);
158158
}
@@ -172,8 +172,8 @@ void View::set_position(const int32_t x, const int32_t y) {
172172

173173
if (scene_tree != nullptr) {
174174
if (ssd.has_value()) {
175-
wlr_scene_node_set_position(
176-
&scene_tree->node, surface_current.x - ssd->get_border_width(), surface_current.y - ssd->get_titlebar_height());
175+
wlr_scene_node_set_position(&scene_tree->node, surface_current.x - ssd->get_horizontal_offset(),
176+
surface_current.y - ssd->get_vertical_offset());
177177
} else {
178178
wlr_scene_node_set_position(&scene_tree->node, surface_current.x, surface_current.y);
179179
}
@@ -439,7 +439,7 @@ wlr_box View::get_max_size_with_decorations() const {
439439

440440
void View::update_surface_node_position() const {
441441
if (ssd.has_value()) {
442-
wlr_scene_node_set_position(surface_node, ssd->get_border_width(), ssd->get_titlebar_height());
442+
wlr_scene_node_set_position(surface_node, ssd->get_horizontal_offset(), ssd->get_vertical_offset());
443443
} else {
444444
wlr_scene_node_set_position(surface_node, 0, 0);
445445
}

0 commit comments

Comments
 (0)