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: Fix ups #254

Merged
merged 1 commit into from
Aug 16, 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
16 changes: 6 additions & 10 deletions src/pin-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class wayfire_pin_view : public wf::plugin_interface_t
{
ipc_repo->register_method("pin-view/pin", ipc_pin_view);
ipc_repo->register_method("pin-view/unpin", ipc_unpin_view);
for (auto & output : wf::get_core().output_layout->get_outputs())
{
output->connect(&on_workspace_changed);
}
}

wf::ipc::method_callback ipc_pin_view = [=] (nlohmann::json data) -> nlohmann::json
Expand All @@ -73,7 +77,6 @@ class wayfire_pin_view : public wf::plugin_interface_t
{
bool was_pinned = unpin(view);
auto output = view->get_output();
output->connect(&on_workspace_changed);
if (!view->get_data<pin_view_data>())
{
pin_view_data pv_data;
Expand Down Expand Up @@ -141,9 +144,8 @@ class wayfire_pin_view : public wf::plugin_interface_t
auto cws = output->wset()->get_view_main_workspace(toplevel);
if (resize)
{
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});
toplevel->set_geometry(wf::geometry_t{(nws.x - cws.x) * og.width,
(nws.y - cws.y) * og.height, og.width, og.height});
} else
{
auto vg = was_pinned ? pvd->geometry : toplevel->get_geometry();
Expand Down Expand Up @@ -191,16 +193,10 @@ class wayfire_pin_view : public wf::plugin_interface_t
if (auto toplevel = toplevel_cast(view))
{
auto output = view->get_output();
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);
}

on_workspace_changed.disconnect();
wf::view_mapped_signal map_signal;
map_signal.view = view;
wf::get_core().emit(&map_signal);
Expand Down
Loading