hang some stuff on ->data

Sure it'll be useful at some point.  Like here.
This commit is contained in:
Devin J. Pohly 2020-04-26 17:22:21 -05:00
parent ab51576556
commit 309f6c96cf

12
dwl.c
View file

@ -304,7 +304,7 @@ buttonpress(struct wl_listener *listener, void *data)
void void
createkeyboard(struct wlr_input_device *device) createkeyboard(struct wlr_input_device *device)
{ {
Keyboard *kb = calloc(1, sizeof(*kb)); Keyboard *kb = device->data = calloc(1, sizeof(*kb));
kb->device = device; kb->device = device;
/* Prepare an XKB keymap and assign it to the keyboard. */ /* Prepare an XKB keymap and assign it to the keyboard. */
@ -350,7 +350,7 @@ createmon(struct wl_listener *listener, void *data)
} }
/* Allocates and configures monitor state using configured rules */ /* Allocates and configures monitor state using configured rules */
Monitor *m = calloc(1, sizeof(*m)); Monitor *m = wlr_output->data = calloc(1, sizeof(*m));
m->wlr_output = wlr_output; m->wlr_output = wlr_output;
m->tagset[0] = m->tagset[1] = 1; m->tagset[0] = m->tagset[1] = 1;
int i; int i;
@ -393,7 +393,7 @@ createnotify(struct wl_listener *listener, void *data)
return; return;
/* Allocate a Client for this surface */ /* Allocate a Client for this surface */
Client *c = calloc(1, sizeof(*c)); Client *c = xdg_surface->data = calloc(1, sizeof(*c));
c->xdg_surface = xdg_surface; c->xdg_surface = xdg_surface;
c->bw = borderpx; c->bw = borderpx;
struct wlr_box geom; struct wlr_box geom;
@ -1375,11 +1375,7 @@ Monitor *
xytomon(double x, double y) xytomon(double x, double y)
{ {
struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y); struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y);
Monitor *m; return o ? o->data : NULL;
wl_list_for_each(m, &mons, link)
if (m->wlr_output == o)
return m;
return NULL;
} }
int int