aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/decoration.c
blob: af0dc5f4849bfd4328b8a3b7d285e750b6c1bae7 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
#include "dwm.h"

/* internal callbacks */
static void mode(struct wl_listener *ev, void *arg);
static void delete(struct wl_listener *ev, void *arg);

// -----------------------------------------------------------------------
// implementations

void
evยทnewdecoration(struct wl_listener *ev, void *arg)
{
    struct wlr_server_decoration *wlr;
    Deco   *deco;

    wlr = arg;

    deco = calloc(1, sizeof(*deco));
    if (!deco)
        return;

    deco->wlr = wlr;

	wl_signal_add(&wlr->events.destroy, &deco->ev.free);
	deco->ev.free.notify = delete;

	wl_signal_add(&wlr->events.mode, &deco->ev.mode);
	deco->ev.mode.notify = mode;

	wl_list_insert(&dwm.decos, &deco->link);
}

static
void
delete(struct wl_listener *ev, void *arg)
{
    Deco *deco;

    deco = wl_container_of(ev, deco, ev.free);

    wl_list_remove(&deco->ev.free.link);
    wl_list_remove(&deco->ev.mode.link);
    wl_list_remove(&deco->link);
    free(deco);
}

static
void
mode(struct wl_listener *ev, void *arg)
{
    /* no op */
}