diff --git a/src/api/wayfire/core.hpp b/src/api/wayfire/core.hpp index e6762c635..5de01dee6 100644 --- a/src/api/wayfire/core.hpp +++ b/src/api/wayfire/core.hpp @@ -317,7 +317,12 @@ enum view_to_output_flag * Adjust the view geometry for the new output and clamp it to the output geometry so it is * at an expected size and position. */ - RECONFIGURE = 1 << 0, + RECONFIGURE = 1 << 0, + /** + * If the new output has the same workspace geometry as the current output, move the view to the + * same workspace as it is currently on. + */ + SAME_WORKSPACE = 1 << 1, }; /** diff --git a/src/core/core.cpp b/src/core/core.cpp index 408a3c8d8..dca22e1ab 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -497,10 +497,13 @@ void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, { auto old_output = v->get_output(); auto old_wset = v->get_wset(); + auto old_ws = old_wset->get_view_main_workspace(v); + auto new_wset = new_output->wset(); uint32_t edges; bool fullscreen; - bool reconfigure = flags & wf::view_to_output_flag::RECONFIGURE; + bool reconfigure = flags & wf::view_to_output_flag::RECONFIGURE; + bool same_workspace = flags & wf::view_to_output_flag::SAME_WORKSPACE; wf::geometry_t view_g; wf::geometry_t old_output_g; wf::geometry_t new_output_g; @@ -520,7 +523,7 @@ void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, assert(new_output); - start_move_view_to_wset(v, new_output->wset()); + start_move_view_to_wset(v, new_wset); if (new_output == wf::get_core().seat->get_active_output()) { wf::get_core().seat->focus_view(v); @@ -538,6 +541,11 @@ void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, { auto new_g = wf::clamp(view_g, new_output->workarea->get_workarea()); v->set_geometry(new_g); + if (same_workspace && + (old_wset->get_workspace_grid_size() == new_wset->get_workspace_grid_size())) + { + v->get_wset()->move_to_workspace(v, old_ws); + } } }