internal.h 9.33 KB
Newer Older
Quentin Glidic's avatar
Quentin Glidic committed
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
/*
 * 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_INTERNAL_H
#define WESTON_DESKTOP_INTERNAL_H

#include "compositor.h"

struct weston_desktop_seat;
struct weston_desktop_client;

struct weston_compositor *
weston_desktop_get_compositor(struct weston_desktop *desktop);
struct wl_display *
weston_desktop_get_display(struct weston_desktop *desktop);

void
weston_desktop_api_ping_timeout(struct weston_desktop *desktop,
				struct weston_desktop_client *client);
void
weston_desktop_api_pong(struct weston_desktop *desktop,
			struct weston_desktop_client *client);
void
weston_desktop_api_surface_added(struct weston_desktop *desktop,
				 struct weston_desktop_surface *surface);
void
weston_desktop_api_surface_removed(struct weston_desktop *desktop,
				   struct weston_desktop_surface *surface);
void
weston_desktop_api_committed(struct weston_desktop *desktop,
			     struct weston_desktop_surface *surface,
			     int32_t sx, int32_t sy);
void
weston_desktop_api_show_window_menu(struct weston_desktop *desktop,
				    struct weston_desktop_surface *surface,
				    struct weston_seat *seat,
				    int32_t x, int32_t y);
void
weston_desktop_api_set_parent(struct weston_desktop *desktop,
			      struct weston_desktop_surface *surface,
			      struct weston_desktop_surface *parent);
void
weston_desktop_api_move(struct weston_desktop *desktop,
			struct weston_desktop_surface *surface,
			struct weston_seat *seat, uint32_t serial);
void
weston_desktop_api_resize(struct weston_desktop *desktop,
			  struct weston_desktop_surface *surface,
			  struct weston_seat *seat, uint32_t serial,
			  enum weston_desktop_surface_edge edges);
void
weston_desktop_api_fullscreen_requested(struct weston_desktop *desktop,
					struct weston_desktop_surface *surface,
					bool fullscreen,
					struct weston_output *output);
void
weston_desktop_api_maximized_requested(struct weston_desktop *desktop,
				       struct weston_desktop_surface *surface,
				       bool maximized);
void
weston_desktop_api_minimized_requested(struct weston_desktop *desktop,
				       struct weston_desktop_surface *surface);
83 84 85 86 87

void
weston_desktop_api_set_xwayland_position(struct weston_desktop *desktop,
					 struct weston_desktop_surface *surface,
					 int32_t x, int32_t y);
Quentin Glidic's avatar
Quentin Glidic committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

struct weston_desktop_seat *
weston_desktop_seat_from_seat(struct weston_seat *wseat);

struct weston_desktop_surface_implementation {
	void (*set_activated)(struct weston_desktop_surface *surface,
			      void *user_data, bool activated);
	void (*set_fullscreen)(struct weston_desktop_surface *surface,
			       void *user_data, bool fullscreen);
	void (*set_maximized)(struct weston_desktop_surface *surface,
			      void *user_data, bool maximized);
	void (*set_resizing)(struct weston_desktop_surface *surface,
			     void *user_data, bool resizing);
	void (*set_size)(struct weston_desktop_surface *surface,
			 void *user_data, int32_t width, int32_t height);
	void (*committed)(struct weston_desktop_surface *surface, void *user_data,
104
		          int32_t sx, int32_t sy);
Quentin Glidic's avatar
Quentin Glidic committed
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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
	void (*update_position)(struct weston_desktop_surface *surface,
				void *user_data);
	void (*ping)(struct weston_desktop_surface *surface, uint32_t serial,
		     void *user_data);
	void (*close)(struct weston_desktop_surface *surface, void *user_data);

	bool (*get_activated)(struct weston_desktop_surface *surface,
			      void *user_data);
	bool (*get_fullscreen)(struct weston_desktop_surface *surface,
			       void *user_data);
	bool (*get_maximized)(struct weston_desktop_surface *surface,
			      void *user_data);
	bool (*get_resizing)(struct weston_desktop_surface *surface,
			     void *user_data);
	struct weston_size
	(*get_max_size)(struct weston_desktop_surface *surface,
			void *user_data);
	struct weston_size
	(*get_min_size)(struct weston_desktop_surface *surface,
			void *user_data);

	void (*destroy)(struct weston_desktop_surface *surface,
			void *user_data);
};

struct weston_desktop_client *
weston_desktop_client_create(struct weston_desktop *desktop,
			     struct wl_client *client,
			     wl_dispatcher_func_t dispatcher,
			     const struct wl_interface *interface,
			     const void *implementation, uint32_t version,
			     uint32_t id);

void
weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
					   struct wl_listener *listener);
struct weston_desktop *
weston_desktop_client_get_desktop(struct weston_desktop_client *client);
struct wl_resource *
weston_desktop_client_get_resource(struct weston_desktop_client *client);
struct wl_list *
weston_desktop_client_get_surface_list(struct weston_desktop_client *client);

void
weston_desktop_client_pong(struct weston_desktop_client *client,
			   uint32_t serial);

struct weston_desktop_surface *
weston_desktop_surface_create(struct weston_desktop *desktop,
			      struct weston_desktop_client *client,
			      struct weston_surface *surface,
			      const struct weston_desktop_surface_implementation *implementation,
			      void *implementation_data);
void
weston_desktop_surface_destroy(struct weston_desktop_surface *surface);
void
weston_desktop_surface_resource_destroy(struct wl_resource *resource);
struct wl_resource *
weston_desktop_surface_add_resource(struct weston_desktop_surface *surface,
				    const struct wl_interface *interface,
				    const void *implementation, uint32_t id,
				    wl_resource_destroy_func_t destroy);
struct weston_desktop_surface *
weston_desktop_surface_from_grab_link(struct wl_list *grab_link);

struct wl_list *
weston_desktop_surface_get_client_link(struct weston_desktop_surface *surface);
struct weston_desktop_surface *
weston_desktop_surface_from_client_link(struct wl_list *link);
bool
weston_desktop_surface_has_implementation(struct weston_desktop_surface *surface,
					  const struct weston_desktop_surface_implementation *implementation);
const struct weston_desktop_surface_implementation *
weston_desktop_surface_get_implementation(struct weston_desktop_surface *surface);
void *
weston_desktop_surface_get_implementation_data(struct weston_desktop_surface *surface);
struct weston_desktop_surface *
weston_desktop_surface_get_parent(struct weston_desktop_surface *surface);
bool
weston_desktop_surface_get_grab(struct weston_desktop_surface *surface);

void
weston_desktop_surface_set_title(struct weston_desktop_surface *surface,
				 const char *title);
void
weston_desktop_surface_set_app_id(struct weston_desktop_surface *surface,
				  const char *app_id);
void
weston_desktop_surface_set_pid(struct weston_desktop_surface *surface,
			       pid_t pid);
void
weston_desktop_surface_set_geometry(struct weston_desktop_surface *surface,
				    struct weston_geometry geometry);
void
weston_desktop_surface_set_relative_to(struct weston_desktop_surface *surface,
				       struct weston_desktop_surface *parent,
				       int32_t x, int32_t y, bool use_geometry);
void
weston_desktop_surface_unset_relative_to(struct weston_desktop_surface *surface);
void
weston_desktop_surface_popup_grab(struct weston_desktop_surface *popup,
				  struct weston_desktop_seat *seat,
				  uint32_t serial);
void
weston_desktop_surface_popup_ungrab(struct weston_desktop_surface *popup,
				    struct weston_desktop_seat *seat);
void
weston_desktop_surface_popup_dismiss(struct weston_desktop_surface *surface);

struct weston_desktop_surface *
weston_desktop_seat_popup_grab_get_topmost_surface(struct weston_desktop_seat *seat);
bool
weston_desktop_seat_popup_grab_start(struct weston_desktop_seat *seat,
				     struct wl_client *client, uint32_t serial);
void
weston_desktop_seat_popup_grab_add_surface(struct weston_desktop_seat *seat,
					   struct wl_list *link);
void
weston_desktop_seat_popup_grab_remove_surface(struct weston_desktop_seat *seat,
					      struct wl_list *link);

void
weston_desktop_destroy_request(struct wl_client *client,
			       struct wl_resource *resource);
struct wl_global *
weston_desktop_xdg_shell_v6_create(struct weston_desktop *desktop,
				   struct wl_display *display);
struct wl_global *
weston_desktop_xdg_shell_v5_create(struct weston_desktop *desktop,
				   struct wl_display *display);
struct wl_global *
weston_desktop_wl_shell_create(struct weston_desktop *desktop,
			       struct wl_display *display);
void
weston_desktop_xwayland_init(struct weston_desktop *desktop);

#endif /* WESTON_DESKTOP_INTERNAL_H */