mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
Adjust views to account for output layout changes
labwc currently doesn't handle output layout changes very well: - Windows can end up "lost" completely offscreen - Maximized/fullscreen windows can end up spanning multiple outputs Currently, new_output_notify() and output_destroy_notify() contain logic to update the cursor and force a repaint when outputs are added or removed. This logic in fact needs to run on any output layout change, so consolidate it into a new function, output_update_for_layout_change(). Then add a second new function, view_adjust_for_layout_change(), which adjusts window placement to account for the new layout. The behavior is roughly as follows: - Normal windows that end up offscreen are centered on the closest output (making use of the existing view_center() logic) - Maximized windows are re-maximized on the closest output. Logic is also added to the unmaximize step to check that the original unmaximized position is still on-screen. - Fullscreen windows are re-fullscreened on the same output if possible; otherwise they are un-fullscreened. Minimized windows don't require any special handling. Their placement is adjusted just the same, but invisible to the user until they are later unminimized. There is some positioning glitch still with un-fullscreening a window whose output has been disconnected/disabled; it can end up in an unexpected position (but at least has the correct size and decoration). I don't think this is due to a bug in my change per se, but perhaps the change has exposed a bug elsewhere. Fixes: #177
This commit is contained in:
parent
12b05604a2
commit
a837fefc80
3 changed files with 127 additions and 62 deletions
46
src/output.c
46
src/output.c
|
|
@ -940,9 +940,6 @@ output_destroy_notify(struct wl_listener *listener, void *data)
|
|||
struct output *output = wl_container_of(listener, output, destroy);
|
||||
wl_list_remove(&output->link);
|
||||
wl_list_remove(&output->destroy.link);
|
||||
|
||||
/* Windows may have moved; redraw all outputs */
|
||||
damage_all_outputs(output->server);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1029,22 +1026,6 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
wlr_output_enable_adaptive_sync(wlr_output, true);
|
||||
}
|
||||
wlr_output_layout_add_auto(server->output_layout, wlr_output);
|
||||
|
||||
/*
|
||||
* Output positions may have changed, so make sure that each
|
||||
* wlr_output_cursor is "moved" (in per-output coordinates) to
|
||||
* align with the seat cursor. Set a default cursor image so
|
||||
* that the cursor isn't invisible on the new output.
|
||||
*
|
||||
* TODO: remember the most recent cursor image (see cursor.c)
|
||||
* and set that rather than XCURSOR_DEFAULT
|
||||
*/
|
||||
wlr_cursor_move(server->seat.cursor, NULL, 0, 0);
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat.xcursor_manager,
|
||||
XCURSOR_DEFAULT, server->seat.cursor);
|
||||
|
||||
/* Windows may have moved; redraw all outputs */
|
||||
damage_all_outputs(server);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1072,6 +1053,31 @@ output_init(struct server *server)
|
|||
output_manager_init(server);
|
||||
}
|
||||
|
||||
static void
|
||||
output_update_for_layout_change(struct server *server)
|
||||
{
|
||||
/* Adjust window positions/sizes */
|
||||
struct view *view;
|
||||
wl_list_for_each(view, &server->views, link) {
|
||||
view_adjust_for_layout_change(view);
|
||||
}
|
||||
|
||||
/*
|
||||
* "Move" each wlr_output_cursor (in per-output coordinates) to
|
||||
* align with the seat cursor. Set a default cursor image so
|
||||
* that the cursor isn't invisible on new outputs.
|
||||
*
|
||||
* TODO: remember the most recent cursor image (see cursor.c)
|
||||
* and set that rather than XCURSOR_DEFAULT
|
||||
*/
|
||||
wlr_cursor_move(server->seat.cursor, NULL, 0, 0);
|
||||
wlr_xcursor_manager_set_cursor_image(server->seat.xcursor_manager,
|
||||
XCURSOR_DEFAULT, server->seat.cursor);
|
||||
|
||||
/* Redraw everything */
|
||||
damage_all_outputs(server);
|
||||
}
|
||||
|
||||
static void
|
||||
output_config_apply(struct server *server,
|
||||
struct wlr_output_configuration_v1 *config)
|
||||
|
|
@ -1111,6 +1117,7 @@ output_config_apply(struct server *server,
|
|||
}
|
||||
|
||||
server->pending_output_config = NULL;
|
||||
output_update_for_layout_change(server);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -1205,6 +1212,7 @@ handle_output_layout_change(struct wl_listener *listener, void *data)
|
|||
arrange_layers(output);
|
||||
}
|
||||
}
|
||||
output_update_for_layout_change(server);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue