mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-27 06:59:46 -05:00
Merge branch 'master' into fullscreen
This commit is contained in:
commit
dcb168914e
19 changed files with 335 additions and 216 deletions
|
|
@ -3,26 +3,23 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <wlr/types/wlr_list.h>
|
||||
|
||||
struct wlr_list *wlr_list_create(void) {
|
||||
struct wlr_list *list = malloc(sizeof(struct wlr_list));
|
||||
if (!list) {
|
||||
return NULL;
|
||||
}
|
||||
bool wlr_list_init(struct wlr_list *list) {
|
||||
list->capacity = 10;
|
||||
list->length = 0;
|
||||
list->items = malloc(sizeof(void*) * list->capacity);
|
||||
if (!list->items) {
|
||||
free(list);
|
||||
return NULL;
|
||||
list->items = malloc(sizeof(void *) * list->capacity);
|
||||
if (list->items == NULL) {
|
||||
return false;
|
||||
}
|
||||
return list;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool list_resize(struct wlr_list *list) {
|
||||
if (list->length == list->capacity) {
|
||||
void *new_items = realloc(list->items, sizeof(void*) * (list->capacity + 10));
|
||||
void *new_items = realloc(list->items,
|
||||
sizeof(void *) * (list->capacity + 10));
|
||||
if (!new_items) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -32,24 +29,17 @@ static bool list_resize(struct wlr_list *list) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void wlr_list_free(struct wlr_list *list) {
|
||||
if (list == NULL) {
|
||||
return;
|
||||
}
|
||||
void wlr_list_finish(struct wlr_list *list) {
|
||||
free(list->items);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void wlr_list_foreach(struct wlr_list *list, void (*callback)(void *item)) {
|
||||
if (list == NULL || callback == NULL) {
|
||||
return;
|
||||
}
|
||||
void wlr_list_for_each(struct wlr_list *list, void (*callback)(void *item)) {
|
||||
for (size_t i = 0; i < list->length; i++) {
|
||||
callback(list->items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int wlr_list_add(struct wlr_list *list, void *item) {
|
||||
ssize_t wlr_list_push(struct wlr_list *list, void *item) {
|
||||
if (!list_resize(list)) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -57,15 +47,12 @@ int wlr_list_add(struct wlr_list *list, void *item) {
|
|||
return list->length;
|
||||
}
|
||||
|
||||
int wlr_list_push(struct wlr_list *list, void *item) {
|
||||
return wlr_list_add(list, item);
|
||||
}
|
||||
|
||||
int wlr_list_insert(struct wlr_list *list, size_t index, void *item) {
|
||||
ssize_t wlr_list_insert(struct wlr_list *list, size_t index, void *item) {
|
||||
if (!list_resize(list)) {
|
||||
return -1;
|
||||
}
|
||||
memmove(&list->items[index + 1], &list->items[index], sizeof(void*) * (list->length - index));
|
||||
memmove(&list->items[index + 1], &list->items[index],
|
||||
sizeof(void *) * (list->length - index));
|
||||
list->length++;
|
||||
list->items[index] = item;
|
||||
return list->length;
|
||||
|
|
@ -73,24 +60,31 @@ int wlr_list_insert(struct wlr_list *list, size_t index, void *item) {
|
|||
|
||||
void wlr_list_del(struct wlr_list *list, size_t index) {
|
||||
list->length--;
|
||||
memmove(&list->items[index], &list->items[index + 1], sizeof(void*) * (list->length - index));
|
||||
memmove(&list->items[index], &list->items[index + 1],
|
||||
sizeof(void *) * (list->length - index));
|
||||
}
|
||||
|
||||
void *wlr_list_pop(struct wlr_list *list) {
|
||||
void *_ = list->items[list->length - 1];
|
||||
if (list->length == 0) {
|
||||
return NULL;
|
||||
}
|
||||
void *last = list->items[list->length - 1];
|
||||
wlr_list_del(list, list->length - 1);
|
||||
return _;
|
||||
return last;
|
||||
}
|
||||
|
||||
void *wlr_list_peek(struct wlr_list *list) {
|
||||
if (list->length == 0) {
|
||||
return NULL;
|
||||
}
|
||||
return list->items[list->length - 1];
|
||||
}
|
||||
|
||||
int wlr_list_cat(struct wlr_list *list, struct wlr_list *source) {
|
||||
ssize_t wlr_list_cat(struct wlr_list *list, const struct wlr_list *source) {
|
||||
size_t old_len = list->length;
|
||||
size_t i;
|
||||
for (i = 0; i < source->length; ++i) {
|
||||
if (wlr_list_add(list, source->items[i]) == -1) {
|
||||
if (wlr_list_push(list, source->items[i]) == -1) {
|
||||
list->length = old_len;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -98,13 +92,13 @@ int wlr_list_cat(struct wlr_list *list, struct wlr_list *source) {
|
|||
return list->length;
|
||||
}
|
||||
|
||||
void wlr_list_qsort(struct wlr_list *list, int compare(const void *left, const void *right)) {
|
||||
void wlr_list_qsort(struct wlr_list *list,
|
||||
int compare(const void *left, const void *right)) {
|
||||
qsort(list->items, list->length, sizeof(void *), compare);
|
||||
}
|
||||
|
||||
int wlr_list_seq_find(struct wlr_list *list,
|
||||
int compare(const void *item, const void *data),
|
||||
const void *data) {
|
||||
ssize_t wlr_list_find(struct wlr_list *list,
|
||||
int compare(const void *item, const void *data), const void *data) {
|
||||
for (size_t i = 0; i < list->length; i++) {
|
||||
void *item = list->items[i];
|
||||
if (compare(item, data) == 0) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/types/wlr_list.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <wlr/render/matrix.h>
|
||||
|
|
|
|||
|
|
@ -809,8 +809,7 @@ static void xdg_surface_ack_configure(struct wl_client *client,
|
|||
}
|
||||
|
||||
surface->configured = true;
|
||||
|
||||
wl_signal_emit(&surface->events.ack_configure, surface);
|
||||
surface->configure_serial = serial;
|
||||
|
||||
free(configure);
|
||||
}
|
||||
|
|
@ -938,7 +937,6 @@ static void wlr_xdg_toplevel_v6_send_configure(
|
|||
|
||||
static void wlr_xdg_surface_send_configure(void *user_data) {
|
||||
struct wlr_xdg_surface_v6 *surface = user_data;
|
||||
struct wl_display *display = wl_client_get_display(surface->client->client);
|
||||
|
||||
surface->configure_idle = NULL;
|
||||
|
||||
|
|
@ -950,7 +948,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
|
|||
}
|
||||
|
||||
wl_list_insert(surface->configure_list.prev, &configure->link);
|
||||
configure->serial = wl_display_next_serial(display);
|
||||
configure->serial = surface->configure_next_serial;
|
||||
|
||||
switch (surface->role) {
|
||||
case WLR_XDG_SURFACE_V6_ROLE_NONE:
|
||||
|
|
@ -971,7 +969,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) {
|
|||
zxdg_surface_v6_send_configure(surface->resource, configure->serial);
|
||||
}
|
||||
|
||||
static void wlr_xdg_surface_v6_schedule_configure(
|
||||
static uint32_t wlr_xdg_surface_v6_schedule_configure(
|
||||
struct wlr_xdg_surface_v6 *surface) {
|
||||
struct wl_display *display = wl_client_get_display(surface->client->client);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
|
|
@ -992,23 +990,23 @@ static void wlr_xdg_surface_v6_schedule_configure(
|
|||
if (surface->configure_idle != NULL) {
|
||||
if (!pending_same) {
|
||||
// configure request already scheduled
|
||||
return;
|
||||
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 (pending_same) {
|
||||
// configure request not necessary
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
surface->configure_idle =
|
||||
wl_event_loop_add_idle(
|
||||
loop,
|
||||
wlr_xdg_surface_send_configure,
|
||||
surface);
|
||||
surface->configure_next_serial = wl_display_next_serial(display);
|
||||
surface->configure_idle = wl_event_loop_add_idle(loop,
|
||||
wlr_xdg_surface_send_configure, surface);
|
||||
return surface->configure_next_serial;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1152,7 +1150,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
|||
wl_signal_init(&surface->events.request_show_window_menu);
|
||||
wl_signal_init(&surface->events.commit);
|
||||
wl_signal_init(&surface->events.destroy);
|
||||
wl_signal_init(&surface->events.ack_configure);
|
||||
wl_signal_init(&surface->events.ping_timeout);
|
||||
|
||||
wl_signal_add(&surface->surface->events.destroy,
|
||||
|
|
@ -1301,45 +1298,45 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) {
|
|||
surface->client->ping_serial);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t width, uint32_t height) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.width = width;
|
||||
surface->toplevel_state->pending.height = height;
|
||||
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface,
|
||||
bool activated) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.activated = activated;
|
||||
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface,
|
||||
bool maximized) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.maximized = maximized;
|
||||
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface,
|
||||
bool fullscreen) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.fullscreen = fullscreen;
|
||||
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
|
||||
uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
|
||||
bool resizing) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.resizing = resizing;
|
||||
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
||||
void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue