Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window-list: additional classes for window state #247

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading