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

pin-view: Make pinned views not show in scale or switchers #252

Merged
merged 1 commit into from
Aug 15, 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
31 changes: 21 additions & 10 deletions src/pin-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class wayfire_pin_view : public wf::plugin_interface_t
layer = wf::scene::layer::TOP;
}

auto pvd = view->get_data<pin_view_data>();
bool resize = data["resize"];
auto og = output->get_relative_geometry();
int x = 0, y = 0;
Expand All @@ -132,7 +133,6 @@ class wayfire_pin_view : public wf::plugin_interface_t
y = data["y"].get<int>();
}

auto pvd = view->get_data<pin_view_data>();
view->role = pvd->role;

wf::point_t nws{x, y};
Expand All @@ -141,32 +141,35 @@ class wayfire_pin_view : public wf::plugin_interface_t
auto cws = output->wset()->get_view_main_workspace(toplevel);
if (resize)
{
toplevel->set_geometry(wf::geometry_t{(nws.x - cws.x) * og.width,
(nws.y - cws.y) * og.height, og.width, og.height});
auto vg = toplevel->get_geometry();
toplevel->set_geometry(wf::geometry_t{vg.x + (nws.x - cws.x) * og.width,
vg.y + (nws.y - cws.y) * og.height, og.width, og.height});
} else
{
auto vg = was_pinned ? pvd->geometry : toplevel->get_geometry();
toplevel->set_geometry(wf::geometry_t{vg.x + (nws.x - cws.x) * og.width,
vg.y + (nws.y - cws.y) * og.height, vg.width, vg.height});
}

output->wset()->remove_view(toplevel);
}
} else
{
if (auto toplevel = toplevel_cast(view))
{
auto vg = toplevel->get_geometry();
auto vg = was_pinned ? pvd->geometry : toplevel->get_geometry();
wf::point_t nws = output->wset()->get_current_workspace();
auto cws = output->wset()->get_view_main_workspace(toplevel);
toplevel->move(vg.x + (nws.x - cws.x) * og.width, vg.y + (nws.y - cws.y) * og.height);
if (resize)
{
toplevel->set_geometry(og);
}

output->wset()->remove_view(toplevel);
}

view->role = wf::VIEW_ROLE_DESKTOP_ENVIRONMENT;
wf::scene::readd_front(view->get_output()->node_for_layer(layer), view->get_root_node());
return wf::ipc::json_ok();
}

wf::scene::readd_front(output->node_for_layer(layer), view->get_root_node());
Expand All @@ -191,6 +194,7 @@ class wayfire_pin_view : public wf::plugin_interface_t
auto og = output->get_relative_geometry();
auto cws = output->wset()->get_view_main_workspace(toplevel);
auto vg = toplevel->get_geometry();
output->wset()->add_view(toplevel);
toplevel->move(vg.x + (pvd->workspace.x - cws.x) * og.width,
vg.y + (pvd->workspace.y - cws.y) * og.height);
toplevel->set_geometry(pvd->geometry);
Expand Down Expand Up @@ -225,22 +229,29 @@ class wayfire_pin_view : public wf::plugin_interface_t
wf::signal::connection_t<wf::workspace_changed_signal> on_workspace_changed =
[=] (wf::workspace_changed_signal *ev)
{
auto ows = ev->old_viewport;
auto nws = ev->new_viewport;
auto output = ev->output;
auto og = output->get_relative_geometry();
for (auto & view : wf::get_core().get_all_views())
{
auto pvd = view->get_data<pin_view_data>();
if (!pvd || (view->role != wf::VIEW_ROLE_DESKTOP_ENVIRONMENT))
if (!pvd)
{
continue;
}

if (auto toplevel = toplevel_cast(view))
{
auto cws = output->wset()->get_view_main_workspace(toplevel);
auto vg = toplevel->get_geometry();
toplevel->move(vg.x + (nws.x - cws.x) * og.width, vg.y + (nws.y - cws.y) * og.height);
auto vg = toplevel->get_geometry();
if (view->role == wf::VIEW_ROLE_DESKTOP_ENVIRONMENT)
{
auto cws = output->wset()->get_view_main_workspace(toplevel);
toplevel->move(vg.x + (nws.x - cws.x) * og.width, vg.y + (nws.y - cws.y) * og.height);
} else
{
toplevel->move(vg.x + (ows.x - nws.x) * og.width, vg.y + (ows.y - nws.y) * og.height);
}
}
}
};
Expand Down
Loading