aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-05 11:38:14 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-05 11:40:39 -0400
commitdcd15a2d3dd93e057fe702238eb21dd70331b44f (patch)
treed3fb74ee77369ad52edeba7bac1f3ada907d3099 /include
parentError handling in swaylock daemonize() (diff)
downloadsway-dcd15a2d3dd93e057fe702238eb21dd70331b44f.tar.gz
sway-dcd15a2d3dd93e057fe702238eb21dd70331b44f.tar.zst
sway-dcd15a2d3dd93e057fe702238eb21dd70331b44f.zip
Implement shell views
Diffstat (limited to 'include')
-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 @@
8#include "sway/input/seat.h" 8#include "sway/input/seat.h"
9 9
10struct sway_container; 10struct sway_container;
11struct sway_view;
12 11
13struct sway_xdg_surface_v6 { 12enum sway_view_type {
14 struct sway_view *view; 13 SWAY_VIEW_WL_SHELL,
14 SWAY_VIEW_XDG_SHELL_V6,
15 SWAY_VIEW_XWAYLAND,
16};
17
18enum sway_view_prop {
19 VIEW_PROP_TITLE,
20 VIEW_PROP_APP_ID,
21 VIEW_PROP_CLASS,
22 VIEW_PROP_INSTANCE,
23};
24
25struct sway_view_impl {
26 const char *(*get_prop)(struct sway_view *view,
27 enum sway_view_prop prop);
28 void (*configure)(struct sway_view *view, double ox, double oy, int width,
29 int height);
30 void (*set_activated)(struct sway_view *view, bool activated);
31 void (*close)(struct sway_view *view);
32 void (*destroy)(struct sway_view *view);
33};
34
35struct sway_view {
36 enum sway_view_type type;
37 const struct sway_view_impl *impl;
38
39 struct sway_container *swayc; // NULL for unmanaged views
40 struct wlr_surface *surface; // NULL for unmapped views
41 int width, height;
42
43 union {
44 struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
45 struct wlr_xwayland_surface *wlr_xwayland_surface;
46 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
47 };
48};
49
50struct sway_xdg_shell_v6_view {
51 struct sway_view view;
15 52
16 struct wl_listener commit; 53 struct wl_listener commit;
17 struct wl_listener request_move; 54 struct wl_listener request_move;
@@ -24,8 +61,8 @@ struct sway_xdg_surface_v6 {
24 int pending_width, pending_height; 61 int pending_width, pending_height;
25}; 62};
26 63
27struct sway_xwayland_surface { 64struct sway_xwayland_view {
28 struct sway_view *view; 65 struct sway_view view;
29 66
30 struct wl_listener commit; 67 struct wl_listener commit;
31 struct wl_listener request_move; 68 struct wl_listener request_move;
@@ -46,8 +83,8 @@ struct sway_xwayland_unmanaged {
46 struct wl_listener destroy; 83 struct wl_listener destroy;
47}; 84};
48 85
49struct sway_wl_shell_surface { 86struct sway_wl_shell_view {
50 struct sway_view *view; 87 struct sway_view view;
51 88
52 struct wl_listener commit; 89 struct wl_listener commit;
53 struct wl_listener request_move; 90 struct wl_listener request_move;
@@ -58,54 +95,6 @@ struct sway_wl_shell_surface {
58 int pending_width, pending_height; 95 int pending_width, pending_height;
59}; 96};
60 97
61enum sway_view_type {
62 SWAY_VIEW_WL_SHELL,
63 SWAY_VIEW_XDG_SHELL_V6,
64 SWAY_VIEW_XWAYLAND,
65};
66
67enum sway_view_prop {
68 VIEW_PROP_TITLE,
69 VIEW_PROP_APP_ID,
70 VIEW_PROP_CLASS,
71 VIEW_PROP_INSTANCE,
72};
73
74struct sway_view_impl {
75 const char *(*get_prop)(struct sway_view *view,
76 enum sway_view_prop prop);
77 void (*configure)(struct sway_view *view, double ox, double oy, int width,
78 int height);
79 void (*set_activated)(struct sway_view *view, bool activated);
80 void (*close)(struct sway_view *view);
81};
82
83struct sway_view {
84 enum sway_view_type type;
85 const struct sway_view_impl *impl;
86
87 struct sway_container *swayc; // NULL for unmanaged views
88 struct wlr_surface *surface; // NULL for unmapped views
89 int width, height;
90
91 union {
92 struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
93 struct wlr_xwayland_surface *wlr_xwayland_surface;
94 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
95 };
96
97 union {
98 struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
99 struct sway_xwayland_surface *sway_xwayland_surface;
100 struct sway_wl_shell_surface *sway_wl_shell_surface;
101 };
102};
103
104struct sway_view *view_create(enum sway_view_type type,
105 const struct sway_view_impl *impl);
106
107void view_destroy(struct sway_view *view);
108
109const char *view_get_title(struct sway_view *view); 98const char *view_get_title(struct sway_view *view);
110 99
111const char *view_get_app_id(struct sway_view *view); 100const char *view_get_app_id(struct sway_view *view);
@@ -127,6 +116,11 @@ void view_damage_from(struct sway_view *view);
127 116
128// view implementation 117// view implementation
129 118
119void view_init(struct sway_view *view, enum sway_view_type type,
120 const struct sway_view_impl *impl);
121
122void view_destroy(struct sway_view *view);
123
130void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); 124void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
131 125
132void view_unmap(struct sway_view *view); 126void view_unmap(struct sway_view *view);