mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 16:42:26 +00:00
Implement layer surface requests
This commit is contained in:
parent
3ba57fccd1
commit
b06105b564
@ -40,7 +40,7 @@ struct wlr_layer_surface_state {
|
|||||||
struct wlr_layer_surface_configure {
|
struct wlr_layer_surface_configure {
|
||||||
struct wl_list link; // wlr_layer_surface::configure_list
|
struct wl_list link; // wlr_layer_surface::configure_list
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
struct wlr_layer_surface_state *state;
|
struct wlr_layer_surface_state state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_layer_surface {
|
struct wlr_layer_surface {
|
||||||
|
@ -131,10 +131,10 @@
|
|||||||
|
|
||||||
Margin is double-buffered, see wl_surface.commit.
|
Margin is double-buffered, see wl_surface.commit.
|
||||||
</description>
|
</description>
|
||||||
<arg name="top" type="int"/>
|
<arg name="top" type="uint"/>
|
||||||
<arg name="right" type="int"/>
|
<arg name="right" type="uint"/>
|
||||||
<arg name="bottom" type="int"/>
|
<arg name="bottom" type="uint"/>
|
||||||
<arg name="left" type="int"/>
|
<arg name="left" type="uint"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<request name="get_popup">
|
<request name="get_popup">
|
||||||
@ -217,6 +217,8 @@
|
|||||||
<enum name="error">
|
<enum name="error">
|
||||||
<entry name="invalid_input_device" value="0" summary="input device bitfield is invalid"/>
|
<entry name="invalid_input_device" value="0" summary="input device bitfield is invalid"/>
|
||||||
<entry name="invalid_anchor" value="1" summary="anchor bitfield is invalid"/>
|
<entry name="invalid_anchor" value="1" summary="anchor bitfield is invalid"/>
|
||||||
|
<entry name="invalid_surface_state" value="2"
|
||||||
|
summary="the client provided an invalid surface state"/>
|
||||||
</enum>
|
</enum>
|
||||||
|
|
||||||
<enum name="anchor" bitfield="true">
|
<enum name="anchor" bitfield="true">
|
||||||
|
@ -31,25 +31,68 @@ static struct wlr_layer_surface *layer_surface_from_resource(
|
|||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void layer_surface_configure_destroy(
|
||||||
|
struct wlr_layer_surface_configure *configure) {
|
||||||
|
if (configure == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wl_list_remove(&configure->link);
|
||||||
|
free(configure);
|
||||||
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_ack_configure(struct wl_client *client,
|
static void layer_surface_handle_ack_configure(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t serial) {
|
struct wl_resource *resource, uint32_t serial) {
|
||||||
// TODO
|
struct wlr_layer_surface *surface = layer_surface_from_resource(resource);
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
struct wlr_layer_surface_configure *configure, *tmp;
|
||||||
|
wl_list_for_each_safe(configure, tmp, &surface->configure_list, link) {
|
||||||
|
if (configure->serial < serial) {
|
||||||
|
layer_surface_configure_destroy(configure);
|
||||||
|
} else if (configure->serial == serial) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
wl_resource_post_error(surface->client->resource,
|
||||||
|
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE,
|
||||||
|
"wrong configure serial: %u", serial);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
surface->configured = true;
|
||||||
|
surface->configure_serial = serial;
|
||||||
|
|
||||||
|
surface->current.anchor = configure->state.anchor;
|
||||||
|
surface->current.exclusive_zone = configure->state.exclusive_zone;
|
||||||
|
surface->current.margin = configure->state.margin;
|
||||||
|
|
||||||
|
layer_surface_configure_destroy(configure);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_set_anchor(struct wl_client *client,
|
static void layer_surface_handle_set_anchor(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t anchor) {
|
struct wl_resource *resource, uint32_t anchor) {
|
||||||
// TODO
|
struct wlr_layer_surface *surface = layer_surface_from_resource(resource);
|
||||||
|
surface->next.anchor = anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_set_exclusive_zone(struct wl_client *client,
|
static void layer_surface_handle_set_exclusive_zone(struct wl_client *client,
|
||||||
struct wl_resource *resource, uint32_t zone) {
|
struct wl_resource *resource, uint32_t zone) {
|
||||||
// TODO
|
struct wlr_layer_surface *surface = layer_surface_from_resource(resource);
|
||||||
|
surface->next.exclusive_zone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_set_margin(struct wl_client *client,
|
static void layer_surface_handle_set_margin(struct wl_client *client,
|
||||||
struct wl_resource *resource, int32_t top, int32_t right,
|
struct wl_resource *resource, uint32_t top,
|
||||||
int32_t bottom, int32_t left) {
|
uint32_t right, uint32_t bottom, uint32_t left) {
|
||||||
// TODO
|
struct wlr_layer_surface *surface = layer_surface_from_resource(resource);
|
||||||
|
surface->next.margin.top = top;
|
||||||
|
surface->next.margin.right = right;
|
||||||
|
surface->next.margin.bottom = bottom;
|
||||||
|
surface->next.margin.left = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_handle_get_popup(struct wl_client *client,
|
static void layer_surface_handle_get_popup(struct wl_client *client,
|
||||||
@ -72,16 +115,6 @@ static const struct zwlr_layer_surface_v1_interface layer_surface_implementation
|
|||||||
.get_input = layer_surface_handle_get_input,
|
.get_input = layer_surface_handle_get_input,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void layer_surface_configure_destroy(
|
|
||||||
struct wlr_layer_surface_configure *configure) {
|
|
||||||
if (configure == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wl_list_remove(&configure->link);
|
|
||||||
free(configure->state);
|
|
||||||
free(configure);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void layer_surface_unmap(struct wlr_layer_surface *surface) {
|
static void layer_surface_unmap(struct wlr_layer_surface *surface) {
|
||||||
// TODO: probably need to ungrab before this event
|
// TODO: probably need to ungrab before this event
|
||||||
wlr_signal_emit_safe(&surface->events.unmap, surface);
|
wlr_signal_emit_safe(&surface->events.unmap, surface);
|
||||||
|
Loading…
Reference in New Issue
Block a user