summaryrefslogtreecommitdiff
path: root/libweston-desktop/libweston-desktop.h
blob: a0fb9381b89786da797e338aa3d58a944d5353bb (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * Copyright © 2016 Quentin "Sardem FF7" Glidic
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#ifndef WESTON_DESKTOP_H
#define WESTON_DESKTOP_H

#include "compositor.h"
#include <pixman.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

enum weston_desktop_surface_edge {
	WESTON_DESKTOP_SURFACE_EDGE_NONE = 0,
	WESTON_DESKTOP_SURFACE_EDGE_TOP = 1,
	WESTON_DESKTOP_SURFACE_EDGE_BOTTOM = 2,
	WESTON_DESKTOP_SURFACE_EDGE_LEFT = 4,
	WESTON_DESKTOP_SURFACE_EDGE_TOP_LEFT = 5,
	WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_LEFT = 6,
	WESTON_DESKTOP_SURFACE_EDGE_RIGHT = 8,
	WESTON_DESKTOP_SURFACE_EDGE_TOP_RIGHT = 9,
	WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_RIGHT = 10,
};

struct weston_desktop;
struct weston_desktop_client;
struct weston_desktop_surface;

struct weston_desktop_api {
	size_t struct_size;
	void (*ping_timeout)(struct weston_desktop_client *client,
			     void *user_data);
	void (*pong)(struct weston_desktop_client *client,
		     void *user_data);

	void (*surface_added)(struct weston_desktop_surface *surface,
			      void *user_data);
	void (*surface_removed)(struct weston_desktop_surface *surface,
				void *user_data);
	void (*committed)(struct weston_desktop_surface *surface,
			  int32_t sx, int32_t sy, void *user_data);
	void (*show_window_menu)(struct weston_desktop_surface *surface,
				 struct weston_seat *seat, int32_t x, int32_t y,
				 void *user_data);
	void (*set_parent)(struct weston_desktop_surface *surface,
			   struct weston_desktop_surface *parent,
			   void *user_data);
	void (*move)(struct weston_desktop_surface *surface,
		     struct weston_seat *seat, uint32_t serial, void *user_data);
	void (*resize)(struct weston_desktop_surface *surface,
		       struct weston_seat *seat, uint32_t serial,
		       enum weston_desktop_surface_edge edges, void *user_data);
	void (*fullscreen_requested)(struct weston_desktop_surface *surface,
				     bool fullscreen,
				     struct weston_output *output,
				     void *user_data);
	void (*maximized_requested)(struct weston_desktop_surface *surface,
				    bool maximized, void *user_data);
	void (*minimized_requested)(struct weston_desktop_surface *surface,
				    void *user_data);

	/** Position suggestion for an Xwayland window
	 *
	 * X11 applications assume they can position their windows as necessary,
	 * which is not possible in Wayland where positioning is driven by the
	 * shell alone. This function is used to relay absolute position wishes
	 * from Xwayland clients to the shell.
	 *
	 * This is particularly used for mapping windows at specified locations,
	 * e.g. via the commonly used '-geometry' command line option. In such
	 * case, a call to surface_added() is immediately followed by
	 * xwayland_position() if the X11 application specified a position.
	 * The committed() call that will map the window occurs later, so it
	 * is recommended to usually store and honour the given position for
	 * windows that are not yet mapped.
	 *
	 * Calls to this function may happen also at other times.
	 *
	 * The given coordinates are in the X11 window system coordinate frame
	 * relative to the X11 root window. Care should be taken to ensure the
	 * window gets mapped to coordinates that correspond to the proposed
	 * position from the X11 client perspective.
	 *
	 * \param surface The surface in question.
	 * \param x The absolute X11 coordinate for x.
	 * \param y The absolute X11 coordinate for y.
	 * \param user_data The user_data argument passed in to
	 * weston_desktop_create().
	 *
	 * This callback can be NULL.
	 */
	void (*set_xwayland_position)(struct weston_desktop_surface *surface,
				      int32_t x, int32_t y, void *user_data);
};

void
weston_seat_break_desktop_grabs(struct weston_seat *seat);

struct weston_desktop *
weston_desktop_create(struct weston_compositor *compositor,
		      const struct weston_desktop_api *api, void *user_data);
void
weston_desktop_destroy(struct weston_desktop *desktop);

struct wl_client *
weston_desktop_client_get_client(struct weston_desktop_client *client);
void
weston_desktop_client_for_each_surface(struct weston_desktop_client *client,
				       void (*callback)(struct weston_desktop_surface *surface, void *user_data),
				       void *user_data);
int
weston_desktop_client_ping(struct weston_desktop_client *client);

bool
weston_surface_is_desktop_surface(struct weston_surface *surface);
struct weston_desktop_surface *
weston_surface_get_desktop_surface(struct weston_surface *surface);

void
weston_desktop_surface_set_user_data(struct weston_desktop_surface *self,
				     void *user_data);
struct weston_view *
weston_desktop_surface_create_view(struct weston_desktop_surface *surface);
void
weston_desktop_surface_unlink_view(struct weston_view *view);
void
weston_desktop_surface_propagate_layer(struct weston_desktop_surface *surface);
void
weston_desktop_surface_set_activated(struct weston_desktop_surface *surface,
				     bool activated);
void
weston_desktop_surface_set_fullscreen(struct weston_desktop_surface *surface,
				      bool fullscreen);
void
weston_desktop_surface_set_maximized(struct weston_desktop_surface *surface,
				     bool maximized);
void
weston_desktop_surface_set_resizing(struct weston_desktop_surface *surface,
				    bool resized);
void
weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
				int32_t width, int32_t height);
void
weston_desktop_surface_close(struct weston_desktop_surface *surface);
void
weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface *surface,
					     struct wl_listener *listener);

void *
weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface);
struct weston_desktop_client *
weston_desktop_surface_get_client(struct weston_desktop_surface *surface);
struct weston_surface *
weston_desktop_surface_get_surface(struct weston_desktop_surface *surface);
const char *
weston_desktop_surface_get_title(struct weston_desktop_surface *surface);
const char *
weston_desktop_surface_get_app_id(struct weston_desktop_surface *surface);
pid_t
weston_desktop_surface_get_pid(struct weston_desktop_surface *surface);
bool
weston_desktop_surface_get_activated(struct weston_desktop_surface *surface);
bool
weston_desktop_surface_get_maximized(struct weston_desktop_surface *surface);
bool
weston_desktop_surface_get_fullscreen(struct weston_desktop_surface *surface);
bool
weston_desktop_surface_get_resizing(struct weston_desktop_surface *surface);
struct weston_geometry
weston_desktop_surface_get_geometry(struct weston_desktop_surface *surface);
struct weston_size
weston_desktop_surface_get_max_size(struct weston_desktop_surface *surface);
struct weston_size
weston_desktop_surface_get_min_size(struct weston_desktop_surface *surface);

#ifdef __cplusplus
}
#endif

#endif /* WESTON_DESKTOP_H */