|
|
@ -151,6 +151,76 @@ static void layer_surface_resource_destroy(struct wl_resource *resource) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool wlr_layer_surface_state_changed(struct wlr_layer_surface *surface) {
|
|
|
|
|
|
|
|
if (!surface->configured) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_layer_surface_state *state;
|
|
|
|
|
|
|
|
if (wl_list_empty(&surface->configure_list)) {
|
|
|
|
|
|
|
|
state = &surface->current;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
struct wlr_layer_surface_configure *configure =
|
|
|
|
|
|
|
|
wl_container_of(surface->configure_list.prev, configure, link);
|
|
|
|
|
|
|
|
state = &configure->state;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !memcmp(state, &surface->pending,
|
|
|
|
|
|
|
|
sizeof(struct wlr_layer_surface_state));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = surface->pending;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
zwlr_layer_surface_v1_send_configure(surface->resource,
|
|
|
|
|
|
|
|
configure->serial, configure->state.width, configure->state.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->pending.width = width;
|
|
|
|
|
|
|
|
surface->pending.height = height;
|
|
|
|
|
|
|
|
wlr_layer_surface_schedule_configure(surface);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|
|
|
static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|
|
|
void *role_data) {
|
|
|
|
void *role_data) {
|
|
|
|
struct wlr_layer_surface *surface = role_data;
|
|
|
|
struct wlr_layer_surface *surface = role_data;
|
|
|
@ -163,8 +233,8 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!surface->added) {
|
|
|
|
if (!surface->added) {
|
|
|
|
surface->added = true;
|
|
|
|
surface->added = true;
|
|
|
|
wlr_signal_emit_safe(
|
|
|
|
wlr_signal_emit_safe(&surface->client->shell->events.new_surface,
|
|
|
|
&surface->client->shell->events.new_surface, surface);
|
|
|
|
surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
|
|
|
if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
|
|
|
|
!surface->mapped) {
|
|
|
|
!surface->mapped) {
|
|
|
|