blob: 03b04c7bc5b18ba7a55f455a4b69729021cfe431 [file] [log] [blame]
Quentin Glidic248dd102016-08-12 10:41:34 +02001/*
2 * Copyright © 2016 Quentin "Sardem FF7" Glidic
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef WESTON_DESKTOP_H
25#define WESTON_DESKTOP_H
26
27#include "compositor.h"
28#include <pixman.h>
29#include <stdbool.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35enum weston_desktop_surface_edge {
36 WESTON_DESKTOP_SURFACE_EDGE_NONE = 0,
37 WESTON_DESKTOP_SURFACE_EDGE_TOP = 1,
38 WESTON_DESKTOP_SURFACE_EDGE_BOTTOM = 2,
39 WESTON_DESKTOP_SURFACE_EDGE_LEFT = 4,
40 WESTON_DESKTOP_SURFACE_EDGE_TOP_LEFT = 5,
41 WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_LEFT = 6,
42 WESTON_DESKTOP_SURFACE_EDGE_RIGHT = 8,
43 WESTON_DESKTOP_SURFACE_EDGE_TOP_RIGHT = 9,
44 WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_RIGHT = 10,
45};
46
47struct weston_desktop;
48struct weston_desktop_client;
49struct weston_desktop_surface;
50
51struct weston_desktop_api {
52 size_t struct_size;
53 void (*ping_timeout)(struct weston_desktop_client *client,
54 void *user_data);
55 void (*pong)(struct weston_desktop_client *client,
56 void *user_data);
57
58 void (*surface_added)(struct weston_desktop_surface *surface,
59 void *user_data);
60 void (*surface_removed)(struct weston_desktop_surface *surface,
61 void *user_data);
62 void (*committed)(struct weston_desktop_surface *surface,
63 int32_t sx, int32_t sy, void *user_data);
64 void (*show_window_menu)(struct weston_desktop_surface *surface,
65 struct weston_seat *seat, int32_t x, int32_t y,
66 void *user_data);
67 void (*set_parent)(struct weston_desktop_surface *surface,
68 struct weston_desktop_surface *parent,
69 void *user_data);
70 void (*move)(struct weston_desktop_surface *surface,
71 struct weston_seat *seat, uint32_t serial, void *user_data);
72 void (*resize)(struct weston_desktop_surface *surface,
73 struct weston_seat *seat, uint32_t serial,
74 enum weston_desktop_surface_edge edges, void *user_data);
75 void (*fullscreen_requested)(struct weston_desktop_surface *surface,
76 bool fullscreen,
77 struct weston_output *output,
78 void *user_data);
79 void (*maximized_requested)(struct weston_desktop_surface *surface,
80 bool maximized, void *user_data);
81 void (*minimized_requested)(struct weston_desktop_surface *surface,
82 void *user_data);
Pekka Paalanen37111e12016-11-16 14:03:31 +020083
84 /** Position suggestion for an Xwayland window
85 *
86 * X11 applications assume they can position their windows as necessary,
87 * which is not possible in Wayland where positioning is driven by the
88 * shell alone. This function is used to relay absolute position wishes
89 * from Xwayland clients to the shell.
90 *
91 * This is particularly used for mapping windows at specified locations,
92 * e.g. via the commonly used '-geometry' command line option. In such
93 * case, a call to surface_added() is immediately followed by
94 * xwayland_position() if the X11 application specified a position.
95 * The committed() call that will map the window occurs later, so it
96 * is recommended to usually store and honour the given position for
97 * windows that are not yet mapped.
98 *
99 * Calls to this function may happen also at other times.
100 *
101 * The given coordinates are in the X11 window system coordinate frame
102 * relative to the X11 root window. Care should be taken to ensure the
103 * window gets mapped to coordinates that correspond to the proposed
104 * position from the X11 client perspective.
105 *
106 * \param surface The surface in question.
107 * \param x The absolute X11 coordinate for x.
108 * \param y The absolute X11 coordinate for y.
109 * \param user_data The user_data argument passed in to
110 * weston_desktop_create().
111 *
112 * This callback can be NULL.
113 */
114 void (*set_xwayland_position)(struct weston_desktop_surface *surface,
115 int32_t x, int32_t y, void *user_data);
Quentin Glidic248dd102016-08-12 10:41:34 +0200116};
117
118void
119weston_seat_break_desktop_grabs(struct weston_seat *seat);
120
121struct weston_desktop *
122weston_desktop_create(struct weston_compositor *compositor,
123 const struct weston_desktop_api *api, void *user_data);
124void
125weston_desktop_destroy(struct weston_desktop *desktop);
126
127struct wl_client *
128weston_desktop_client_get_client(struct weston_desktop_client *client);
129void
130weston_desktop_client_for_each_surface(struct weston_desktop_client *client,
131 void (*callback)(struct weston_desktop_surface *surface, void *user_data),
132 void *user_data);
133int
134weston_desktop_client_ping(struct weston_desktop_client *client);
135
136bool
137weston_surface_is_desktop_surface(struct weston_surface *surface);
138struct weston_desktop_surface *
139weston_surface_get_desktop_surface(struct weston_surface *surface);
140
141void
142weston_desktop_surface_set_user_data(struct weston_desktop_surface *self,
143 void *user_data);
144struct weston_view *
145weston_desktop_surface_create_view(struct weston_desktop_surface *surface);
146void
Quentin Glidicf01ecee2016-08-16 10:52:46 +0200147weston_desktop_surface_unlink_view(struct weston_view *view);
Quentin Glidic248dd102016-08-12 10:41:34 +0200148void
149weston_desktop_surface_propagate_layer(struct weston_desktop_surface *surface);
150void
151weston_desktop_surface_set_activated(struct weston_desktop_surface *surface,
152 bool activated);
153void
154weston_desktop_surface_set_fullscreen(struct weston_desktop_surface *surface,
155 bool fullscreen);
156void
157weston_desktop_surface_set_maximized(struct weston_desktop_surface *surface,
158 bool maximized);
159void
160weston_desktop_surface_set_resizing(struct weston_desktop_surface *surface,
161 bool resized);
162void
163weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
164 int32_t width, int32_t height);
165void
166weston_desktop_surface_close(struct weston_desktop_surface *surface);
167
168void *
169weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface);
170struct weston_desktop_client *
171weston_desktop_surface_get_client(struct weston_desktop_surface *surface);
172struct weston_surface *
173weston_desktop_surface_get_surface(struct weston_desktop_surface *surface);
174const char *
175weston_desktop_surface_get_title(struct weston_desktop_surface *surface);
176const char *
177weston_desktop_surface_get_app_id(struct weston_desktop_surface *surface);
178pid_t
179weston_desktop_surface_get_pid(struct weston_desktop_surface *surface);
180bool
181weston_desktop_surface_get_activated(struct weston_desktop_surface *surface);
182bool
183weston_desktop_surface_get_maximized(struct weston_desktop_surface *surface);
184bool
185weston_desktop_surface_get_fullscreen(struct weston_desktop_surface *surface);
186bool
187weston_desktop_surface_get_resizing(struct weston_desktop_surface *surface);
188struct weston_geometry
189weston_desktop_surface_get_geometry(struct weston_desktop_surface *surface);
190struct weston_size
191weston_desktop_surface_get_max_size(struct weston_desktop_surface *surface);
192struct weston_size
193weston_desktop_surface_get_min_size(struct weston_desktop_surface *surface);
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif /* WESTON_DESKTOP_H */