aboutsummaryrefslogtreecommitdiff
path: root/include/sway/tree/view.h
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-04-05 11:38:14 -0400
committeremersion <contact@emersion.fr>2018-04-05 11:40:39 -0400
commitdcd15a2d3dd93e057fe702238eb21dd70331b44f (patch)
treed3fb74ee77369ad52edeba7bac1f3ada907d3099 /include/sway/tree/view.h
parent9939d98454db32635dd9d0887ac930d7a24440bc (diff)
Implement shell views
Diffstat (limited to 'include/sway/tree/view.h')
-rw-r--r--include/sway/tree/view.h104
1 files changed, 49 insertions, 55 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index f32ccc5a..d4dace4a 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -8,10 +8,47 @@
#include "sway/input/seat.h"
struct sway_container;
-struct sway_view;
-struct sway_xdg_surface_v6 {
- struct sway_view *view;
+enum sway_view_type {
+ SWAY_VIEW_WL_SHELL,
+ SWAY_VIEW_XDG_SHELL_V6,
+ SWAY_VIEW_XWAYLAND,
+};
+
+enum sway_view_prop {
+ VIEW_PROP_TITLE,
+ VIEW_PROP_APP_ID,
+ VIEW_PROP_CLASS,
+ VIEW_PROP_INSTANCE,
+};
+
+struct sway_view_impl {
+ const char *(*get_prop)(struct sway_view *view,
+ enum sway_view_prop prop);
+ void (*configure)(struct sway_view *view, double ox, double oy, int width,
+ int height);
+ void (*set_activated)(struct sway_view *view, bool activated);
+ void (*close)(struct sway_view *view);
+ void (*destroy)(struct sway_view *view);
+};
+
+struct sway_view {
+ enum sway_view_type type;
+ const struct sway_view_impl *impl;
+
+ struct sway_container *swayc; // NULL for unmanaged views
+ struct wlr_surface *surface; // NULL for unmapped views
+ int width, height;
+
+ union {
+ struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
+ struct wlr_xwayland_surface *wlr_xwayland_surface;
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface;
+ };
+};
+
+struct sway_xdg_shell_v6_view {
+ struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
@@ -24,8 +61,8 @@ struct sway_xdg_surface_v6 {
int pending_width, pending_height;
};
-struct sway_xwayland_surface {
- struct sway_view *view;
+struct sway_xwayland_view {
+ struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
@@ -46,8 +83,8 @@ struct sway_xwayland_unmanaged {
struct wl_listener destroy;
};
-struct sway_wl_shell_surface {
- struct sway_view *view;
+struct sway_wl_shell_view {
+ struct sway_view view;
struct wl_listener commit;
struct wl_listener request_move;
@@ -58,54 +95,6 @@ struct sway_wl_shell_surface {
int pending_width, pending_height;
};
-enum sway_view_type {
- SWAY_VIEW_WL_SHELL,
- SWAY_VIEW_XDG_SHELL_V6,
- SWAY_VIEW_XWAYLAND,
-};
-
-enum sway_view_prop {
- VIEW_PROP_TITLE,
- VIEW_PROP_APP_ID,
- VIEW_PROP_CLASS,
- VIEW_PROP_INSTANCE,
-};
-
-struct sway_view_impl {
- const char *(*get_prop)(struct sway_view *view,
- enum sway_view_prop prop);
- void (*configure)(struct sway_view *view, double ox, double oy, int width,
- int height);
- void (*set_activated)(struct sway_view *view, bool activated);
- void (*close)(struct sway_view *view);
-};
-
-struct sway_view {
- enum sway_view_type type;
- const struct sway_view_impl *impl;
-
- struct sway_container *swayc; // NULL for unmanaged views
- struct wlr_surface *surface; // NULL for unmapped views
- int width, height;
-
- union {
- struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
- struct wlr_xwayland_surface *wlr_xwayland_surface;
- struct wlr_wl_shell_surface *wlr_wl_shell_surface;
- };
-
- union {
- struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
- struct sway_xwayland_surface *sway_xwayland_surface;
- struct sway_wl_shell_surface *sway_wl_shell_surface;
- };
-};
-
-struct sway_view *view_create(enum sway_view_type type,
- const struct sway_view_impl *impl);
-
-void view_destroy(struct sway_view *view);
-
const char *view_get_title(struct sway_view *view);
const char *view_get_app_id(struct sway_view *view);
@@ -127,6 +116,11 @@ void view_damage_from(struct sway_view *view);
// view implementation
+void view_init(struct sway_view *view, enum sway_view_type type,
+ const struct sway_view_impl *impl);
+
+void view_destroy(struct sway_view *view);
+
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
void view_unmap(struct sway_view *view);