aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/view.h
blob: 2d9b4ef535c1981b82856ca75d51313ce2426f24 (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
#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>

struct sway_container;
struct sway_view;

struct sway_xdg_surface_v6 {
	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;
};

struct sway_xwayland_surface {
	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 destroy;

	int pending_width, pending_height;
};

enum sway_view_type {
	SWAY_WL_SHELL_VIEW,
	SWAY_XDG_SHELL_V6_VIEW,
	SWAY_XWAYLAND_VIEW,
	// Keep last
	SWAY_VIEW_TYPES,
};

enum sway_view_prop {
	VIEW_PROP_TITLE,
	VIEW_PROP_CLASS,
	VIEW_PROP_INSTANCE,
	VIEW_PROP_APP_ID,
};

/**
 * sway_view is a state container for surfaces that are arranged in the sway
 * tree (shell surfaces).
 */
struct sway_view {
	enum sway_view_type type;
	struct sway_container *swayc;
	struct wlr_surface *surface;
	int width, height;

	union {
		struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
		struct wlr_xwayland_surface *wlr_xwayland_surface;
	};

	union {
		struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
		struct sway_xwayland_surface *sway_xwayland_surface;
	};

	struct {
		const char *(*get_prop)(struct sway_view *view,
				enum sway_view_prop prop);
		void (*set_size)(struct sway_view *view,
				int width, int height);
	} iface;
};

#endif