diff --git a/src/decorations/ssd.cpp b/src/decorations/ssd.cpp index e413a2f54..3787f19fb 100644 --- a/src/decorations/ssd.cpp +++ b/src/decorations/ssd.cpp @@ -4,11 +4,13 @@ #include "server.hpp" constexpr uint8_t TITLEBAR_HEIGHT = 24; -constexpr uint32_t TITLEBAR_COLOR = 0x303030; +constexpr uint32_t TITLEBAR_ACTIVE_COLOR = 0x303030; +constexpr uint32_t TITLEBAR_INACTIVE_COLOR = 0x202020; constexpr uint8_t BORDER_WIDTH = 1; -constexpr uint32_t BORDER_COLOR = 0x505050; +constexpr uint32_t BORDER_ACTIVE_COLOR = 0x505050; +constexpr uint32_t BORDER_INACTIVE_COLOR = 0x404040; -static consteval std::array rrggbb_to_floats(uint32_t rrggbb) { +static constexpr std::array rrggbb_to_floats(uint32_t rrggbb) { return std::array( {(float) (rrggbb >> 16 & 0xff) / 255.0f, (float) (rrggbb >> 8 & 0xff) / 255.0f, (float) (rrggbb & 0xff) / 255.0f, 1.0}); } @@ -19,7 +21,7 @@ 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 titlebar_color = rrggbb_to_floats(TITLEBAR_COLOR); + auto titlebar_color = rrggbb_to_floats(TITLEBAR_INACTIVE_COLOR); auto view_geo = view.get_surface_geometry(); titlebar_rect = wlr_scene_rect_create(scene_tree, view_geo.width, TITLEBAR_HEIGHT, titlebar_color.data()); titlebar_rect->node.data = &parent; @@ -27,7 +29,7 @@ Ssd::Ssd(View& parent) noexcept : view(parent) { wlr_scene_node_lower_to_bottom(&titlebar_rect->node); wlr_scene_node_set_enabled(&titlebar_rect->node, true); - auto border_color = rrggbb_to_floats(BORDER_COLOR); + auto border_color = rrggbb_to_floats(BORDER_INACTIVE_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); @@ -45,6 +47,14 @@ void Ssd::update() const { wlr_scene_rect_set_size(border_rect, view_geo.width + get_extra_width(), view_geo.height + get_extra_height()); } +void Ssd::set_activated(const bool activated) const { + auto titlebar_color = rrggbb_to_floats(activated ? TITLEBAR_ACTIVE_COLOR : TITLEBAR_INACTIVE_COLOR); + wlr_scene_rect_set_color(titlebar_rect, titlebar_color.data()); + + auto border_color = rrggbb_to_floats(activated ? BORDER_ACTIVE_COLOR : BORDER_INACTIVE_COLOR); + wlr_scene_rect_set_color(border_rect, border_color.data()); +} + wlr_box Ssd::get_geometry() const { auto view_geo = view.get_surface_geometry(); return {.x = view_geo.x - get_horizontal_offset(), diff --git a/src/decorations/ssd.hpp b/src/decorations/ssd.hpp index 541f2d23f..9cd5fef25 100644 --- a/src/decorations/ssd.hpp +++ b/src/decorations/ssd.hpp @@ -20,8 +20,9 @@ class Ssd final : public std::enable_shared_from_this { ~Ssd(); void update() const; - wlr_box get_geometry() const; + void set_activated(bool activated) const; + wlr_box get_geometry() const; uint8_t get_vertical_offset() const; uint8_t get_horizontal_offset() const; int32_t get_extra_width() const; diff --git a/src/surface/view.cpp b/src/surface/view.cpp index e0e178b14..886249a62 100644 --- a/src/surface/view.cpp +++ b/src/surface/view.cpp @@ -249,6 +249,10 @@ void View::set_activated(const bool activated) { toplevel_handle->set_activated(activated); } + if (ssd.has_value()) { + ssd->set_activated(activated); + } + const auto seat = get_server().seat; if (activated) { wlr_scene_node_raise_to_top(&scene_tree->node);