diff --git a/include/labwc.h b/include/labwc.h index fbeb992b..642cf4cb 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -403,39 +403,6 @@ struct server { pid_t primary_client_pid; }; -#define LAB_NR_LAYERS (4) - -struct output { - struct wl_list link; /* server.outputs */ - struct server *server; - struct wlr_output *wlr_output; - struct wlr_output_state pending; - struct wlr_scene_output *scene_output; - struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS]; - struct wlr_scene_tree *layer_popup_tree; - struct wlr_scene_tree *osd_tree; - struct wlr_scene_tree *session_lock_tree; - struct wlr_scene_buffer *workspace_osd; - - struct osd_scene { - struct wl_array items; /* struct osd_scene_item */ - struct wlr_scene_tree *tree; - } osd_scene; - - /* In output-relative scene coordinates */ - struct wlr_box usable_area; - - struct wl_list regions; /* struct region.link */ - - struct wl_listener destroy; - struct wl_listener frame; - struct wl_listener request_state; - - bool gamma_lut_changed; -}; - -#undef LAB_NR_LAYERS - struct constraint { struct seat *seat; struct wlr_pointer_constraint_v1 *constraint; @@ -548,45 +515,6 @@ void interactive_cancel(struct view *view); /* Possibly returns VIEW_EDGE_CENTER if is yes */ enum view_edge edge_from_cursor(struct seat *seat, struct output **dest_output); -void output_init(struct server *server); -void output_finish(struct server *server); -void output_manager_init(struct server *server); -struct output *output_from_wlr_output(struct server *server, - struct wlr_output *wlr_output); -struct output *output_from_name(struct server *server, const char *name); -struct output *output_nearest_to(struct server *server, int lx, int ly); -struct output *output_nearest_to_cursor(struct server *server); - -/** - * output_get_adjacent() - get next output, in a given direction, - * from a given output - * - * @output: reference output - * @edge: direction in which to look for the nearest output - * @wrap: if true, wrap around at layout edge - * - * Note: if output is NULL, the output nearest the cursor will be used as the - * reference instead. - */ -struct output *output_get_adjacent(struct output *output, - enum view_edge edge, bool wrap); - -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); -bool output_get_tearing_allowance(struct output *output); -struct wlr_box output_usable_area_in_layout_coords(struct output *output); -void handle_output_power_manager_set_mode(struct wl_listener *listener, - void *data); -void output_enable_adaptive_sync(struct output *output, bool enabled); - -/** - * output_max_scale() - get maximum scale factor of all usable outputs. - * Used when loading/rendering resources (e.g. icons) that may be - * displayed on any output. - */ -float output_max_scale(struct server *server); - void handle_tearing_new_object(struct wl_listener *listener, void *data); void server_init(struct server *server); diff --git a/include/output.h b/include/output.h new file mode 100644 index 00000000..d96a8c21 --- /dev/null +++ b/include/output.h @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LABWC_OUTPUT_H +#define LABWC_OUTPUT_H + +#include + +enum view_edge; + +#define LAB_NR_LAYERS (4) + +struct output { + struct wl_list link; /* server.outputs */ + struct server *server; + struct wlr_output *wlr_output; + struct wlr_output_state pending; + struct wlr_scene_output *scene_output; + struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS]; + struct wlr_scene_tree *layer_popup_tree; + struct wlr_scene_tree *osd_tree; + struct wlr_scene_tree *session_lock_tree; + struct wlr_scene_buffer *workspace_osd; + + struct osd_scene { + struct wl_array items; /* struct osd_scene_item */ + struct wlr_scene_tree *tree; + } osd_scene; + + /* In output-relative scene coordinates */ + struct wlr_box usable_area; + + struct wl_list regions; /* struct region.link */ + + struct wl_listener destroy; + struct wl_listener frame; + struct wl_listener request_state; + + bool gamma_lut_changed; +}; + +#undef LAB_NR_LAYERS + +void output_init(struct server *server); +void output_finish(struct server *server); +void output_manager_init(struct server *server); +struct output *output_from_wlr_output(struct server *server, + struct wlr_output *wlr_output); +struct output *output_from_name(struct server *server, const char *name); +struct output *output_nearest_to(struct server *server, int lx, int ly); +struct output *output_nearest_to_cursor(struct server *server); + +/** + * output_get_adjacent() - get next output, in a given direction, + * from a given output + * + * @output: reference output + * @edge: direction in which to look for the nearest output + * @wrap: if true, wrap around at layout edge + * + * Note: if output is NULL, the output nearest the cursor will be used as the + * reference instead. + */ +struct output *output_get_adjacent(struct output *output, + enum view_edge edge, bool wrap); + +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); +bool output_get_tearing_allowance(struct output *output); +struct wlr_box output_usable_area_in_layout_coords(struct output *output); +void handle_output_power_manager_set_mode(struct wl_listener *listener, + void *data); +void output_enable_adaptive_sync(struct output *output, bool enabled); + +/** + * output_max_scale() - get maximum scale factor of all usable outputs. + * Used when loading/rendering resources (e.g. icons) that may be + * displayed on any output. + */ +float output_max_scale(struct server *server); + +#endif // LABWC_OUTPUT_H diff --git a/src/action.c b/src/action.c index adcae7cf..ec1914c4 100644 --- a/src/action.c +++ b/src/action.c @@ -18,6 +18,7 @@ #include "magnifier.h" #include "menu/menu.h" #include "osd.h" +#include "output.h" #include "output-virtual.h" #include "regions.h" #include "ssd.h" diff --git a/src/common/scene-helpers.c b/src/common/scene-helpers.c index 9b787b26..5f8a8139 100644 --- a/src/common/scene-helpers.c +++ b/src/common/scene-helpers.c @@ -9,6 +9,7 @@ #include #include "labwc.h" #include "magnifier.h" +#include "output.h" #include "output-state.h" struct wlr_surface * diff --git a/src/debug.c b/src/debug.c index e482a357..60b4a82c 100644 --- a/src/debug.c +++ b/src/debug.c @@ -8,6 +8,7 @@ #include "input/ime.h" #include "labwc.h" #include "node.h" +#include "output.h" #include "ssd.h" #include "view.h" #include "workspaces.h" diff --git a/src/desktop.c b/src/desktop.c index 28af6cc6..739cc3ef 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -8,6 +8,7 @@ #include "layers.h" #include "node.h" #include "osd.h" +#include "output.h" #include "ssd.h" #include "view.h" #include "window-rules.h" diff --git a/src/edges.c b/src/edges.c index 237991a2..94c541b5 100644 --- a/src/edges.c +++ b/src/edges.c @@ -10,6 +10,7 @@ #include "common/macros.h" #include "config/rcxml.h" #include "labwc.h" +#include "output.h" #include "view.h" #include "node.h" diff --git a/src/foreign-toplevel/wlr-foreign.c b/src/foreign-toplevel/wlr-foreign.c index 76eb01e5..7c915ac4 100644 --- a/src/foreign-toplevel/wlr-foreign.c +++ b/src/foreign-toplevel/wlr-foreign.c @@ -3,6 +3,7 @@ #include #include "common/macros.h" #include "labwc.h" +#include "output.h" #include "view.h" #include "foreign-toplevel-internal.h" diff --git a/src/input/cursor.c b/src/input/cursor.c index be292822..d7eabb75 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -25,6 +25,7 @@ #include "labwc.h" #include "layers.h" #include "menu/menu.h" +#include "output.h" #include "regions.h" #include "resistance.h" #include "resize-outlines.h" diff --git a/src/input/ime.c b/src/input/ime.c index 0cb656de..1e4cddc4 100644 --- a/src/input/ime.c +++ b/src/input/ime.c @@ -5,6 +5,7 @@ #include #include "common/mem.h" #include "node.h" +#include "output.h" #include "view.h" #define SAME_CLIENT(wlr_obj1, wlr_obj2) \ diff --git a/src/interactive.c b/src/interactive.c index bd620edb..f6fd5450 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -3,6 +3,7 @@ #include "edges.h" #include "input/keyboard.h" #include "labwc.h" +#include "output.h" #include "regions.h" #include "resize-indicator.h" #include "snap.h" diff --git a/src/layers.c b/src/layers.c index 44a2e131..7ed3f84d 100644 --- a/src/layers.c +++ b/src/layers.c @@ -21,6 +21,7 @@ #include "config/rcxml.h" #include "labwc.h" #include "node.h" +#include "output.h" #define LAB_LAYERSHELL_VERSION 4 diff --git a/src/magnifier.c b/src/magnifier.c index 9fb5b264..49499211 100644 --- a/src/magnifier.c +++ b/src/magnifier.c @@ -7,6 +7,7 @@ #include #include "common/box.h" #include "labwc.h" +#include "output.h" #include "theme.h" static bool magnify_on; diff --git a/src/menu/menu.c b/src/menu/menu.c index a44790eb..f8695a2a 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -26,6 +26,7 @@ #include "common/spawn.h" #include "common/string-helpers.h" #include "labwc.h" +#include "output.h" #include "workspaces.h" #include "view.h" #include "node.h" diff --git a/src/osd-field.c b/src/osd-field.c index 0819e1e6..c27b9379 100644 --- a/src/osd-field.c +++ b/src/osd-field.c @@ -9,6 +9,7 @@ #include "labwc.h" #include "desktop-entry.h" #include "osd.h" +#include "output.h" /* includes '%', terminating 's' and NULL byte, 8 is enough for %-9999s */ #define LAB_FIELD_SINGLE_FMT_MAX_LEN 8 diff --git a/src/osd.c b/src/osd.c index 89ba415d..6ae3381d 100644 --- a/src/osd.c +++ b/src/osd.c @@ -8,7 +8,6 @@ #include "common/buf.h" #include "common/font.h" #include "common/lab-scene-rect.h" -#include "common/macros.h" #include "common/scaled-font-buffer.h" #include "common/scaled-icon-buffer.h" #include "common/scene-helpers.h" @@ -16,6 +15,7 @@ #include "config/rcxml.h" #include "labwc.h" #include "node.h" +#include "output.h" #include "theme.h" #include "view.h" #include "window-rules.h" diff --git a/src/output-state.c b/src/output-state.c index 7ebcc19e..7da1108b 100644 --- a/src/output-state.c +++ b/src/output-state.c @@ -3,7 +3,8 @@ #include "output-state.h" #include #include -#include "labwc.h" +#include +#include "output.h" void output_state_init(struct output *output) diff --git a/src/output-virtual.c b/src/output-virtual.c index 888f832b..164be7b6 100644 --- a/src/output-virtual.c +++ b/src/output-virtual.c @@ -6,6 +6,7 @@ #include #include "common/string-helpers.h" #include "labwc.h" +#include "output.h" static struct wlr_output *fallback_output = NULL; diff --git a/src/output.c b/src/output.c index 3b4a26ca..99c1b847 100644 --- a/src/output.c +++ b/src/output.c @@ -7,6 +7,7 @@ */ #define _POSIX_C_SOURCE 200809L +#include "output.h" #include #include #include diff --git a/src/overlay.c b/src/overlay.c index 78a9c172..cf7b96b1 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -3,6 +3,7 @@ #include #include "common/lab-scene-rect.h" #include "labwc.h" +#include "output.h" #include "view.h" #include "theme.h" diff --git a/src/placement.c b/src/placement.c index c0377038..869bede3 100644 --- a/src/placement.c +++ b/src/placement.c @@ -3,10 +3,9 @@ #include #include #include -#include -#include "common/macros.h" #include "common/mem.h" #include "labwc.h" +#include "output.h" #include "ssd.h" #include "view.h" diff --git a/src/regions.c b/src/regions.c index 3463c97f..26c1e6d7 100644 --- a/src/regions.c +++ b/src/regions.c @@ -13,6 +13,7 @@ #include "common/mem.h" #include "input/keyboard.h" #include "labwc.h" +#include "output.h" #include "view.h" bool diff --git a/src/seat.c b/src/seat.c index 0beaf487..1b3b7a3f 100644 --- a/src/seat.c +++ b/src/seat.c @@ -17,6 +17,7 @@ #include "input/keyboard.h" #include "input/key-state.h" #include "labwc.h" +#include "output.h" #include "view.h" static void diff --git a/src/server.c b/src/server.c index 214885b1..ca24392a 100644 --- a/src/server.c +++ b/src/server.c @@ -47,6 +47,7 @@ #include "layers.h" #include "magnifier.h" #include "menu/menu.h" +#include "output.h" #include "output-state.h" #include "output-virtual.h" #include "regions.h" diff --git a/src/session-lock.c b/src/session-lock.c index fe118566..1dce3b6a 100644 --- a/src/session-lock.c +++ b/src/session-lock.c @@ -5,6 +5,7 @@ #include "common/mem.h" #include "labwc.h" #include "node.h" +#include "output.h" struct session_lock_output { struct wlr_scene_tree *tree; diff --git a/src/snap.c b/src/snap.c index 4e8e1d44..7991d48c 100644 --- a/src/snap.c +++ b/src/snap.c @@ -1,12 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only #include "snap.h" #include -#include #include #include "common/border.h" -#include "common/macros.h" #include "edges.h" #include "labwc.h" +#include "output.h" #include "snap-constraints.h" #include "view.h" diff --git a/src/ssd/ssd-extents.c b/src/ssd/ssd-extents.c index c2ff6d0c..90f12ce6 100644 --- a/src/ssd/ssd-extents.c +++ b/src/ssd/ssd-extents.c @@ -2,10 +2,10 @@ #include #include -#include "common/mem.h" #include "common/scene-helpers.h" #include "config/rcxml.h" #include "labwc.h" +#include "output.h" #include "ssd-internal.h" #include "theme.h" #include "view.h" diff --git a/src/view.c b/src/view.c index 98c61d92..45b87458 100644 --- a/src/view.c +++ b/src/view.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only #include "view.h" #include -#include #include #include #include @@ -9,16 +8,15 @@ #include "buffer.h" #include "common/box.h" #include "common/list.h" -#include "common/macros.h" #include "common/match.h" #include "common/mem.h" -#include "common/parse-bool.h" #include "common/scene-helpers.h" #include "foreign-toplevel.h" #include "input/keyboard.h" #include "labwc.h" #include "menu/menu.h" #include "osd.h" +#include "output.h" #include "output-state.h" #include "placement.h" #include "regions.h" diff --git a/src/workspaces.c b/src/workspaces.c index fc1cd524..2057adf0 100644 --- a/src/workspaces.c +++ b/src/workspaces.c @@ -8,7 +8,6 @@ #include #include #include -#include "config.h" #include "buffer.h" #include "common/font.h" #include "common/graphic-helpers.h" @@ -16,10 +15,10 @@ #include "common/mem.h" #include "input/keyboard.h" #include "labwc.h" +#include "output.h" #include "protocols/cosmic-workspaces.h" #include "protocols/ext-workspace.h" #include "view.h" -#include "xwayland.h" #define COSMIC_WORKSPACES_VERSION 1 #define EXT_WORKSPACES_VERSION 1 diff --git a/src/xdg-popup.c b/src/xdg-popup.c index d4daadd6..23942b69 100644 --- a/src/xdg-popup.c +++ b/src/xdg-popup.c @@ -11,6 +11,7 @@ #include "common/mem.h" #include "labwc.h" #include "node.h" +#include "output.h" #include "view.h" struct xdg_popup { diff --git a/src/xdg.c b/src/xdg.c index be8cfc20..f551c204 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -12,6 +12,7 @@ #include "labwc.h" #include "menu/menu.h" #include "node.h" +#include "output.h" #include "snap-constraints.h" #include "view.h" #include "view-impl-common.h" diff --git a/src/xwayland.c b/src/xwayland.c index fae5b659..097fc731 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -13,6 +13,7 @@ #include "foreign-toplevel.h" #include "labwc.h" #include "node.h" +#include "output.h" #include "ssd.h" #include "view.h" #include "view-impl-common.h"