aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/tree/view.h
blob: d4dace4ab819242d9ea854374403228fe85794cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef _SWAY_VIEW_H
#define _SWAY_VIEW_H
#include <wayland-server.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/xwayland.h>
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"

struct sway_container;

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;
	struct wl_listener request_resize;
	struct wl_listener request_maximize;
	struct wl_listener map;
	struct wl_listener unmap;
	struct wl_listener destroy;

	int pending_width, pending_height;
};

struct sway_xwayland_view {
	struct sway_view view;

	struct wl_listener commit;
	struct wl_listener request_move;
	struct wl_listener request_resize;
	struct wl_listener request_maximize;
	struct wl_listener request_configure;
	struct wl_listener map;
	struct wl_listener unmap;
	struct wl_listener destroy;

	int pending_width, pending_height;
};

struct sway_xwayland_unmanaged {
	struct wlr_xwayland_surface *wlr_xwayland_surface;
	struct wl_list link;

	struct wl_listener destroy;
};

struct sway_wl_shell_view {
	struct sway_view view;

	struct wl_listener commit;
	struct wl_listener request_move;
	struct wl_listener request_resize;
	struct wl_listener request_maximize;
	struct wl_listener destroy;

	int pending_width, pending_height;
};

const char *view_get_title(struct sway_view *view);

const char *view_get_app_id(struct sway_view *view);

const char *view_get_class(struct sway_view *view);

const char *view_get_instance(struct sway_view *view);

void view_configure(struct sway_view *view, double ox, double oy, int width,
	int height);

void view_set_activated(struct sway_view *view, bool activated);

void view_close(struct sway_view *view);

void view_damage_whole(struct sway_view *view);

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);

void view_update_position(struct sway_view *view, double ox, double oy);

void view_update_size(struct sway_view *view, int width, int height);

#endif