Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 1 | /* |
| 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 |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | enum 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 | |
| 47 | struct weston_desktop; |
| 48 | struct weston_desktop_client; |
| 49 | struct weston_desktop_surface; |
| 50 | |
| 51 | struct 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 Paalanen | 37111e1 | 2016-11-16 14:03:31 +0200 | [diff] [blame] | 83 | |
| 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 Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | void |
| 119 | weston_seat_break_desktop_grabs(struct weston_seat *seat); |
| 120 | |
| 121 | struct weston_desktop * |
| 122 | weston_desktop_create(struct weston_compositor *compositor, |
| 123 | const struct weston_desktop_api *api, void *user_data); |
| 124 | void |
| 125 | weston_desktop_destroy(struct weston_desktop *desktop); |
| 126 | |
| 127 | struct wl_client * |
| 128 | weston_desktop_client_get_client(struct weston_desktop_client *client); |
| 129 | void |
| 130 | weston_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); |
| 133 | int |
| 134 | weston_desktop_client_ping(struct weston_desktop_client *client); |
| 135 | |
| 136 | bool |
| 137 | weston_surface_is_desktop_surface(struct weston_surface *surface); |
| 138 | struct weston_desktop_surface * |
| 139 | weston_surface_get_desktop_surface(struct weston_surface *surface); |
| 140 | |
| 141 | void |
| 142 | weston_desktop_surface_set_user_data(struct weston_desktop_surface *self, |
| 143 | void *user_data); |
| 144 | struct weston_view * |
| 145 | weston_desktop_surface_create_view(struct weston_desktop_surface *surface); |
| 146 | void |
Quentin Glidic | f01ecee | 2016-08-16 10:52:46 +0200 | [diff] [blame] | 147 | weston_desktop_surface_unlink_view(struct weston_view *view); |
Quentin Glidic | 248dd10 | 2016-08-12 10:41:34 +0200 | [diff] [blame] | 148 | void |
| 149 | weston_desktop_surface_propagate_layer(struct weston_desktop_surface *surface); |
| 150 | void |
| 151 | weston_desktop_surface_set_activated(struct weston_desktop_surface *surface, |
| 152 | bool activated); |
| 153 | void |
| 154 | weston_desktop_surface_set_fullscreen(struct weston_desktop_surface *surface, |
| 155 | bool fullscreen); |
| 156 | void |
| 157 | weston_desktop_surface_set_maximized(struct weston_desktop_surface *surface, |
| 158 | bool maximized); |
| 159 | void |
| 160 | weston_desktop_surface_set_resizing(struct weston_desktop_surface *surface, |
| 161 | bool resized); |
| 162 | void |
| 163 | weston_desktop_surface_set_size(struct weston_desktop_surface *surface, |
| 164 | int32_t width, int32_t height); |
| 165 | void |
| 166 | weston_desktop_surface_close(struct weston_desktop_surface *surface); |
| 167 | |
| 168 | void * |
| 169 | weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface); |
| 170 | struct weston_desktop_client * |
| 171 | weston_desktop_surface_get_client(struct weston_desktop_surface *surface); |
| 172 | struct weston_surface * |
| 173 | weston_desktop_surface_get_surface(struct weston_desktop_surface *surface); |
| 174 | const char * |
| 175 | weston_desktop_surface_get_title(struct weston_desktop_surface *surface); |
| 176 | const char * |
| 177 | weston_desktop_surface_get_app_id(struct weston_desktop_surface *surface); |
| 178 | pid_t |
| 179 | weston_desktop_surface_get_pid(struct weston_desktop_surface *surface); |
| 180 | bool |
| 181 | weston_desktop_surface_get_activated(struct weston_desktop_surface *surface); |
| 182 | bool |
| 183 | weston_desktop_surface_get_maximized(struct weston_desktop_surface *surface); |
| 184 | bool |
| 185 | weston_desktop_surface_get_fullscreen(struct weston_desktop_surface *surface); |
| 186 | bool |
| 187 | weston_desktop_surface_get_resizing(struct weston_desktop_surface *surface); |
| 188 | struct weston_geometry |
| 189 | weston_desktop_surface_get_geometry(struct weston_desktop_surface *surface); |
| 190 | struct weston_size |
| 191 | weston_desktop_surface_get_max_size(struct weston_desktop_surface *surface); |
| 192 | struct weston_size |
| 193 | weston_desktop_surface_get_min_size(struct weston_desktop_surface *surface); |
| 194 | |
| 195 | #ifdef __cplusplus |
| 196 | } |
| 197 | #endif |
| 198 | |
| 199 | #endif /* WESTON_DESKTOP_H */ |