Skip to content

Commit

Permalink
pin-view: Fix ups (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau authored Aug 16, 2024
1 parent e77d13f commit df679db
Showing 1 changed file with 6 additions and 10 deletions.
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

0 comments on commit df679db

Please sign in to comment.