mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
view: Add view_set_output()
This commit is contained in:
parent
55c6280322
commit
331f62f662
4 changed files with 28 additions and 15 deletions
|
|
@ -52,7 +52,7 @@ struct view {
|
||||||
*
|
*
|
||||||
* Many view functions (e.g. view_center(), view_fullscreen(),
|
* Many view functions (e.g. view_center(), view_fullscreen(),
|
||||||
* view_maximize(), etc.) allow specifying a particular output
|
* 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 output *output;
|
||||||
struct workspace *workspace;
|
struct workspace *workspace;
|
||||||
|
|
@ -131,6 +131,7 @@ struct xdg_toplevel_view {
|
||||||
};
|
};
|
||||||
|
|
||||||
void view_set_activated(struct view *view);
|
void view_set_activated(struct view *view);
|
||||||
|
void view_set_output(struct view *view, struct output *output);
|
||||||
void view_close(struct view *view);
|
void view_close(struct view *view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
20
src/view.c
20
src/view.c
|
|
@ -111,6 +111,7 @@ static void
|
||||||
view_discover_output(struct view *view)
|
view_discover_output(struct view *view)
|
||||||
{
|
{
|
||||||
assert(view);
|
assert(view);
|
||||||
|
assert(!view->fullscreen);
|
||||||
view->output = output_nearest_to(view->server,
|
view->output = output_nearest_to(view->server,
|
||||||
view->current.x + view->current.width / 2,
|
view->current.x + view->current.width / 2,
|
||||||
view->current.y + view->current.height / 2);
|
view->current.y + view->current.height / 2);
|
||||||
|
|
@ -144,6 +145,18 @@ view_set_activated(struct view *view)
|
||||||
view->server->focused_view = view;
|
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
|
void
|
||||||
view_close(struct view *view)
|
view_close(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -786,6 +799,11 @@ void
|
||||||
view_on_output_destroy(struct view *view)
|
view_on_output_destroy(struct view *view)
|
||||||
{
|
{
|
||||||
assert(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->output = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -938,7 +956,7 @@ view_snap_to_edge(struct view *view, const char *direction,
|
||||||
view_store_natural_geometry(view);
|
view_store_natural_geometry(view);
|
||||||
}
|
}
|
||||||
view_set_untiled(view);
|
view_set_untiled(view);
|
||||||
view->output = output;
|
view_set_output(view, output);
|
||||||
view->tiled = edge;
|
view->tiled = edge;
|
||||||
view_apply_tiled_geometry(view);
|
view_apply_tiled_geometry(view);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
src/xdg.c
18
src/xdg.c
|
|
@ -179,7 +179,7 @@ handle_request_maximize(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct view *view = wl_container_of(listener, view, request_maximize);
|
struct view *view = wl_container_of(listener, view, request_maximize);
|
||||||
if (!view->mapped && !view->output) {
|
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,
|
view_maximize(view, xdg_toplevel_from_view(view)->requested.maximized,
|
||||||
/*store_natural_geometry*/ true);
|
/*store_natural_geometry*/ true);
|
||||||
|
|
@ -191,14 +191,8 @@ set_fullscreen_from_request(struct view *view,
|
||||||
{
|
{
|
||||||
if (!view->fullscreen && requested->fullscreen
|
if (!view->fullscreen && requested->fullscreen
|
||||||
&& requested->fullscreen_output) {
|
&& requested->fullscreen_output) {
|
||||||
struct output *output = output_from_wlr_output(view->server,
|
view_set_output(view, output_from_wlr_output(view->server,
|
||||||
requested->fullscreen_output);
|
requested->fullscreen_output));
|
||||||
if (output_is_usable(output)) {
|
|
||||||
view->output = output;
|
|
||||||
} else {
|
|
||||||
wlr_log(WLR_ERROR,
|
|
||||||
"invalid output in fullscreen request");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
view_set_fullscreen(view, requested->fullscreen);
|
view_set_fullscreen(view, requested->fullscreen);
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +202,7 @@ handle_request_fullscreen(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct view *view = wl_container_of(listener, view, request_fullscreen);
|
struct view *view = wl_container_of(listener, view, request_fullscreen);
|
||||||
if (!view->mapped && !view->output) {
|
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,
|
set_fullscreen_from_request(view,
|
||||||
&xdg_toplevel_from_view(view)->requested);
|
&xdg_toplevel_from_view(view)->requested);
|
||||||
|
|
@ -315,7 +309,7 @@ position_xdg_toplevel_view(struct view *view)
|
||||||
struct view *parent = lookup_view_by_xdg_toplevel(
|
struct view *parent = lookup_view_by_xdg_toplevel(
|
||||||
view->server, parent_xdg_toplevel);
|
view->server, parent_xdg_toplevel);
|
||||||
assert(parent);
|
assert(parent);
|
||||||
view->output = parent->output;
|
view_set_output(view, parent->output);
|
||||||
view_center(view, &parent->pending);
|
view_center(view, &parent->pending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -341,7 +335,7 @@ xdg_toplevel_view_map(struct view *view)
|
||||||
}
|
}
|
||||||
view->mapped = true;
|
view->mapped = true;
|
||||||
if (!view->output) {
|
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);
|
struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
|
||||||
view->surface = xdg_surface->surface;
|
view->surface = xdg_surface->surface;
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ ensure_initial_geometry_and_output(struct view *view)
|
||||||
* Just use the cursor output since we don't know yet
|
* Just use the cursor output since we don't know yet
|
||||||
* whether the surface position is meaningful.
|
* whether the surface position is meaningful.
|
||||||
*/
|
*/
|
||||||
view->output = output_nearest_to_cursor(view->server);
|
view_set_output(view, output_nearest_to_cursor(view->server));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue