2018-02-14 12:40:13 +01:00
|
|
|
#ifndef WLR_TYPES_WLR_XDG_SHELL_H
|
|
|
|
#define WLR_TYPES_WLR_XDG_SHELL_H
|
|
|
|
#include <wlr/types/wlr_box.h>
|
|
|
|
#include <wlr/types/wlr_seat.h>
|
|
|
|
#include <wayland-server.h>
|
2018-04-15 03:17:40 +02:00
|
|
|
#include "xdg-shell-protocol.h"
|
2018-02-14 12:40:13 +01:00
|
|
|
|
|
|
|
struct wlr_xdg_shell {
|
|
|
|
struct wl_global *wl_global;
|
|
|
|
struct wl_list clients;
|
|
|
|
struct wl_list popup_grabs;
|
|
|
|
uint32_t ping_timeout;
|
|
|
|
|
|
|
|
struct wl_listener display_destroy;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal new_surface;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_client {
|
|
|
|
struct wlr_xdg_shell *shell;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wl_client *client;
|
|
|
|
struct wl_list surfaces;
|
|
|
|
|
|
|
|
struct wl_list link; // wlr_xdg_shell::clients
|
|
|
|
|
|
|
|
uint32_t ping_serial;
|
|
|
|
struct wl_event_source *ping_timer;
|
|
|
|
};
|
|
|
|
|
2018-04-15 03:17:40 +02:00
|
|
|
struct wlr_xdg_positioner {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
struct wlr_box anchor_rect;
|
|
|
|
enum xdg_positioner_anchor anchor;
|
|
|
|
enum xdg_positioner_gravity gravity;
|
|
|
|
enum xdg_positioner_constraint_adjustment constraint_adjustment;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int32_t width, height;
|
|
|
|
} size;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int32_t x, y;
|
|
|
|
} offset;
|
|
|
|
};
|
2018-04-14 21:47:51 +02:00
|
|
|
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_xdg_popup {
|
|
|
|
struct wlr_xdg_surface *base;
|
|
|
|
struct wl_list link;
|
|
|
|
|
|
|
|
struct wl_resource *resource;
|
|
|
|
bool committed;
|
2018-04-14 21:47:51 +02:00
|
|
|
struct wlr_surface *parent;
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_seat *seat;
|
2018-03-27 04:11:41 +02:00
|
|
|
|
|
|
|
// Position of the popup relative to the upper left corner of the window
|
|
|
|
// geometry of the parent surface
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_box geometry;
|
|
|
|
|
2018-04-15 03:17:40 +02:00
|
|
|
struct wlr_xdg_positioner positioner;
|
|
|
|
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wl_list grab_link; // wlr_xdg_popup_grab::popups
|
|
|
|
};
|
|
|
|
|
|
|
|
// each seat gets a popup grab
|
|
|
|
struct wlr_xdg_popup_grab {
|
|
|
|
struct wl_client *client;
|
|
|
|
struct wlr_seat_pointer_grab pointer_grab;
|
|
|
|
struct wlr_seat_keyboard_grab keyboard_grab;
|
|
|
|
struct wlr_seat *seat;
|
|
|
|
struct wl_list popups;
|
|
|
|
struct wl_list link; // wlr_xdg_shell::popup_grabs
|
2017-12-30 17:16:00 +01:00
|
|
|
struct wl_listener seat_destroy;
|
2018-02-14 12:40:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum wlr_xdg_surface_role {
|
|
|
|
WLR_XDG_SURFACE_ROLE_NONE,
|
|
|
|
WLR_XDG_SURFACE_ROLE_TOPLEVEL,
|
|
|
|
WLR_XDG_SURFACE_ROLE_POPUP,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_state {
|
2018-03-15 20:15:09 +01:00
|
|
|
bool maximized, fullscreen, resizing, activated;
|
|
|
|
uint32_t width, height;
|
|
|
|
uint32_t max_width, max_height;
|
|
|
|
uint32_t min_width, min_height;
|
2018-02-14 12:40:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel {
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wlr_xdg_surface *base;
|
|
|
|
struct wlr_xdg_surface *parent;
|
|
|
|
bool added;
|
2018-03-27 16:25:02 +02:00
|
|
|
|
2018-03-18 18:58:01 +01:00
|
|
|
struct wlr_xdg_toplevel_state client_pending;
|
|
|
|
struct wlr_xdg_toplevel_state server_pending;
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_xdg_toplevel_state current;
|
2018-03-27 16:25:02 +02:00
|
|
|
|
|
|
|
char *title;
|
|
|
|
char *app_id;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal request_maximize;
|
|
|
|
struct wl_signal request_fullscreen;
|
|
|
|
struct wl_signal request_minimize;
|
|
|
|
struct wl_signal request_move;
|
|
|
|
struct wl_signal request_resize;
|
|
|
|
struct wl_signal request_show_window_menu;
|
|
|
|
} events;
|
2018-02-14 12:40:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_configure {
|
|
|
|
struct wl_list link; // wlr_xdg_surface::configure_list
|
|
|
|
uint32_t serial;
|
2018-03-15 20:15:09 +01:00
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_state *toplevel_state;
|
2018-02-14 12:40:13 +01:00
|
|
|
};
|
|
|
|
|
2018-04-12 05:09:13 +02:00
|
|
|
/**
|
|
|
|
* An xdg-surface is a user interface element requiring management by the
|
|
|
|
* compositor. An xdg-surface alone isn't useful, a role should be assigned to
|
|
|
|
* it in order to map it.
|
|
|
|
*
|
|
|
|
* When a surface has a role and is ready to be displayed, the `map` event is
|
|
|
|
* emitted. When a surface should no longer be displayed, the `unmap` event is
|
|
|
|
* emitted. The `unmap` event is guaranted to be emitted before the `destroy`
|
|
|
|
* event if the view is destroyed when mapped.
|
|
|
|
*/
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_xdg_surface {
|
|
|
|
struct wlr_xdg_client *client;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
struct wl_list link; // wlr_xdg_client::surfaces
|
|
|
|
enum wlr_xdg_surface_role role;
|
|
|
|
|
|
|
|
union {
|
2018-03-15 20:15:09 +01:00
|
|
|
struct wlr_xdg_toplevel *toplevel;
|
|
|
|
struct wlr_xdg_popup *popup;
|
2018-02-14 12:40:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wl_list popups; // wlr_xdg_popup::link
|
|
|
|
|
2018-03-15 20:15:09 +01:00
|
|
|
bool added, configured, mapped;
|
2018-02-14 12:40:13 +01:00
|
|
|
uint32_t configure_serial;
|
|
|
|
struct wl_event_source *configure_idle;
|
|
|
|
uint32_t configure_next_serial;
|
|
|
|
struct wl_list configure_list;
|
|
|
|
|
|
|
|
bool has_next_geometry;
|
2018-03-15 20:15:09 +01:00
|
|
|
struct wlr_box next_geometry;
|
|
|
|
struct wlr_box geometry;
|
2018-02-14 12:40:13 +01:00
|
|
|
|
|
|
|
struct wl_listener surface_destroy_listener;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal destroy;
|
|
|
|
struct wl_signal ping_timeout;
|
|
|
|
struct wl_signal new_popup;
|
2018-03-15 20:15:09 +01:00
|
|
|
struct wl_signal map;
|
|
|
|
struct wl_signal unmap;
|
2018-02-14 12:40:13 +01:00
|
|
|
} events;
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_move_event {
|
|
|
|
struct wlr_xdg_surface *surface;
|
|
|
|
struct wlr_seat_client *seat;
|
|
|
|
uint32_t serial;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_resize_event {
|
|
|
|
struct wlr_xdg_surface *surface;
|
|
|
|
struct wlr_seat_client *seat;
|
|
|
|
uint32_t serial;
|
|
|
|
uint32_t edges;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_set_fullscreen_event {
|
|
|
|
struct wlr_xdg_surface *surface;
|
|
|
|
bool fullscreen;
|
|
|
|
struct wlr_output *output;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_toplevel_show_window_menu_event {
|
|
|
|
struct wlr_xdg_surface *surface;
|
|
|
|
struct wlr_seat_client *seat;
|
|
|
|
uint32_t serial;
|
|
|
|
uint32_t x, y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wlr_xdg_shell *wlr_xdg_shell_create(struct wl_display *display);
|
|
|
|
void wlr_xdg_shell_destroy(struct wlr_xdg_shell *xdg_shell);
|
|
|
|
|
2018-04-14 21:47:51 +02:00
|
|
|
struct wlr_xdg_surface *wlr_xdg_surface_from_resource(
|
|
|
|
struct wl_resource *resource);
|
2018-04-14 22:50:05 +02:00
|
|
|
struct wlr_xdg_surface *wlr_xdg_surface_from_popup_resource(
|
|
|
|
struct wl_resource *resource);
|
2018-04-14 21:47:51 +02:00
|
|
|
|
2018-04-15 03:17:40 +02:00
|
|
|
struct wlr_box wlr_xdg_positioner_get_geometry(
|
|
|
|
struct wlr_xdg_positioner *positioner);
|
2018-04-14 21:47:51 +02:00
|
|
|
|
2018-02-14 12:40:13 +01:00
|
|
|
/**
|
|
|
|
* Send a ping to the surface. If the surface does not respond in a reasonable
|
|
|
|
* amount of time, the ping_timeout event will be emitted.
|
|
|
|
*/
|
|
|
|
void wlr_xdg_surface_ping(struct wlr_xdg_surface *surface);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request that this toplevel surface be the given size. Returns the associated
|
|
|
|
* configure serial.
|
|
|
|
*/
|
|
|
|
uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_surface *surface,
|
|
|
|
uint32_t width, uint32_t height);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request that this toplevel surface show itself in an activated or deactivated
|
|
|
|
* state. Returns the associated configure serial.
|
|
|
|
*/
|
|
|
|
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface,
|
|
|
|
bool activated);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request that this toplevel surface consider itself maximized or not
|
|
|
|
* maximized. Returns the associated configure serial.
|
|
|
|
*/
|
|
|
|
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface,
|
|
|
|
bool maximized);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request that this toplevel surface consider itself fullscreen or not
|
|
|
|
* fullscreen. Returns the associated configure serial.
|
|
|
|
*/
|
|
|
|
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface,
|
|
|
|
bool fullscreen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request that this toplevel surface consider itself to be resizing or not
|
|
|
|
* resizing. Returns the associated configure serial.
|
|
|
|
*/
|
|
|
|
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface,
|
|
|
|
bool resizing);
|
|
|
|
|
|
|
|
/**
|
2018-03-24 20:10:15 +01:00
|
|
|
* Request that this xdg surface closes.
|
2018-02-14 12:40:13 +01:00
|
|
|
*/
|
2018-03-24 20:10:15 +01:00
|
|
|
void wlr_xdg_surface_send_close(struct wlr_xdg_surface *surface);
|
2018-02-14 12:40:13 +01:00
|
|
|
|
|
|
|
/**
|
2018-04-04 23:45:24 +02:00
|
|
|
* Compute the popup position in its parent's surface-local coordinate system.
|
2018-04-14 21:47:51 +02:00
|
|
|
* This aborts if called for popups whose parent is not an xdg_surface.
|
2018-02-14 12:40:13 +01:00
|
|
|
*/
|
|
|
|
void wlr_xdg_surface_popup_get_position(struct wlr_xdg_surface *surface,
|
|
|
|
double *popup_sx, double *popup_sy);
|
|
|
|
|
2018-04-15 03:34:50 +02:00
|
|
|
/**
|
|
|
|
* Get the geometry for this positioner based on the anchor rect, gravity, and
|
|
|
|
* size of this positioner.
|
|
|
|
*/
|
|
|
|
struct wlr_box wlr_xdg_positioner_get_geometry(
|
|
|
|
struct wlr_xdg_positioner *positioner);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the anchor point for this popup in the toplevel parent's coordinate system.
|
|
|
|
*/
|
|
|
|
void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup,
|
|
|
|
int *toplevel_sx, int *toplevel_sy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the given coordinates in the popup coordinate system to the toplevel
|
|
|
|
* surface coordinate system.
|
|
|
|
*/
|
|
|
|
void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
|
|
|
|
int popup_sx, int popup_sy, int *toplevel_sx, int *toplevel_sy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the geometry of this popup to unconstrain it according to its
|
|
|
|
* xdg-positioner rules. The box should be in the popup's root toplevel parent
|
|
|
|
* surface coordinate system.
|
|
|
|
*/
|
|
|
|
void wlr_xdg_popup_unconstrain_from_box(struct wlr_xdg_popup *popup,
|
|
|
|
struct wlr_box *toplevel_sx_box);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Invert the right/left anchor and gravity for this positioner. This can be
|
|
|
|
used to "flip" the positioner around the anchor rect in the x direction.
|
|
|
|
*/
|
|
|
|
void wlr_positioner_invert_x(struct wlr_xdg_positioner *positioner);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Invert the top/bottom anchor and gravity for this positioner. This can be
|
|
|
|
used to "flip" the positioner around the anchor rect in the y direction.
|
|
|
|
*/
|
|
|
|
void wlr_positioner_invert_y(struct wlr_xdg_positioner *positioner);
|
|
|
|
|
2018-02-14 12:40:13 +01:00
|
|
|
/**
|
2018-04-04 23:45:24 +02:00
|
|
|
* Find a surface within this xdg-surface tree at the given surface-local
|
|
|
|
* coordinates. Returns the surface and coordinates in the leaf surface
|
|
|
|
* coordinate system or NULL if no surface is found at that location.
|
2018-02-14 12:40:13 +01:00
|
|
|
*/
|
2018-04-04 23:45:24 +02:00
|
|
|
struct wlr_surface *wlr_xdg_surface_surface_at(
|
2018-02-14 12:40:13 +01:00
|
|
|
struct wlr_xdg_surface *surface, double sx, double sy,
|
2018-04-04 23:45:24 +02:00
|
|
|
double *sub_x, double *sub_y);
|
2018-02-14 12:40:13 +01:00
|
|
|
|
2018-04-03 02:39:33 +02:00
|
|
|
bool wlr_surface_is_xdg_surface(struct wlr_surface *surface);
|
|
|
|
|
|
|
|
struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface(
|
|
|
|
struct wlr_surface *surface);
|
|
|
|
|
2018-04-05 02:10:47 +02:00
|
|
|
/**
|
|
|
|
* Call `iterator` on each surface in the xdg-surface tree, with the surface's
|
|
|
|
* positon relative to the root xdg-surface. The function is called from root to
|
|
|
|
* leaves (in rendering order).
|
|
|
|
*/
|
|
|
|
void wlr_xdg_surface_for_each_surface(struct wlr_xdg_surface *surface,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2018-02-14 12:40:13 +01:00
|
|
|
#endif
|