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: fix moving view between different outputs #2165

Merged
merged 1 commit into from
Mar 10, 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
52 changes: 37 additions & 15 deletions plugins/scale/scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
scale_show_title_t show_title;
std::vector<int> current_row_sizes;
wf::point_t initial_workspace;
bool active, hook_set;
bool hook_set;
/* View that was active before scale began. */
wayfire_toplevel_view initial_focus_view;
/* View that has active focus. */
Expand Down Expand Up @@ -135,10 +135,12 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
};

public:
bool active = false;

void init() override
{
active = hook_set = false;
grab = std::make_unique<wf::input_grab_t>("scale", output, this, this, this);
hook_set = false;
grab = std::make_unique<wf::input_grab_t>("scale", output, this, this, this);

allow_scale_zoom.set_callback(allow_scale_zoom_option_changed);

Expand Down Expand Up @@ -1095,15 +1097,6 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
layout_slots(get_views());
}

wf::signal::connection_t<wf::view_set_output_signal> on_view_set_output =
[=] (wf::view_set_output_signal *ev)
{
if (auto toplevel = wf::toplevel_cast(ev->view))
{
handle_new_view(toplevel);
}
};

wf::signal::connection_t<wf::view_mapped_signal> on_view_mapped = [=] (wf::view_mapped_signal *ev)
{
if (auto toplevel = wf::toplevel_cast(ev->view))
Expand Down Expand Up @@ -1353,7 +1346,6 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,

layout_slots(get_views());

output->connect(&on_view_set_output);
output->connect(&on_view_mapped);
output->connect(&workspace_changed);
output->connect(&workarea_changed);
Expand All @@ -1374,7 +1366,6 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,

set_hook();
on_view_mapped.disconnect();
on_view_set_output.disconnect();
view_unmapped.disconnect();
view_minimized.disconnect();
workspace_changed.disconnect();
Expand Down Expand Up @@ -1431,7 +1422,6 @@ class wayfire_scale : public wf::per_output_plugin_instance_t,
scale_data.clear();
grab->ungrab_input();
on_view_mapped.disconnect();
on_view_set_output.disconnect();
view_unmapped.disconnect();
view_disappeared.disconnect();
view_minimized.disconnect();
Expand Down Expand Up @@ -1497,6 +1487,38 @@ class wayfire_scale_global : public wf::plugin_interface_t,
this->fini_output_tracking();
}

void handle_new_output(wf::output_t *output) override
{
per_output_tracker_mixin_t::handle_new_output(output);
output->connect(&on_view_set_output);
}

void handle_output_removed(wf::output_t *output) override
{
per_output_tracker_mixin_t::handle_output_removed(output);
output->disconnect(&on_view_set_output);
}

wf::signal::connection_t<wf::view_set_output_signal> on_view_set_output =
[=] (wf::view_set_output_signal *ev)
{
if (auto toplevel = wf::toplevel_cast(ev->view))
{
if (auto old_output = ev->output)
{
this->output_instance[old_output]->handle_view_disappeared(toplevel);
}

if (auto new_output = ev->view->get_output())
{
if (output_instance[new_output]->active)
{
this->output_instance[ev->view->get_output()]->handle_new_view(toplevel);
}
}
}
};

wf::ipc_activator_t::handler_t toggle_cb = [=] (wf::output_t *output, wayfire_view)
{
if (this->output_instance[output]->handle_toggle(false))
Expand Down
Loading