2018-07-13 14:40:56 +02:00
|
|
|
/*
|
|
|
|
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
|
|
* future consistency of this API.
|
|
|
|
*/
|
|
|
|
#ifndef WLR_USE_UNSTABLE
|
|
|
|
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
|
|
#endif
|
|
|
|
|
2018-09-14 19:32:33 +02:00
|
|
|
#ifndef WLR_TYPES_WLR_LAYER_SHELL_V1_H
|
|
|
|
#define WLR_TYPES_WLR_LAYER_SHELL_V1_H
|
2021-07-01 22:36:01 +02:00
|
|
|
|
2018-03-18 00:03:52 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2019-07-27 10:53:54 +02:00
|
|
|
#include <wayland-server-core.h>
|
2022-01-13 09:55:09 +01:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2018-03-18 00:03:52 +01:00
|
|
|
#include "wlr-layer-shell-unstable-v1-protocol.h"
|
2018-03-17 20:07:48 +01:00
|
|
|
|
2018-03-18 02:06:54 +01:00
|
|
|
/**
|
2018-09-14 19:32:33 +02:00
|
|
|
* wlr_layer_shell_v1 allows clients to arrange themselves in "layers" on the
|
2018-03-18 02:06:54 +01:00
|
|
|
* desktop in accordance with the wlr-layer-shell protocol. When a client is
|
|
|
|
* added, the new_surface signal will be raised and passed a reference to our
|
2022-05-24 18:46:59 +02:00
|
|
|
* struct wlr_layer_surface_v1. At this time, the client will have configured the
|
2018-09-14 19:32:33 +02:00
|
|
|
* surface as it desires, including information like desired anchors and
|
|
|
|
* margins. The compositor should use this information to decide how to arrange
|
|
|
|
* the layer on-screen, then determine the dimensions of the layer and call
|
2022-05-24 18:46:59 +02:00
|
|
|
* wlr_layer_surface_v1_configure(). The client will then attach a buffer and
|
2018-09-14 19:32:33 +02:00
|
|
|
* commit the surface, at which point the wlr_layer_surface_v1 map signal is
|
|
|
|
* raised and the compositor should begin rendering the surface.
|
2018-03-18 02:06:54 +01:00
|
|
|
*/
|
2018-09-14 19:32:33 +02:00
|
|
|
struct wlr_layer_shell_v1 {
|
2018-07-08 20:21:31 +02:00
|
|
|
struct wl_global *global;
|
2018-03-17 20:07:48 +01:00
|
|
|
|
|
|
|
struct wl_listener display_destroy;
|
|
|
|
|
|
|
|
struct {
|
2018-09-14 19:32:33 +02:00
|
|
|
// Note: the output may be NULL. In this case, it is your
|
|
|
|
// responsibility to assign an output before returning.
|
2023-08-23 20:12:12 +02:00
|
|
|
struct wl_signal new_surface; // struct wlr_layer_surface_v1
|
2018-08-26 23:23:12 +02:00
|
|
|
struct wl_signal destroy;
|
2018-03-17 20:07:48 +01:00
|
|
|
} events;
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2021-09-24 06:58:59 +02:00
|
|
|
enum wlr_layer_surface_v1_state_field {
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_DESIRED_SIZE = 1 << 0,
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_ANCHOR = 1 << 1,
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_EXCLUSIVE_ZONE = 1 << 2,
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_MARGIN = 1 << 3,
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_KEYBOARD_INTERACTIVITY = 1 << 4,
|
|
|
|
WLR_LAYER_SURFACE_V1_STATE_LAYER = 1 << 5,
|
|
|
|
};
|
|
|
|
|
2018-09-14 19:32:33 +02:00
|
|
|
struct wlr_layer_surface_v1_state {
|
2021-09-24 06:58:59 +02:00
|
|
|
uint32_t committed; // enum wlr_layer_surface_v1_state_field
|
|
|
|
|
2018-03-18 00:03:52 +01:00
|
|
|
uint32_t anchor;
|
2018-03-27 00:12:31 +02:00
|
|
|
int32_t exclusive_zone;
|
2018-03-18 00:03:52 +01:00
|
|
|
struct {
|
2021-12-15 16:30:32 +01:00
|
|
|
int32_t top, right, bottom, left;
|
2018-03-18 00:03:52 +01:00
|
|
|
} margin;
|
2020-11-26 13:18:22 +01:00
|
|
|
enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_interactive;
|
2018-03-27 00:12:31 +02:00
|
|
|
uint32_t desired_width, desired_height;
|
2019-10-03 22:06:46 +02:00
|
|
|
enum zwlr_layer_shell_v1_layer layer;
|
2021-09-24 06:58:59 +02:00
|
|
|
|
2021-09-18 10:32:23 +02:00
|
|
|
uint32_t configure_serial;
|
2021-09-24 06:58:59 +02:00
|
|
|
uint32_t actual_width, actual_height;
|
2018-03-18 00:03:52 +01:00
|
|
|
};
|
|
|
|
|
2018-09-14 19:32:33 +02:00
|
|
|
struct wlr_layer_surface_v1_configure {
|
2022-05-24 18:46:59 +02:00
|
|
|
struct wl_list link; // wlr_layer_surface_v1.configure_list
|
2018-03-18 00:03:52 +01:00
|
|
|
uint32_t serial;
|
2021-09-18 10:32:23 +02:00
|
|
|
|
|
|
|
uint32_t width, height;
|
2018-03-18 00:03:52 +01:00
|
|
|
};
|
|
|
|
|
2018-09-14 19:32:33 +02:00
|
|
|
struct wlr_layer_surface_v1 {
|
2018-03-18 00:03:52 +01:00
|
|
|
struct wlr_surface *surface;
|
2018-03-20 04:11:37 +01:00
|
|
|
struct wlr_output *output;
|
2018-03-18 00:03:52 +01:00
|
|
|
struct wl_resource *resource;
|
2018-09-14 19:32:33 +02:00
|
|
|
struct wlr_layer_shell_v1 *shell;
|
2022-05-24 18:46:59 +02:00
|
|
|
struct wl_list popups; // wlr_xdg_popup.link
|
2018-03-18 00:03:52 +01:00
|
|
|
|
2018-04-24 23:40:48 +02:00
|
|
|
char *namespace;
|
2018-03-18 00:03:52 +01:00
|
|
|
|
2023-07-11 10:48:21 +02:00
|
|
|
bool configured;
|
2018-03-18 00:03:52 +01:00
|
|
|
struct wl_list configure_list;
|
|
|
|
|
2021-09-18 10:32:23 +02:00
|
|
|
struct wlr_layer_surface_v1_state current, pending;
|
2018-03-18 00:03:52 +01:00
|
|
|
|
2023-10-14 18:58:26 +02:00
|
|
|
// Whether the surface is ready to receive configure events
|
|
|
|
bool initialized;
|
|
|
|
// Whether the latest commit is an initial commit
|
|
|
|
bool initial_commit;
|
|
|
|
|
2018-03-18 00:03:52 +01:00
|
|
|
struct {
|
2020-04-17 15:11:59 +02:00
|
|
|
/**
|
2022-05-24 18:46:59 +02:00
|
|
|
* The destroy signal indicates that the struct wlr_layer_surface is
|
|
|
|
* about to be freed. It is guaranteed that the unmap signal is raised
|
|
|
|
* before the destroy signal if the layer surface is destroyed while
|
|
|
|
* mapped.
|
2020-04-17 15:11:59 +02:00
|
|
|
*/
|
2018-03-18 00:03:52 +01:00
|
|
|
struct wl_signal destroy;
|
2020-04-17 15:11:59 +02:00
|
|
|
/**
|
|
|
|
* The new_popup signal is raised when a new popup is created. The data
|
2022-05-24 18:46:59 +02:00
|
|
|
* parameter passed to the listener is a pointer to the new
|
|
|
|
* struct wlr_xdg_popup.
|
2020-04-17 15:11:59 +02:00
|
|
|
*/
|
2018-04-14 21:47:51 +02:00
|
|
|
struct wl_signal new_popup;
|
2018-03-18 00:03:52 +01:00
|
|
|
} events;
|
|
|
|
|
|
|
|
void *data;
|
2023-12-07 21:20:17 +01:00
|
|
|
|
|
|
|
// private state
|
|
|
|
|
|
|
|
struct wlr_surface_synced synced;
|
2018-03-18 00:03:52 +01:00
|
|
|
};
|
|
|
|
|
2022-11-14 09:52:13 +01:00
|
|
|
struct wlr_layer_shell_v1 *wlr_layer_shell_v1_create(struct wl_display *display,
|
|
|
|
uint32_t version);
|
2018-03-17 20:07:48 +01:00
|
|
|
|
2018-03-18 02:06:54 +01:00
|
|
|
/**
|
|
|
|
* Notifies the layer surface to configure itself with this width/height. The
|
|
|
|
* layer_surface will signal its map event when the surface is ready to assume
|
2021-09-18 10:32:23 +02:00
|
|
|
* this size. Returns the associated configure serial.
|
2018-03-18 02:06:54 +01:00
|
|
|
*/
|
2021-09-18 10:32:23 +02:00
|
|
|
uint32_t wlr_layer_surface_v1_configure(struct wlr_layer_surface_v1 *surface,
|
2018-03-18 02:06:54 +01:00
|
|
|
uint32_t width, uint32_t height);
|
|
|
|
|
2018-03-24 23:00:01 +01:00
|
|
|
/**
|
2021-08-12 21:30:58 +02:00
|
|
|
* Notify the client that the surface has been closed and destroy the
|
2022-05-24 18:46:59 +02:00
|
|
|
* struct wlr_layer_surface_v1, rendering the resource inert.
|
2018-03-24 23:00:01 +01:00
|
|
|
*/
|
2021-08-12 21:30:58 +02:00
|
|
|
void wlr_layer_surface_v1_destroy(struct wlr_layer_surface_v1 *surface);
|
2018-03-24 23:00:01 +01:00
|
|
|
|
2022-07-01 20:37:34 +02:00
|
|
|
/**
|
|
|
|
* Get a struct wlr_layer_surface from a struct wlr_surface.
|
2023-02-01 20:13:53 +01:00
|
|
|
*
|
|
|
|
* Returns NULL if the surface doesn't have the layer surface role or if
|
|
|
|
* the layer surface has been destroyed.
|
2022-07-01 20:37:34 +02:00
|
|
|
*/
|
2023-02-01 20:13:53 +01:00
|
|
|
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_try_from_wlr_surface(
|
2018-04-03 02:39:33 +02:00
|
|
|
struct wlr_surface *surface);
|
|
|
|
|
2021-09-25 18:40:12 +02:00
|
|
|
/**
|
|
|
|
* Calls the iterator function for each mapped sub-surface and popup of this
|
|
|
|
* surface (whether or not this surface is mapped).
|
|
|
|
*/
|
2018-09-14 19:32:33 +02:00
|
|
|
void wlr_layer_surface_v1_for_each_surface(struct wlr_layer_surface_v1 *surface,
|
2018-04-15 02:36:01 +02:00
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2021-01-08 11:14:42 +01:00
|
|
|
/**
|
|
|
|
* Call `iterator` on each popup's surface and popup's subsurface in the
|
|
|
|
* layer surface's tree, with the surfaces's position relative to the root
|
|
|
|
* layer surface. The function is called from root to leaves (in rendering
|
|
|
|
* order).
|
|
|
|
*/
|
|
|
|
void wlr_layer_surface_v1_for_each_popup_surface(
|
|
|
|
struct wlr_layer_surface_v1 *surface,
|
2020-09-08 18:03:33 +02:00
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2018-05-08 15:19:31 +02:00
|
|
|
/**
|
|
|
|
* Find a surface within this layer-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-09-14 19:32:33 +02:00
|
|
|
struct wlr_surface *wlr_layer_surface_v1_surface_at(
|
|
|
|
struct wlr_layer_surface_v1 *surface, double sx, double sy,
|
2018-05-08 15:19:31 +02:00
|
|
|
double *sub_x, double *sub_y);
|
2018-09-14 19:32:33 +02:00
|
|
|
|
2021-01-07 15:11:29 +01:00
|
|
|
/**
|
|
|
|
* Find a surface within this layer-surface's popup 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.
|
|
|
|
*/
|
|
|
|
struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
|
|
|
|
struct wlr_layer_surface_v1 *surface, double sx, double sy,
|
|
|
|
double *sub_x, double *sub_y);
|
|
|
|
|
2022-05-24 18:46:59 +02:00
|
|
|
/**
|
|
|
|
* Get the corresponding struct wlr_layer_surface_v1 from a resource.
|
2022-03-08 12:26:59 +01:00
|
|
|
*
|
|
|
|
* Aborts if the resource doesn't have the correct type.
|
|
|
|
*/
|
|
|
|
struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_resource(
|
|
|
|
struct wl_resource *resource);
|
|
|
|
|
2018-03-17 20:07:48 +01:00
|
|
|
#endif
|