Skip to content

Commit

Permalink
window-list: additional classes for window state (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
trigg authored Apr 25, 2024
1 parent 37beec0 commit dffc9d8
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/panel/widgets/window-list/toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class WayfireToplevel::impl
grab_start_x = _x;
grab_start_y = _y;

set_flat_class(false);
set_classes(state);
window_list->box.set_top_widget(&button);

/* Find the distance between pointer X and button origin */
Expand Down Expand Up @@ -195,7 +195,7 @@ class WayfireToplevel::impl
int height = button.get_allocated_height();

window_list->box.set_top_widget(nullptr);
set_flat_class(!(state & WF_TOPLEVEL_STATE_ACTIVATED));
set_classes(state);

/* When a button is dropped after dnd, we ignore the unclick
* event so action doesn't happen in addition to dropping.
Expand Down Expand Up @@ -461,21 +461,39 @@ class WayfireToplevel::impl
}
}

void set_flat_class(bool on)
void set_classes(uint32_t state)
{
if (on)
if (state & WF_TOPLEVEL_STATE_ACTIVATED)
{
button.get_style_context()->add_class("activated");
button.get_style_context()->remove_class("flat");
} else
{
button.get_style_context()->add_class("flat");
button.get_style_context()->remove_class("activated");
}

if (state & WF_TOPLEVEL_STATE_MINIMIZED)
{
button.get_style_context()->add_class("minimized");
} else
{
button.get_style_context()->remove_class("flat");
button.get_style_context()->remove_class("minimized");
}

if (state & WF_TOPLEVEL_STATE_MAXIMIZED)
{
button.get_style_context()->add_class("maximized");
} else
{
button.get_style_context()->remove_class("maximized");
}
}

void set_state(uint32_t state)
{
this->state = state;
set_flat_class(!(state & WF_TOPLEVEL_STATE_ACTIVATED));
set_classes(state);
update_menu_item_text();
}

Expand Down

0 comments on commit dffc9d8

Please sign in to comment.