WIP progress towards layer
This commit is contained in:
parent
5fcd796e74
commit
9cb10980e3
2 changed files with 52 additions and 27 deletions
76
wayland.c
76
wayland.c
|
|
@ -42,10 +42,9 @@ static void xdg_toplevel_configure (
|
||||||
state->height = height;
|
state->height = height;
|
||||||
// resize egl window
|
// resize egl window
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
while (next != NULL) {
|
|
||||||
|
while (next->data.xdg_toplevel != xdg_toplevel) { next = next->next; }
|
||||||
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
||||||
next = next->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) {
|
static void xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) {
|
||||||
|
|
@ -67,11 +66,13 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) {
|
static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) {
|
||||||
// struct client_state *state = data;
|
struct client_state *state = data;
|
||||||
// state->width = width;
|
state->width = width;
|
||||||
// state->height = height;
|
state->height = height;
|
||||||
// wl_egl_window_resize(state->egl_window, width, height, 0, 0);
|
struct surface_list *next = state->surface_list;
|
||||||
// zwlr_layer_surface_v1_ack_configure(zwlr_layer_surface_v1, serial);
|
while (next->data.zwlr_layer_surface_v1 != zwlr_layer_surface_v1) { next = next->next; }
|
||||||
|
wl_egl_window_resize(next->data.egl_window, width, height, 0, 0);
|
||||||
|
zwlr_layer_surface_v1_ack_configure(zwlr_layer_surface_v1, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zwlr_layer_surface_v1_closed(void *data, struct zwlr_layer_surface_v1 * zwlr_layer_surface_v1) {
|
static void zwlr_layer_surface_v1_closed(void *data, struct zwlr_layer_surface_v1 * zwlr_layer_surface_v1) {
|
||||||
|
|
@ -127,13 +128,47 @@ static void registry_handle_global(
|
||||||
state->surface_list->data = surface;
|
state->surface_list->data = surface;
|
||||||
state->surface_list->next = NULL;
|
state->surface_list->next = NULL;
|
||||||
}
|
}
|
||||||
//if ((strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) && (state->output_type == OUTPUT_LAYER)) {
|
if ((strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) && (state->output_type == OUTPUT_LAYER)) {
|
||||||
// state->zwlr_layer_shell_v1 = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 4);
|
state->zwlr_layer_shell_v1 = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 4);
|
||||||
//}
|
}
|
||||||
//if (strcmp(interface, wl_output_interface.name) == 0) {
|
if (strcmp(interface, wl_output_interface.name) == 0 && state->output_type == OUTPUT_LAYER) {
|
||||||
// state->wl_output = wl_registry_bind(
|
struct wl_output *wl_output = wl_registry_bind(
|
||||||
// registry, name, &wl_output_interface, 4);
|
registry, name, &wl_output_interface, 4);
|
||||||
//}
|
|
||||||
|
struct wl_surface *wl_surface = wl_compositor_create_surface(state->wl_compositor);
|
||||||
|
|
||||||
|
// wlr_layer_shell
|
||||||
|
int layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||||
|
struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1 =
|
||||||
|
zwlr_layer_shell_v1_get_layer_surface(
|
||||||
|
state->zwlr_layer_shell_v1,
|
||||||
|
wl_surface,
|
||||||
|
wl_output,
|
||||||
|
layer,
|
||||||
|
"wallpaper"
|
||||||
|
);
|
||||||
|
zwlr_layer_surface_v1_set_anchor(zwlr_layer_surface_v1,
|
||||||
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
|
||||||
|
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
|
||||||
|
zwlr_layer_surface_v1_set_size(zwlr_layer_surface_v1, 0, 0);
|
||||||
|
zwlr_layer_surface_v1_add_listener(zwlr_layer_surface_v1, &zwlr_layer_surface_v1_listener, state);
|
||||||
|
|
||||||
|
struct surface surface = {
|
||||||
|
.wl_surface = wl_surface,
|
||||||
|
.zwlr_layer_surface_v1 = zwlr_layer_surface_v1,
|
||||||
|
};
|
||||||
|
if (state->surface_list == NULL) {
|
||||||
|
state->surface_list = malloc(sizeof(struct surface_list));
|
||||||
|
state->surface_list->data = surface;
|
||||||
|
state->surface_list->next = NULL;
|
||||||
|
} else {
|
||||||
|
struct surface_list *next = state->surface_list;
|
||||||
|
while (next->next != NULL) { next = next->next; }
|
||||||
|
next->next = malloc(sizeof(struct surface_list));
|
||||||
|
next->next->data = surface;
|
||||||
|
next->next->next = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void registry_handle_global_remove(
|
static void registry_handle_global_remove(
|
||||||
|
|
@ -253,17 +288,6 @@ void wayland_init(struct client_state *state, int output_type) {
|
||||||
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
|
||||||
wl_display_roundtrip(state->wl_display);
|
wl_display_roundtrip(state->wl_display);
|
||||||
|
|
||||||
//if (output_type == OUTPUT_LAYER) {
|
|
||||||
// // wlr_layer_shell
|
|
||||||
// int layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
|
||||||
// state->zwlr_layer_surface_v1 = zwlr_layer_shell_v1_get_layer_surface(state->zwlr_layer_shell_v1, state->wl_surface, state->wl_output, layer, "wallpaper");
|
|
||||||
// zwlr_layer_surface_v1_set_anchor(state->zwlr_layer_surface_v1,
|
|
||||||
// ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
|
|
||||||
// | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
|
|
||||||
// zwlr_layer_surface_v1_set_size(state->zwlr_layer_surface_v1, 0, 0);
|
|
||||||
// zwlr_layer_surface_v1_add_listener(state->zwlr_layer_surface_v1, &zwlr_layer_surface_v1_listener, state);
|
|
||||||
//}
|
|
||||||
|
|
||||||
struct surface_list *next = state->surface_list;
|
struct surface_list *next = state->surface_list;
|
||||||
while (next != NULL) {
|
while (next != NULL) {
|
||||||
wl_surface_commit(next->data.wl_surface);
|
wl_surface_commit(next->data.wl_surface);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ struct surface_list {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct client_state {
|
struct client_state {
|
||||||
|
// TODO: move this to surface
|
||||||
int width, height;
|
int width, height;
|
||||||
int running;
|
int running;
|
||||||
int output_type;
|
int output_type;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue