add monitor destroy listener
This commit is contained in:
parent
5ca1e22fef
commit
89e9a4be33
18
dwl.c
18
dwl.c
|
@ -110,6 +110,7 @@ struct Monitor {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wlr_output *wlr_output;
|
struct wlr_output *wlr_output;
|
||||||
struct wl_listener frame;
|
struct wl_listener frame;
|
||||||
|
struct wl_listener destroy;
|
||||||
struct wlr_box m; /* monitor area, layout-relative */
|
struct wlr_box m; /* monitor area, layout-relative */
|
||||||
struct wlr_box w; /* window area, layout-relative */
|
struct wlr_box w; /* window area, layout-relative */
|
||||||
const Layout *lt[2];
|
const Layout *lt[2];
|
||||||
|
@ -152,6 +153,7 @@ static void arrange(Monitor *m);
|
||||||
static void axisnotify(struct wl_listener *listener, void *data);
|
static void axisnotify(struct wl_listener *listener, void *data);
|
||||||
static void buttonpress(struct wl_listener *listener, void *data);
|
static void buttonpress(struct wl_listener *listener, void *data);
|
||||||
static void chvt(const Arg *arg);
|
static void chvt(const Arg *arg);
|
||||||
|
static void cleanupmon(struct wl_listener *listener, void *data);
|
||||||
static void createkeyboard(struct wlr_input_device *device);
|
static void createkeyboard(struct wlr_input_device *device);
|
||||||
static void createmon(struct wl_listener *listener, void *data);
|
static void createmon(struct wl_listener *listener, void *data);
|
||||||
static void createnotify(struct wl_listener *listener, void *data);
|
static void createnotify(struct wl_listener *listener, void *data);
|
||||||
|
@ -393,6 +395,16 @@ chvt(const Arg *arg)
|
||||||
wlr_session_change_vt(s, arg->ui);
|
wlr_session_change_vt(s, arg->ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cleanupmon(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct wlr_output *wlr_output = data;
|
||||||
|
Monitor *m = wlr_output->data;
|
||||||
|
|
||||||
|
wl_list_remove(&m->destroy.link);
|
||||||
|
free(m);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
createkeyboard(struct wlr_input_device *device)
|
createkeyboard(struct wlr_input_device *device)
|
||||||
{
|
{
|
||||||
|
@ -455,11 +467,15 @@ createmon(struct wl_listener *listener, void *data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Sets up a listener for the frame notify event. */
|
/* Set up event listeners */
|
||||||
m->frame.notify = rendermon;
|
m->frame.notify = rendermon;
|
||||||
wl_signal_add(&wlr_output->events.frame, &m->frame);
|
wl_signal_add(&wlr_output->events.frame, &m->frame);
|
||||||
wl_list_insert(&mons, &m->link);
|
wl_list_insert(&mons, &m->link);
|
||||||
|
|
||||||
|
m->destroy.notify = cleanupmon;
|
||||||
|
wl_signal_add(&wlr_output->events.destroy, &m->destroy);
|
||||||
|
wl_list_insert(&mons, &m->link);
|
||||||
|
|
||||||
wlr_output_enable(wlr_output, 1);
|
wlr_output_enable(wlr_output, 1);
|
||||||
if (!wlr_output_commit(wlr_output))
|
if (!wlr_output_commit(wlr_output))
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue