*
* Many view functions (e.g. view_center(), view_fullscreen(),
* view_maximize(), etc.) allow specifying a particular output
- * by setting view->output explicitly before calling them.
+ * by calling view_set_output() beforehand.
*/
struct output *output;
struct workspace *workspace;
};
void view_set_activated(struct view *view);
+void view_set_output(struct view *view, struct output *output);
void view_close(struct view *view);
/**
view_discover_output(struct view *view)
{
assert(view);
+ assert(!view->fullscreen);
view->output = output_nearest_to(view->server,
view->current.x + view->current.width / 2,
view->current.y + view->current.height / 2);
view->server->focused_view = view;
}
+void
+view_set_output(struct view *view, struct output *output)
+{
+ assert(view);
+ assert(!view->fullscreen);
+ if (!output_is_usable(output)) {
+ wlr_log(WLR_ERROR, "invalid output set for view");
+ return;
+ }
+ view->output = output;
+}
+
void
view_close(struct view *view)
{
view_on_output_destroy(struct view *view)
{
assert(view);
+ /*
+ * This is the only time we modify view->output for a fullscreen
+ * view. We expect view_adjust_for_layout_change() to be called
+ * shortly afterward, which will exit fullscreen.
+ */
view->output = NULL;
}
view_store_natural_geometry(view);
}
view_set_untiled(view);
- view->output = output;
+ view_set_output(view, output);
view->tiled = edge;
view_apply_tiled_geometry(view);
}
{
struct view *view = wl_container_of(listener, view, request_maximize);
if (!view->mapped && !view->output) {
- view->output = output_nearest_to_cursor(view->server);
+ view_set_output(view, output_nearest_to_cursor(view->server));
}
view_maximize(view, xdg_toplevel_from_view(view)->requested.maximized,
/*store_natural_geometry*/ true);
{
if (!view->fullscreen && requested->fullscreen
&& requested->fullscreen_output) {
- struct output *output = output_from_wlr_output(view->server,
- requested->fullscreen_output);
- if (output_is_usable(output)) {
- view->output = output;
- } else {
- wlr_log(WLR_ERROR,
- "invalid output in fullscreen request");
- }
+ view_set_output(view, output_from_wlr_output(view->server,
+ requested->fullscreen_output));
}
view_set_fullscreen(view, requested->fullscreen);
}
{
struct view *view = wl_container_of(listener, view, request_fullscreen);
if (!view->mapped && !view->output) {
- view->output = output_nearest_to_cursor(view->server);
+ view_set_output(view, output_nearest_to_cursor(view->server));
}
set_fullscreen_from_request(view,
&xdg_toplevel_from_view(view)->requested);
struct view *parent = lookup_view_by_xdg_toplevel(
view->server, parent_xdg_toplevel);
assert(parent);
- view->output = parent->output;
+ view_set_output(view, parent->output);
view_center(view, &parent->pending);
}
}
}
view->mapped = true;
if (!view->output) {
- view->output = output_nearest_to_cursor(view->server);
+ view_set_output(view, output_nearest_to_cursor(view->server));
}
struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
view->surface = xdg_surface->surface;