aboutsummaryrefslogtreecommitdiff
path: root/include/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-02-23 12:15:37 +0100
committeremersion <contact@emersion.fr>2019-02-23 12:15:37 +0100
commite86c7a3dd67f14d738b058c4aa3698e9e74958c9 (patch)
tree3b29e9ee934afcaeb5f848cc95bc6516612939c3 /include/rootston
parent4f66565606c8958684c00f28d0b4996904c041bc (diff)
rootston: move part of desktop.c to view.c, use an interface for views
Diffstat (limited to 'include/rootston')
-rw-r--r--include/rootston/desktop.h13
-rw-r--r--include/rootston/view.h37
2 files changed, 26 insertions, 24 deletions
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index d8fc53e2..81faba81 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -100,19 +100,6 @@ struct wlr_surface *desktop_surface_at(struct roots_desktop *desktop,
double lx, double ly, double *sx, double *sy,
struct roots_view **view);
-struct roots_view *view_create(struct roots_desktop *desktop);
-void view_destroy(struct roots_view *view);
-void view_activate(struct roots_view *view, bool activate);
-void view_apply_damage(struct roots_view *view);
-void view_damage_whole(struct roots_view *view);
-void view_update_position(struct roots_view *view, int x, int y);
-void view_update_size(struct roots_view *view, int width, int height);
-void view_update_decorated(struct roots_view *view, bool decorated);
-void view_initial_focus(struct roots_view *view);
-void view_map(struct roots_view *view, struct wlr_surface *surface);
-void view_unmap(struct roots_view *view);
-void view_arrange_maximized(struct roots_view *view);
-
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data);
diff --git a/include/rootston/view.h b/include/rootston/view.h
index 0174e4f3..64c49618 100644
--- a/include/rootston/view.h
+++ b/include/rootston/view.h
@@ -94,7 +94,20 @@ enum roots_view_type {
#endif
};
+struct roots_view_interface {
+ void (*activate)(struct roots_view *view, bool active);
+ void (*move)(struct roots_view *view, double x, double y);
+ void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
+ void (*move_resize)(struct roots_view *view, double x, double y,
+ uint32_t width, uint32_t height);
+ void (*maximize)(struct roots_view *view, bool maximized);
+ void (*set_fullscreen)(struct roots_view *view, bool fullscreen);
+ void (*close)(struct roots_view *view);
+ void (*destroy)(struct roots_view *view);
+};
+
struct roots_view {
+ const struct roots_view_interface *impl;
struct roots_desktop *desktop;
struct wl_list link; // roots_desktop::views
@@ -153,17 +166,6 @@ struct roots_view {
struct wl_signal unmap;
struct wl_signal destroy;
} events;
-
- // TODO: this should follow the typical type/impl pattern we use elsewhere
- void (*activate)(struct roots_view *view, bool active);
- void (*move)(struct roots_view *view, double x, double y);
- void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
- void (*move_resize)(struct roots_view *view, double x, double y,
- uint32_t width, uint32_t height);
- void (*maximize)(struct roots_view *view, bool maximized);
- void (*set_fullscreen)(struct roots_view *view, bool fullscreen);
- void (*close)(struct roots_view *view);
- void (*destroy)(struct roots_view *view);
};
struct roots_view_child {
@@ -219,6 +221,19 @@ struct roots_xdg_toplevel_decoration {
struct wl_listener surface_commit;
};
+struct roots_view *view_create(struct roots_desktop *desktop,
+ const struct roots_view_interface *impl);
+void view_destroy(struct roots_view *view);
+void view_activate(struct roots_view *view, bool activate);
+void view_apply_damage(struct roots_view *view);
+void view_damage_whole(struct roots_view *view);
+void view_update_position(struct roots_view *view, int x, int y);
+void view_update_size(struct roots_view *view, int width, int height);
+void view_update_decorated(struct roots_view *view, bool decorated);
+void view_initial_focus(struct roots_view *view);
+void view_map(struct roots_view *view, struct wlr_surface *surface);
+void view_unmap(struct roots_view *view);
+void view_arrange_maximized(struct roots_view *view);
void view_get_box(const struct roots_view *view, struct wlr_box *box);
void view_activate(struct roots_view *view, bool active);
void view_move(struct roots_view *view, double x, double y);