-
Notifications
You must be signed in to change notification settings - Fork 136
/
surface.c
40 lines (34 loc) · 1 KB
/
surface.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <string.h>
#include <stdlib.h>
#include "mako.h"
#include "surface.h"
void destroy_surface(struct mako_surface *surface) {
if (surface->layer_surface != NULL) {
zwlr_layer_surface_v1_destroy(surface->layer_surface);
}
if (surface->surface != NULL) {
wl_surface_destroy(surface->surface);
}
if (surface->frame_callback != NULL) {
wl_callback_destroy(surface->frame_callback);
}
finish_buffer(&surface->buffers[0]);
finish_buffer(&surface->buffers[1]);
/* Clean up memory resources */
free(surface->configured_output);
wl_list_remove(&surface->link);
free(surface);
}
struct mako_surface *create_surface(struct mako_state *state, const char *output,
enum zwlr_layer_shell_v1_layer layer, uint32_t anchor) {
struct mako_surface *surface = calloc(1, sizeof(*surface));
if (!surface) {
return NULL;
}
surface->configured_output = strdup(output);
surface->layer = layer;
surface->anchor = anchor;
surface->state = state;
wl_list_insert(&state->surfaces, &surface->link);
return surface;
}