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

decor: Don't put minimize buttons on child views #2057

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions plugins/decor/deco-button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class decoration_theme_t;

enum button_type_t
{
BUTTON_CLOSE,
BUTTON_TOGGLE_MAXIMIZE,
BUTTON_MINIMIZE,
BUTTON_CLOSE = 1 << 0,
BUTTON_TOGGLE_MAXIMIZE = 1 << 1,
BUTTON_MINIMIZE = 1 << 2,
};

class button_t
Expand Down
6 changes: 3 additions & 3 deletions plugins/decor/deco-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ wf::geometry_t decoration_layout_t::create_buttons(int width, int)
std::string button_name;
while (stream >> button_name)
{
if (button_name == "minimize")
if ((button_name == "minimize") && (theme.button_flags & BUTTON_MINIMIZE))
{
buttons.push_back(BUTTON_MINIMIZE);
}

if (button_name == "maximize")
if ((button_name == "maximize") && (theme.button_flags & BUTTON_TOGGLE_MAXIMIZE))
{
buttons.push_back(BUTTON_TOGGLE_MAXIMIZE);
}

if (button_name == "close")
if ((button_name == "close") && (theme.button_flags & BUTTON_CLOSE))
{
buttons.push_back(BUTTON_CLOSE);
}
Expand Down
9 changes: 9 additions & 0 deletions plugins/decor/deco-subsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
{
this->_view = view->weak_from_this();
view->connect(&title_set);
if (view->parent)
{
theme.set_buttons(wf::decor::button_type_t(wf::decor::BUTTON_TOGGLE_MAXIMIZE |
wf::decor::BUTTON_CLOSE));
} else
{
theme.set_buttons(wf::decor::button_type_t(wf::decor::BUTTON_MINIMIZE |
wf::decor::BUTTON_TOGGLE_MAXIMIZE | wf::decor::BUTTON_CLOSE));
}

// make sure to hide frame if the view is fullscreen
update_decoration_size();
Expand Down
6 changes: 6 additions & 0 deletions plugins/decor/deco-theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ int decoration_theme_t::get_border_size() const
return border_size;
}

/** @return The available border for resizing */
void decoration_theme_t::set_buttons(button_type_t flags)
{
button_flags = flags;
}

/**
* Fill the given rectangle with the background color(s).
*
Expand Down
3 changes: 3 additions & 0 deletions plugins/decor/deco-theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class decoration_theme_t
int get_title_height() const;
/** @return The available border for resizing */
int get_border_size() const;
/** Set the flags for buttons */
void set_buttons(button_type_t flags);
button_type_t button_flags;

/**
* Fill the given rectangle with the background color(s).
Expand Down