void output_manager_init(struct server *server);
struct output *output_from_wlr_output(struct server *server,
struct wlr_output *wlr_output);
+bool output_is_usable(struct output *output);
void output_update_usable_area(struct output *output);
void output_update_all_usable_areas(struct server *server, bool layout_changed);
struct wlr_box output_usable_area_in_layout_coords(struct output *output);
foreign_toplevel_update_outputs(struct view *view)
{
assert(view->toplevel.handle);
-
- struct wlr_box view_geo = view->current;
struct wlr_output_layout *layout = view->server->output_layout;
-
struct output *output;
wl_list_for_each(output, &view->server->outputs, link) {
- if (output->wlr_output->enabled && !output->leased) {
- if (wlr_output_layout_intersects(layout,
- output->wlr_output, &view_geo)) {
- wlr_foreign_toplevel_handle_v1_output_enter(
- view->toplevel.handle, output->wlr_output);
- continue;
- }
+ if (output_is_usable(output) && wlr_output_layout_intersects(
+ layout, output->wlr_output, &view->current)) {
+ wlr_foreign_toplevel_handle_v1_output_enter(
+ view->toplevel.handle, output->wlr_output);
+ } else {
+ wlr_foreign_toplevel_handle_v1_output_leave(
+ view->toplevel.handle, output->wlr_output);
}
- wlr_foreign_toplevel_handle_v1_output_leave(
- view->toplevel.handle, output->wlr_output);
}
}
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
destroy_osd_nodes(output);
- if (!output->wlr_output->enabled) {
- continue;
+ if (output_is_usable(output)) {
+ display_osd(output);
}
- display_osd(output);
}
/* Outline current window */
output_frame_notify(struct wl_listener *listener, void *data)
{
struct output *output = wl_container_of(listener, output, frame);
- if (!output->wlr_output->enabled) {
+ if (!output_is_usable(output)) {
return;
}
return NULL;
}
+bool
+output_is_usable(struct output *output)
+{
+ /* output_is_usable(NULL) is safe and returns false */
+ return output && output->wlr_output->enabled && !output->leased;
+}
+
/* returns true if usable area changed */
static bool
update_usable_area(struct output *output)
}
wl_list_for_each(output, &server->outputs, link) {
- if (!output->wlr_output->enabled) {
+ if (!output_is_usable(output)) {
continue;
}
return;
}
wl_list_for_each(output, &server->outputs, link) {
- if (!output->wlr_output->enabled) {
+ if (!output_is_usable(output)) {
continue;
}