]> git.mdlowis.com Git - proto/labwc.git/commitdiff
include: Break out view.h from labwc.h
authorJohn Lindgren <john@jlindgren.net>
Mon, 21 Nov 2022 15:10:39 +0000 (10:10 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 21 Nov 2022 21:42:37 +0000 (21:42 +0000)
IMHO it encourages better design (by making dependencies more obvious)
to have source file/header file pairs like view.c/view.h, rather than a
monolithic header like labwc.h with everything in it.

I don't think we need to break up all of labwc.h at once, but maybe we
can start pulling it apart bit by bit as it's convenient.

Also:

- Move "struct border" to ssd.h so that view.h can use it without pulling
  in all of labwc.h.
- Add a missing required #include within scaled_font_buffer.h (forward
  declaration of "struct font" is not enough).

25 files changed:
include/common/scaled_font_buffer.h
include/labwc.h
include/ssd.h
include/view.h [new file with mode: 0644]
src/action.c
src/cursor.c
src/debug.c
src/desktop.c
src/foreign.c
src/interactive.c
src/osd.c
src/output.c
src/resistance.c
src/server.c
src/ssd/ssd.c
src/ssd/ssd_border.c
src/ssd/ssd_extents.c
src/ssd/ssd_titlebar.c
src/view-impl.c
src/view.c
src/workspaces.c
src/xdg-deco.c
src/xdg-popup.c
src/xdg.c
src/xwayland.c

index dbce8fff64b92e9b89a523425d6cd8139e9f6384..fb5e925db0198552ca9162be8ba2ef02d3391d17 100644 (file)
@@ -2,7 +2,8 @@
 #ifndef __LAB_COMMON_SCALED_FONT_BUFFER_H
 #define __LAB_COMMON_SCALED_FONT_BUFFER_H
 
-struct font;
+#include "common/font.h"
+
 struct wlr_scene_tree;
 struct wlr_scene_buffer;
 struct scaled_scene_buffere;
index f5bf413401e512229cac99059a6cd3cb58d70d60..788bfa0ec960eb5cbf5d06b58322df2ecc74074c 100644 (file)
@@ -316,110 +316,6 @@ struct output {
 
 #undef LAB_NR_LAYERS
 
-enum view_type {
-       LAB_XDG_SHELL_VIEW,
-#if HAVE_XWAYLAND
-       LAB_XWAYLAND_VIEW,
-#endif
-};
-
-struct view_impl {
-       void (*configure)(struct view *view, struct wlr_box geo);
-       void (*close)(struct view *view);
-       const char *(*get_string_prop)(struct view *view, const char *prop);
-       void (*map)(struct view *view);
-       void (*move)(struct view *view, int x, int y);
-       void (*set_activated)(struct view *view, bool activated);
-       void (*set_fullscreen)(struct view *view, bool fullscreen);
-       void (*unmap)(struct view *view);
-       void (*maximize)(struct view *view, bool maximize);
-};
-
-struct border {
-       int top;
-       int right;
-       int bottom;
-       int left;
-};
-
-struct view {
-       struct server *server;
-       enum view_type type;
-       const struct view_impl *impl;
-       struct wl_list link;
-       struct output *output;
-       struct workspace *workspace;
-
-       union {
-               struct wlr_xdg_surface *xdg_surface;
-#if HAVE_XWAYLAND
-               struct wlr_xwayland_surface *xwayland_surface;
-#endif
-       };
-       struct wlr_surface *surface;
-       struct wlr_scene_tree *scene_tree;
-       struct wlr_scene_node *scene_node;
-
-       bool mapped;
-       bool been_mapped;
-       bool minimized;
-       bool maximized;
-       uint32_t tiled;  /* private, enum view_edge in src/view.c */
-       struct wlr_output *fullscreen;
-
-       /* geometry of the wlr_surface contained within the view */
-       int x, y, w, h;
-
-       /* user defined geometry before maximize / tiling / fullscreen */
-       struct wlr_box natural_geometry;
-
-       /*
-        * margin refers to the space between the extremities of the
-        * wlr_surface and the max extents of the server-side decorations.
-        * For xdg-shell views with CSD, this margin is zero.
-        */
-       struct border margin;
-
-       struct view_pending_move_resize {
-               bool update_x, update_y;
-               int x, y;
-               uint32_t width, height;
-               uint32_t configure_serial;
-       } pending_move_resize;
-
-       struct ssd ssd;
-
-       struct wlr_foreign_toplevel_handle_v1 *toplevel_handle;
-       struct wl_listener toplevel_handle_request_maximize;
-       struct wl_listener toplevel_handle_request_minimize;
-       struct wl_listener toplevel_handle_request_fullscreen;
-       struct wl_listener toplevel_handle_request_activate;
-       struct wl_listener toplevel_handle_request_close;
-
-       struct wl_listener map;
-       struct wl_listener unmap;
-       struct wl_listener destroy;
-       struct wl_listener surface_destroy;
-       struct wl_listener commit;
-       struct wl_listener request_move;
-       struct wl_listener request_resize;
-       struct wl_listener request_configure;   /* xwayland only */
-       struct wl_listener request_activate;
-       struct wl_listener request_minimize;
-       struct wl_listener request_maximize;
-       struct wl_listener request_fullscreen;
-       struct wl_listener set_title;
-       struct wl_listener set_app_id;          /* class on xwayland */
-       struct wl_listener set_decorations;     /* xwayland only */
-       struct wl_listener override_redirect;   /* xwayland only */
-       struct wl_listener new_popup;           /* xdg-shell only */
-
-       /* Not (yet) implemented */
-/*     struct wl_listener set_role; */
-/*     struct wl_listener set_window_type; */
-/*     struct wl_listener set_hints; */
-};
-
 #if HAVE_XWAYLAND
 struct xwayland_unmanaged {
        struct server *server;
@@ -463,50 +359,6 @@ struct xwayland_unmanaged *xwayland_unmanaged_create(struct server *server,
 void unmanaged_handle_map(struct wl_listener *listener, void *data);
 #endif
 
-void view_set_activated(struct view *view);
-void view_close(struct view *view);
-
-/**
- * view_move_resize - resize and move view
- * @view: view to be resized and moved
- * @geo: the new geometry
- * NOTE: Only use this when the view actually changes width and/or height
- * otherwise the serials might cause a delay in moving xdg-shell clients.
- * For move only, use view_move()
- */
-void view_move_resize(struct view *view, struct wlr_box geo);
-void view_move(struct view *view, int x, int y);
-void view_moved(struct view *view);
-void view_minimize(struct view *view, bool minimized);
-/* view_wlr_output - return the output that a view is mostly on */
-struct wlr_output *view_wlr_output(struct view *view);
-void view_store_natural_geometry(struct view *view);
-void view_center(struct view *view);
-void view_restore_to(struct view *view, struct wlr_box geometry);
-void view_maximize(struct view *view, bool maximize,
-       bool store_natural_geometry);
-void view_set_fullscreen(struct view *view, bool fullscreen,
-       struct wlr_output *wlr_output);
-void view_toggle_maximize(struct view *view);
-void view_toggle_decorations(struct view *view);
-void view_toggle_always_on_top(struct view *view);
-void view_set_decorations(struct view *view, bool decorations);
-void view_toggle_fullscreen(struct view *view);
-void view_adjust_for_layout_change(struct view *view);
-void view_discover_output(struct view *view);
-void view_move_to_edge(struct view *view, const char *direction);
-void view_snap_to_edge(struct view *view, const char *direction,
-       bool store_natural_geometry);
-const char *view_get_string_prop(struct view *view, const char *prop);
-void view_update_title(struct view *view);
-void view_update_app_id(struct view *view);
-
-void view_impl_map(struct view *view);
-void view_adjust_size(struct view *view, int *w, int *h);
-
-void view_on_output_destroy(struct view *view);
-void view_destroy(struct view *view);
-
 void foreign_toplevel_handle_create(struct view *view);
 
 /*
index 12797cc5ab5facafe11beba7f717ad841ad429b0..e412ea80938b0386d633e5e45f47eee4db037609 100644 (file)
@@ -55,6 +55,13 @@ struct wlr_box;
 struct wlr_scene_tree;
 struct scaled_font_buffer;
 
+struct border {
+       int top;
+       int right;
+       int bottom;
+       int left;
+};
+
 struct ssd_button {
        struct view *view;
        enum ssd_part_type type;
diff --git a/include/view.h b/include/view.h
new file mode 100644 (file)
index 0000000..0df97d4
--- /dev/null
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LABWC_VIEW_H
+#define __LABWC_VIEW_H
+
+#include "config.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include <wayland-util.h>
+#include <wlr/util/box.h>
+#include "ssd.h"
+
+enum view_type {
+       LAB_XDG_SHELL_VIEW,
+#if HAVE_XWAYLAND
+       LAB_XWAYLAND_VIEW,
+#endif
+};
+
+struct view_impl {
+       void (*configure)(struct view *view, struct wlr_box geo);
+       void (*close)(struct view *view);
+       const char *(*get_string_prop)(struct view *view, const char *prop);
+       void (*map)(struct view *view);
+       void (*move)(struct view *view, int x, int y);
+       void (*set_activated)(struct view *view, bool activated);
+       void (*set_fullscreen)(struct view *view, bool fullscreen);
+       void (*unmap)(struct view *view);
+       void (*maximize)(struct view *view, bool maximize);
+};
+
+struct view {
+       struct server *server;
+       enum view_type type;
+       const struct view_impl *impl;
+       struct wl_list link;
+       struct output *output;
+       struct workspace *workspace;
+
+       union {
+               struct wlr_xdg_surface *xdg_surface;
+#if HAVE_XWAYLAND
+               struct wlr_xwayland_surface *xwayland_surface;
+#endif
+       };
+       struct wlr_surface *surface;
+       struct wlr_scene_tree *scene_tree;
+       struct wlr_scene_node *scene_node;
+
+       bool mapped;
+       bool been_mapped;
+       bool minimized;
+       bool maximized;
+       uint32_t tiled;  /* private, enum view_edge in src/view.c */
+       struct wlr_output *fullscreen;
+
+       /* geometry of the wlr_surface contained within the view */
+       int x, y, w, h;
+
+       /* user defined geometry before maximize / tiling / fullscreen */
+       struct wlr_box natural_geometry;
+
+       /*
+        * margin refers to the space between the extremities of the
+        * wlr_surface and the max extents of the server-side decorations.
+        * For xdg-shell views with CSD, this margin is zero.
+        */
+       struct border margin;
+
+       struct view_pending_move_resize {
+               bool update_x, update_y;
+               int x, y;
+               uint32_t width, height;
+               uint32_t configure_serial;
+       } pending_move_resize;
+
+       struct ssd ssd;
+
+       struct wlr_foreign_toplevel_handle_v1 *toplevel_handle;
+       struct wl_listener toplevel_handle_request_maximize;
+       struct wl_listener toplevel_handle_request_minimize;
+       struct wl_listener toplevel_handle_request_fullscreen;
+       struct wl_listener toplevel_handle_request_activate;
+       struct wl_listener toplevel_handle_request_close;
+
+       struct wl_listener map;
+       struct wl_listener unmap;
+       struct wl_listener destroy;
+       struct wl_listener surface_destroy;
+       struct wl_listener commit;
+       struct wl_listener request_move;
+       struct wl_listener request_resize;
+       struct wl_listener request_configure;   /* xwayland only */
+       struct wl_listener request_activate;
+       struct wl_listener request_minimize;
+       struct wl_listener request_maximize;
+       struct wl_listener request_fullscreen;
+       struct wl_listener set_title;
+       struct wl_listener set_app_id;          /* class on xwayland */
+       struct wl_listener set_decorations;     /* xwayland only */
+       struct wl_listener override_redirect;   /* xwayland only */
+       struct wl_listener new_popup;           /* xdg-shell only */
+
+       /* Not (yet) implemented */
+/*     struct wl_listener set_role; */
+/*     struct wl_listener set_window_type; */
+/*     struct wl_listener set_hints; */
+};
+
+void view_set_activated(struct view *view);
+void view_close(struct view *view);
+
+/**
+ * view_move_resize - resize and move view
+ * @view: view to be resized and moved
+ * @geo: the new geometry
+ * NOTE: Only use this when the view actually changes width and/or height
+ * otherwise the serials might cause a delay in moving xdg-shell clients.
+ * For move only, use view_move()
+ */
+void view_move_resize(struct view *view, struct wlr_box geo);
+void view_move(struct view *view, int x, int y);
+void view_moved(struct view *view);
+void view_minimize(struct view *view, bool minimized);
+/* view_wlr_output - return the output that a view is mostly on */
+struct wlr_output *view_wlr_output(struct view *view);
+void view_store_natural_geometry(struct view *view);
+void view_center(struct view *view);
+void view_restore_to(struct view *view, struct wlr_box geometry);
+void view_maximize(struct view *view, bool maximize,
+       bool store_natural_geometry);
+void view_set_fullscreen(struct view *view, bool fullscreen,
+       struct wlr_output *wlr_output);
+void view_toggle_maximize(struct view *view);
+void view_toggle_decorations(struct view *view);
+void view_toggle_always_on_top(struct view *view);
+void view_set_decorations(struct view *view, bool decorations);
+void view_toggle_fullscreen(struct view *view);
+void view_adjust_for_layout_change(struct view *view);
+void view_discover_output(struct view *view);
+void view_move_to_edge(struct view *view, const char *direction);
+void view_snap_to_edge(struct view *view, const char *direction,
+       bool store_natural_geometry);
+const char *view_get_string_prop(struct view *view, const char *prop);
+void view_update_title(struct view *view);
+void view_update_app_id(struct view *view);
+
+void view_impl_map(struct view *view);
+void view_adjust_size(struct view *view, int *w, int *h);
+
+void view_on_output_destroy(struct view *view);
+void view_destroy(struct view *view);
+
+#endif /* __LABWC_VIEW_H */
index e1d8778d8a5d0aa0c64e837d5344607a67bfad94..dc5a73c2ddfba88382185eb25ecab68662a6ecac 100644 (file)
@@ -14,6 +14,7 @@
 #include "menu/menu.h"
 #include "private/action.h"
 #include "ssd.h"
+#include "view.h"
 #include "workspaces.h"
 
 enum action_type {
index b81583c9a8ed2372d4dbb3171a97381b0aaac9e2..a2f324d20a8db7c8ec743ff43637c8cf53561a99 100644 (file)
@@ -14,6 +14,7 @@
 #include "menu/menu.h"
 #include "resistance.h"
 #include "ssd.h"
+#include "view.h"
 
 static const char * const *cursor_names = NULL;
 
index 815748d155196f3148edc5d92712816ca4fbd858..135390d4c70028e1585abea651ccd80f86f11477 100644 (file)
@@ -1,10 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <wlr/types/wlr_layer_shell_v1.h>
 #include <wlr/types/wlr_scene.h>
-#include "buffer.h"
+#include "common/scene-helpers.h"
 #include "labwc.h"
 #include "node.h"
-#include "common/scene-helpers.h"
+#include "view.h"
 
 #define HEADER_CHARS "------------------------------"
 
index 52054fbdc0341b5464c5a9bb4bd77b4283faca4d..dde5e2c35fa382e38f3f420e4a9bb4c529db2061 100644 (file)
@@ -5,9 +5,9 @@
 #include "common/scene-helpers.h"
 #include "dnd.h"
 #include "labwc.h"
-#include "layers.h"
 #include "node.h"
 #include "ssd.h"
+#include "view.h"
 #include "workspaces.h"
 
 static void
index 915520b6821e07d92b962aaf26295828cce3695d..09e3d982bf210ca587fd6bb7d709b91b9bb0290a 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include "labwc.h"
+#include "view.h"
 #include "workspaces.h"
 
 static void
index 2691cccd2449b8e225cc780f74ee540ac42f463f..dcfe061a6a85588a6094c1186811d3aefb9da817 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include "labwc.h"
+#include "view.h"
 
 static int
 max_move_scale(double pos_cursor, double pos_current,
index a91ec00077d58ca668131187a025e3ed974dc2c4..d92afac34b308238ae691524948bb8953d998635 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -14,6 +14,7 @@
 #include "labwc.h"
 #include "theme.h"
 #include "node.h"
+#include "view.h"
 #include "workspaces.h"
 
 #define OSD_ITEM_HEIGHT (20)
index 0e9d898b0651e990abe8aaab86cd84800c80508f..0fb94512b56a40ac4f611e342c66762692ed017b 100644 (file)
@@ -19,6 +19,7 @@
 #include "labwc.h"
 #include "layers.h"
 #include "node.h"
+#include "view.h"
 
 static void
 output_frame_notify(struct wl_listener *listener, void *data)
index 96d4908e64ba04a8b5bb379b1b55ef83f77ab39d..55a9713f0c809787d46967cdb4920e6a72df8002 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
-#include "labwc.h"
 #include "config/rcxml.h"
+#include "labwc.h"
+#include "view.h"
 
 struct edges {
        int left;
index f6a122494a35acccae803acae254a9ce0e17ec54..8b41234180a2592dfe145f32872846e3df3d11a4 100644 (file)
@@ -18,6 +18,7 @@
 #include "menu/menu.h"
 #include "ssd.h"
 #include "theme.h"
+#include "view.h"
 #include "workspaces.h"
 
 #define LAB_XDG_SHELL_VERSION (2)
index f556b24d553034f2d010e1db5f3e569e91ab1f79..a1706a58759c267aac80c8a727628cc0cd2c7028 100644 (file)
@@ -7,12 +7,11 @@
  */
 
 #include <assert.h>
-#include "config/rcxml.h"
-#include "common/font.h"
+#include "common/scene-helpers.h"
 #include "labwc.h"
-#include "theme.h"
 #include "ssd.h"
-#include "common/scene-helpers.h"
+#include "theme.h"
+#include "view.h"
 
 struct border
 ssd_thickness(struct view *view)
index 719012c27cc54e9c55af7ea706ee01fb00076c0b..e39f3e5fdb378c0e3b3ee0b59c492607c165b44a 100644 (file)
@@ -1,9 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include "common/scene-helpers.h"
 #include "labwc.h"
 #include "ssd.h"
 #include "theme.h"
-#include "common/scene-helpers.h"
+#include "view.h"
 
 #define FOR_EACH_STATE(view, tmp) FOR_EACH(tmp, \
        &(view)->ssd.border.active, \
index a60056384453c3c39daa6ccc38c8eceebb32189c..027086deddce29debe7c3f2bf14dda98c9535800 100644 (file)
@@ -1,10 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
+#include "common/mem.h"
+#include "common/scene-helpers.h"
 #include "labwc.h"
 #include "ssd.h"
 #include "theme.h"
-#include "common/mem.h"
-#include "common/scene-helpers.h"
+#include "view.h"
 
 static struct ssd_part *
 add_extent(struct wl_list *part_list, enum ssd_part_type type,
index 945c2844011a6f9761fe65415d3da3e7a6baffa4..fd7d820d2ed546876dbb46db20090f485296ed91 100644 (file)
@@ -3,14 +3,14 @@
 #define _POSIX_C_SOURCE 200809L
 #include <assert.h>
 #include <string.h>
-#include "labwc.h"
-#include "ssd.h"
-#include "theme.h"
-#include "common/font.h"
 #include "common/mem.h"
 #include "common/scaled_font_buffer.h"
 #include "common/scene-helpers.h"
+#include "labwc.h"
 #include "node.h"
+#include "ssd.h"
+#include "theme.h"
+#include "view.h"
 
 #define FOR_EACH_STATE(view, tmp) FOR_EACH(tmp, \
        &(view)->ssd.titlebar.active, \
index ff8f9e3f0967e26ef82b1fc61c45f76c9db786bf..5402a388bb131200892dca596c61cd5a0315e3eb 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <strings.h>
 #include "labwc.h"
+#include "view.h"
 
 void
 view_impl_map(struct view *view)
index 61408b0ee81327cb31e8c696bebf66f9005a56dc..526c6dfdc94308f02f579cb28b43b544eb8b0d5c 100644 (file)
@@ -7,6 +7,7 @@
 #include "labwc.h"
 #include "ssd.h"
 #include "menu/menu.h"
+#include "view.h"
 #include "workspaces.h"
 
 #define LAB_FALLBACK_WIDTH 640
index 3d6a0b51c78866a3f5cc06f8d8befe8a66f425e6..54d5ee4f756cfaa2ddccd6daf5ba406b84faed07 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/list.h"
 #include "common/mem.h"
 #include "labwc.h"
+#include "view.h"
 #include "workspaces.h"
 
 /* Internal helpers */
index 9f4efcb1ffe3d8964f4be10a7201cf1e59880464..0b96583eba0080f388fce43a9a588a7597ecb55d 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include "common/mem.h"
 #include "labwc.h"
+#include "view.h"
 
 struct xdg_deco {
        struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
index 35e4931637fc2606831a2f97b70200c76bb68eda..ab2c54239d8cdb17dde74979d37c172866b07138 100644 (file)
@@ -10,6 +10,7 @@
 #include "common/mem.h"
 #include "labwc.h"
 #include "node.h"
+#include "view.h"
 
 struct xdg_popup {
        struct view *parent_view;
index f3e28d3ee44e3e0ed3302be68ab2bfb2a1e25e86..f09de3b2ed801320e304228b7295e354a25eb982 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -4,6 +4,7 @@
 #include "labwc.h"
 #include "node.h"
 #include "ssd.h"
+#include "view.h"
 #include "workspaces.h"
 
 static void
index 8bfa31a8b968725ded8c8253c559904b7d4c75f4..1aebd01f2ad5db7a396b294a33266e953f5d4de8 100644 (file)
@@ -4,6 +4,7 @@
 #include "labwc.h"
 #include "node.h"
 #include "ssd.h"
+#include "view.h"
 #include "workspaces.h"
 
 static void