diff --git a/src/decorations/ssd.cpp b/src/decorations/ssd.cpp index 96ea5e2c1..2e211cf7d 100644 --- a/src/decorations/ssd.cpp +++ b/src/decorations/ssd.cpp @@ -5,6 +5,8 @@ constexpr uint8_t TITLEBAR_HEIGHT = 24; constexpr uint32_t TITLEBAR_COLOR = 0x303030; +constexpr uint8_t BORDER_WIDTH = 1; +constexpr uint32_t BORDER_COLOR = 0x505050; static consteval std::array rrggbb_to_floats(uint32_t rrggbb) { return std::array( @@ -17,14 +19,18 @@ Ssd::Ssd(View& parent) noexcept : view(parent) { wlr_scene_node_set_position(&scene_tree->node, 0, 0); wlr_scene_node_set_enabled(&scene_tree->node, true); - auto color = rrggbb_to_floats(TITLEBAR_COLOR); - titlebar_rect = wlr_scene_rect_create( - scene_tree, parent.surface_current.width + get_extra_width(), get_titlebar_height(), color.data()); + auto titlebar_color = rrggbb_to_floats(TITLEBAR_COLOR); + auto view_geo = view.get_surface_geometry(); + titlebar_rect = wlr_scene_rect_create(scene_tree, view_geo.width, TITLEBAR_HEIGHT, titlebar_color.data()); + wlr_scene_node_set_position(&titlebar_rect->node, BORDER_WIDTH, BORDER_WIDTH); + wlr_scene_node_lower_to_bottom(&titlebar_rect->node); wlr_scene_node_set_enabled(&titlebar_rect->node, true); - border_rect = wlr_scene_rect_create(scene_tree, parent.surface_current.width + get_extra_width(), - parent.surface_current.height + get_border_width(), color.data()); - wlr_scene_node_set_position(&border_rect->node, 0, TITLEBAR_HEIGHT); + auto border_color = rrggbb_to_floats(BORDER_COLOR); + border_rect = wlr_scene_rect_create( + scene_tree, view_geo.width + get_extra_width(), view_geo.height + get_extra_height(), border_color.data()); + wlr_scene_node_set_position(&border_rect->node, 0, 0); + wlr_scene_node_lower_to_bottom(&border_rect->node); wlr_scene_node_set_enabled(&border_rect->node, true); } @@ -34,30 +40,30 @@ Ssd::~Ssd() { void Ssd::update() const { auto view_geo = view.get_surface_geometry(); - wlr_scene_rect_set_size(titlebar_rect, view_geo.width + 2, TITLEBAR_HEIGHT); - wlr_scene_rect_set_size(border_rect, view_geo.width + 2, view_geo.height + 1); + wlr_scene_rect_set_size(titlebar_rect, view_geo.width, TITLEBAR_HEIGHT); + wlr_scene_rect_set_size(border_rect, view_geo.width + get_extra_width(), view_geo.height + get_extra_height()); } wlr_box Ssd::get_geometry() const { auto view_geo = view.get_surface_geometry(); - return {.x = view_geo.x - get_border_width(), - .y = view_geo.y - get_titlebar_height(), + return {.x = view_geo.x - get_horizontal_offset(), + .y = view_geo.y - get_vertical_offset(), .width = view_geo.width + get_extra_width(), .height = view_geo.height + get_extra_height()}; } -uint8_t Ssd::get_titlebar_height() const { - return TITLEBAR_HEIGHT; +uint8_t Ssd::get_vertical_offset() const { + return TITLEBAR_HEIGHT + BORDER_WIDTH; } -uint8_t Ssd::get_border_width() const { - return 1; +uint8_t Ssd::get_horizontal_offset() const { + return BORDER_WIDTH; } int32_t Ssd::get_extra_width() const { - return get_border_width() * 2; + return BORDER_WIDTH * 2; } int32_t Ssd::get_extra_height() const { - return get_titlebar_height() + get_border_width(); + return TITLEBAR_HEIGHT + BORDER_WIDTH * 2; } diff --git a/src/decorations/ssd.hpp b/src/decorations/ssd.hpp index 5fb1388e5..541f2d23f 100644 --- a/src/decorations/ssd.hpp +++ b/src/decorations/ssd.hpp @@ -22,8 +22,8 @@ class Ssd final : public std::enable_shared_from_this { void update() const; wlr_box get_geometry() const; - uint8_t get_titlebar_height() const; - uint8_t get_border_width() const; + uint8_t get_vertical_offset() const; + uint8_t get_horizontal_offset() const; int32_t get_extra_width() const; int32_t get_extra_height() const; }; diff --git a/src/surface/view.cpp b/src/surface/view.cpp index c43ad888e..e0e178b14 100644 --- a/src/surface/view.cpp +++ b/src/surface/view.cpp @@ -98,7 +98,7 @@ int32_t View::find_surface_min_y() const { min_y = min_y == INT32_MAX ? 0 : min_y; if (ssd.has_value()) { - return min_y + ssd->get_titlebar_height(); + return min_y + ssd->get_vertical_offset(); } else { return min_y; } @@ -151,8 +151,8 @@ void View::set_geometry(const int32_t x, const int32_t y, const int32_t width, c if (scene_tree != nullptr) { if (ssd.has_value()) { - wlr_scene_node_set_position( - &scene_tree->node, surface_current.x - ssd->get_border_width(), surface_current.y - ssd->get_titlebar_height()); + wlr_scene_node_set_position(&scene_tree->node, surface_current.x - ssd->get_horizontal_offset(), + surface_current.y - ssd->get_vertical_offset()); } else { wlr_scene_node_set_position(&scene_tree->node, surface_current.x, surface_current.y); } @@ -172,8 +172,8 @@ void View::set_position(const int32_t x, const int32_t y) { if (scene_tree != nullptr) { if (ssd.has_value()) { - wlr_scene_node_set_position( - &scene_tree->node, surface_current.x - ssd->get_border_width(), surface_current.y - ssd->get_titlebar_height()); + wlr_scene_node_set_position(&scene_tree->node, surface_current.x - ssd->get_horizontal_offset(), + surface_current.y - ssd->get_vertical_offset()); } else { wlr_scene_node_set_position(&scene_tree->node, surface_current.x, surface_current.y); } @@ -439,7 +439,7 @@ wlr_box View::get_max_size_with_decorations() const { void View::update_surface_node_position() const { if (ssd.has_value()) { - wlr_scene_node_set_position(surface_node, ssd->get_border_width(), ssd->get_titlebar_height()); + wlr_scene_node_set_position(surface_node, ssd->get_horizontal_offset(), ssd->get_vertical_offset()); } else { wlr_scene_node_set_position(surface_node, 0, 0); }