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

core: transfer views to same workspace as on destroyed output #2294

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
34 changes: 30 additions & 4 deletions src/api/wayfire/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,37 @@ class compositor_core_t : public wf::object_base_t, public signal::provider_t
};

/**
* Change the view's output to new_output. If the reconfigure flag is
* set, it will adjust the view geometry for the new output and clamp
* it to the output geometry so it is at an expected size and position.
* Flags for move_view_to_output.
*/
void move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, bool reconfigure);
enum
{
/**
* Adjust the view geometry for the new output and clamp it to the output geometry so it is
* at an expected size and position.
*/
VIEW_TO_OUTPUT_FLAG_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.
*/
VIEW_TO_OUTPUT_FLAG_SAME_WORKSPACE = 1 << 1,
};

/**
* Change the view's output to new_output.
*/
void move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, unsigned flags);

/**
* Change the view's output to new_output. Equivalent to calling the move_view_to_output with
* the RECONFIGURE flag set to the specified value and no other flags set.
*/
inline void move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output,
bool reconfigure)
{
unsigned flags = reconfigure ? VIEW_TO_OUTPUT_FLAG_RECONFIGURE : 0;
move_view_to_output(v, new_output, flags);
}

/**
* Start a move of a view to a new workspace set (and thus potentially to a new output).
Expand Down
13 changes: 11 additions & 2 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,17 @@ void wf::start_move_view_to_wset(wayfire_toplevel_view v, std::shared_ptr<wf::wo
new_wset->add_view(v);
}

void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, bool reconfigure)
void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, unsigned flags)
{
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 & VIEW_TO_OUTPUT_FLAG_RECONFIGURE;
bool same_workspace = flags & VIEW_TO_OUTPUT_FLAG_SAME_WORKSPACE;
wf::geometry_t view_g;
wf::geometry_t old_output_g;
wf::geometry_t new_output_g;
Expand All @@ -518,7 +522,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);
Expand All @@ -536,6 +540,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 &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it also make sense to have similar treatment for fullscreen and tiled windows? You can pass the requested workspace to fullscreen/tile request too.

(old_wset->get_workspace_grid_size() == new_wset->get_workspace_grid_size()))
{
v->get_wset()->move_to_workspace(v, old_ws);
}
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/core/output-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ void transfer_views(wf::output_t *from, wf::output_t *to)
auto views = from->wset()->get_views(WSET_SORT_STACKING);
for (auto& view : views)
{
move_view_to_output(view, to, true);
unsigned flags = VIEW_TO_OUTPUT_FLAG_RECONFIGURE | VIEW_TO_OUTPUT_FLAG_SAME_WORKSPACE;
move_view_to_output(view, to, flags);
}
}

Expand Down Expand Up @@ -546,7 +547,13 @@ struct output_layout_output_t

/* It doesn't make sense to transfer to another output if we're
* going to shut down the compositor */
transfer_views(wo, shutdown ? nullptr : get_core().seat->get_active_output());
wf::output_t *new_output = shutdown ? nullptr : get_core().seat->get_active_output();
transfer_views(wo, new_output);
if (new_output &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehh I'm not quite sure about this particular change. Is this really what users expect?

(wo->wset()->get_workspace_grid_size() == new_output->wset()->get_workspace_grid_size()))
{
new_output->wset()->set_workspace(wo->wset()->get_current_workspace());
}

wf::output_removed_signal data2;
data2.output = wo;
Expand Down Expand Up @@ -1119,7 +1126,9 @@ class output_layout_t::impl

if (!noop_output)
{
auto handle = wlr_headless_add_output(noop_backend, 1280, 720);
// NOOP output should be at least as large as actual screen sizes. Otherwise, when
// when windows are temporarily mapped to it, they will be moved/cropped to match it.
auto handle = wlr_headless_add_output(noop_backend, 3840, 2160);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The noop output can be configured from the config file (IIRC), so this is only the default size if nothing else is set. I would rather not make it that big by default because if the user has some underpowered GPU mayybe this buffer would be too big?

handle->data = WF_NOOP_OUTPUT_MAGIC;
strcpy(handle->name, "NOOP-1");

Expand Down
Loading