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

scale: auto-close scale when a new view opens #2265

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions metadata/scale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<_long>Whether to show views that are minimized when starting scale.</_long>
<default>false</default>
</option>
<option name="close_on_new_view" type="bool">
<_short>Close on new views</_short>
<_long>Whether to close scale when a new view is mapped.</_long>
<default>false</default>
</option>
</group>
<group>
<_short>Appearance</_short>
Expand Down
13 changes: 10 additions & 3 deletions plugins/scale/scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
wf::option_wrapper_t<double> minimized_alpha{"scale/minimized_alpha"};
wf::option_wrapper_t<bool> allow_scale_zoom{"scale/allow_zoom"};
wf::option_wrapper_t<bool> include_minimized{"scale/include_minimized"};
wf::option_wrapper_t<bool> close_on_new_view{"scale/close_on_new_view"};

/* maximum scale -- 1.0 means we will not "zoom in" on a view */
const double max_scale_factor = 1.0;
Expand Down Expand Up @@ -1092,21 +1093,27 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
layout_slots(get_views());
};

void handle_new_view(wayfire_toplevel_view view)
void handle_new_view(wayfire_toplevel_view view, bool close_scale)
{
if (!should_scale_view(view))
{
return;
}

if (close_scale)
{
deactivate();
return;
}

layout_slots(get_views());
}

wf::signal::connection_t<wf::view_mapped_signal> on_view_mapped = [=] (wf::view_mapped_signal *ev)
{
if (auto toplevel = wf::toplevel_cast(ev->view))
{
handle_new_view(toplevel);
handle_new_view(toplevel, close_on_new_view);
}
};

Expand Down Expand Up @@ -1518,7 +1525,7 @@ class wayfire_scale_global : public wf::plugin_interface_t,
auto new_output = ev->view->get_output();
if (new_output && output_instance.count(new_output) && output_instance[new_output]->active)
{
this->output_instance[ev->view->get_output()]->handle_new_view(toplevel);
this->output_instance[ev->view->get_output()]->handle_new_view(toplevel, false);
}
}
};
Expand Down
Loading