mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 08:55:58 +01:00
Address @emersion's feedback
This commit is contained in:
parent
0e318df13d
commit
e841e5602b
2 changed files with 39 additions and 63 deletions
|
@ -93,8 +93,9 @@
|
|||
|
||||
<request name="set_size">
|
||||
<description summary="sets the size of the surface">
|
||||
Sets the size of the surface in pixels. The compositor will display the
|
||||
surface centered with respect to its anchors.
|
||||
Sets the size of the surface in surface-local coordinates. The
|
||||
compositor will display the surface centered with respect to its
|
||||
anchors.
|
||||
|
||||
If you pass 0 for either value, the compositor will assign it and
|
||||
inform you of the assignment in the configure event. You must set your
|
||||
|
@ -128,8 +129,8 @@
|
|||
actually be occluded.
|
||||
|
||||
A positive value is only meaningful if the surface is anchored to an
|
||||
edge, rather than a corner. The zone is the number of pixels from the
|
||||
edge that are considered exclusive.
|
||||
edge, rather than a corner. The zone is the number of surface-local
|
||||
coordinates from the edge that are considered exclusive.
|
||||
|
||||
Surfaces that do not wish to have an exclusive zone may instead specify
|
||||
how they should interact with surfaces that do. If set to zero, the
|
||||
|
@ -139,13 +140,15 @@
|
|||
surfaces, and the compositor should extend it all the way to the edges
|
||||
it is anchored to.
|
||||
|
||||
For example, a panel might set its exclusive zone to 10 pixels, so that
|
||||
For example, a panel might set its exclusive zone to 10, so that
|
||||
maximized shell surfaces are not shown on top of it. A notification
|
||||
might set its exclusive zone to zero, so that it is moved to avoid
|
||||
might set its exclusive zone to 0, so that it is moved to avoid
|
||||
occluding the panel, but shell surfaces are shown underneath it. A
|
||||
wallpaper or lock screen might set their exclusive zone to -1, so that
|
||||
they stretch below or over the panel.
|
||||
|
||||
The default value is 0.
|
||||
|
||||
Exclusive zone is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="zone" type="int"/>
|
||||
|
@ -154,8 +157,8 @@
|
|||
<request name="set_margin">
|
||||
<description summary="sets a margin from the anchor point">
|
||||
Requests that the surface be placed some distance away from the anchor
|
||||
point on the output, in pixels. Setting this value for edges you are
|
||||
not anchored to has no effect.
|
||||
point on the output, in surface-local coordinates. Setting this value
|
||||
for edges you are not anchored to has no effect.
|
||||
|
||||
The exclusive zone includes the margin.
|
||||
|
||||
|
@ -254,11 +257,11 @@
|
|||
|
||||
<event name="closed">
|
||||
<description summary="surface should be closed">
|
||||
The closed event is sent by the compositor when the surface will no
|
||||
longer be shown. The output may have been destroyed or the user may have
|
||||
asked for it to be removed. Further changes to the surface will be ignored.
|
||||
The client should destroy the resource after receiving this event, and
|
||||
create a new surface if they so choose.
|
||||
The closed event is sent by the compositor when the surface will no
|
||||
longer be shown. The output may have been destroyed or the user may
|
||||
have asked for it to be removed. Further changes to the surface will be
|
||||
ignored. The client should destroy the resource after receiving this
|
||||
event, and create a new surface if they so choose.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ static void layer_surface_handle_set_keyboard_interactivity(
|
|||
struct wl_client *client, struct wl_resource *resource,
|
||||
uint32_t interactive) {
|
||||
struct wlr_layer_surface *surface = layer_surface_from_resource(resource);
|
||||
surface->client_pending.keyboard_interactive = interactive == 1;
|
||||
surface->client_pending.keyboard_interactive = !!interactive;
|
||||
}
|
||||
|
||||
static void layer_surface_handle_get_popup(struct wl_client *client,
|
||||
|
@ -143,7 +143,7 @@ static void layer_surface_unmap(struct wlr_layer_surface *surface) {
|
|||
layer_surface_configure_destroy(configure);
|
||||
}
|
||||
|
||||
surface->added = surface->configured = surface->mapped = false;
|
||||
surface->configured = surface->mapped = false;
|
||||
surface->configure_serial = 0;
|
||||
if (surface->configure_idle) {
|
||||
wl_event_source_remove(surface->configure_idle);
|
||||
|
@ -189,61 +189,34 @@ static bool wlr_layer_surface_state_changed(struct wlr_layer_surface *surface) {
|
|||
return changed;
|
||||
}
|
||||
|
||||
static void wlr_layer_surface_send_configure(void *user_data) {
|
||||
struct wlr_layer_surface *surface = user_data;
|
||||
surface->configure_idle = NULL;
|
||||
struct wlr_layer_surface_configure *configure =
|
||||
calloc(1, sizeof(struct wlr_layer_surface_configure));
|
||||
if (configure == NULL) {
|
||||
wl_client_post_no_memory(surface->client->client);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_insert(surface->configure_list.prev, &configure->link);
|
||||
configure->serial = surface->configure_next_serial;
|
||||
configure->state.actual_width = surface->server_pending.actual_width;
|
||||
configure->state.actual_height = surface->server_pending.actual_height;
|
||||
|
||||
zwlr_layer_surface_v1_send_configure(surface->resource,
|
||||
configure->serial, configure->state.actual_width,
|
||||
configure->state.actual_height);
|
||||
}
|
||||
|
||||
static uint32_t wlr_layer_surface_schedule_configure(
|
||||
struct wlr_layer_surface *surface) {
|
||||
struct wl_display *display = wl_client_get_display(surface->client->client);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
bool changed = wlr_layer_surface_state_changed(surface);
|
||||
|
||||
if (surface->configure_idle != NULL) {
|
||||
if (changed) {
|
||||
// configure request already scheduled
|
||||
return surface->configure_next_serial;
|
||||
}
|
||||
// configure request not necessary anymore
|
||||
wl_event_source_remove(surface->configure_idle);
|
||||
surface->configure_idle = NULL;
|
||||
return 0;
|
||||
} else {
|
||||
if (!changed) {
|
||||
// configure request not necessary
|
||||
return 0;
|
||||
}
|
||||
surface->configure_next_serial = wl_display_next_serial(display);
|
||||
surface->configure_idle = wl_event_loop_add_idle(loop,
|
||||
wlr_layer_surface_send_configure, surface);
|
||||
return surface->configure_next_serial;
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_layer_surface_configure(struct wlr_layer_surface *surface,
|
||||
uint32_t width, uint32_t height) {
|
||||
surface->server_pending.actual_width = width;
|
||||
surface->server_pending.actual_height = height;
|
||||
wlr_layer_surface_schedule_configure(surface);
|
||||
if (wlr_layer_surface_state_changed(surface)) {
|
||||
struct wl_display *display =
|
||||
wl_client_get_display(surface->client->client);
|
||||
struct wlr_layer_surface_configure *configure =
|
||||
calloc(1, sizeof(struct wlr_layer_surface_configure));
|
||||
if (configure == NULL) {
|
||||
wl_client_post_no_memory(surface->client->client);
|
||||
return;
|
||||
}
|
||||
surface->configure_next_serial = wl_display_next_serial(display);
|
||||
wl_list_insert(surface->configure_list.prev, &configure->link);
|
||||
configure->state.actual_width = width;
|
||||
configure->state.actual_height = height;
|
||||
configure->serial = surface->configure_next_serial;
|
||||
zwlr_layer_surface_v1_send_configure(surface->resource,
|
||||
configure->serial, configure->state.actual_width,
|
||||
configure->state.actual_height);
|
||||
}
|
||||
}
|
||||
|
||||
void wlr_layer_surface_close(struct wlr_layer_surface *surface) {
|
||||
if (surface->closed) {
|
||||
return;
|
||||
}
|
||||
surface->closed = true;
|
||||
layer_surface_unmap(surface);
|
||||
zwlr_layer_surface_v1_send_closed(surface->resource);
|
||||
|
|
Loading…
Reference in a new issue