commit cfb719d

Michael Forney  ·  2015-05-18 05:58:29 +0000 UTC
parent 0cac681
Fix up some style issues
67 files changed,  +975, -1659
+2, -2
 1@@ -131,8 +131,8 @@ screen_usable_geometry_changed(void *data)
 2 	struct screen *screen = data;
 3 
 4 	/* If the usable geometry of the screen changes, for example when a panel is
 5-     * docked to the edge of the screen, we need to rearrange the windows to
 6-     * ensure they are all within the new usable geometry. */
 7+	 * docked to the edge of the screen, we need to rearrange the windows to
 8+	 * ensure they are all within the new usable geometry. */
 9 	arrange(screen);
10 }
11 
+10, -19
 1@@ -55,8 +55,7 @@
 2 
 3 pid_t child_pid = -1;
 4 
 5-static struct
 6-    {
 7+static struct {
 8 	int socket;
 9 	int input_fds[128];
10 	unsigned num_input_fds;
11@@ -66,8 +65,7 @@ static struct
12 	bool active;
13 } launcher;
14 
15-static struct
16-    {
17+static struct {
18 	bool altered;
19 	int vt;
20 	long kb_mode;
21@@ -109,12 +107,10 @@ stop_devices(bool fatal)
22 	}
23 
24 	for (index = 0; index < launcher.num_input_fds; ++index) {
25-		if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1
26-		    && errno != ENODEV && fatal) {
27+		if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1 && errno != ENODEV && fatal)
28 			die("FATAL: Your kernel does not support EVIOCREVOKE; "
29 			    "input devices cannot be revoked: %s",
30 			    strerror(errno));
31-		}
32 
33 		close(launcher.input_fds[index]);
34 	}
35@@ -136,8 +132,8 @@ cleanup(void)
36 	ioctl(launcher.tty_fd, KDSETMODE, original_vt_state.console_mode);
37 	ioctl(launcher.tty_fd, KDSKBMODE, original_vt_state.kb_mode);
38 
39-	/* Stop devices before switching the VT to make sure we have released the
40-     * DRM device before the next session tries to claim it. */
41+	/* Stop devices before switching the VT to make sure we have released the DRM
42+	 * device before the next session tries to claim it. */
43 	stop_devices(false);
44 	ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
45 
46@@ -236,8 +232,7 @@ handle_socket_data(int socket)
47 
48 	switch (request->type) {
49 	case SWC_LAUNCH_REQUEST_OPEN_DEVICE:
50-		if (request->path[size - __builtin_offsetof(typeof(*request),
51-		                                            path) - 1] != '\0') {
52+		if (request->path[size - __builtin_offsetof(typeof(*request), path) - 1] != '\0') {
53 			fprintf(stderr, "Path is not NULL terminated\n");
54 			goto fail;
55 		}
56@@ -252,15 +247,13 @@ handle_socket_data(int socket)
57 			if (!launcher.active)
58 				goto fail;
59 
60-			if (launcher.num_input_fds
61-			    == ARRAY_LENGTH(launcher.input_fds)) {
62+			if (launcher.num_input_fds == ARRAY_LENGTH(launcher.input_fds)) {
63 				fprintf(stderr, "Too many input devices opened\n");
64 				goto fail;
65 			}
66 			break;
67 		case DRM_MAJOR:
68-			if (launcher.num_drm_fds
69-			    == ARRAY_LENGTH(launcher.drm_fds)) {
70+			if (launcher.num_drm_fds == ARRAY_LENGTH(launcher.drm_fds)) {
71 				fprintf(stderr, "Too many DRM devices opened\n");
72 				goto fail;
73 			}
74@@ -291,10 +284,8 @@ handle_socket_data(int socket)
75 		if (!launcher.active)
76 			goto fail;
77 
78-		if (ioctl(launcher.tty_fd, VT_ACTIVATE, request->vt) == -1) {
79-			fprintf(stderr, "Could not activate VT %d: %s\n",
80-			        request->vt, strerror(errno));
81-		}
82+		if (ioctl(launcher.tty_fd, VT_ACTIVATE, request->vt) == -1)
83+			fprintf(stderr, "Could not activate VT %d: %s\n", request->vt, strerror(errno));
84 		break;
85 	default:
86 		fprintf(stderr, "Unknown request %u\n", request->type);
+15, -26
  1@@ -39,38 +39,33 @@ struct binding {
  2 	void *data;
  3 };
  4 
  5-static bool handle_key(struct keyboard *keyboard, uint32_t time,
  6-                       struct key *key, uint32_t state);
  7+static bool handle_key(struct keyboard *keyboard, uint32_t time, struct key *key, uint32_t state);
  8 
  9 static struct keyboard_handler key_binding_handler = {
 10-	.key = &handle_key
 11+	.key = handle_key,
 12 };
 13 
 14-static bool handle_button(struct pointer_handler *handler, uint32_t time,
 15-                          struct button *button, uint32_t state);
 16+static bool handle_button(struct pointer_handler *handler, uint32_t time, struct button *button, uint32_t state);
 17 
 18 static struct pointer_handler button_binding_handler = {
 19-	.button = &handle_button
 20+	.button = handle_button,
 21 };
 22 
 23 static struct wl_array key_bindings, button_bindings;
 24 
 25 const struct swc_bindings swc_bindings = {
 26 	.keyboard_handler = &key_binding_handler,
 27-	.pointer_handler = &button_binding_handler
 28+	.pointer_handler = &button_binding_handler,
 29 };
 30 
 31 static struct binding *
 32-find_binding(struct wl_array *bindings,
 33-             uint32_t modifiers, uint32_t value)
 34+find_binding(struct wl_array *bindings, uint32_t modifiers, uint32_t value)
 35 {
 36 	struct binding *binding;
 37 
 38 	wl_array_for_each (binding, bindings) {
 39-		if (binding->value == value && (binding->modifiers == modifiers
 40-		                                || binding->modifiers == SWC_MOD_ANY)) {
 41+		if (binding->value == value && (binding->modifiers == modifiers || binding->modifiers == SWC_MOD_ANY))
 42 			return binding;
 43-		}
 44 	}
 45 
 46 	return NULL;
 47@@ -95,8 +90,7 @@ find_key_binding(uint32_t modifiers, uint32_t key)
 48 
 49 	/* Then try the keysym associated with shift-level 0 for the key. */
 50 	layout = xkb_state_key_get_layout(xkb->state, XKB_KEY(key));
 51-	xkb_keymap_key_get_syms_by_level(xkb->keymap.map, XKB_KEY(key),
 52-	                                 layout, 0, &keysyms);
 53+	xkb_keymap_key_get_syms_by_level(xkb->keymap.map, XKB_KEY(key), layout, 0, &keysyms);
 54 
 55 	if (!keysyms)
 56 		return NULL;
 57@@ -113,8 +107,7 @@ find_button_binding(uint32_t modifiers, uint32_t value)
 58 }
 59 
 60 static bool
 61-handle_binding(uint32_t time, struct press *press, uint32_t state,
 62-               struct binding *(*find_binding)(uint32_t, uint32_t))
 63+handle_binding(uint32_t time, struct press *press, uint32_t state, struct binding *(*find_binding)(uint32_t, uint32_t))
 64 {
 65 	struct binding *binding;
 66 
 67@@ -125,8 +118,9 @@ handle_binding(uint32_t time, struct press *press, uint32_t state,
 68 			return false;
 69 
 70 		press->data = binding;
 71-	} else
 72+	} else {
 73 		binding = press->data;
 74+	}
 75 
 76 	binding->handler(binding->data, time, binding->value, state);
 77 
 78@@ -134,15 +128,13 @@ handle_binding(uint32_t time, struct press *press, uint32_t state,
 79 }
 80 
 81 bool
 82-handle_key(struct keyboard *keyboard, uint32_t time,
 83-           struct key *key, uint32_t state)
 84+handle_key(struct keyboard *keyboard, uint32_t time, struct key *key, uint32_t state)
 85 {
 86 	return handle_binding(time, &key->press, state, &find_key_binding);
 87 }
 88 
 89 bool
 90-handle_button(struct pointer_handler *handler, uint32_t time,
 91-              struct button *button, uint32_t state)
 92+handle_button(struct pointer_handler *handler, uint32_t time, struct button *button, uint32_t state)
 93 {
 94 	return handle_binding(time, &button->press, state, &find_button_binding);
 95 }
 96@@ -163,11 +155,8 @@ bindings_finalize(void)
 97 	wl_array_release(&button_bindings);
 98 }
 99 
100-EXPORT
101-int
102-swc_add_binding(enum swc_binding_type type,
103-                uint32_t modifiers, uint32_t value,
104-                swc_binding_handler handler, void *data)
105+EXPORT int
106+swc_add_binding(enum swc_binding_type type, uint32_t modifiers, uint32_t value, swc_binding_handler handler, void *data)
107 {
108 	struct binding *binding;
109 	struct wl_array *bindings;
+85, -140
  1@@ -62,26 +62,22 @@ struct target {
  2 	struct wl_listener screen_destroy_listener;
  3 };
  4 
  5-static bool handle_motion(struct pointer_handler *handler, uint32_t time,
  6-                          wl_fixed_t x, wl_fixed_t y);
  7+static bool handle_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t x, wl_fixed_t y);
  8 static void perform_update(void *data);
  9 
 10 static struct pointer_handler pointer_handler = {
 11-	.motion = &handle_motion
 12+	.motion = handle_motion,
 13 };
 14 
 15-static struct
 16-    {
 17+static struct {
 18 	struct wl_list views;
 19 	pixman_region32_t damage, opaque;
 20 	struct wl_listener swc_listener;
 21 
 22-	/* A mask of screens that have been repainted but are waiting on a page
 23-     * flip. */
 24+	/* A mask of screens that have been repainted but are waiting on a page flip. */
 25 	uint32_t pending_flips;
 26 
 27-	/* A mask of screens that are scheduled to be repainted on the next
 28-     * idle. */
 29+	/* A mask of screens that are scheduled to be repainted on the next idle. */
 30 	uint32_t scheduled_updates;
 31 
 32 	bool updating;
 33@@ -89,7 +85,7 @@ static struct
 34 } compositor;
 35 
 36 struct swc_compositor swc_compositor = {
 37-	.pointer_handler = &pointer_handler
 38+	.pointer_handler = &pointer_handler,
 39 };
 40 
 41 static void
 42@@ -107,8 +103,7 @@ target_get(struct screen *screen)
 43 	struct wl_listener *listener = wl_signal_get(&screen->destroy_signal, &handle_screen_destroy);
 44 	struct target *target;
 45 
 46-	return listener ? wl_container_of(listener, target, screen_destroy_listener)
 47-	                : NULL;
 48+	return listener ? wl_container_of(listener, target, screen_destroy_listener) : NULL;
 49 }
 50 
 51 static void
 52@@ -129,16 +124,16 @@ handle_screen_frame(struct view_handler *handler, uint32_t time)
 53 
 54 	target->current_buffer = target->next_buffer;
 55 
 56-	/* If we had scheduled updates that couldn't run because we were
 57-     * waiting on a page flip, run them now. If the compositor is
 58-     * currently updating, then the frame finished immediately, and we
 59-     * can be sure that there are no pending updates. */
 60+	/* If we had scheduled updates that couldn't run because we were waiting on a
 61+	 * page flip, run them now. If the compositor is currently updating, then the
 62+	 * frame finished immediately, and we can be sure that there are no pending
 63+	 * updates. */
 64 	if (compositor.scheduled_updates && !compositor.updating)
 65 		perform_update(NULL);
 66 }
 67 
 68 static const struct view_handler_impl screen_view_handler = {
 69-	.frame = &handle_screen_frame,
 70+	.frame = handle_screen_frame,
 71 };
 72 
 73 static int
 74@@ -152,15 +147,12 @@ static struct target *
 75 target_new(struct screen *screen)
 76 {
 77 	struct target *target;
 78+	struct swc_rectangle *geom = &screen->base.geometry;
 79 
 80 	if (!(target = malloc(sizeof *target)))
 81 		goto error0;
 82 
 83-	target->surface = wld_create_surface(swc.drm->context,
 84-	                                     screen->base.geometry.width,
 85-	                                     screen->base.geometry.height,
 86-	                                     WLD_FORMAT_XRGB8888,
 87-	                                     WLD_DRM_FLAG_SCANOUT);
 88+	target->surface = wld_create_surface(swc.drm->context, geom->width, geom->height, WLD_FORMAT_XRGB8888, WLD_DRM_FLAG_SCANOUT);
 89 
 90 	if (!target->surface)
 91 		goto error1;
 92@@ -185,17 +177,15 @@ error0:
 93 /* Rendering {{{ */
 94 
 95 static void
 96-repaint_view(struct target *target, struct compositor_view *view,
 97-             pixman_region32_t *damage)
 98+repaint_view(struct target *target, struct compositor_view *view, pixman_region32_t *damage)
 99 {
100 	pixman_region32_t view_region, view_damage, border_damage;
101-	const struct swc_rectangle *geometry = &view->base.geometry;
102+	const struct swc_rectangle *geom = &view->base.geometry, *target_geom = &target->view->geometry;
103 
104 	if (!view->base.buffer)
105 		return;
106 
107-	pixman_region32_init_rect(&view_region, geometry->x, geometry->y,
108-	                          geometry->width, geometry->height);
109+	pixman_region32_init_rect(&view_region, geom->x, geom->y, geom->width, geom->height);
110 	pixman_region32_init_with_extents(&view_damage, &view->extents);
111 	pixman_region32_init(&border_damage);
112 
113@@ -207,19 +197,15 @@ repaint_view(struct target *target, struct compositor_view *view,
114 	pixman_region32_fini(&view_region);
115 
116 	if (pixman_region32_not_empty(&view_damage)) {
117-		pixman_region32_translate(&view_damage, -geometry->x, -geometry->y);
118-		wld_copy_region(swc.drm->renderer, view->buffer,
119-		                geometry->x - target->view->geometry.x,
120-		                geometry->y - target->view->geometry.y, &view_damage);
121+		pixman_region32_translate(&view_damage, -geom->x, -geom->y);
122+		wld_copy_region(swc.drm->renderer, view->buffer, geom->x - target_geom->x, geom->y - target_geom->y, &view_damage);
123 	}
124 
125 	pixman_region32_fini(&view_damage);
126 
127 	/* Draw border */
128 	if (pixman_region32_not_empty(&border_damage)) {
129-		pixman_region32_translate(&border_damage,
130-		                          -target->view->geometry.x,
131-		                          -target->view->geometry.y);
132+		pixman_region32_translate(&border_damage, -target_geom->x, -target_geom->y);
133 		wld_fill_region(swc.drm->renderer, view->border.color, &border_damage);
134 	}
135 
136@@ -227,10 +213,7 @@ repaint_view(struct target *target, struct compositor_view *view,
137 }
138 
139 static void
140-renderer_repaint(struct target *target,
141-                 pixman_region32_t *damage,
142-                 pixman_region32_t *base_damage,
143-                 struct wl_list *views)
144+renderer_repaint(struct target *target, pixman_region32_t *damage, pixman_region32_t *base_damage, struct wl_list *views)
145 {
146 	struct compositor_view *view;
147 
148@@ -242,9 +225,7 @@ renderer_repaint(struct target *target,
149 
150 	/* Paint base damage black. */
151 	if (pixman_region32_not_empty(base_damage)) {
152-		pixman_region32_translate(base_damage,
153-		                          -target->view->geometry.x,
154-		                          -target->view->geometry.y);
155+		pixman_region32_translate(base_damage, -target->view->geometry.x, -target->view->geometry.y);
156 		wld_fill_region(swc.drm->renderer, 0xff000000, base_damage);
157 	}
158 
159@@ -257,28 +238,20 @@ renderer_repaint(struct target *target,
160 }
161 
162 static int
163-renderer_attach(struct compositor_view *view,
164-                struct wld_buffer *client_buffer)
165+renderer_attach(struct compositor_view *view, struct wld_buffer *client_buffer)
166 {
167 	struct wld_buffer *buffer;
168 	bool was_proxy = view->buffer != view->base.buffer;
169-	bool needs_proxy = client_buffer
170-	                   && !(wld_capabilities(swc.drm->renderer,
171-	                                         client_buffer) & WLD_CAPABILITY_READ);
172-	bool resized = view->buffer && client_buffer
173-	               && (view->buffer->width != client_buffer->width
174-	                   || view->buffer->height != client_buffer->height);
175+	bool needs_proxy = client_buffer && !(wld_capabilities(swc.drm->renderer, client_buffer) & WLD_CAPABILITY_READ);
176+	bool resized = view->buffer && client_buffer && (view->buffer->width != client_buffer->width || view->buffer->height != client_buffer->height);
177 
178 	if (client_buffer) {
179-		/* Create a proxy buffer if necessary (for example a hardware buffer
180-         * backing a SHM buffer). */
181+		/* Create a proxy buffer if necessary (for example a hardware buffer backing
182+		 * a SHM buffer). */
183 		if (needs_proxy) {
184 			if (!was_proxy || resized) {
185 				DEBUG("Creating a proxy buffer\n");
186-				buffer = wld_create_buffer(swc.drm->context,
187-				                           client_buffer->width,
188-				                           client_buffer->height,
189-				                           client_buffer->format, WLD_FLAG_MAP);
190+				buffer = wld_create_buffer(swc.drm->context, client_buffer->width, client_buffer->height, client_buffer->format, WLD_FLAG_MAP);
191 
192 				if (!buffer)
193 					return -ENOMEM;
194@@ -286,17 +259,17 @@ renderer_attach(struct compositor_view *view,
195 				/* Otherwise we can keep the original proxy buffer. */
196 				buffer = view->buffer;
197 			}
198-		} else
199+		} else {
200 			buffer = client_buffer;
201-	} else
202+		}
203+	} else {
204 		buffer = NULL;
205+	}
206 
207 	/* If we no longer need a proxy buffer, or the original buffer is of a
208-     * different size, destroy the old proxy image. */
209-	if (view->buffer && ((!needs_proxy && was_proxy)
210-	                     || (needs_proxy && resized))) {
211+	 * different size, destroy the old proxy image. */
212+	if (view->buffer && ((!needs_proxy && was_proxy) || (needs_proxy && resized)))
213 		wld_buffer_unreference(view->buffer);
214-	}
215 
216 	view->buffer = buffer;
217 
218@@ -310,8 +283,7 @@ renderer_flush_view(struct compositor_view *view)
219 		return;
220 
221 	wld_set_target_buffer(swc.shm->renderer, view->buffer);
222-	wld_copy_region(swc.shm->renderer, view->base.buffer,
223-	                0, 0, &view->surface->state.damage);
224+	wld_copy_region(swc.shm->renderer, view->base.buffer, 0, 0, &view->surface->state.damage);
225 	wld_flush(swc.shm->renderer);
226 }
227 
228@@ -330,8 +302,7 @@ damage_below_view(struct compositor_view *view)
229 
230 	pixman_region32_init_with_extents(&damage_below, &view->extents);
231 	pixman_region32_subtract(&damage_below, &damage_below, &view->clip);
232-	pixman_region32_union(&compositor.damage, &compositor.damage,
233-	                      &damage_below);
234+	pixman_region32_union(&compositor.damage, &compositor.damage, &damage_below);
235 	pixman_region32_fini(&damage_below);
236 }
237 
238@@ -350,10 +321,8 @@ update_extents(struct compositor_view *view)
239 {
240 	view->extents.x1 = view->base.geometry.x - view->border.width;
241 	view->extents.y1 = view->base.geometry.y - view->border.width;
242-	view->extents.x2 = view->base.geometry.x + view->base.geometry.width
243-	                   + view->border.width;
244-	view->extents.y2 = view->base.geometry.y + view->base.geometry.height
245-	                   + view->border.width;
246+	view->extents.x2 = view->base.geometry.x + view->base.geometry.width + view->border.width;
247+	view->extents.y2 = view->base.geometry.y + view->base.geometry.height + view->border.width;
248 
249 	/* Damage border. */
250 	view->border.damaged = true;
251@@ -430,8 +399,8 @@ move(struct view *base, int32_t x, int32_t y)
252 		update_extents(view);
253 
254 		if (view->visible) {
255-			/* Assume worst-case no clipping until we draw the next frame (in
256-             * case the surface gets moved again before that). */
257+			/* Assume worst-case no clipping until we draw the next frame (in case the
258+			 * surface gets moved again before that). */
259 			pixman_region32_init(&view->clip);
260 
261 			view_update_screens(&view->base);
262@@ -444,9 +413,9 @@ move(struct view *base, int32_t x, int32_t y)
263 }
264 
265 const static struct view_impl view_impl = {
266-	.update = &update,
267-	.attach = &attach,
268-	.move = &move
269+	.update = update,
270+	.attach = attach,
271+	.move = move,
272 };
273 
274 struct compositor_view *
275@@ -499,8 +468,7 @@ compositor_view(struct view *view)
276 }
277 
278 void
279-compositor_view_set_parent(struct compositor_view *view,
280-                           struct compositor_view *parent)
281+compositor_view_set_parent(struct compositor_view *view, struct compositor_view *parent)
282 {
283 	view->parent = view;
284 
285@@ -522,7 +490,7 @@ compositor_view_show(struct compositor_view *view)
286 	view_update_screens(&view->base);
287 
288 	/* Assume worst-case no clipping until we draw the next frame (in case the
289-     * surface gets moved before that. */
290+	 * surface gets moved before that. */
291 	pixman_region32_clear(&view->clip);
292 	damage_view(view);
293 	update(&view->base);
294@@ -555,8 +523,7 @@ compositor_view_hide(struct compositor_view *view)
295 }
296 
297 void
298-compositor_view_set_border_width(struct compositor_view *view,
299-                                 uint32_t width)
300+compositor_view_set_border_width(struct compositor_view *view, uint32_t width)
301 {
302 	if (view->border.width == width)
303 		return;
304@@ -571,8 +538,7 @@ compositor_view_set_border_width(struct compositor_view *view,
305 }
306 
307 void
308-compositor_view_set_border_color(struct compositor_view *view,
309-                                 uint32_t color)
310+compositor_view_set_border_color(struct compositor_view *view, uint32_t color)
311 {
312 	if (view->border.color == color)
313 		return;
314@@ -591,6 +557,7 @@ static void
315 calculate_damage(void)
316 {
317 	struct compositor_view *view;
318+	struct swc_rectangle *geom;
319 	pixman_region32_t surface_opaque, *surface_damage;
320 
321 	pixman_region32_clear(&compositor.opaque);
322@@ -601,18 +568,17 @@ calculate_damage(void)
323 		if (!view->visible)
324 			continue;
325 
326+		geom = &view->base.geometry;
327+
328 		/* Clip the surface by the opaque region covering it. */
329 		pixman_region32_copy(&view->clip, &compositor.opaque);
330 
331 		/* Translate the opaque region to global coordinates. */
332 		pixman_region32_copy(&surface_opaque, &view->surface->state.opaque);
333-		pixman_region32_translate(&surface_opaque,
334-		                          view->base.geometry.x, view->base.geometry.y);
335+		pixman_region32_translate(&surface_opaque, geom->x, geom->y);
336 
337-		/* Add the surface's opaque region to the accumulated opaque
338-         * region. */
339-		pixman_region32_union(&compositor.opaque, &compositor.opaque,
340-		                      &surface_opaque);
341+		/* Add the surface's opaque region to the accumulated opaque region. */
342+		pixman_region32_union(&compositor.opaque, &compositor.opaque, &surface_opaque);
343 
344 		surface_damage = &view->surface->state.damage;
345 
346@@ -620,11 +586,10 @@ calculate_damage(void)
347 			renderer_flush_view(view);
348 
349 			/* Translate surface damage to global coordinates. */
350-			pixman_region32_translate(surface_damage, view->base.geometry.x, view->base.geometry.y);
351+			pixman_region32_translate(surface_damage, geom->x, geom->y);
352 
353 			/* Add the surface damage to the compositor damage. */
354-			pixman_region32_union(&compositor.damage, &compositor.damage,
355-			                      surface_damage);
356+			pixman_region32_union(&compositor.damage, &compositor.damage, surface_damage);
357 			pixman_region32_clear(surface_damage);
358 		}
359 
360@@ -632,14 +597,11 @@ calculate_damage(void)
361 			pixman_region32_t border_region, view_region;
362 
363 			pixman_region32_init_with_extents(&border_region, &view->extents);
364-			pixman_region32_init_rect(&view_region, view->base.geometry.x, view->base.geometry.y,
365-			                          view->base.geometry.width, view->base.geometry.height);
366+			pixman_region32_init_rect(&view_region, geom->x, geom->y, geom->width, geom->height);
367 
368-			pixman_region32_subtract(&border_region, &border_region,
369-			                         &view_region);
370+			pixman_region32_subtract(&border_region, &border_region, &view_region);
371 
372-			pixman_region32_union(&compositor.damage, &compositor.damage,
373-			                      &border_region);
374+			pixman_region32_union(&compositor.damage, &compositor.damage, &border_region);
375 
376 			pixman_region32_fini(&border_region);
377 			pixman_region32_fini(&view_region);
378@@ -655,7 +617,7 @@ static void
379 update_screen(struct screen *screen)
380 {
381 	struct target *target;
382-	const struct swc_rectangle *geometry = &screen->base.geometry;
383+	const struct swc_rectangle *geom = &screen->base.geometry;
384 	pixman_region32_t damage, *total_damage;
385 
386 	if (!(compositor.scheduled_updates & screen_mask(screen)))
387@@ -665,10 +627,8 @@ update_screen(struct screen *screen)
388 		return;
389 
390 	pixman_region32_init(&damage);
391-	pixman_region32_intersect_rect(&damage, &compositor.damage,
392-	                               geometry->x, geometry->y,
393-	                               geometry->width, geometry->height);
394-	pixman_region32_translate(&damage, -geometry->x, -geometry->y);
395+	pixman_region32_intersect_rect(&damage, &compositor.damage, geom->x, geom->y, geom->width, geom->height);
396+	pixman_region32_translate(&damage, -geom->x, -geom->y);
397 	total_damage = wld_surface_damage(target->surface, &damage);
398 
399 	/* Don't repaint the screen if it is waiting for a page flip. */
400@@ -679,7 +639,7 @@ update_screen(struct screen *screen)
401 
402 	pixman_region32_t base_damage;
403 	pixman_region32_copy(&damage, total_damage);
404-	pixman_region32_translate(&damage, geometry->x, geometry->y);
405+	pixman_region32_translate(&damage, geom->x, geom->y);
406 	pixman_region32_init(&base_damage);
407 	pixman_region32_subtract(&base_damage, &damage, &compositor.opaque);
408 	renderer_repaint(target, &damage, &base_damage, &compositor.views);
409@@ -688,9 +648,8 @@ update_screen(struct screen *screen)
410 
411 	switch (target_swap_buffers(target)) {
412 	case -EACCES:
413-		/* If we get an EACCES, it is because this session is being
414-             * deactivated, but we haven't yet received the deactivate signal
415-             * from swc-launch. */
416+		/* If we get an EACCES, it is because this session is being deactivated, but
417+		 * we haven't yet received the deactivate signal from swc-launch. */
418 		swc_deactivate();
419 		break;
420 	case 0:
421@@ -703,8 +662,7 @@ static void
422 perform_update(void *data)
423 {
424 	struct screen *screen;
425-	uint32_t updates = compositor.scheduled_updates
426-	                   & ~compositor.pending_flips;
427+	uint32_t updates = compositor.scheduled_updates & ~compositor.pending_flips;
428 
429 	if (!swc.active || !updates)
430 		return;
431@@ -724,23 +682,22 @@ perform_update(void *data)
432 }
433 
434 bool
435-handle_motion(struct pointer_handler *handler, uint32_t time,
436-              wl_fixed_t fx, wl_fixed_t fy)
437+handle_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t fx, wl_fixed_t fy)
438 {
439 	struct compositor_view *view;
440 	bool found = false;
441 	int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
442+	struct swc_rectangle *geom;
443 
444 	wl_list_for_each (view, &compositor.views, link) {
445 		if (!view->visible)
446 			continue;
447-
448-		if (rectangle_contains_point(&view->base.geometry, x, y)
449-		    && pixman_region32_contains_point(&view->surface->state.input,
450-		                                      x - view->base.geometry.x,
451-		                                      y - view->base.geometry.y, NULL)) {
452-			found = true;
453-			break;
454+		geom = &view->base.geometry;
455+		if (rectangle_contains_point(geom, x, y)) {
456+			if (pixman_region32_contains_point(&view->surface->state.input, x - geom->x, y - geom->y, NULL)) {
457+				found = true;
458+				break;
459+			}
460 		}
461 	}
462 
463@@ -750,16 +707,14 @@ handle_motion(struct pointer_handler *handler, uint32_t time,
464 }
465 
466 static void
467-handle_terminate(void *data, uint32_t time,
468-                 uint32_t value, uint32_t state)
469+handle_terminate(void *data, uint32_t time, uint32_t value, uint32_t state)
470 {
471 	if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
472 		wl_display_terminate(swc.display);
473 }
474 
475 static void
476-handle_switch_vt(void *data, uint32_t time,
477-                 uint32_t value, uint32_t state)
478+handle_switch_vt(void *data, uint32_t time, uint32_t value, uint32_t state)
479 {
480 	uint8_t vt = value - XKB_KEY_XF86Switch_VT_1 + 1;
481 
482@@ -783,8 +738,7 @@ handle_swc_event(struct wl_listener *listener, void *data)
483 }
484 
485 static void
486-create_surface(struct wl_client *client,
487-               struct wl_resource *resource, uint32_t id)
488+create_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id)
489 {
490 	struct surface *surface;
491 
492@@ -800,8 +754,7 @@ create_surface(struct wl_client *client,
493 }
494 
495 static void
496-create_region(struct wl_client *client,
497-              struct wl_resource *resource, uint32_t id)
498+create_region(struct wl_client *client, struct wl_resource *resource, uint32_t id)
499 {
500 	struct region *region;
501 
502@@ -812,23 +765,20 @@ create_region(struct wl_client *client,
503 }
504 
505 static struct wl_compositor_interface compositor_implementation = {
506-	.create_surface = &create_surface,
507-	.create_region = &create_region
508+	.create_surface = create_surface,
509+	.create_region = create_region,
510 };
511 
512 static void
513-bind_compositor(struct wl_client *client, void *data,
514-                uint32_t version, uint32_t id)
515+bind_compositor(struct wl_client *client, void *data, uint32_t version, uint32_t id)
516 {
517 	struct wl_resource *resource;
518 
519 	if (version > 3)
520 		version = 3;
521 
522-	resource = wl_resource_create(client, &wl_compositor_interface,
523-	                              version, id);
524-	wl_resource_set_implementation(resource, &compositor_implementation,
525-	                               NULL, NULL);
526+	resource = wl_resource_create(client, &wl_compositor_interface, version, id);
527+	wl_resource_set_implementation(resource, &compositor_implementation, NULL, NULL);
528 }
529 
530 bool
531@@ -857,15 +807,10 @@ compositor_initialize(void)
532 	if (swc.active)
533 		schedule_updates(-1);
534 
535-	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_CTRL | SWC_MOD_ALT,
536-	                XKB_KEY_BackSpace, &handle_terminate, NULL);
537+	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_CTRL | SWC_MOD_ALT, XKB_KEY_BackSpace, &handle_terminate, NULL);
538 
539-	for (keysym = XKB_KEY_XF86Switch_VT_1;
540-	     keysym <= XKB_KEY_XF86Switch_VT_12;
541-	     ++keysym) {
542-		swc_add_binding(SWC_BINDING_KEY, SWC_MOD_ANY, keysym,
543-		                &handle_switch_vt, NULL);
544-	}
545+	for (keysym = XKB_KEY_XF86Switch_VT_1; keysym <= XKB_KEY_XF86Switch_VT_12; ++keysym)
546+		swc_add_binding(SWC_BINDING_KEY, SWC_MOD_ANY, keysym, &handle_switch_vt, NULL);
547 
548 	return true;
549 }
+11, -16
 1@@ -31,14 +31,13 @@
 2 
 3 struct swc_compositor {
 4 	struct pointer_handler *const pointer_handler;
 5-	struct
 6-	    {
 7+	struct {
 8 		/**
 9-         * Emitted when a new surface is created.
10-         *
11-         * The data argument of the signal refers to the surface that has been
12-         * created.
13-         */
14+		 * Emitted when a new surface is created.
15+		 *
16+		 * The data argument of the signal refers to the surface that has been
17+		 * created.
18+		 */
19 		struct wl_signal new_surface;
20 	} signal;
21 };
22@@ -60,11 +59,10 @@ struct compositor_view {
23 	pixman_box32_t extents;
24 
25 	/* The region that is covered by opaque regions of surfaces above this
26-     * surface. */
27+	 * surface. */
28 	pixman_region32_t clip;
29 
30-	struct
31-	    {
32+	struct {
33 		uint32_t width;
34 		uint32_t color;
35 		bool damaged;
36@@ -83,15 +81,12 @@ void compositor_view_destroy(struct compositor_view *view);
37  */
38 struct compositor_view *compositor_view(struct view *view);
39 
40-void compositor_view_set_parent(struct compositor_view *view,
41-                                struct compositor_view *parent);
42+void compositor_view_set_parent(struct compositor_view *view, struct compositor_view *parent);
43 
44 void compositor_view_show(struct compositor_view *view);
45 void compositor_view_hide(struct compositor_view *view);
46 
47-void compositor_view_set_border_color(struct compositor_view *view,
48-                                      uint32_t color);
49-void compositor_view_set_border_width(struct compositor_view *view,
50-                                      uint32_t width);
51+void compositor_view_set_border_color(struct compositor_view *view, uint32_t color);
52+void compositor_view_set_border_width(struct compositor_view *view, uint32_t width);
53 
54 #endif
+5, -6
 1@@ -51,7 +51,7 @@ attach(struct view *view, struct wld_buffer *buffer)
 2 		if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object)) {
 3 			ERROR("Could not get export buffer to DRM handle\n");
 4 			/* XXX: Not the best error code, but we don't know better until wld
 5-             * returns an actual error code. */
 6+			 * returns an actual error code. */
 7 			return -EINVAL;
 8 		}
 9 
10@@ -84,9 +84,9 @@ move(struct view *view, int32_t x, int32_t y)
11 }
12 
13 static const struct view_impl view_impl = {
14-	.update = &update,
15-	.attach = &attach,
16-	.move = &move
17+	.update = update,
18+	.attach = attach,
19+	.move = move,
20 };
21 
22 static void
23@@ -104,8 +104,7 @@ handle_swc_event(struct wl_listener *listener, void *data)
24 }
25 
26 bool
27-cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc,
28-                        const struct swc_rectangle *origin)
29+cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc, const struct swc_rectangle *origin)
30 {
31 	plane->origin = origin;
32 	plane->crtc = crtc;
+1, -3
 1@@ -33,9 +33,7 @@ struct cursor_plane {
 2 	struct wl_listener swc_listener;
 3 };
 4 
 5-bool cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc,
 6-                             const struct swc_rectangle *origin);
 7-
 8+bool cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc, const struct swc_rectangle *origin);
 9 void cursor_plane_finalize(struct cursor_plane *plane);
10 
11 #endif
+23, -38
  1@@ -36,9 +36,7 @@ struct data {
  2 };
  3 
  4 static void
  5-offer_accept(struct wl_client *client,
  6-             struct wl_resource *offer,
  7-             uint32_t serial, const char *mime_type)
  8+offer_accept(struct wl_client *client, struct wl_resource *offer, uint32_t serial, const char *mime_type)
  9 {
 10 	struct data *data = wl_resource_get_user_data(offer);
 11 
 12@@ -50,9 +48,7 @@ offer_accept(struct wl_client *client,
 13 }
 14 
 15 static void
 16-offer_receive(struct wl_client *client,
 17-              struct wl_resource *offer,
 18-              const char *mime_type, int fd)
 19+offer_receive(struct wl_client *client, struct wl_resource *offer, const char *mime_type, int fd)
 20 {
 21 	struct data *data = wl_resource_get_user_data(offer);
 22 
 23@@ -65,22 +61,19 @@ offer_receive(struct wl_client *client,
 24 }
 25 
 26 static void
 27-offer_destroy(struct wl_client *client,
 28-              struct wl_resource *offer)
 29+offer_destroy(struct wl_client *client, struct wl_resource *offer)
 30 {
 31 	wl_resource_destroy(offer);
 32 }
 33 
 34 static struct wl_data_offer_interface data_offer_implementation = {
 35-	.accept = &offer_accept,
 36-	.receive = &offer_receive,
 37-	.destroy = &offer_destroy
 38+	.accept = offer_accept,
 39+	.receive = offer_receive,
 40+	.destroy = offer_destroy,
 41 };
 42 
 43 static void
 44-source_offer(struct wl_client *client,
 45-             struct wl_resource *source,
 46-             const char *mime_type)
 47+source_offer(struct wl_client *client, struct wl_resource *source, const char *mime_type)
 48 {
 49 	struct data *data = wl_resource_get_user_data(source);
 50 	char **destination;
 51@@ -90,15 +83,14 @@ source_offer(struct wl_client *client,
 52 }
 53 
 54 static void
 55-source_destroy(struct wl_client *client,
 56-               struct wl_resource *source)
 57+source_destroy(struct wl_client *client, struct wl_resource *source)
 58 {
 59 	wl_resource_destroy(source);
 60 }
 61 
 62 static struct wl_data_source_interface data_source_implementation = {
 63-	.offer = &source_offer,
 64-	.destroy = &source_destroy
 65+	.offer = source_offer,
 66+	.destroy = source_destroy,
 67 };
 68 
 69 static void
 70@@ -113,13 +105,13 @@ data_destroy(struct wl_resource *source)
 71 	wl_array_release(&data->mime_types);
 72 
 73 	/* After this data_source is destroyed, each of the data_offer objects
 74-     * associated with the data_source has a pointer to a free'd struct. We
 75-     * can't destroy the resources because this results in a segfault on the
 76-     * client when it correctly tries to call data_source.destroy. However, a
 77-     * misbehaving client could still attempt to call accept or receive on the
 78-     * data_offer, which would crash the server.
 79-     *
 80-     * So, we clear the user data on each of the offers to protect us. */
 81+	 * associated with the data_source has a pointer to a free'd struct. We can't
 82+	 * destroy the resources because this results in a segfault on the client when
 83+	 * it correctly tries to call data_source.destroy. However, a misbehaving
 84+	 * client could still attempt to call accept or receive on the data_offer,
 85+	 * which would crash the server.
 86+	 *
 87+	 * So, we clear the user data on each of the offers to protect us. */
 88 	wl_resource_for_each (offer, &data->offers) {
 89 		wl_resource_set_user_data(offer, NULL);
 90 		wl_resource_set_destructor(offer, NULL);
 91@@ -145,8 +137,7 @@ data_new(void)
 92 }
 93 
 94 struct wl_resource *
 95-data_source_new(struct wl_client *client,
 96-                uint32_t version, uint32_t id)
 97+data_source_new(struct wl_client *client, uint32_t version, uint32_t id)
 98 {
 99 	struct data *data;
100 
101@@ -156,35 +147,29 @@ data_source_new(struct wl_client *client,
102 		return NULL;
103 
104 	/* Add the data source to the client. */
105-	data->source = wl_resource_create(client, &wl_data_source_interface,
106-	                                  version, id);
107+	data->source = wl_resource_create(client, &wl_data_source_interface, version, id);
108 
109 	/* Destroy the data object when the source disappears. */
110-	wl_resource_set_implementation(data->source, &data_source_implementation,
111-	                               data, &data_destroy);
112+	wl_resource_set_implementation(data->source, &data_source_implementation, data, &data_destroy);
113 
114 	return data->source;
115 }
116 
117 struct wl_resource *
118-data_offer_new(struct wl_client *client,
119-               struct wl_resource *source,
120-               uint32_t version)
121+data_offer_new(struct wl_client *client, struct wl_resource *source, uint32_t version)
122 {
123 	struct data *data = wl_resource_get_user_data(source);
124 	struct wl_resource *offer;
125 
126 	offer = wl_resource_create(client, &wl_data_offer_interface, version, 0);
127-	wl_resource_set_implementation(offer, &data_offer_implementation,
128-	                               data, &remove_resource);
129+	wl_resource_set_implementation(offer, &data_offer_implementation, data, &remove_resource);
130 	wl_list_insert(&data->offers, wl_resource_get_link(offer));
131 
132 	return offer;
133 }
134 
135 void
136-data_send_mime_types(struct wl_resource *source,
137-                     struct wl_resource *offer)
138+data_send_mime_types(struct wl_resource *source, struct wl_resource *offer)
139 {
140 	struct data *data = wl_resource_get_user_data(source);
141 	char **mime_type;
+3, -9
 1@@ -28,14 +28,8 @@
 2 
 3 struct wl_client;
 4 
 5-struct wl_resource *data_source_new(struct wl_client *client,
 6-                                    uint32_t version, uint32_t id);
 7-
 8-struct wl_resource *data_offer_new(struct wl_client *client,
 9-                                   struct wl_resource *source,
10-                                   uint32_t version);
11-
12-void data_send_mime_types(struct wl_resource *source,
13-                          struct wl_resource *offer);
14+struct wl_resource *data_source_new(struct wl_client *client, uint32_t version, uint32_t id);
15+struct wl_resource *data_offer_new(struct wl_client *client, struct wl_resource *source, uint32_t version);
16+void data_send_mime_types(struct wl_resource *source, struct wl_resource *offer);
17 
18 #endif
+13, -27
  1@@ -27,17 +27,14 @@
  2 
  3 static void
  4 start_drag(struct wl_client *client, struct wl_resource *resource,
  5-           struct wl_resource *source_resource,
  6-           struct wl_resource *origin_resource,
  7+           struct wl_resource *source_resource, struct wl_resource *origin_resource,
  8            struct wl_resource *icon_resource, uint32_t serial)
  9 {
 10 	/* XXX: Implement */
 11 }
 12 
 13 static void
 14-set_selection(struct wl_client *client,
 15-              struct wl_resource *resource,
 16-              struct wl_resource *data_source, uint32_t serial)
 17+set_selection(struct wl_client *client, struct wl_resource *resource, struct wl_resource *data_source, uint32_t serial)
 18 {
 19 	struct data_device *data_device = wl_resource_get_user_data(resource);
 20 
 21@@ -52,17 +49,15 @@ set_selection(struct wl_client *client,
 22 
 23 	data_device->selection = data_source;
 24 
 25-	if (data_source) {
 26+	if (data_source)
 27 		wl_resource_add_destroy_listener(data_source, &data_device->selection_destroy_listener);
 28-	}
 29 
 30-	send_event(&data_device->event_signal,
 31-	           DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 32+	send_event(&data_device->event_signal, DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 33 }
 34 
 35 static struct wl_data_device_interface data_device_implementation = {
 36-	.start_drag = &start_drag,
 37-	.set_selection = &set_selection
 38+	.start_drag = start_drag,
 39+	.set_selection = set_selection,
 40 };
 41 
 42 static void
 43@@ -71,8 +66,7 @@ handle_selection_destroy(struct wl_listener *listener, void *data)
 44 	struct data_device *data_device = wl_container_of(listener, data_device, selection_destroy_listener);
 45 
 46 	data_device->selection = NULL;
 47-	send_event(&data_device->event_signal,
 48-	           DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 49+	send_event(&data_device->event_signal, DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 50 }
 51 
 52 bool
 53@@ -95,22 +89,17 @@ data_device_finalize(struct data_device *data_device)
 54 }
 55 
 56 void
 57-data_device_bind(struct data_device *data_device,
 58-                 struct wl_client *client, uint32_t version, uint32_t id)
 59+data_device_bind(struct data_device *data_device, struct wl_client *client, uint32_t version, uint32_t id)
 60 {
 61 	struct wl_resource *resource;
 62 
 63-	resource = wl_resource_create(client, &wl_data_device_interface,
 64-	                              version, id);
 65-	wl_resource_set_implementation(resource, &data_device_implementation,
 66-	                               data_device, &remove_resource);
 67+	resource = wl_resource_create(client, &wl_data_device_interface, version, id);
 68+	wl_resource_set_implementation(resource, &data_device_implementation, data_device, &remove_resource);
 69 	wl_list_insert(&data_device->resources, &resource->link);
 70 }
 71 
 72 static struct wl_resource *
 73-new_offer(struct wl_resource *resource,
 74-          struct wl_client *client,
 75-          struct wl_resource *source)
 76+new_offer(struct wl_resource *resource, struct wl_client *client, struct wl_resource *source)
 77 {
 78 	struct wl_resource *offer;
 79 
 80@@ -122,8 +111,7 @@ new_offer(struct wl_resource *resource,
 81 }
 82 
 83 void
 84-data_device_offer_selection(struct data_device *data_device,
 85-                            struct wl_client *client)
 86+data_device_offer_selection(struct data_device *data_device, struct wl_client *client)
 87 {
 88 	struct wl_resource *resource;
 89 	struct wl_resource *offer;
 90@@ -136,9 +124,7 @@ data_device_offer_selection(struct data_device *data_device,
 91 		return;
 92 
 93 	/* If we don't have a selection, send NULL to the client. */
 94-	offer = data_device->selection
 95-	            ? new_offer(resource, client, data_device->selection)
 96-	            : NULL;
 97+	offer = data_device->selection ? new_offer(resource, client, data_device->selection) : NULL;
 98 
 99 	wl_data_device_send_selection(resource, offer);
100 }
+2, -6
 1@@ -44,11 +44,7 @@ struct data_device {
 2 
 3 bool data_device_initialize(struct data_device *data_device);
 4 void data_device_finalize(struct data_device *data_device);
 5-
 6-void data_device_bind(struct data_device *data_device,
 7-                      struct wl_client *client, uint32_t version, uint32_t id);
 8-
 9-void data_device_offer_selection(struct data_device *data_device,
10-                                 struct wl_client *client);
11+void data_device_bind(struct data_device *data_device, struct wl_client *client, uint32_t version, uint32_t id);
12+void data_device_offer_selection(struct data_device *data_device, struct wl_client *client);
13 
14 #endif
+11, -20
 1@@ -27,50 +27,41 @@
 2 #include "internal.h"
 3 #include "seat.h"
 4 
 5-static struct
 6-    {
 7+static struct {
 8 	struct wl_global *global;
 9 } data_device_manager;
10 
11 static void
12-create_data_source(struct wl_client *client,
13-                   struct wl_resource *resource, uint32_t id)
14+create_data_source(struct wl_client *client, struct wl_resource *resource, uint32_t id)
15 {
16 	struct wl_resource *data_source;
17 
18-	data_source = data_source_new(client,
19-	                              wl_resource_get_version(resource), id);
20+	data_source = data_source_new(client, wl_resource_get_version(resource), id);
21 
22 	if (!data_source)
23 		wl_resource_post_no_memory(resource);
24 }
25 
26 static void
27-get_data_device(struct wl_client *client,
28-                struct wl_resource *resource, uint32_t id,
29-                struct wl_resource *seat_resource)
30+get_data_device(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *seat_resource)
31 {
32-	data_device_bind(swc.seat->data_device, client,
33-	                 wl_resource_get_version(resource), id);
34+	data_device_bind(swc.seat->data_device, client, wl_resource_get_version(resource), id);
35 }
36 
37-static struct wl_data_device_manager_interface
38-    data_device_manager_implementation = {
39-	    .create_data_source = &create_data_source,
40-	    .get_data_device = &get_data_device
41-    };
42+static struct wl_data_device_manager_interface data_device_manager_implementation = {
43+	.create_data_source = create_data_source,
44+	.get_data_device = get_data_device,
45+};
46 
47 static void
48-bind_data_device_manager(struct wl_client *client, void *data,
49-                         uint32_t version, uint32_t id)
50+bind_data_device_manager(struct wl_client *client, void *data, uint32_t version, uint32_t id)
51 {
52 	struct wl_resource *resource;
53 
54 	if (version > 1)
55 		version = 1;
56 
57-	resource = wl_resource_create(client, &wl_data_device_manager_interface,
58-	                              version, id);
59+	resource = wl_resource_create(client, &wl_data_device_manager_interface, version, id);
60 	wl_resource_set_implementation(resource, &data_device_manager_implementation, NULL, NULL);
61 }
62 
+39, -70
  1@@ -46,8 +46,7 @@
  2 
  3 struct swc_drm swc_drm;
  4 
  5-static struct
  6-    {
  7+static struct {
  8 	char path[128];
  9 
 10 	uint32_t taken_ids;
 11@@ -57,51 +56,40 @@ static struct
 12 } drm;
 13 
 14 static void
 15-authenticate(struct wl_client *client,
 16-             struct wl_resource *resource, uint32_t magic)
 17+authenticate(struct wl_client *client, struct wl_resource *resource, uint32_t magic)
 18 {
 19 	wl_drm_send_authenticated(resource);
 20 }
 21 
 22 static void
 23-create_buffer(struct wl_client *client,
 24-              struct wl_resource *resource, uint32_t id,
 25-              uint32_t name, int32_t width, int32_t height,
 26-              uint32_t stride, uint32_t format)
 27+create_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id,
 28+              uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
 29 {
 30-	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_NAME,
 31-	                       "GEM names are not supported, "
 32-	                       "use a PRIME fd instead");
 33+	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_NAME, "GEM names are not supported, use a PRIME fd instead");
 34 }
 35 
 36 static void
 37-create_planar_buffer(struct wl_client *client,
 38-                     struct wl_resource *resource, uint32_t id,
 39-                     uint32_t name, int32_t width, int32_t height,
 40-                     uint32_t format,
 41+create_planar_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id,
 42+                     uint32_t name, int32_t width, int32_t height, uint32_t format,
 43                      int32_t offset0, int32_t stride0,
 44                      int32_t offset1, int32_t stride1,
 45                      int32_t offset2, int32_t stride2)
 46 {
 47-	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT,
 48-	                       "planar buffers are not supported\n");
 49+	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT, "planar buffers are not supported\n");
 50 }
 51 
 52 static void
 53-create_prime_buffer(struct wl_client *client,
 54-                    struct wl_resource *resource, uint32_t id,
 55-                    int32_t fd, int32_t width, int32_t height,
 56-                    uint32_t format,
 57+create_prime_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id,
 58+                    int32_t fd, int32_t width, int32_t height, uint32_t format,
 59                     int32_t offset0, int32_t stride0,
 60                     int32_t offset1, int32_t stride1,
 61                     int32_t offset2, int32_t stride2)
 62 {
 63 	struct wld_buffer *buffer;
 64 	struct wl_resource *buffer_resource;
 65-	union wld_object object = {.i = fd };
 66+	union wld_object object = { .i = fd };
 67 
 68-	buffer = wld_import_buffer(swc.drm->context, WLD_DRM_OBJECT_PRIME_FD,
 69-	                           object, width, height, format, stride0);
 70+	buffer = wld_import_buffer(swc.drm->context, WLD_DRM_OBJECT_PRIME_FD, object, width, height, format, stride0);
 71 	close(fd);
 72 
 73 	if (!buffer)
 74@@ -121,17 +109,16 @@ error0:
 75 }
 76 
 77 static const struct wl_drm_interface drm_implementation = {
 78-	.authenticate = &authenticate,
 79-	.create_buffer = &create_buffer,
 80-	.create_planar_buffer = &create_planar_buffer,
 81-	.create_prime_buffer = &create_prime_buffer
 82+	.authenticate = authenticate,
 83+	.create_buffer = create_buffer,
 84+	.create_planar_buffer = create_planar_buffer,
 85+	.create_prime_buffer = create_prime_buffer,
 86 };
 87 
 88 static int
 89 select_card(const struct dirent *entry)
 90 {
 91 	unsigned num;
 92-
 93 	return sscanf(entry->d_name, "card%u", &num) == 1;
 94 }
 95 
 96@@ -150,8 +137,7 @@ find_primary_drm_device(char *path, size_t size)
 97 		return false;
 98 
 99 	for (index = 0; index < num_cards; ++index) {
100-		snprintf(path, size, "/sys/class/drm/%s/device/boot_vga",
101-		         cards[index]->d_name);
102+		snprintf(path, size, "/sys/class/drm/%s/device/boot_vga", cards[index]->d_name);
103 
104 		if ((file = fopen(path, "r"))) {
105 			ret = fscanf(file, "%hhu", &boot_vga);
106@@ -184,26 +170,20 @@ find_primary_drm_device(char *path, size_t size)
107 }
108 
109 static bool
110-find_available_crtc(drmModeRes *resources,
111-                    drmModeConnector *connector,
112-                    uint32_t taken_crtcs, uint32_t *crtc)
113+find_available_crtc(drmModeRes *resources, drmModeConnector *connector, uint32_t taken_crtcs, int *crtc_index)
114 {
115-	uint32_t encoder_index, crtc_index;
116+	int i, j;
117 	uint32_t possible_crtcs;
118 	drmModeEncoder *encoder;
119 
120-	for (encoder_index = 0;
121-	     encoder_index < connector->count_encoders;
122-	     ++encoder_index) {
123-		encoder = drmModeGetEncoder(swc.drm->fd,
124-		                            connector->encoders[encoder_index]);
125+	for (i = 0; i < connector->count_encoders; ++i) {
126+		encoder = drmModeGetEncoder(swc.drm->fd, connector->encoders[i]);
127 		possible_crtcs = encoder->possible_crtcs;
128 		drmModeFreeEncoder(encoder);
129 
130-		for (crtc_index = 0; crtc_index < resources->count_crtcs; ++crtc_index) {
131-			if ((possible_crtcs & (1 << crtc_index))
132-			    && !(taken_crtcs & (1 << crtc_index))) {
133-				*crtc = crtc_index;
134+		for (j = 0; j < resources->count_crtcs; ++j) {
135+			if ((possible_crtcs & (1 << j)) && !(taken_crtcs & (1 << j))) {
136+				*crtc_index = j;
137 				return true;
138 			}
139 		}
140@@ -225,14 +205,12 @@ find_available_id(uint32_t *id)
141 }
142 
143 static void
144-handle_vblank(int fd, unsigned int sequence, unsigned int sec,
145-              unsigned int usec, void *data)
146+handle_vblank(int fd, unsigned int sequence, unsigned int sec, unsigned int usec, void *data)
147 {
148 }
149 
150 static void
151-handle_page_flip(int fd, unsigned int sequence, unsigned int sec,
152-                 unsigned int usec, void *data)
153+handle_page_flip(int fd, unsigned int sequence, unsigned int sec, unsigned int usec, void *data)
154 {
155 	struct drm_handler *handler = data;
156 
157@@ -241,21 +219,19 @@ handle_page_flip(int fd, unsigned int sequence, unsigned int sec,
158 
159 static drmEventContext event_context = {
160 	.version = DRM_EVENT_CONTEXT_VERSION,
161-	.vblank_handler = &handle_vblank,
162-	.page_flip_handler = &handle_page_flip
163+	.vblank_handler = handle_vblank,
164+	.page_flip_handler = handle_page_flip,
165 };
166 
167 static int
168 handle_data(int fd, uint32_t mask, void *data)
169 {
170 	drmHandleEvent(fd, &event_context);
171-
172 	return 1;
173 }
174 
175 static void
176-bind_drm(struct wl_client *client, void *data, uint32_t version,
177-         uint32_t id)
178+bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
179 {
180 	struct wl_resource *resource;
181 
182@@ -296,20 +272,17 @@ drm_initialize(void)
183 		goto error1;
184 	}
185 
186-	if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d",
187-	             minor(master.st_rdev) + 0x80) >= sizeof drm.path) {
188+	if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d", minor(master.st_rdev) + 0x80) >= sizeof drm.path) {
189 		ERROR("Render node path is too long");
190 		goto error1;
191 	}
192 
193 	if (stat(drm.path, &render) != 0) {
194-		ERROR("Could not stat render node for primary DRM device: %s\n",
195-		      strerror(errno));
196+		ERROR("Could not stat render node for primary DRM device: %s\n", strerror(errno));
197 		goto error1;
198 	}
199 
200-	if (master.st_mode != render.st_mode
201-	    || minor(master.st_rdev) + 0x80 != minor(render.st_rdev)) {
202+	if (master.st_mode != render.st_mode || minor(master.st_rdev) + 0x80 != minor(render.st_rdev)) {
203 		ERROR("Render node does not have expected mode or minor number\n");
204 		goto error1;
205 	}
206@@ -332,8 +305,7 @@ drm_initialize(void)
207 	}
208 
209 	if (!wld_drm_is_dumb(swc.drm->context)) {
210-		drm.global = wl_global_create(swc.display, &wl_drm_interface, 2,
211-		                              NULL, &bind_drm);
212+		drm.global = wl_global_create(swc.display, &wl_drm_interface, 2, NULL, &bind_drm);
213 
214 		if (!drm.global) {
215 			ERROR("Could not create wl_drm global\n");
216@@ -371,7 +343,7 @@ drm_create_screens(struct wl_list *screens)
217 {
218 	drmModeRes *resources;
219 	drmModeConnector *connector;
220-	uint32_t index;
221+	int i;
222 	struct output *output;
223 	uint32_t taken_crtcs = 0;
224 
225@@ -380,18 +352,15 @@ drm_create_screens(struct wl_list *screens)
226 		return false;
227 	}
228 
229-	for (index = 0; index < resources->count_connectors;
230-	     ++index, drmModeFreeConnector(connector)) {
231-		connector = drmModeGetConnector(swc.drm->fd,
232-		                                resources->connectors[index]);
233+	for (i = 0; i < resources->count_connectors; ++i, drmModeFreeConnector(connector)) {
234+		connector = drmModeGetConnector(swc.drm->fd, resources->connectors[i]);
235 
236 		if (connector->connection == DRM_MODE_CONNECTED) {
237-			uint32_t crtc_index;
238+			int crtc_index;
239 			uint32_t id;
240 
241-			if (!find_available_crtc(resources, connector, taken_crtcs,
242-			                         &crtc_index)) {
243-				WARNING("Could not find CRTC for connector %u\n", index);
244+			if (!find_available_crtc(resources, connector, taken_crtcs, &crtc_index)) {
245+				WARNING("Could not find CRTC for connector %d\n", i);
246 				continue;
247 			}
248 
+45, -56
  1@@ -50,47 +50,42 @@ timeval_to_msec(struct timeval *time)
  2 }
  3 
  4 static void
  5-handle_key_event(struct evdev_device *device,
  6-                 struct input_event *input_event)
  7+handle_key_event(struct evdev_device *device, struct input_event *ev)
  8 {
  9-	uint32_t time = timeval_to_msec(&input_event->time);
 10+	uint32_t time = timeval_to_msec(&ev->time);
 11 	uint32_t state;
 12 
 13-	if ((input_event->code >= BTN_MISC && input_event->code <= BTN_GEAR_UP)
 14-	    || input_event->code >= BTN_TRIGGER_HAPPY) {
 15-		state = input_event->value ? WL_POINTER_BUTTON_STATE_PRESSED
 16-		                           : WL_POINTER_BUTTON_STATE_RELEASED;
 17-		device->handler->button(time, input_event->code, state);
 18+	if ((ev->code >= BTN_MISC && ev->code <= BTN_GEAR_UP) || ev->code >= BTN_TRIGGER_HAPPY) {
 19+		state = ev->value ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED;
 20+		device->handler->button(time, ev->code, state);
 21 	} else {
 22-		state = input_event->value ? WL_KEYBOARD_KEY_STATE_PRESSED
 23-		                           : WL_KEYBOARD_KEY_STATE_RELEASED;
 24-		device->handler->key(time, input_event->code, state);
 25+		state = ev->value ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED;
 26+		device->handler->key(time, ev->code, state);
 27 	}
 28 }
 29 
 30 static void
 31-handle_rel_event(struct evdev_device *device,
 32-                 struct input_event *input_event)
 33+handle_rel_event(struct evdev_device *device, struct input_event *ev)
 34 {
 35-	uint32_t time = timeval_to_msec(&input_event->time);
 36+	uint32_t time = timeval_to_msec(&ev->time);
 37 	uint32_t axis, amount;
 38 
 39-	switch (input_event->code) {
 40+	switch (ev->code) {
 41 	case REL_X:
 42-		device->motion.rel.dx += input_event->value;
 43+		device->motion.rel.dx += ev->value;
 44 		device->motion.rel.pending = true;
 45 		return;
 46 	case REL_Y:
 47-		device->motion.rel.dy += input_event->value;
 48+		device->motion.rel.dy += ev->value;
 49 		device->motion.rel.pending = true;
 50 		return;
 51 	case REL_WHEEL:
 52 		axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
 53-		amount = -AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
 54+		amount = -AXIS_STEP_DISTANCE * wl_fixed_from_int(ev->value);
 55 		break;
 56 	case REL_HWHEEL:
 57 		axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
 58-		amount = AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
 59+		amount = AXIS_STEP_DISTANCE * wl_fixed_from_int(ev->value);
 60 		break;
 61 	default:
 62 		return;
 63@@ -100,28 +95,25 @@ handle_rel_event(struct evdev_device *device,
 64 }
 65 
 66 static void
 67-handle_abs_event(struct evdev_device *device,
 68-                 struct input_event *input_event)
 69+handle_abs_event(struct evdev_device *device, struct input_event *input_event)
 70 {
 71 }
 72 
 73-static void (*event_handlers[])(struct evdev_device *device,
 74-                                struct input_event *input_event) = {
 75-	    [EV_KEY] = &handle_key_event,
 76-	    [EV_REL] = &handle_rel_event,
 77-	    [EV_ABS] = &handle_abs_event
 78+static void (*event_handlers[])(struct evdev_device *device, struct input_event *ev) = {
 79+	[EV_KEY] = handle_key_event,
 80+	[EV_REL] = handle_rel_event,
 81+	[EV_ABS] = handle_abs_event,
 82 };
 83 
 84 static bool
 85-is_motion_event(struct input_event *event)
 86+is_motion_event(struct input_event *ev)
 87 {
 88-	return (event->type == EV_REL && (event->code == REL_X || event->code == REL_Y))
 89-	       || (event->type == EV_ABS && (event->code == ABS_X || event->code == ABS_Y));
 90+	return (ev->type == EV_REL && (ev->code == REL_X || ev->code == REL_Y))
 91+	    || (ev->type == EV_ABS && (ev->code == ABS_X || ev->code == ABS_Y));
 92 }
 93 
 94 static void
 95-handle_motion_events(struct evdev_device *device,
 96-                     uint32_t time)
 97+handle_motion_events(struct evdev_device *device, uint32_t time)
 98 {
 99 	if (device->motion.rel.pending) {
100 		wl_fixed_t dx = wl_fixed_from_int(device->motion.rel.dx);
101@@ -136,16 +128,13 @@ handle_motion_events(struct evdev_device *device,
102 }
103 
104 static void
105-handle_event(struct evdev_device *device,
106-             struct input_event *event)
107+handle_event(struct evdev_device *device, struct input_event *ev)
108 {
109-	if (!is_motion_event(event))
110-		handle_motion_events(device, timeval_to_msec(&event->time));
111+	if (!is_motion_event(ev))
112+		handle_motion_events(device, timeval_to_msec(&ev->time));
113 
114-	if (event->type < ARRAY_SIZE(event_handlers)
115-	    && event_handlers[event->type]) {
116-		event_handlers[event->type](device, event);
117-	}
118+	if (ev->type < ARRAY_SIZE(event_handlers) && event_handlers[ev->type])
119+		event_handlers[ev->type](device, ev);
120 }
121 
122 static void
123@@ -162,29 +151,30 @@ handle_data(int fd, uint32_t mask, void *data)
124 {
125 	struct evdev_device *device = data;
126 	struct input_event event;
127-	unsigned flags = device->needs_sync ? LIBEVDEV_READ_FLAG_FORCE_SYNC
128-	                                    : LIBEVDEV_READ_FLAG_NORMAL;
129+	unsigned flags = device->needs_sync ? LIBEVDEV_READ_FLAG_FORCE_SYNC : LIBEVDEV_READ_FLAG_NORMAL;
130 	int ret;
131 
132 	device->needs_sync = false;
133 
134-	while (true) {
135+	for (;;) {
136 		ret = libevdev_next_event(device->dev, flags, &event);
137 
138-		if (ret < 0)
139-			goto done;
140-		else if (ret == LIBEVDEV_READ_STATUS_SUCCESS)
141+		switch (ret) {
142+		case LIBEVDEV_READ_STATUS_SUCCESS:
143 			handle_event(device, &event);
144-		else {
145+			break;
146+		case LIBEVDEV_READ_STATUS_SYNC:
147 			while (ret == LIBEVDEV_READ_STATUS_SYNC) {
148-				ret = libevdev_next_event(device->dev, LIBEVDEV_READ_FLAG_SYNC,
149-				                          &event);
150+				ret = libevdev_next_event(device->dev, LIBEVDEV_READ_FLAG_SYNC, &event);
151 
152 				if (ret < 0)
153 					goto done;
154 
155 				handle_event(device, &event);
156 			}
157+			break;
158+		default:
159+			goto done;
160 		}
161 	}
162 
163@@ -240,8 +230,9 @@ evdev_device_new(const char *path, const struct evdev_device_handler *handler)
164 	}
165 
166 	if (libevdev_has_event_code(device->dev, EV_REL, REL_X)
167-	    && libevdev_has_event_code(device->dev, EV_REL, REL_Y)
168-	    && libevdev_has_event_code(device->dev, EV_KEY, BTN_MOUSE)) {
169+	 && libevdev_has_event_code(device->dev, EV_REL, REL_Y)
170+	 && libevdev_has_event_code(device->dev, EV_KEY, BTN_MOUSE))
171+	{
172 		device->capabilities |= WL_SEAT_CAPABILITY_POINTER;
173 		DEBUG("\tThis device is a pointer\n");
174 	}
175@@ -279,12 +270,10 @@ evdev_device_reopen(struct evdev_device *device)
176 	if (device->source)
177 		close_device(device);
178 
179-	device->fd = launch_open_device(device->path,
180-	                                O_RDWR | O_NONBLOCK | O_CLOEXEC);
181+	device->fd = launch_open_device(device->path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
182 
183 	if (device->fd == -1) {
184-		WARNING("Failed to reopen input device at %s: %s\n",
185-		        device->path, strerror(errno));
186+		WARNING("Failed to reopen input device at %s: %s\n", device->path, strerror(errno));
187 		goto error0;
188 	}
189 
190@@ -293,8 +282,8 @@ evdev_device_reopen(struct evdev_device *device)
191 		goto error1;
192 	}
193 
194-	/* According to libevdev documentation, after changing the fd for the
195-     * device, you should force a sync to bring it's state up to date. */
196+	/* According to libevdev documentation, after changing the fd for the device,
197+	 * you should force a sync to bring it's state up to date. */
198 	device->needs_sync = true;
199 	device->source = wl_event_loop_add_fd(swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
200 
+4, -10
 1@@ -50,12 +50,9 @@ struct evdev_device {
 2 
 3 	const struct evdev_device_handler *handler;
 4 
 5-	struct
 6-	    {
 7-		struct
 8-		    {
 9-			struct
10-			    {
11+	struct {
12+		struct {
13+			struct {
14 				struct input_absinfo x, y;
15 			} info;
16 
17@@ -63,8 +60,7 @@ struct evdev_device {
18 			bool pending;
19 		} abs;
20 
21-		struct
22-		    {
23+		struct {
24 			int32_t dx, dy;
25 			bool pending;
26 		} rel;
27@@ -77,9 +73,7 @@ struct evdev_device {
28 };
29 
30 struct evdev_device *evdev_device_new(const char *path, const struct evdev_device_handler *handler);
31-
32 void evdev_device_destroy(struct evdev_device *device);
33-
34 bool evdev_device_reopen(struct evdev_device *device);
35 
36 #endif
+12, -14
 1@@ -12,28 +12,26 @@
 2  */
 3 struct event {
 4 	/**
 5-     * The type of event that was sent.
 6-     *
 7-     * The meaning of this field depends on the type of object containing the
 8-     * event_signal that passed this event.
 9-     */
10+	 * The type of event that was sent.
11+	 *
12+	 * The meaning of this field depends on the type of object containing the
13+	 * event_signal that passed this event.
14+	 */
15 	uint32_t type;
16 
17 	/**
18-     * Data specific to the event type.
19-     *
20-     * Unless explicitly stated in the description of the event type, this
21-     * value is undefined.
22-     */
23+	 * Data specific to the event type.
24+	 *
25+	 * Unless explicitly stated in the description of the event type, this value
26+	 * is undefined.
27+	 */
28 	void *data;
29 };
30 
31 static inline void
32-send_event(struct wl_signal *signal, uint32_t type,
33-           void *event_data)
34+send_event(struct wl_signal *signal, uint32_t type, void *event_data)
35 {
36-	struct event event = {.type = type, .data = event_data };
37-
38+	struct event event = { .type = type, .data = event_data };
39 	wl_signal_emit(signal, &event);
40 }
41 
+12, -27
  1@@ -45,9 +45,7 @@ struct framebuffer {
  2 };
  3 
  4 static bool
  5-framebuffer_export(struct wld_exporter *exporter,
  6-                   struct wld_buffer *buffer,
  7-                   uint32_t type, union wld_object *object)
  8+framebuffer_export(struct wld_exporter *exporter, struct wld_buffer *buffer, uint32_t type, union wld_object *object)
  9 {
 10 	struct framebuffer *framebuffer = wl_container_of(exporter, framebuffer, exporter);
 11 
 12@@ -103,8 +101,7 @@ attach(struct view *view, struct wld_buffer *buffer)
 13 		if (!(framebuffer = malloc(sizeof *framebuffer)))
 14 			return -ENOMEM;
 15 
 16-		ret = drmModeAddFB(swc.drm->fd, buffer->width, buffer->height, 24, 32,
 17-		                   buffer->pitch, object.u32, &framebuffer->id);
 18+		ret = drmModeAddFB(swc.drm->fd, buffer->width, buffer->height, 24, 32, buffer->pitch, object.u32, &framebuffer->id);
 19 
 20 		if (ret < 0) {
 21 			free(framebuffer);
 22@@ -120,21 +117,17 @@ attach(struct view *view, struct wld_buffer *buffer)
 23 	}
 24 
 25 	if (plane->need_modeset) {
 26-		ret = drmModeSetCrtc(swc.drm->fd, plane->crtc, object.u32, 0, 0,
 27-		                     plane->connectors.data, plane->connectors.size / 4,
 28-		                     &plane->mode.info);
 29+		ret = drmModeSetCrtc(swc.drm->fd, plane->crtc, object.u32, 0, 0, plane->connectors.data, plane->connectors.size / 4, &plane->mode.info);
 30 
 31 		if (ret == 0) {
 32 			wl_event_loop_add_idle(swc.event_loop, &send_frame, plane);
 33 			plane->need_modeset = false;
 34 		} else {
 35-			ERROR("Could not set CRTC to next framebuffer: %s\n",
 36-			      strerror(-ret));
 37+			ERROR("Could not set CRTC to next framebuffer: %s\n", strerror(-ret));
 38 			return ret;
 39 		}
 40 	} else {
 41-		ret = drmModePageFlip(swc.drm->fd, plane->crtc, object.u32,
 42-		                      DRM_MODE_PAGE_FLIP_EVENT, &plane->drm_handler);
 43+		ret = drmModePageFlip(swc.drm->fd, plane->crtc, object.u32, DRM_MODE_PAGE_FLIP_EVENT, &plane->drm_handler);
 44 
 45 		if (ret < 0) {
 46 			ERROR("Page flip failed: %s\n", strerror(errno));
 47@@ -149,21 +142,19 @@ static bool
 48 move(struct view *view, int32_t x, int32_t y)
 49 {
 50 	view_set_position(view, x, y);
 51-
 52 	return true;
 53 }
 54 
 55 const static struct view_impl view_impl = {
 56-	.update = &update,
 57-	.attach = &attach,
 58-	.move = &move
 59+	.update = update,
 60+	.attach = attach,
 61+	.move = move,
 62 };
 63 
 64 static void
 65 handle_page_flip(struct drm_handler *handler, uint32_t time)
 66 {
 67 	struct framebuffer_plane *plane = wl_container_of(handler, plane, drm_handler);
 68-
 69 	view_frame(&plane->view, time);
 70 }
 71 
 72@@ -181,22 +172,17 @@ handle_swc_event(struct wl_listener *listener, void *data)
 73 }
 74 
 75 bool
 76-framebuffer_plane_initialize(struct framebuffer_plane *plane,
 77-                             uint32_t crtc, struct mode *mode,
 78-                             uint32_t *connectors,
 79-                             uint32_t num_connectors)
 80+framebuffer_plane_initialize(struct framebuffer_plane *plane, uint32_t crtc, struct mode *mode, uint32_t *connectors, uint32_t num_connectors)
 81 {
 82 	uint32_t *plane_connectors;
 83 
 84 	if (!(plane->original_crtc_state = drmModeGetCrtc(swc.drm->fd, crtc))) {
 85-		ERROR("Failed to get CRTC state for CRTC %u: %s\n",
 86-		      crtc, strerror(errno));
 87+		ERROR("Failed to get CRTC state for CRTC %u: %s\n", crtc, strerror(errno));
 88 		goto error0;
 89 	}
 90 
 91 	wl_array_init(&plane->connectors);
 92-	plane_connectors = wl_array_add(&plane->connectors,
 93-	                                num_connectors * sizeof connectors[0]);
 94+	plane_connectors = wl_array_add(&plane->connectors, num_connectors * sizeof connectors[0]);
 95 
 96 	if (!plane_connectors) {
 97 		ERROR("Failed to allocate connector array\n");
 98@@ -227,7 +213,6 @@ framebuffer_plane_finalize(struct framebuffer_plane *plane)
 99 {
100 	wl_array_release(&plane->connectors);
101 	drmModeCrtcPtr crtc = plane->original_crtc_state;
102-	drmModeSetCrtc(swc.drm->fd, crtc->crtc_id, crtc->buffer_id,
103-	               crtc->x, crtc->y, NULL, 0, &crtc->mode);
104+	drmModeSetCrtc(swc.drm->fd, crtc->crtc_id, crtc->buffer_id, crtc->x, crtc->y, NULL, 0, &crtc->mode);
105 	drmModeFreeCrtc(crtc);
106 }
+1, -5
 1@@ -40,11 +40,7 @@ struct framebuffer_plane {
 2 	struct wl_listener swc_listener;
 3 };
 4 
 5-bool framebuffer_plane_initialize(struct framebuffer_plane *plane,
 6-                                  uint32_t crtc, struct mode *mode,
 7-                                  uint32_t *connectors,
 8-                                  uint32_t num_connectors);
 9-
10+bool framebuffer_plane_initialize(struct framebuffer_plane *plane, uint32_t crtc, struct mode *mode, uint32_t *connectors, uint32_t num_connectors);
11 void framebuffer_plane_finalize(struct framebuffer_plane *plane);
12 
13 #endif
+11, -24
  1@@ -28,8 +28,7 @@
  2 #include "util.h"
  3 
  4 static inline void
  5-focus(struct input_focus *input_focus,
  6-      struct compositor_view *view)
  7+focus(struct input_focus *input_focus, struct compositor_view *view)
  8 {
  9 	struct wl_resource *resource = NULL;
 10 
 11@@ -39,8 +38,7 @@ focus(struct input_focus *input_focus,
 12 		client = wl_resource_get_client(view->surface->resource);
 13 		resource = wl_resource_find_for_client(&input_focus->resources, client);
 14 
 15-		wl_signal_add(&view->destroy_signal,
 16-		              &input_focus->view_destroy_listener);
 17+		wl_signal_add(&view->destroy_signal, &input_focus->view_destroy_listener);
 18 
 19 		if (resource)
 20 			input_focus->handler->enter(input_focus->handler, resource, view);
 21@@ -56,15 +54,12 @@ unfocus(struct input_focus *input_focus)
 22 	if (input_focus->view)
 23 		wl_list_remove(&input_focus->view_destroy_listener.link);
 24 
 25-	if (input_focus->resource) {
 26-		input_focus->handler->leave(input_focus->handler, input_focus->resource,
 27-		                            input_focus->view);
 28-	}
 29+	if (input_focus->resource)
 30+		input_focus->handler->leave(input_focus->handler, input_focus->resource, input_focus->view);
 31 }
 32 
 33 static void
 34-handle_focus_view_destroy(struct wl_listener *listener,
 35-                          void *data)
 36+handle_focus_view_destroy(struct wl_listener *listener, void *data)
 37 {
 38 	struct input_focus *input_focus = wl_container_of(listener, input_focus, view_destroy_listener);
 39 
 40@@ -73,8 +68,7 @@ handle_focus_view_destroy(struct wl_listener *listener,
 41 }
 42 
 43 bool
 44-input_focus_initialize(struct input_focus *input_focus,
 45-                       struct input_focus_handler *handler)
 46+input_focus_initialize(struct input_focus *input_focus, struct input_focus_handler *handler)
 47 {
 48 	input_focus->resource = NULL;
 49 	input_focus->view = NULL;
 50@@ -94,11 +88,9 @@ input_focus_finalize(struct input_focus *input_focus)
 51 }
 52 
 53 void
 54-input_focus_add_resource(struct input_focus *input_focus,
 55-                         struct wl_resource *resource)
 56+input_focus_add_resource(struct input_focus *input_focus, struct wl_resource *resource)
 57 {
 58-	/* If this new input resource corresponds to our focus, set it as our
 59-     * focus. */
 60+	/* If this new input resource corresponds to our focus, set it as our focus. */
 61 	if (input_focus->view) {
 62 		struct wl_client *client, *surface_client;
 63 
 64@@ -106,8 +98,7 @@ input_focus_add_resource(struct input_focus *input_focus,
 65 		surface_client = wl_resource_get_client(input_focus->view->surface->resource);
 66 
 67 		if (client == surface_client) {
 68-			input_focus->handler->enter(input_focus->handler, resource,
 69-			                            input_focus->view);
 70+			input_focus->handler->enter(input_focus->handler, resource, input_focus->view);
 71 			input_focus->resource = resource;
 72 		}
 73 	}
 74@@ -116,8 +107,7 @@ input_focus_add_resource(struct input_focus *input_focus,
 75 }
 76 
 77 void
 78-input_focus_remove_resource(struct input_focus *input_focus,
 79-                            struct wl_resource *resource)
 80+input_focus_remove_resource(struct input_focus *input_focus, struct wl_resource *resource)
 81 {
 82 	if (resource == input_focus->resource)
 83 		input_focus->resource = NULL;
 84@@ -126,8 +116,7 @@ input_focus_remove_resource(struct input_focus *input_focus,
 85 }
 86 
 87 void
 88-input_focus_set(struct input_focus *input_focus,
 89-                struct compositor_view *view)
 90+input_focus_set(struct input_focus *input_focus, struct compositor_view *view)
 91 {
 92 	struct input_focus_event_data data;
 93 
 94@@ -144,6 +133,4 @@ input_focus_set(struct input_focus *input_focus,
 95 	focus(input_focus, view);
 96 
 97 	send_event(&input_focus->event_signal, INPUT_FOCUS_EVENT_CHANGED, &data);
 98-
 99-	return;
100 }
+6, -18
 1@@ -38,12 +38,8 @@ struct input_focus_event_data {
 2 };
 3 
 4 struct input_focus_handler {
 5-	void (*enter)(struct input_focus_handler *handler,
 6-	              struct wl_resource *resource,
 7-	              struct compositor_view *view);
 8-	void (*leave)(struct input_focus_handler *handler,
 9-	              struct wl_resource *resource,
10-	              struct compositor_view *view);
11+	void (*enter)(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view);
12+	void (*leave)(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view);
13 };
14 
15 struct input_focus {
16@@ -57,19 +53,11 @@ struct input_focus {
17 	struct wl_signal event_signal;
18 };
19 
20-bool input_focus_initialize(struct input_focus *input_focus,
21-                            struct input_focus_handler *input_handler);
22-
23+bool input_focus_initialize(struct input_focus *input_focus, struct input_focus_handler *input_handler);
24 void input_focus_finalize(struct input_focus *input_focus);
25-
26-void input_focus_add_resource(struct input_focus *input_focus,
27-                              struct wl_resource *resource);
28-
29-void input_focus_remove_resource(struct input_focus *input_focus,
30-                                 struct wl_resource *resource);
31-
32-void input_focus_set(struct input_focus *input_focus,
33-                     struct compositor_view *view);
34+void input_focus_add_resource(struct input_focus *input_focus, struct wl_resource *resource);
35+void input_focus_remove_resource(struct input_focus *input_focus, struct wl_resource *resource);
36+void input_focus_set(struct input_focus *input_focus, struct compositor_view *view);
37 
38 /* }}} */
39 
+29, -51
  1@@ -39,23 +39,19 @@
  2 static const int repeat_delay = 500, repeat_rate = 40;
  3 
  4 static void
  5-enter(struct input_focus_handler *handler,
  6-      struct wl_resource *resource, struct compositor_view *view)
  7+enter(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view)
  8 {
  9 	struct keyboard *keyboard = wl_container_of(handler, keyboard, focus_handler);
 10 	struct keyboard_modifier_state *state = &keyboard->modifier_state;
 11 	uint32_t serial;
 12 
 13 	serial = wl_display_next_serial(swc.display);
 14-	wl_keyboard_send_modifiers(resource, serial, state->depressed,
 15-	                           state->locked, state->latched, state->group);
 16-	wl_keyboard_send_enter(resource, serial, view->surface->resource,
 17-	                       &keyboard->client_keys);
 18+	wl_keyboard_send_modifiers(resource, serial, state->depressed, state->locked, state->latched, state->group);
 19+	wl_keyboard_send_enter(resource, serial, view->surface->resource, &keyboard->client_keys);
 20 }
 21 
 22 static void
 23-leave(struct input_focus_handler *handler,
 24-      struct wl_resource *resource, struct compositor_view *view)
 25+leave(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view)
 26 {
 27 	uint32_t serial;
 28 
 29@@ -64,8 +60,7 @@ leave(struct input_focus_handler *handler,
 30 }
 31 
 32 static bool
 33-client_handle_key(struct keyboard *keyboard, uint32_t time,
 34-                  struct key *key, uint32_t state)
 35+client_handle_key(struct keyboard *keyboard, uint32_t time, struct key *key, uint32_t state)
 36 {
 37 	uint32_t *value;
 38 
 39@@ -83,10 +78,8 @@ client_handle_key(struct keyboard *keyboard, uint32_t time,
 40 		}
 41 	}
 42 
 43-	if (keyboard->focus.resource) {
 44-		wl_keyboard_send_key(keyboard->focus.resource, key->press.serial, time,
 45-		                     key->press.value, state);
 46-	}
 47+	if (keyboard->focus.resource)
 48+		wl_keyboard_send_key(keyboard->focus.resource, key->press.serial, time, key->press.value, state);
 49 
 50 	return true;
 51 }
 52@@ -104,9 +97,7 @@ client_handle_modifiers(struct keyboard *keyboard, const struct keyboard_modifie
 53 	client = wl_resource_get_client(keyboard->focus.resource);
 54 	display = wl_client_get_display(client);
 55 	serial = wl_display_next_serial(display);
 56-	wl_keyboard_send_modifiers(keyboard->focus.resource, serial,
 57-	                           state->depressed, state->locked, state->latched,
 58-	                           state->group);
 59+	wl_keyboard_send_modifiers(keyboard->focus.resource, serial, state->depressed, state->locked, state->latched, state->group);
 60 
 61 	return true;
 62 }
 63@@ -160,16 +151,15 @@ keyboard_reset(struct keyboard *keyboard)
 64 	wl_array_for_each (key, &keyboard->keys) {
 65 		if (key->handler) {
 66 			key->press.serial = wl_display_next_serial(swc.display);
 67-			key->handler->key(keyboard, time, key,
 68-			                  WL_KEYBOARD_KEY_STATE_RELEASED);
 69-			/* Don't bother updating the XKB state because we will be resetting
 70-             * it later on and it is unlikely that a key handler cares about the
 71-             * keyboard state for release events. */
 72+			key->handler->key(keyboard, time, key, WL_KEYBOARD_KEY_STATE_RELEASED);
 73+			/* Don't bother updating the XKB state because we will be resetting it
 74+			 * later on and it is unlikely that a key handler cares about the keyboard
 75+			 * state for release events. */
 76 		}
 77 	}
 78 
 79 	/* We should have removed all the client keys by calling the client key
 80-     * handler. */
 81+	 * handler. */
 82 	assert(keyboard->client_keys.size == 0);
 83 	keyboard->keys.size = 0;
 84 	keyboard->modifier_state = (struct keyboard_modifier_state){};
 85@@ -181,8 +171,7 @@ keyboard_reset(struct keyboard *keyboard)
 86  * Sets the focus of the keyboard to the specified surface.
 87  */
 88 void
 89-keyboard_set_focus(struct keyboard *keyboard,
 90-                   struct compositor_view *view)
 91+keyboard_set_focus(struct keyboard *keyboard, struct compositor_view *view)
 92 {
 93 	input_focus_set(&keyboard->focus, view);
 94 }
 95@@ -194,46 +183,36 @@ release(struct wl_client *client, struct wl_resource *resource)
 96 }
 97 
 98 static struct wl_keyboard_interface keyboard_implementation = {
 99-	.release = &release,
100+	.release = release,
101 };
102 
103 static void
104 unbind(struct wl_resource *resource)
105 {
106 	struct keyboard *keyboard = wl_resource_get_user_data(resource);
107-
108 	input_focus_remove_resource(&keyboard->focus, resource);
109 }
110 
111 struct wl_resource *
112-keyboard_bind(struct keyboard *keyboard,
113-              struct wl_client *client,
114-              uint32_t version, uint32_t id)
115+keyboard_bind(struct keyboard *keyboard, struct wl_client *client, uint32_t version, uint32_t id)
116 {
117 	struct wl_resource *client_resource;
118 
119-	client_resource = wl_resource_create(client, &wl_keyboard_interface,
120-	                                     version, id);
121-	wl_resource_set_implementation(client_resource, &keyboard_implementation,
122-	                               keyboard, &unbind);
123+	client_resource = wl_resource_create(client, &wl_keyboard_interface, version, id);
124+	wl_resource_set_implementation(client_resource, &keyboard_implementation, keyboard, &unbind);
125 	input_focus_add_resource(&keyboard->focus, client_resource);
126 
127 	/* Subtract one to remove terminating NULL character. */
128-	wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
129-	                        keyboard->xkb.keymap.fd,
130-	                        keyboard->xkb.keymap.size - 1);
131+	wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keyboard->xkb.keymap.fd, keyboard->xkb.keymap.size - 1);
132 
133-	if (version >= 4) {
134-		wl_keyboard_send_repeat_info(client_resource,
135-		                             repeat_rate, repeat_delay);
136-	}
137+	if (version >= 4)
138+		wl_keyboard_send_repeat_info(client_resource, repeat_rate, repeat_delay);
139 
140 	return client_resource;
141 }
142 
143 void
144-keyboard_handle_key(struct keyboard *keyboard, uint32_t time,
145-                    uint32_t value, uint32_t state)
146+keyboard_handle_key(struct keyboard *keyboard, uint32_t time, uint32_t value, uint32_t state)
147 {
148 	struct key *key;
149 	struct keyboard_modifier_state modifier_state;
150@@ -280,10 +259,9 @@ keyboard_handle_key(struct keyboard *keyboard, uint32_t time,
151 		}
152 	}
153 
154-/* Update XKB state. */
155+	/* Update XKB state. */
156 update_xkb_state:
157-	direction = state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN
158-	                                                   : XKB_KEY_UP;
159+	direction = state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP;
160 	xkb_state_update_key(xkb->state, XKB_KEY(value), direction);
161 
162 	modifier_state.depressed = xkb_state_serialize_mods(xkb->state, XKB_STATE_DEPRESSED);
163@@ -292,11 +270,11 @@ update_xkb_state:
164 	modifier_state.group = xkb_state_serialize_layout(xkb->state, XKB_STATE_LAYOUT_EFFECTIVE);
165 
166 	if (modifier_state.depressed != keyboard->modifier_state.depressed
167-	    || modifier_state.latched != keyboard->modifier_state.latched
168-	    || modifier_state.locked != keyboard->modifier_state.locked
169-	    || modifier_state.group != keyboard->modifier_state.group) {
170-		uint32_t mods_active = modifier_state.depressed
171-		                       | modifier_state.latched;
172+	 || modifier_state.latched != keyboard->modifier_state.latched
173+	 || modifier_state.locked != keyboard->modifier_state.locked
174+	 || modifier_state.group != keyboard->modifier_state.group)
175+	{
176+		uint32_t mods_active = modifier_state.depressed | modifier_state.latched;
177 
178 		/* Update keyboard modifier state. */
179 		keyboard->modifier_state = modifier_state;
+5, -11
 1@@ -45,10 +45,8 @@ struct keyboard_modifier_state {
 2 };
 3 
 4 struct keyboard_handler {
 5-	bool (*key)(struct keyboard *keyboard, uint32_t time,
 6-	            struct key *key, uint32_t state);
 7-	bool (*modifiers)(struct keyboard *keyboard,
 8-	                  const struct keyboard_modifier_state *state);
 9+	bool (*key)(struct keyboard *keyboard, uint32_t time, struct key *key, uint32_t state);
10+	bool (*modifiers)(struct keyboard *keyboard, const struct keyboard_modifier_state *state);
11 
12 	struct wl_list link;
13 };
14@@ -70,12 +68,8 @@ struct keyboard {
15 bool keyboard_initialize(struct keyboard *keyboard);
16 void keyboard_finalize(struct keyboard *keyboard);
17 void keyboard_reset(struct keyboard *keyboard);
18-void keyboard_set_focus(struct keyboard *keyboard,
19-                        struct compositor_view *view);
20-struct wl_resource *keyboard_bind(struct keyboard *keyboard,
21-                                  struct wl_client *client,
22-                                  uint32_t version, uint32_t id);
23-void keyboard_handle_key(struct keyboard *keyboard, uint32_t time,
24-                         uint32_t key, uint32_t state);
25+void keyboard_set_focus(struct keyboard *keyboard, struct compositor_view *view);
26+struct wl_resource *keyboard_bind(struct keyboard *keyboard, struct wl_client *client, uint32_t version, uint32_t id);
27+void keyboard_handle_key(struct keyboard *keyboard, uint32_t time, uint32_t key, uint32_t state);
28 
29 #endif
+4, -12
 1@@ -30,8 +30,7 @@
 2 #include <unistd.h>
 3 #include <wayland-server.h>
 4 
 5-static struct
 6-    {
 7+static struct {
 8 	int socket;
 9 	struct wl_event_source *source;
10 	uint32_t next_serial;
11@@ -61,7 +60,6 @@ handle_data(int fd, uint32_t mask, void *data)
12 
13 	if (receive_fd(fd, NULL, &event, sizeof event) != -1)
14 		handle_event(&event);
15-
16 	return 1;
17 }
18 
19@@ -78,8 +76,7 @@ launch_initialize(void)
20 	if (*end != '\0')
21 		return false;
22 
23-	launch.source = wl_event_loop_add_fd(swc.event_loop, launch.socket,
24-	                                     WL_EVENT_READABLE, &handle_data, NULL);
25+	launch.source = wl_event_loop_add_fd(swc.event_loop, launch.socket, WL_EVENT_READABLE, &handle_data, NULL);
26 
27 	if (!launch.source)
28 		return false;
29@@ -95,9 +92,7 @@ launch_finalize(void)
30 }
31 
32 static bool
33-send_request(struct swc_launch_request *request, size_t size,
34-             struct swc_launch_event *event,
35-             int out_fd, int *in_fd)
36+send_request(struct swc_launch_request *request, size_t size, struct swc_launch_event *event, int out_fd, int *in_fd)
37 {
38 	request->serial = ++launch.next_serial;
39 
40@@ -105,11 +100,8 @@ send_request(struct swc_launch_request *request, size_t size,
41 		return false;
42 
43 	while (receive_fd(launch.socket, in_fd, event, sizeof *event) != -1) {
44-		if (event->type == SWC_LAUNCH_EVENT_RESPONSE
45-		    && event->serial == request->serial) {
46+		if (event->type == SWC_LAUNCH_EVENT_RESPONSE && event->serial == request->serial)
47 			return true;
48-		}
49-
50 		handle_event(event);
51 	}
52 
+0, -1
1@@ -29,7 +29,6 @@
2 
3 bool launch_initialize(void);
4 void launch_finalize(void);
5-
6 int launch_open_device(const char *path, int flags);
7 bool launch_activate_vt(unsigned vt);
8 
+2, -4
 1@@ -30,9 +30,7 @@ mode_initialize(struct mode *mode, drmModeModeInfo *mode_info)
 2 	mode->height = mode_info->vdisplay;
 3 	mode->refresh = mode_info->vrefresh * 1000;
 4 	mode->preferred = mode_info->type & DRM_MODE_TYPE_PREFERRED;
 5-
 6 	mode->info = *mode_info;
 7-
 8 	return true;
 9 }
10 
11@@ -45,6 +43,6 @@ bool
12 mode_equal(const struct mode *mode1, const struct mode *mode2)
13 {
14 	return mode1->width == mode2->width
15-	       && mode1->height == mode2->height
16-	       && mode1->refresh == mode2->refresh;
17+	    && mode1->height == mode2->height
18+	    && mode1->refresh == mode2->refresh;
19 }
+0, -1
1@@ -42,7 +42,6 @@ struct mode {
2 
3 bool mode_initialize(struct mode *mode, drmModeModeInfo *mode_info);
4 void mode_finish(struct mode *mode);
5-
6 bool mode_equal(const struct mode *mode1, const struct mode *mode2);
7 
8 #endif
+10, -13
 1@@ -12,8 +12,7 @@
 2 #include <xf86drm.h>
 3 
 4 static void
 5-bind_output(struct wl_client *client, void *data,
 6-            uint32_t version, uint32_t id)
 7+bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 8 {
 9 	struct output *output = data;
10 	struct screen *screen = output->screen;
11@@ -35,8 +34,8 @@ bind_output(struct wl_client *client, void *data,
12 	wl_list_insert(&output->resources, wl_resource_get_link(resource));
13 
14 	wl_output_send_geometry(resource, screen->base.geometry.x, screen->base.geometry.y,
15-	                        output->physical_width, output->physical_height, 0, "unknown",
16-	                        "unknown", WL_OUTPUT_TRANSFORM_NORMAL);
17+	                        output->physical_width, output->physical_height,
18+	                        0, "unknown", "unknown", WL_OUTPUT_TRANSFORM_NORMAL);
19 
20 	wl_array_for_each (mode, &output->modes) {
21 		flags = 0;
22@@ -45,8 +44,7 @@ bind_output(struct wl_client *client, void *data,
23 		if (mode_equal(&screen->planes.framebuffer.mode, mode))
24 			flags |= WL_OUTPUT_MODE_CURRENT;
25 
26-		wl_output_send_mode(resource, flags,
27-		                    mode->width, mode->height, mode->refresh);
28+		wl_output_send_mode(resource, flags, mode->width, mode->height, mode->refresh);
29 	}
30 
31 	if (version >= 2)
32@@ -58,15 +56,14 @@ output_new(drmModeConnectorPtr connector)
33 {
34 	struct output *output;
35 	struct mode *modes;
36-	uint32_t index;
37+	uint32_t i;
38 
39 	if (!(output = malloc(sizeof *output))) {
40 		ERROR("Failed to allocated output\n");
41 		goto error0;
42 	}
43 
44-	output->global = wl_global_create(swc.display, &wl_output_interface, 2,
45-	                                  output, &bind_output);
46+	output->global = wl_global_create(swc.display, &wl_output_interface, 2, output, &bind_output);
47 
48 	if (!output->global) {
49 		ERROR("Failed to create output global\n");
50@@ -88,11 +85,11 @@ output_new(drmModeConnectorPtr connector)
51 	if (!modes)
52 		goto error2;
53 
54-	for (index = 0; index < connector->count_modes; ++index) {
55-		mode_initialize(&modes[index], &connector->modes[index]);
56+	for (i = 0; i < connector->count_modes; ++i) {
57+		mode_initialize(&modes[i], &connector->modes[i]);
58 
59-		if (modes[index].preferred)
60-			output->preferred_mode = &modes[index];
61+		if (modes[i].preferred)
62+			output->preferred_mode = &modes[i];
63 	}
64 
65 	return output;
+29, -44
  1@@ -53,8 +53,7 @@ static void
  2 update_position(struct panel *panel)
  3 {
  4 	int32_t x, y;
  5-	struct swc_rectangle *screen = &panel->screen->base.geometry,
  6-	                     *view = &panel->view->base.geometry;
  7+	struct swc_rectangle *screen = &panel->screen->base.geometry, *view = &panel->view->base.geometry;
  8 
  9 	switch (panel->edge) {
 10 	case SWC_PANEL_EDGE_TOP:
 11@@ -81,17 +80,17 @@ update_position(struct panel *panel)
 12 }
 13 
 14 static void
 15-dock(struct wl_client *client, struct wl_resource *resource,
 16-     uint32_t edge, struct wl_resource *screen_resource,
 17-     uint32_t focus)
 18+dock(struct wl_client *client, struct wl_resource *resource, uint32_t edge, struct wl_resource *screen_resource, uint32_t focus)
 19 {
 20 	struct panel *panel = wl_resource_get_user_data(resource);
 21-	struct screen *screen = screen_resource
 22-	                            ? wl_resource_get_user_data(screen_resource)
 23-	                            : wl_container_of(swc.screens.next, screen, link);
 24-	bool screen_changed = screen != panel->screen;
 25+	struct screen *screen;
 26 	uint32_t length;
 27 
 28+	if (screen_resource)
 29+		screen = wl_resource_get_user_data(screen_resource);
 30+	else
 31+		screen = wl_container_of(swc.screens.next, screen, link);
 32+
 33 	switch (edge) {
 34 	case SWC_PANEL_EDGE_TOP:
 35 	case SWC_PANEL_EDGE_BOTTOM:
 36@@ -105,7 +104,7 @@ dock(struct wl_client *client, struct wl_resource *resource,
 37 		return;
 38 	}
 39 
 40-	if (panel->screen && screen_changed) {
 41+	if (panel->screen && screen != panel->screen) {
 42 		wl_list_remove(&panel->modifier.link);
 43 		screen_update_usable_geometry(panel->screen);
 44 	}
 45@@ -125,56 +124,51 @@ dock(struct wl_client *client, struct wl_resource *resource,
 46 }
 47 
 48 static void
 49-set_offset(struct wl_client *client, struct wl_resource *resource,
 50-           uint32_t offset)
 51+set_offset(struct wl_client *client, struct wl_resource *resource, uint32_t offset)
 52 {
 53 	struct panel *panel = wl_resource_get_user_data(resource);
 54 
 55 	panel->offset = offset;
 56-
 57 	if (panel->docked)
 58 		update_position(panel);
 59 }
 60 
 61 static void
 62-set_strut(struct wl_client *client, struct wl_resource *resource,
 63-          uint32_t size, uint32_t begin, uint32_t end)
 64+set_strut(struct wl_client *client, struct wl_resource *resource, uint32_t size, uint32_t begin, uint32_t end)
 65 {
 66 	struct panel *panel = wl_resource_get_user_data(resource);
 67 
 68 	panel->strut_size = size;
 69-
 70 	if (panel->docked)
 71 		screen_update_usable_geometry(panel->screen);
 72 }
 73 
 74 static const struct swc_panel_interface panel_implementation = {
 75-	.dock = &dock,
 76-	.set_offset = &set_offset,
 77-	.set_strut = &set_strut
 78+	.dock = dock,
 79+	.set_offset = set_offset,
 80+	.set_strut = set_strut,
 81 };
 82 
 83 static void
 84-handle_resize(struct view_handler *handler,
 85-              uint32_t old_width, uint32_t old_height)
 86+handle_resize(struct view_handler *handler, uint32_t old_width, uint32_t old_height)
 87 {
 88 	struct panel *panel = wl_container_of(handler, panel, view_handler);
 89-
 90 	update_position(panel);
 91 }
 92 
 93 static const struct view_handler_impl view_handler_impl = {
 94-	.resize = &handle_resize,
 95+	.resize = handle_resize,
 96 };
 97 
 98 static void
 99-modify(struct screen_modifier *modifier,
100-       const struct swc_rectangle *geometry,
101-       pixman_region32_t *usable)
102+modify(struct screen_modifier *modifier, const struct swc_rectangle *geom, pixman_region32_t *usable)
103 {
104 	struct panel *panel = wl_container_of(modifier, panel, modifier);
105 	pixman_box32_t box = {
106-		.x1 = geometry->x, .y1 = geometry->y, .x2 = geometry->x + geometry->width, .y2 = geometry->y + geometry->height
107+		.x1 = geom->x,
108+		.y1 = geom->y,
109+		.x2 = geom->x + geom->width,
110+		.y2 = geom->y + geom->height
111 	};
112 
113 	assert(panel->docked);
114@@ -184,18 +178,16 @@ modify(struct screen_modifier *modifier,
115 
116 	switch (panel->edge) {
117 	case SWC_PANEL_EDGE_TOP:
118-		box.y1 = MAX(box.y1, geometry->y + panel->strut_size);
119+		box.y1 = MAX(box.y1, geom->y + panel->strut_size);
120 		break;
121 	case SWC_PANEL_EDGE_BOTTOM:
122-		box.y2 = MIN(box.y2, geometry->y + geometry->height
123-		                         - panel->strut_size);
124+		box.y2 = MIN(box.y2, geom->y + geom->height - panel->strut_size);
125 		break;
126 	case SWC_PANEL_EDGE_LEFT:
127-		box.x1 = MAX(box.x1, geometry->x + panel->strut_size);
128+		box.x1 = MAX(box.x1, geom->x + panel->strut_size);
129 		break;
130 	case SWC_PANEL_EDGE_RIGHT:
131-		box.x2 = MIN(box.x2, geometry->x + geometry->width
132-		                         - panel->strut_size);
133+		box.x2 = MIN(box.x2, geom->x + geom->width - panel->strut_size);
134 		break;
135 	}
136 
137@@ -223,13 +215,11 @@ static void
138 handle_surface_destroy(struct wl_listener *listener, void *data)
139 {
140 	struct panel *panel = wl_container_of(listener, panel, surface_destroy_listener);
141-
142 	wl_resource_destroy(panel->resource);
143 }
144 
145 struct panel *
146-panel_new(struct wl_client *client, uint32_t version,
147-          uint32_t id, struct surface *surface)
148+panel_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface)
149 {
150 	struct panel *panel;
151 
152@@ -238,8 +228,7 @@ panel_new(struct wl_client *client, uint32_t version,
153 	if (!panel)
154 		goto error0;
155 
156-	panel->resource = wl_resource_create(client, &swc_panel_interface,
157-	                                     version, id);
158+	panel->resource = wl_resource_create(client, &swc_panel_interface, version, id);
159 
160 	if (!panel->resource)
161 		goto error1;
162@@ -247,9 +236,7 @@ panel_new(struct wl_client *client, uint32_t version,
163 	if (!(panel->view = compositor_create_view(surface)))
164 		goto error2;
165 
166-	wl_resource_set_implementation(panel->resource, &panel_implementation,
167-	                               panel, &destroy_panel);
168-
169+	wl_resource_set_implementation(panel->resource, &panel_implementation, panel, &destroy_panel);
170 	panel->surface_destroy_listener.notify = &handle_surface_destroy;
171 	panel->view_handler.impl = &view_handler_impl;
172 	panel->modifier.modify = &modify;
173@@ -257,10 +244,8 @@ panel_new(struct wl_client *client, uint32_t version,
174 	panel->offset = 0;
175 	panel->strut_size = 0;
176 	panel->docked = false;
177-
178 	wl_list_insert(&panel->view->base.handlers, &panel->view_handler.link);
179-	wl_resource_add_destroy_listener(surface->resource,
180-	                                 &panel->surface_destroy_listener);
181+	wl_resource_add_destroy_listener(surface->resource, &panel->surface_destroy_listener);
182 
183 	return panel;
184 
+4, -5
 1@@ -24,12 +24,11 @@
 2 #ifndef SWC_PANEL_H
 3 #define SWC_PANEL_H
 4 
 5-#include "screen.h"
 6+#include <stdint.h>
 7 
 8-#include <stdbool.h>
 9-#include <wayland-server.h>
10+struct surface;
11+struct wl_client;
12 
13-struct panel *panel_new(struct wl_client *client, uint32_t version,
14-                        uint32_t id, struct surface *surface);
15+struct panel *panel_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface);
16 
17 #endif
+7, -17
 1@@ -28,15 +28,12 @@
 2 #include <wayland-server.h>
 3 #include "protocol/swc-server-protocol.h"
 4 
 5-static struct
 6-    {
 7+static struct {
 8 	struct wl_global *global;
 9 } panel_manager;
10 
11 static void
12-create_panel(struct wl_client *client,
13-             struct wl_resource *resource, uint32_t id,
14-             struct wl_resource *surface_resource)
15+create_panel(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
16 {
17 	struct surface *surface = wl_resource_get_user_data(surface_resource);
18 
19@@ -45,30 +42,25 @@ create_panel(struct wl_client *client,
20 }
21 
22 static const struct swc_panel_manager_interface panel_manager_implementation = {
23-	.create_panel = &create_panel
24+	.create_panel = create_panel,
25 };
26 
27 static void
28-bind_panel_manager(struct wl_client *client, void *data,
29-                   uint32_t version, uint32_t id)
30+bind_panel_manager(struct wl_client *client, void *data, uint32_t version, uint32_t id)
31 {
32 	struct wl_resource *resource;
33 
34 	if (version > 1)
35 		version = 1;
36 
37-	resource = wl_resource_create(client, &swc_panel_manager_interface,
38-	                              version, id);
39-	wl_resource_set_implementation(resource, &panel_manager_implementation,
40-	                               NULL, NULL);
41+	resource = wl_resource_create(client, &swc_panel_manager_interface, version, id);
42+	wl_resource_set_implementation(resource, &panel_manager_implementation, NULL, NULL);
43 }
44 
45 bool
46 panel_manager_initialize(void)
47 {
48-	panel_manager.global = wl_global_create(swc.display,
49-	                                        &swc_panel_manager_interface, 1,
50-	                                        NULL, &bind_panel_manager);
51+	panel_manager.global = wl_global_create(swc.display, &swc_panel_manager_interface, 1, NULL, &bind_panel_manager);
52 
53 	if (!panel_manager.global)
54 		return false;
55@@ -81,5 +73,3 @@ panel_manager_finalize(void)
56 {
57 	wl_global_destroy(panel_manager.global);
58 }
59-
60-// vim: fdm=syntax fo=croql et sw=4 sts=4 ts=8
+55, -83
  1@@ -35,8 +35,7 @@
  2 #include <wld/wld.h>
  3 
  4 static void
  5-enter(struct input_focus_handler *handler,
  6-      struct wl_resource *resource, struct compositor_view *view)
  7+enter(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view)
  8 {
  9 	struct pointer *pointer = wl_container_of(handler, pointer, focus_handler);
 10 	uint32_t serial;
 11@@ -45,24 +44,20 @@ enter(struct input_focus_handler *handler,
 12 	serial = wl_display_next_serial(swc.display);
 13 	surface_x = pointer->x - wl_fixed_from_int(view->base.geometry.x);
 14 	surface_y = pointer->y - wl_fixed_from_int(view->base.geometry.y);
 15-	wl_pointer_send_enter(resource, serial, view->surface->resource,
 16-	                      surface_x, surface_y);
 17+	wl_pointer_send_enter(resource, serial, view->surface->resource, surface_x, surface_y);
 18 }
 19 
 20 static void
 21-leave(struct input_focus_handler *handler,
 22-      struct wl_resource *resource, struct compositor_view *view)
 23+leave(struct input_focus_handler *handler, struct wl_resource *resource, struct compositor_view *view)
 24 {
 25 	uint32_t serial;
 26 
 27 	serial = wl_display_next_serial(swc.display);
 28-
 29 	wl_pointer_send_leave(resource, serial, view->surface->resource);
 30 }
 31 
 32 static void
 33-handle_cursor_surface_destroy(struct wl_listener *listener,
 34-                              void *data)
 35+handle_cursor_surface_destroy(struct wl_listener *listener, void *data)
 36 {
 37 	struct pointer *pointer = wl_container_of(listener, pointer, cursor.destroy_listener);
 38 
 39@@ -88,10 +83,8 @@ attach(struct view *view, struct wld_buffer *buffer)
 40 	wld_set_target_buffer(swc.shm->renderer, pointer->cursor.buffer);
 41 	wld_fill_rectangle(swc.shm->renderer, 0x00000000, 0, 0, 64, 64);
 42 
 43-	if (buffer) {
 44-		wld_copy_rectangle(swc.shm->renderer, buffer, 0, 0, 0, 0,
 45-		                   buffer->width, buffer->height);
 46-	}
 47+	if (buffer)
 48+		wld_copy_rectangle(swc.shm->renderer, buffer, 0, 0, 0, 0, buffer->width, buffer->height);
 49 
 50 	wld_flush(swc.shm->renderer);
 51 
 52@@ -114,69 +107,66 @@ move(struct view *view, int32_t x, int32_t y)
 53 	if (view_set_position(view, x, y))
 54 		view_update_screens(view);
 55 
 56-	wl_list_for_each (screen, &swc.screens, link) {
 57-		view_move(&screen->planes.cursor.view,
 58-		          view->geometry.x, view->geometry.y);
 59-	}
 60+	wl_list_for_each (screen, &swc.screens, link)
 61+		view_move(&screen->planes.cursor.view, view->geometry.x, view->geometry.y);
 62 
 63 	return true;
 64 }
 65 
 66 static const struct view_impl view_impl = {
 67-	.update = &update,
 68-	.attach = &attach,
 69-	.move = &move,
 70+	.update = update,
 71+	.attach = attach,
 72+	.move = move,
 73 };
 74 
 75 static inline void
 76 update_cursor(struct pointer *pointer)
 77 {
 78-	view_move(&pointer->cursor.view,
 79-	          wl_fixed_to_int(pointer->x) - pointer->cursor.hotspot.x,
 80-	          wl_fixed_to_int(pointer->y) - pointer->cursor.hotspot.y);
 81+	int32_t x = wl_fixed_to_int(pointer->x) - pointer->cursor.hotspot.x,
 82+	        y = wl_fixed_to_int(pointer->y) - pointer->cursor.hotspot.y;
 83+
 84+	view_move(&pointer->cursor.view, x, y);
 85 }
 86 
 87 void
 88 pointer_set_cursor(struct pointer *pointer, uint32_t id)
 89 {
 90 	struct cursor *cursor = &cursor_metadata[id];
 91-	union wld_object object = {.ptr = &cursor_data[cursor->offset] };
 92+	union wld_object object = { .ptr = &cursor_data[cursor->offset] };
 93+	struct wld_buffer *buffer;
 94 
 95 	if (pointer->cursor.internal_buffer)
 96 		wld_buffer_unreference(pointer->cursor.internal_buffer);
 97 
 98-	pointer->cursor.internal_buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
 99-	                                                    cursor->width, cursor->height, WLD_FORMAT_ARGB8888, cursor->width * 4);
100+	buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
101+	                           cursor->width, cursor->height, WLD_FORMAT_ARGB8888, cursor->width * 4);
102 
103-	if (!pointer->cursor.internal_buffer) {
104+	if (!buffer) {
105 		ERROR("Failed to create cursor buffer\n");
106 		return;
107 	}
108 
109+	pointer->cursor.internal_buffer = buffer;
110 	pointer->cursor.hotspot.x = cursor->hotspot_x;
111 	pointer->cursor.hotspot.y = cursor->hotspot_y;
112 	update_cursor(pointer);
113-	view_attach(&pointer->cursor.view, pointer->cursor.internal_buffer);
114+	view_attach(&pointer->cursor.view, buffer);
115 }
116 
117 static bool
118-client_handle_button(struct pointer_handler *handler, uint32_t time,
119-                     struct button *button, uint32_t state)
120+client_handle_button(struct pointer_handler *handler, uint32_t time, struct button *button, uint32_t state)
121 {
122 	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
123 
124 	if (!pointer->focus.resource)
125 		return false;
126 
127-	wl_pointer_send_button(pointer->focus.resource, button->press.serial, time,
128-	                       button->press.value, state);
129-
130+	wl_pointer_send_button(pointer->focus.resource, button->press.serial, time, button->press.value, state);
131 	return true;
132 }
133 
134 static bool
135-client_handle_axis(struct pointer_handler *handler,
136-                   uint32_t time, uint32_t axis, wl_fixed_t amount)
137+client_handle_axis(struct pointer_handler *handler, uint32_t time, uint32_t axis, wl_fixed_t amount)
138 {
139 	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
140 
141@@ -184,41 +174,39 @@ client_handle_axis(struct pointer_handler *handler,
142 		return false;
143 
144 	wl_pointer_send_axis(pointer->focus.resource, time, axis, amount);
145-
146 	return true;
147 }
148 
149 static bool
150-client_handle_motion(struct pointer_handler *handler,
151-                     uint32_t time, wl_fixed_t x, wl_fixed_t y)
152+client_handle_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t x, wl_fixed_t y)
153 {
154 	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
155+	wl_fixed_t sx, sy;
156 
157 	if (!pointer->focus.resource)
158 		return false;
159 
160-	wl_pointer_send_motion(pointer->focus.resource, time,
161-	                       x - wl_fixed_from_int(pointer->focus.view->base.geometry.x),
162-	                       y - wl_fixed_from_int(pointer->focus.view->base.geometry.y));
163-
164+	sx = x - wl_fixed_from_int(pointer->focus.view->base.geometry.x);
165+	sy = y - wl_fixed_from_int(pointer->focus.view->base.geometry.y);
166+	wl_pointer_send_motion(pointer->focus.resource, time, sx, sy);
167 	return true;
168 }
169 
170 bool
171 pointer_initialize(struct pointer *pointer)
172 {
173-	struct screen *screen;
174+	struct screen *screen = wl_container_of(swc.screens.next, screen, link);
175+	struct swc_rectangle *geom = &screen->base.geometry;
176 
177 	/* Center cursor in the geometry of the first screen. */
178 	screen = wl_container_of(swc.screens.next, screen, link);
179-	pointer->x = wl_fixed_from_int(screen->base.geometry.x + screen->base.geometry.width / 2);
180-	pointer->y = wl_fixed_from_int(screen->base.geometry.y + screen->base.geometry.height / 2);
181-
182-	pointer->focus_handler.enter = &enter;
183-	pointer->focus_handler.leave = &leave;
184-	pointer->client_handler.button = &client_handle_button;
185-	pointer->client_handler.axis = &client_handle_axis;
186-	pointer->client_handler.motion = &client_handle_motion;
187+	pointer->x = wl_fixed_from_int(geom->x + geom->width / 2);
188+	pointer->y = wl_fixed_from_int(geom->y + geom->height / 2);
189+	pointer->focus_handler.enter = enter;
190+	pointer->focus_handler.leave = leave;
191+	pointer->client_handler.button = client_handle_button;
192+	pointer->client_handler.axis = client_handle_axis;
193+	pointer->client_handler.motion = client_handle_motion;
194 	wl_list_init(&pointer->handlers);
195 	wl_list_insert(&pointer->handlers, &pointer->client_handler.link);
196 	wl_array_init(&pointer->buttons);
197@@ -257,8 +245,7 @@ pointer_set_focus(struct pointer *pointer, struct compositor_view *view)
198 }
199 
200 static void
201-clip_position(struct pointer *pointer,
202-              wl_fixed_t fx, wl_fixed_t fy)
203+clip_position(struct pointer *pointer, wl_fixed_t fx, wl_fixed_t fy)
204 {
205 	int32_t x, y, last_x, last_y;
206 	pixman_box32_t box;
207@@ -269,8 +256,7 @@ clip_position(struct pointer *pointer,
208 	last_y = wl_fixed_to_int(pointer->y);
209 
210 	if (!pixman_region32_contains_point(&pointer->region, x, y, NULL)) {
211-		assert(pixman_region32_contains_point(&pointer->region,
212-		                                      last_x, last_y, &box));
213+		assert(pixman_region32_contains_point(&pointer->region, last_x, last_y, &box));
214 
215 		/* Do some clipping. */
216 		x = MAX(MIN(x, box.x2 - 1), box.x1);
217@@ -289,10 +275,8 @@ pointer_set_region(struct pointer *pointer, pixman_region32_t *region)
218 }
219 
220 static void
221-set_cursor(struct wl_client *client,
222-           struct wl_resource *resource, uint32_t serial,
223-           struct wl_resource *surface_resource,
224-           int32_t hotspot_x, int32_t hotspot_y)
225+set_cursor(struct wl_client *client, struct wl_resource *resource,
226+           uint32_t serial, struct wl_resource *surface_resource, int32_t hotspot_x, int32_t hotspot_y)
227 {
228 	struct pointer *pointer = wl_resource_get_user_data(resource);
229 	struct surface *surface;
230@@ -303,16 +287,14 @@ set_cursor(struct wl_client *client,
231 	if (pointer->cursor.surface)
232 		wl_list_remove(&pointer->cursor.destroy_listener.link);
233 
234-	surface = surface_resource ? wl_resource_get_user_data(surface_resource)
235-	                           : NULL;
236+	surface = surface_resource ? wl_resource_get_user_data(surface_resource) : NULL;
237 	pointer->cursor.surface = surface;
238 	pointer->cursor.hotspot.x = hotspot_x;
239 	pointer->cursor.hotspot.y = hotspot_y;
240 
241 	if (surface) {
242 		surface_set_view(surface, &pointer->cursor.view);
243-		wl_resource_add_destroy_listener(surface->resource,
244-		                                 &pointer->cursor.destroy_listener);
245+		wl_resource_add_destroy_listener(surface->resource, &pointer->cursor.destroy_listener);
246 		update_cursor(pointer);
247 	}
248 }
249@@ -324,29 +306,24 @@ release(struct wl_client *client, struct wl_resource *resource)
250 }
251 
252 static struct wl_pointer_interface pointer_implementation = {
253-	.set_cursor = &set_cursor,
254-	.release = &release,
255+	.set_cursor = set_cursor,
256+	.release = release,
257 };
258 
259 static void
260 unbind(struct wl_resource *resource)
261 {
262 	struct pointer *pointer = wl_resource_get_user_data(resource);
263-
264 	input_focus_remove_resource(&pointer->focus, resource);
265 }
266 
267 struct wl_resource *
268-pointer_bind(struct pointer *pointer,
269-             struct wl_client *client,
270-             uint32_t version, uint32_t id)
271+pointer_bind(struct pointer *pointer, struct wl_client *client, uint32_t version, uint32_t id)
272 {
273 	struct wl_resource *client_resource;
274 
275-	client_resource = wl_resource_create(client, &wl_pointer_interface,
276-	                                     version, id);
277-	wl_resource_set_implementation(client_resource, &pointer_implementation,
278-	                               pointer, &unbind);
279+	client_resource = wl_resource_create(client, &wl_pointer_interface, version, id);
280+	wl_resource_set_implementation(client_resource, &pointer_implementation, pointer, &unbind);
281 	input_focus_add_resource(&pointer->focus, client_resource);
282 
283 	return client_resource;
284@@ -366,8 +343,7 @@ pointer_get_button(struct pointer *pointer, uint32_t serial)
285 }
286 
287 void
288-pointer_handle_button(struct pointer *pointer, uint32_t time,
289-                      uint32_t value, uint32_t state)
290+pointer_handle_button(struct pointer *pointer, uint32_t time, uint32_t value, uint32_t state)
291 {
292 	struct pointer_handler *handler;
293 	struct button *button;
294@@ -380,8 +356,7 @@ pointer_handle_button(struct pointer *pointer, uint32_t time,
295 			if (button->press.value == value) {
296 				if (button->handler) {
297 					button->press.serial = serial;
298-					button->handler->button(button->handler, time,
299-					                        button, state);
300+					button->handler->button(button->handler, time, button, state);
301 				}
302 
303 				array_remove(&pointer->buttons, button, sizeof *button);
304@@ -408,8 +383,7 @@ pointer_handle_button(struct pointer *pointer, uint32_t time,
305 }
306 
307 void
308-pointer_handle_axis(struct pointer *pointer, uint32_t time,
309-                    uint32_t axis, wl_fixed_t amount)
310+pointer_handle_axis(struct pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t amount)
311 {
312 	struct pointer_handler *handler;
313 
314@@ -420,17 +394,15 @@ pointer_handle_axis(struct pointer *pointer, uint32_t time,
315 }
316 
317 void
318-pointer_handle_relative_motion(struct pointer *pointer, uint32_t time,
319-                               wl_fixed_t dx, wl_fixed_t dy)
320+pointer_handle_relative_motion(struct pointer *pointer, uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
321 {
322 	struct pointer_handler *handler;
323 
324 	clip_position(pointer, pointer->x + dx, pointer->y + dy);
325 
326 	wl_list_for_each (handler, &pointer->handlers, link) {
327-		if (handler->motion && handler->motion(handler, time, pointer->x, pointer->y)) {
328+		if (handler->motion && handler->motion(handler, time, pointer->x, pointer->y))
329 			break;
330-		}
331 	}
332 
333 	update_cursor(pointer);
+9, -19
 1@@ -37,12 +37,9 @@ struct button {
 2 };
 3 
 4 struct pointer_handler {
 5-	bool (*motion)(struct pointer_handler *handler, uint32_t time,
 6-	               wl_fixed_t x, wl_fixed_t y);
 7-	bool (*button)(struct pointer_handler *handler, uint32_t time,
 8-	               struct button *button, uint32_t state);
 9-	bool (*axis)(struct pointer_handler *handler, uint32_t time,
10-	             enum wl_pointer_axis axis, wl_fixed_t amount);
11+	bool (*motion)(struct pointer_handler *handler, uint32_t time, wl_fixed_t x, wl_fixed_t y);
12+	bool (*button)(struct pointer_handler *handler, uint32_t time, struct button *button, uint32_t state);
13+	bool (*axis)(struct pointer_handler *handler, uint32_t time, enum wl_pointer_axis axis, wl_fixed_t amount);
14 
15 	struct wl_list link;
16 };
17@@ -51,8 +48,7 @@ struct pointer {
18 	struct input_focus focus;
19 	struct input_focus_handler focus_handler;
20 
21-	struct
22-	    {
23+	struct {
24 		struct view view;
25 		struct surface *surface;
26 		struct wl_listener destroy_listener;
27@@ -61,8 +57,7 @@ struct pointer {
28 		/* Used for cursors set with pointer_set_cursor */
29 		struct wld_buffer *internal_buffer;
30 
31-		struct
32-		    {
33+		struct {
34 			int32_t x, y;
35 		} hotspot;
36 	} cursor;
37@@ -83,14 +78,9 @@ void pointer_set_cursor(struct pointer *pointer, uint32_t id);
38 
39 struct button *pointer_get_button(struct pointer *pointer, uint32_t serial);
40 
41-struct wl_resource *pointer_bind(struct pointer *pointer,
42-                                 struct wl_client *client,
43-                                 uint32_t version, uint32_t id);
44-void pointer_handle_button(struct pointer *pointer, uint32_t time,
45-                           uint32_t button, uint32_t state);
46-void pointer_handle_axis(struct pointer *pointer, uint32_t time,
47-                         uint32_t axis, wl_fixed_t amount);
48-void pointer_handle_relative_motion(struct pointer *pointer, uint32_t time,
49-                                    wl_fixed_t dx, wl_fixed_t dy);
50+struct wl_resource *pointer_bind(struct pointer *pointer, struct wl_client *client, uint32_t version, uint32_t id);
51+void pointer_handle_button(struct pointer *pointer, uint32_t time, uint32_t button, uint32_t state);
52+void pointer_handle_axis(struct pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t amount);
53+void pointer_handle_relative_motion(struct pointer *pointer, uint32_t time, wl_fixed_t dx, wl_fixed_t dy);
54 
55 #endif
+9, -21
 1@@ -10,18 +10,14 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 2 }
 3 
 4 static void
 5-add(struct wl_client *client, struct wl_resource *resource,
 6-    int32_t x, int32_t y, int32_t width, int32_t height)
 7+add(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
 8 {
 9 	struct region *region = wl_resource_get_user_data(resource);
10-
11-	pixman_region32_union_rect(&region->region, &region->region,
12-	                           x, y, width, height);
13+	pixman_region32_union_rect(&region->region, &region->region, x, y, width, height);
14 }
15 
16 static void
17-subtract(struct wl_client *client, struct wl_resource *resource,
18-         int32_t x, int32_t y, int32_t width, int32_t height)
19+subtract(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
20 {
21 	struct region *region = wl_resource_get_user_data(resource);
22 	pixman_region32_t operand;
23@@ -31,9 +27,9 @@ subtract(struct wl_client *client, struct wl_resource *resource,
24 }
25 
26 static const struct wl_region_interface region_implementation = {
27-	.destroy = &destroy,
28-	.add = &add,
29-	.subtract = &subtract
30+	.destroy = destroy,
31+	.add = add,
32+	.subtract = subtract,
33 };
34 
35 static void
36@@ -41,15 +37,12 @@ region_destroy(struct wl_resource *resource)
37 {
38 	struct region *region = wl_resource_get_user_data(resource);
39 
40-	/* Finish the region. */
41 	pixman_region32_fini(&region->region);
42-
43 	free(region);
44 }
45 
46 struct region *
47-region_new(struct wl_client *client,
48-           uint32_t version, uint32_t id)
49+region_new(struct wl_client *client, uint32_t version, uint32_t id)
50 {
51 	struct region *region;
52 
53@@ -58,14 +51,9 @@ region_new(struct wl_client *client,
54 	if (!region)
55 		return NULL;
56 
57-	/* Initialize the region. */
58 	pixman_region32_init(&region->region);
59-
60-	/* Add the region to the client. */
61-	region->resource = wl_resource_create(client, &wl_region_interface,
62-	                                      version, id);
63-	wl_resource_set_implementation(region->resource, &region_implementation,
64-	                               region, &region_destroy);
65+	region->resource = wl_resource_create(client, &wl_region_interface, version, id);
66+	wl_resource_set_implementation(region->resource, &region_implementation, region, &region_destroy);
67 
68 	return region;
69 }
+1, -2
1@@ -11,7 +11,6 @@ struct region {
2 	pixman_region32_t region;
3 };
4 
5-struct region *region_new(struct wl_client *client,
6-                          uint32_t version, uint32_t id);
7+struct region *region_new(struct wl_client *client, uint32_t version, uint32_t id);
8 
9 #endif
+16, -27
  1@@ -39,18 +39,14 @@
  2 static struct screen *active_screen;
  3 static const struct swc_screen_handler null_handler;
  4 
  5-static bool handle_motion(struct pointer_handler *handler, uint32_t time,
  6-                          wl_fixed_t x, wl_fixed_t y);
  7+static bool handle_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t x, wl_fixed_t y);
  8 
  9 struct pointer_handler screens_pointer_handler = {
 10-	.motion = &handle_motion
 11+	.motion = handle_motion,
 12 };
 13 
 14-EXPORT
 15-void
 16-swc_screen_set_handler(struct swc_screen *base,
 17-                       const struct swc_screen_handler *handler,
 18-                       void *data)
 19+EXPORT void
 20+swc_screen_set_handler(struct swc_screen *base, const struct swc_screen_handler *handler, void *data)
 21 {
 22 	struct screen *screen = INTERNAL(base);
 23 
 24@@ -82,8 +78,7 @@ screens_finalize(void)
 25 }
 26 
 27 static void
 28-bind_screen(struct wl_client *client, void *data,
 29-            uint32_t version, uint32_t id)
 30+bind_screen(struct wl_client *client, void *data, uint32_t version, uint32_t id)
 31 {
 32 	struct screen *screen = data;
 33 	struct wl_resource *resource;
 34@@ -115,23 +110,19 @@ screen_new(uint32_t crtc, struct output *output)
 35 	if (!(screen = malloc(sizeof *screen)))
 36 		goto error0;
 37 
 38-	screen->global = wl_global_create(swc.display, &swc_screen_interface, 1,
 39-	                                  screen, &bind_screen);
 40+	screen->global = wl_global_create(swc.display, &swc_screen_interface, 1, screen, &bind_screen);
 41 
 42 	if (!screen->global) {
 43 		ERROR("Failed to create screen global\n");
 44 		goto error1;
 45 	}
 46 
 47-	if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc,
 48-	                                  output->preferred_mode,
 49-	                                  &output->connector, 1)) {
 50+	if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc, output->preferred_mode, &output->connector, 1)) {
 51 		ERROR("Failed to initialize framebuffer plane\n");
 52 		goto error2;
 53 	}
 54 
 55-	if (!cursor_plane_initialize(&screen->planes.cursor, crtc,
 56-	                             &screen->base.geometry)) {
 57+	if (!cursor_plane_initialize(&screen->planes.cursor, crtc, &screen->base.geometry)) {
 58 		ERROR("Failed to initialize cursor plane\n");
 59 		goto error3;
 60 	}
 61@@ -184,26 +175,25 @@ screen_update_usable_geometry(struct screen *screen)
 62 	pixman_region32_t total_usable, usable;
 63 	pixman_box32_t *extents;
 64 	struct screen_modifier *modifier;
 65+	struct swc_rectangle *geom = &screen->base.geometry;
 66 
 67 	DEBUG("Updating usable geometry\n");
 68 
 69-	pixman_region32_init_rect(&total_usable,
 70-	                          screen->base.geometry.x, screen->base.geometry.y,
 71-	                          screen->base.geometry.width,
 72-	                          screen->base.geometry.height);
 73+	pixman_region32_init_rect(&total_usable, geom->x, geom->y, geom->width, geom->height);
 74 	pixman_region32_init(&usable);
 75 
 76 	wl_list_for_each (modifier, &screen->modifiers, link) {
 77-		modifier->modify(modifier, &screen->base.geometry, &usable);
 78+		modifier->modify(modifier, geom, &usable);
 79 		pixman_region32_intersect(&total_usable, &total_usable, &usable);
 80 	}
 81 
 82 	extents = pixman_region32_extents(&total_usable);
 83 
 84 	if (extents->x1 != screen->base.usable_geometry.x
 85-	    || extents->y1 != screen->base.usable_geometry.y
 86-	    || (extents->x2 - extents->x1) != screen->base.usable_geometry.width
 87-	    || (extents->y2 - extents->y1) != screen->base.usable_geometry.height) {
 88+	 || extents->y1 != screen->base.usable_geometry.y
 89+	 || (extents->x2 - extents->x1) != screen->base.usable_geometry.width
 90+	 || (extents->y2 - extents->y1) != screen->base.usable_geometry.height)
 91+	{
 92 		screen->base.usable_geometry.x = extents->x1;
 93 		screen->base.usable_geometry.y = extents->y1;
 94 		screen->base.usable_geometry.width = extents->x2 - extents->x1;
 95@@ -215,8 +205,7 @@ screen_update_usable_geometry(struct screen *screen)
 96 }
 97 
 98 bool
 99-handle_motion(struct pointer_handler *handler, uint32_t time,
100-              wl_fixed_t fx, wl_fixed_t fy)
101+handle_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t fx, wl_fixed_t fy)
102 {
103 	struct screen *screen;
104 	int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
+5, -8
 1@@ -35,12 +35,10 @@ struct pixman_region32;
 2 
 3 struct screen_modifier {
 4 	/**
 5-     * Takes the screen geometry and sets 'usable' to the usable region of the
 6-     * screen. 'usable' is an already initialized pixman region.
 7-     */
 8-	void (*modify)(struct screen_modifier *modifier,
 9-	               const struct swc_rectangle *geometry,
10-	               struct pixman_region32 *usable);
11+	 * Takes the screen geometry and sets 'usable' to the usable region of the
12+	 * screen. 'usable' is an already initialized pixman region.
13+	 */
14+	void (*modify)(struct screen_modifier *modifier, const struct swc_rectangle *geometry, struct pixman_region32 *usable);
15 
16 	struct wl_list link;
17 };
18@@ -53,8 +51,7 @@ struct screen {
19 	struct wl_signal destroy_signal;
20 	uint8_t id;
21 
22-	struct
23-	    {
24+	struct {
25 		struct framebuffer_plane framebuffer;
26 		struct cursor_plane cursor;
27 	} planes;
+66, -84
  1@@ -39,12 +39,11 @@
  2 #include <string.h>
  3 #include <unistd.h>
  4 #ifdef ENABLE_LIBINPUT
  5-#include <libudev.h>
  6-#include <libinput.h>
  7+# include <libudev.h>
  8+# include <libinput.h>
  9 #endif
 10 
 11-static struct
 12-    {
 13+static struct {
 14 	char *name;
 15 	uint32_t capabilities;
 16 
 17@@ -69,7 +68,7 @@ static struct
 18 const struct swc_seat swc_seat = {
 19 	.pointer = &seat.pointer,
 20 	.keyboard = &seat.keyboard,
 21-	.data_device = &seat.data_device
 22+	.data_device = &seat.data_device,
 23 };
 24 
 25 static void
 26@@ -97,66 +96,62 @@ handle_relative_motion(uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
 27 }
 28 
 29 static void
 30-handle_keyboard_focus_event(struct wl_listener *listener,
 31-                            void *data)
 32+handle_keyboard_focus_event(struct wl_listener *listener, void *data)
 33 {
 34-	struct event *event = data;
 35-	struct input_focus_event_data *event_data = event->data;
 36+	struct event *ev = data;
 37+	struct input_focus_event_data *event_data = ev->data;
 38 
 39-	switch (event->type) {
 40-	case INPUT_FOCUS_EVENT_CHANGED:
 41-		if (event_data->new) {
 42-			struct wl_client *client = wl_resource_get_client(event_data->new->surface->resource);
 43+	if (ev->type != INPUT_FOCUS_EVENT_CHANGED)
 44+		return;
 45 
 46-			/* Offer the selection to the new focus. */
 47-			data_device_offer_selection(&seat.data_device, client);
 48-		}
 49-		break;
 50+	if (event_data->new) {
 51+		struct wl_client *client = wl_resource_get_client(event_data->new->surface->resource);
 52+
 53+		/* Offer the selection to the new focus. */
 54+		data_device_offer_selection(&seat.data_device, client);
 55 	}
 56 }
 57 
 58 static struct wl_listener keyboard_focus_listener = {
 59-	.notify = &handle_keyboard_focus_event
 60+	.notify = handle_keyboard_focus_event,
 61 };
 62 
 63 static void
 64 handle_data_device_event(struct wl_listener *listener, void *data)
 65 {
 66-	struct event *event = data;
 67+	struct event *ev = data;
 68 
 69-	switch (event->type) {
 70-	case DATA_DEVICE_EVENT_SELECTION_CHANGED:
 71-		if (seat.keyboard.focus.resource) {
 72-			struct wl_client *client = wl_resource_get_client(seat.keyboard.focus.resource);
 73-			data_device_offer_selection(&seat.data_device, client);
 74-		}
 75-		break;
 76+	if (ev->type != DATA_DEVICE_EVENT_SELECTION_CHANGED)
 77+		return;
 78+
 79+	if (seat.keyboard.focus.resource) {
 80+		struct wl_client *client = wl_resource_get_client(seat.keyboard.focus.resource);
 81+		data_device_offer_selection(&seat.data_device, client);
 82 	}
 83 }
 84 
 85 static struct wl_listener data_device_listener = {
 86-	.notify = &handle_data_device_event
 87+	.notify = handle_data_device_event,
 88 };
 89 
 90 static void
 91 handle_swc_event(struct wl_listener *listener, void *data)
 92 {
 93-	struct event *event = data;
 94+	struct event *ev = data;
 95+	struct evdev_device *device, *next;
 96 
 97-	switch (event->type) {
 98+	switch (ev->type) {
 99 	case SWC_EVENT_DEACTIVATED:
100 #ifdef ENABLE_LIBINPUT
101 		libinput_suspend(seat.libinput);
102 #endif
103 		keyboard_reset(&seat.keyboard);
104 		break;
105-	case SWC_EVENT_ACTIVATED: {
106+	case SWC_EVENT_ACTIVATED:
107 #ifdef ENABLE_LIBINPUT
108 		if (libinput_resume(seat.libinput) != 0)
109 			WARNING("Failed to resume libinput context\n");
110 #else
111-		struct evdev_device *device, *next;
112-
113 		/* Re-open all input devices */
114 		wl_list_for_each_safe (device, next, &seat.devices, link) {
115 			if (!evdev_device_reopen(device)) {
116@@ -167,41 +162,35 @@ handle_swc_event(struct wl_listener *listener, void *data)
117 #endif
118 		break;
119 	}
120-	}
121 }
122 
123 /* Wayland Seat Interface */
124 static void
125-get_pointer(struct wl_client *client,
126-            struct wl_resource *resource, uint32_t id)
127+get_pointer(struct wl_client *client, struct wl_resource *resource, uint32_t id)
128 {
129 	pointer_bind(&seat.pointer, client, wl_resource_get_version(resource), id);
130 }
131 
132 static void
133-get_keyboard(struct wl_client *client,
134-             struct wl_resource *resource, uint32_t id)
135+get_keyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id)
136 {
137-	keyboard_bind(&seat.keyboard, client,
138-	              wl_resource_get_version(resource), id);
139+	keyboard_bind(&seat.keyboard, client, wl_resource_get_version(resource), id);
140 }
141 
142 static void
143-get_touch(struct wl_client *client, struct wl_resource *resource,
144-          uint32_t id)
145+get_touch(struct wl_client *client, struct wl_resource *resource, uint32_t id)
146 {
147 	/* XXX: Implement */
148 }
149 
150 static struct wl_seat_interface seat_implementation = {
151-	.get_pointer = &get_pointer,
152-	.get_keyboard = &get_keyboard,
153-	.get_touch = &get_touch
154+	.get_pointer = get_pointer,
155+	.get_keyboard = get_keyboard,
156+	.get_touch = get_touch,
157 };
158 
159 static void
160-bind_seat(struct wl_client *client, void *data, uint32_t version,
161-          uint32_t id)
162+bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id)
163 {
164 	struct wl_resource *resource;
165 
166@@ -209,8 +198,7 @@ bind_seat(struct wl_client *client, void *data, uint32_t version,
167 		version = 4;
168 
169 	resource = wl_resource_create(client, &wl_seat_interface, version, id);
170-	wl_resource_set_implementation(resource, &seat_implementation, NULL,
171-	                               &remove_resource);
172+	wl_resource_set_implementation(resource, &seat_implementation, NULL, &remove_resource);
173 	wl_list_insert(&seat.resources, wl_resource_get_link(resource));
174 
175 	if (version >= 2)
176@@ -222,13 +210,14 @@ bind_seat(struct wl_client *client, void *data, uint32_t version,
177 static void
178 update_capabilities(uint32_t capabilities)
179 {
180-	if (~seat.capabilities & capabilities) {
181-		struct wl_resource *resource;
182+	struct wl_resource *resource;
183 
184-		seat.capabilities |= capabilities;
185-		wl_list_for_each (resource, &seat.resources, link)
186-			wl_seat_send_capabilities(resource, seat.capabilities);
187-	}
188+	if (!(~seat.capabilities & capabilities))
189+		return;
190+
191+	seat.capabilities |= capabilities;
192+	wl_list_for_each(resource, &seat.resources, link)
193+		wl_seat_send_capabilities(resource, seat.capabilities);
194 }
195 
196 #ifdef ENABLE_LIBINPUT
197@@ -245,8 +234,8 @@ close_restricted(int fd, void *user_data)
198 }
199 
200 const struct libinput_interface libinput_interface = {
201-	.open_restricted = &open_restricted,
202-	.close_restricted = &close_restricted,
203+	.open_restricted = open_restricted,
204+	.close_restricted = close_restricted,
205 };
206 
207 static uint32_t
208@@ -259,25 +248,23 @@ device_capabilities(struct libinput_device *device)
209 	if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
210 		capabilities |= WL_SEAT_CAPABILITY_POINTER;
211 	/* TODO: Add touch device support
212-    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
213-        capabilities |= WL_SEAT_CAPABILITY_TOUCH;
214-    */
215+	 * if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
216+	 * 	capabilities |= WL_SEAT_CAPABILITY_TOUCH;
217+	 */
218 
219 	return capabilities;
220 }
221 
222 static void
223-handle_libinput_axis_event(struct libinput_event_pointer *event,
224-                           enum libinput_pointer_axis axis)
225+handle_libinput_axis_event(struct libinput_event_pointer *event, enum libinput_pointer_axis axis)
226 {
227+	double amount;
228+
229 	if (!libinput_event_pointer_has_axis(event, axis))
230 		return;
231 
232-	double amount;
233-
234 	amount = libinput_event_pointer_get_axis_value(event, axis);
235-	handle_axis(libinput_event_pointer_get_time(event), axis,
236-	            wl_fixed_from_double(amount));
237+	handle_axis(libinput_event_pointer_get_time(event), axis, wl_fixed_from_double(amount));
238 }
239 
240 static int
241@@ -315,8 +302,7 @@ handle_libinput_data(int fd, uint32_t mask, void *data)
242 			event = libinput_event_get_pointer_event(generic_event);
243 			dx = wl_fixed_from_double(libinput_event_pointer_get_dx(event));
244 			dy = wl_fixed_from_double(libinput_event_pointer_get_dy(event));
245-			handle_relative_motion(libinput_event_pointer_get_time(event),
246-			                       dx, dy);
247+			handle_relative_motion(libinput_event_pointer_get_time(event), dx, dy);
248 			break;
249 		}
250 		case LIBINPUT_EVENT_POINTER_BUTTON: {
251@@ -334,7 +320,6 @@ handle_libinput_data(int fd, uint32_t mask, void *data)
252 			event = libinput_event_get_pointer_event(generic_event);
253 			handle_libinput_axis_event(event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
254 			handle_libinput_axis_event(event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
255-
256 			break;
257 		}
258 		default:
259@@ -355,8 +340,7 @@ initialize_libinput(const char *seat_name)
260 		goto error0;
261 	}
262 
263-	seat.libinput = libinput_udev_create_context(&libinput_interface, NULL,
264-	                                             seat.udev);
265+	seat.libinput = libinput_udev_create_context(&libinput_interface, NULL, seat.udev);
266 
267 	if (!seat.libinput) {
268 		ERROR("Could not create libinput context\n");
269@@ -368,8 +352,9 @@ initialize_libinput(const char *seat_name)
270 		goto error2;
271 	}
272 
273-	seat.libinput_source = wl_event_loop_add_fd(swc.event_loop, libinput_get_fd(seat.libinput), WL_EVENT_READABLE,
274-	                                            &handle_libinput_data, NULL);
275+	seat.libinput_source = wl_event_loop_add_fd
276+		(swc.event_loop, libinput_get_fd(seat.libinput), WL_EVENT_READABLE,
277+		 &handle_libinput_data, NULL);
278 
279 	if (!seat.libinput_source) {
280 		ERROR("Could not create event source for libinput\n");
281@@ -398,10 +383,10 @@ finalize_libinput(void)
282 }
283 #else
284 const static struct evdev_device_handler evdev_handler = {
285-	.key = &handle_key,
286-	.button = &handle_button,
287-	.axis = &handle_axis,
288-	.relative_motion = &handle_relative_motion,
289+	.key = handle_key,
290+	.button = handle_button,
291+	.axis = handle_axis,
292+	.relative_motion = handle_relative_motion,
293 };
294 
295 static void
296@@ -422,7 +407,6 @@ static int
297 select_device(const struct dirent *entry)
298 {
299 	unsigned num;
300-
301 	return sscanf(entry->d_name, "event%u", &num) == 1;
302 }
303 
304@@ -430,9 +414,8 @@ static bool
305 add_devices(void)
306 {
307 	struct dirent **devices;
308-	int num_devices;
309+	int i, num_devices;
310 	char path[64];
311-	unsigned index;
312 
313 	num_devices = scandir("/dev/input", &devices, &select_device, &alphasort);
314 
315@@ -441,9 +424,9 @@ add_devices(void)
316 		return false;
317 	}
318 
319-	for (index = 0; index < num_devices; ++index) {
320-		snprintf(path, sizeof path, "/dev/input/%s", devices[index]->d_name);
321-		free(devices[index]);
322+	for (i = 0; i < num_devices; ++i) {
323+		snprintf(path, sizeof path, "/dev/input/%s", devices[i]->d_name);
324+		free(devices[i]);
325 		add_device(path);
326 	}
327 
328@@ -461,8 +444,7 @@ seat_initialize(const char *seat_name)
329 		goto error0;
330 	}
331 
332-	seat.global = wl_global_create(swc.display, &wl_seat_interface, 4,
333-	                               NULL, &bind_seat);
334+	seat.global = wl_global_create(swc.display, &wl_seat_interface, 4, NULL, &bind_seat);
335 
336 	if (!seat.global)
337 		goto error1;
+6, -13
 1@@ -27,33 +27,28 @@
 2 
 3 #include <wayland-server.h>
 4 
 5-static struct
 6-    {
 7+static struct {
 8 	struct wl_global *global;
 9 } shell;
10 
11 static void
12-get_shell_surface(struct wl_client *client,
13-                  struct wl_resource *resource, uint32_t id,
14-                  struct wl_resource *surface_resource)
15+get_shell_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
16 {
17 	struct surface *surface = wl_resource_get_user_data(surface_resource);
18 	struct shell_surface *shell_surface;
19 
20-	shell_surface = shell_surface_new(client, wl_resource_get_version(resource),
21-	                                  id, surface);
22+	shell_surface = shell_surface_new(client, wl_resource_get_version(resource), id, surface);
23 
24 	if (!shell_surface)
25 		wl_resource_post_no_memory(resource);
26 }
27 
28 static const struct wl_shell_interface shell_implementation = {
29-	&get_shell_surface
30+	.get_shell_surface = get_shell_surface,
31 };
32 
33 static void
34-bind_shell(struct wl_client *client, void *data,
35-           uint32_t version, uint32_t id)
36+bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
37 {
38 	struct wl_resource *resource;
39 
40@@ -67,9 +62,7 @@ bind_shell(struct wl_client *client, void *data,
41 bool
42 shell_initialize(void)
43 {
44-	shell.global = wl_global_create(swc.display, &wl_shell_interface, 1,
45-	                                NULL, &bind_shell);
46-
47+	shell.global = wl_global_create(swc.display, &wl_shell_interface, 1, NULL, &bind_shell);
48 	return shell.global;
49 }
50 
+32, -60
  1@@ -48,9 +48,8 @@ configure(struct window *window, uint32_t width, uint32_t height)
  2 {
  3 	struct shell_surface *shell_surface = wl_container_of(window, shell_surface, window);
  4 
  5-	wl_shell_surface_send_configure(shell_surface->resource,
  6-	                                WL_SHELL_SURFACE_RESIZE_NONE,
  7-	                                width, height);
  8+	wl_shell_surface_send_configure(shell_surface->resource, WL_SHELL_SURFACE_RESIZE_NONE, width, height);
  9+
 10 	/* wl_shell does not support acknowledging configures. */
 11 	window->configure.acknowledged = true;
 12 }
 13@@ -68,19 +67,17 @@ close(struct window *window)
 14 }
 15 
 16 static const struct window_impl window_impl = {
 17-	.configure = &configure,
 18-	.close = &close,
 19+	.configure = configure,
 20+	.close = close,
 21 };
 22 
 23 static void
 24-pong(struct wl_client *client, struct wl_resource *resource,
 25-     uint32_t serial)
 26+pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
 27 {
 28 }
 29 
 30 static void
 31-move(struct wl_client *client, struct wl_resource *resource,
 32-     struct wl_resource *seat_resource, uint32_t serial)
 33+move(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial)
 34 {
 35 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 36 	struct button *button;
 37@@ -93,8 +90,7 @@ move(struct wl_client *client, struct wl_resource *resource,
 38 
 39 static void
 40 resize(struct wl_client *client, struct wl_resource *resource,
 41-       struct wl_resource *seat_resource, uint32_t serial,
 42-       uint32_t edges)
 43+       struct wl_resource *seat_resource, uint32_t serial, uint32_t edges)
 44 {
 45 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 46 	struct button *button;
 47@@ -106,8 +102,7 @@ resize(struct wl_client *client, struct wl_resource *resource,
 48 }
 49 
 50 static void
 51-set_toplevel(struct wl_client *client,
 52-             struct wl_resource *resource)
 53+set_toplevel(struct wl_client *client, struct wl_resource *resource)
 54 {
 55 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 56 
 57@@ -116,10 +111,8 @@ set_toplevel(struct wl_client *client,
 58 }
 59 
 60 static void
 61-set_transient(struct wl_client *client,
 62-              struct wl_resource *resource,
 63-              struct wl_resource *parent_resource,
 64-              int32_t x, int32_t y, uint32_t flags)
 65+set_transient(struct wl_client *client, struct wl_resource *resource,
 66+              struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags)
 67 {
 68 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 69 	struct surface *parent_surface = wl_resource_get_user_data(parent_resource);
 70@@ -133,19 +126,14 @@ set_transient(struct wl_client *client,
 71 }
 72 
 73 static void
 74-set_fullscreen(struct wl_client *client,
 75-               struct wl_resource *resource,
 76-               uint32_t method, uint32_t framerate,
 77-               struct wl_resource *output_resource)
 78+set_fullscreen(struct wl_client *client, struct wl_resource *resource,
 79+               uint32_t method, uint32_t framerate, struct wl_resource *output_resource)
 80 {
 81 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 82-	struct output *output = output_resource
 83-	                            ? wl_resource_get_user_data(output_resource)
 84-	                            : NULL;
 85+	struct output *output = output_resource ? wl_resource_get_user_data(output_resource) : NULL;
 86 	struct screen *screen;
 87 
 88-	screen = output ? output->screen
 89-	                : wl_container_of(swc.screens.next, screen, link);
 90+	screen = output ? output->screen : wl_container_of(swc.screens.next, screen, link);
 91 
 92 	/* TODO: Handle fullscreen windows. */
 93 
 94@@ -156,8 +144,7 @@ set_fullscreen(struct wl_client *client,
 95 static void
 96 set_popup(struct wl_client *client, struct wl_resource *resource,
 97           struct wl_resource *seat_resource, uint32_t serial,
 98-          struct wl_resource *parent_resource,
 99-          int32_t x, int32_t y, uint32_t flags)
100+          struct wl_resource *parent_resource, int32_t x, int32_t y, uint32_t flags)
101 {
102 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
103 	struct surface *parent_surface = wl_resource_get_user_data(parent_resource);
104@@ -168,15 +155,11 @@ set_popup(struct wl_client *client, struct wl_resource *resource,
105 
106 	window_unmanage(&shell_surface->window);
107 	window_set_parent(&shell_surface->window, parent_view->window);
108-	view_move(&shell_surface->window.view->base,
109-	          parent_view->base.geometry.x + x,
110-	          parent_view->base.geometry.y + y);
111+	view_move(&shell_surface->window.view->base, parent_view->base.geometry.x + x, parent_view->base.geometry.y + y);
112 }
113 
114 static void
115-set_maximized(struct wl_client *client,
116-              struct wl_resource *resource,
117-              struct wl_resource *output_resource)
118+set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource)
119 {
120 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
121 
122@@ -187,41 +170,36 @@ set_maximized(struct wl_client *client,
123 }
124 
125 static void
126-set_title(struct wl_client *client, struct wl_resource *resource,
127-          const char *title)
128+set_title(struct wl_client *client, struct wl_resource *resource, const char *title)
129 {
130 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
131-
132 	window_set_title(&shell_surface->window, title, -1);
133 }
134 
135 static void
136-set_class(struct wl_client *client, struct wl_resource *resource,
137-          const char *class)
138+set_class(struct wl_client *client, struct wl_resource *resource, const char *class)
139 {
140 	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
141-
142 	window_set_app_id(&shell_surface->window, class);
143 }
144 
145 static const struct wl_shell_surface_interface shell_surface_implementation = {
146-	.pong = &pong,
147-	.move = &move,
148-	.resize = &resize,
149-	.set_toplevel = &set_toplevel,
150-	.set_transient = &set_transient,
151-	.set_fullscreen = &set_fullscreen,
152-	.set_popup = &set_popup,
153-	.set_maximized = &set_maximized,
154-	.set_title = &set_title,
155-	.set_class = &set_class
156+	.pong = pong,
157+	.move = move,
158+	.resize = resize,
159+	.set_toplevel = set_toplevel,
160+	.set_transient = set_transient,
161+	.set_fullscreen = set_fullscreen,
162+	.set_popup = set_popup,
163+	.set_maximized = set_maximized,
164+	.set_title = set_title,
165+	.set_class = set_class,
166 };
167 
168 static void
169 handle_surface_destroy(struct wl_listener *listener, void *data)
170 {
171 	struct shell_surface *shell_surface = wl_container_of(listener, shell_surface, surface_destroy_listener);
172-
173 	wl_resource_destroy(shell_surface->resource);
174 }
175 
176@@ -235,9 +213,7 @@ destroy_shell_surface(struct wl_resource *resource)
177 }
178 
179 struct shell_surface *
180-shell_surface_new(struct wl_client *client,
181-                  uint32_t version, uint32_t id,
182-                  struct surface *surface)
183+shell_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface)
184 {
185 	struct shell_surface *shell_surface;
186 
187@@ -251,14 +227,10 @@ shell_surface_new(struct wl_client *client,
188 	if (!shell_surface->resource)
189 		goto error1;
190 
191-	wl_resource_set_implementation(shell_surface->resource,
192-	                               &shell_surface_implementation,
193-	                               shell_surface, &destroy_shell_surface);
194-
195+	wl_resource_set_implementation(shell_surface->resource, &shell_surface_implementation, shell_surface, &destroy_shell_surface);
196 	window_initialize(&shell_surface->window, &window_impl, surface);
197 	shell_surface->surface_destroy_listener.notify = &handle_surface_destroy;
198-	wl_resource_add_destroy_listener(surface->resource,
199-	                                 &shell_surface->surface_destroy_listener);
200+	wl_resource_add_destroy_listener(surface->resource, &shell_surface->surface_destroy_listener);
201 
202 	return shell_surface;
203 
+1, -3
 1@@ -29,8 +29,6 @@
 2 struct surface;
 3 struct wl_client;
 4 
 5-struct shell_surface *shell_surface_new(struct wl_client *client,
 6-                                        uint32_t version, uint32_t id,
 7-                                        struct surface *surface);
 8+struct shell_surface *shell_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface);
 9 
10 #endif
+16, -33
  1@@ -39,8 +39,7 @@
  2 
  3 struct swc_shm swc_shm;
  4 
  5-static struct
  6-    {
  7+static struct {
  8 	struct wl_global *global;
  9 } shm;
 10 
 11@@ -70,7 +69,6 @@ static void
 12 destroy_pool_resource(struct wl_resource *resource)
 13 {
 14 	struct pool *pool = wl_resource_get_user_data(resource);
 15-
 16 	unref_pool(pool);
 17 }
 18 
 19@@ -78,7 +76,6 @@ static void
 20 handle_buffer_destroy(struct wld_destructor *destructor)
 21 {
 22 	struct pool_reference *reference = wl_container_of(destructor, reference, destructor);
 23-
 24 	unref_pool(reference->pool);
 25 }
 26 
 27@@ -96,10 +93,8 @@ format_shm_to_wld(uint32_t format)
 28 }
 29 
 30 static void
 31-create_buffer(struct wl_client *client,
 32-              struct wl_resource *resource, uint32_t id,
 33-              int32_t offset, int32_t width, int32_t height,
 34-              int32_t stride, uint32_t format)
 35+create_buffer(struct wl_client *client, struct wl_resource *resource,
 36+              uint32_t id, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format)
 37 {
 38 	struct pool *pool = wl_resource_get_user_data(resource);
 39 	struct pool_reference *reference;
 40@@ -108,15 +103,12 @@ create_buffer(struct wl_client *client,
 41 	union wld_object object;
 42 
 43 	if (offset > pool->size || offset < 0) {
 44-		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE,
 45-		                       "offset is too big or negative");
 46+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE, "offset is too big or negative");
 47 		return;
 48 	}
 49 
 50 	object.ptr = (void *)((uintptr_t)pool->data + offset);
 51-	buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
 52-	                           width, height, format_shm_to_wld(format),
 53-	                           stride);
 54+	buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object, width, height, format_shm_to_wld(format), stride);
 55 
 56 	if (!buffer)
 57 		goto error0;
 58@@ -151,8 +143,7 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 59 }
 60 
 61 static void
 62-resize(struct wl_client *client, struct wl_resource *resource,
 63-       int32_t size)
 64+resize(struct wl_client *client, struct wl_resource *resource, int32_t size)
 65 {
 66 	struct pool *pool = wl_resource_get_user_data(resource);
 67 	void *data;
 68@@ -160,8 +151,7 @@ resize(struct wl_client *client, struct wl_resource *resource,
 69 	data = mremap(pool->data, pool->size, size, MREMAP_MAYMOVE);
 70 
 71 	if (data == MAP_FAILED) {
 72-		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
 73-		                       "mremap failed: %s", strerror(errno));
 74+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD, "mremap failed: %s", strerror(errno));
 75 		return;
 76 	}
 77 
 78@@ -170,15 +160,13 @@ resize(struct wl_client *client, struct wl_resource *resource,
 79 }
 80 
 81 static struct wl_shm_pool_interface shm_pool_implementation = {
 82-	.create_buffer = &create_buffer,
 83-	.destroy = &destroy,
 84-	.resize = &resize
 85+	.create_buffer = create_buffer,
 86+	.destroy = destroy,
 87+	.resize = resize,
 88 };
 89 
 90 static void
 91-create_pool(struct wl_client *client,
 92-            struct wl_resource *resource, uint32_t id,
 93-            int32_t fd, int32_t size)
 94+create_pool(struct wl_client *client, struct wl_resource *resource, uint32_t id, int32_t fd, int32_t size)
 95 {
 96 	struct pool *pool;
 97 
 98@@ -187,21 +175,18 @@ create_pool(struct wl_client *client,
 99 		return;
100 	}
101 
102-	pool->resource = wl_resource_create(client, &wl_shm_pool_interface,
103-	                                    wl_resource_get_version(resource), id);
104+	pool->resource = wl_resource_create(client, &wl_shm_pool_interface, wl_resource_get_version(resource), id);
105 
106 	if (!pool->resource) {
107 		wl_resource_post_no_memory(resource);
108 		goto error0;
109 	}
110 
111-	wl_resource_set_implementation(pool->resource, &shm_pool_implementation,
112-	                               pool, &destroy_pool_resource);
113+	wl_resource_set_implementation(pool->resource, &shm_pool_implementation, pool, &destroy_pool_resource);
114 	pool->data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
115 
116 	if (pool->data == MAP_FAILED) {
117-		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
118-		                       "mmap failed: %s", strerror(errno));
119+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD, "mmap failed: %s", strerror(errno));
120 		goto error1;
121 	}
122 
123@@ -221,8 +206,7 @@ static struct wl_shm_interface shm_implementation = {
124 };
125 
126 static void
127-bind_shm(struct wl_client *client, void *data, uint32_t version,
128-         uint32_t id)
129+bind_shm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
130 {
131 	struct wl_resource *resource;
132 
133@@ -245,8 +229,7 @@ shm_initialize(void)
134 	if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
135 		goto error1;
136 
137-	shm.global = wl_global_create(swc.display, &wl_shm_interface, 1,
138-	                              NULL, &bind_shm);
139+	shm.global = wl_global_create(swc.display, &wl_shm_interface, 1, NULL, &bind_shm);
140 
141 	if (!shm.global)
142 		goto error2;
+0, -1
1@@ -32,7 +32,6 @@ struct swc_shm {
2 };
3 
4 bool shm_initialize(void);
5-
6 void shm_finalize(void);
7 
8 #endif
+9, -16
 1@@ -29,11 +29,8 @@
 2 static struct wl_global *global;
 3 
 4 static void
 5-get_subsurface(struct wl_client *client,
 6-               struct wl_resource *resource,
 7-               uint32_t id,
 8-               struct wl_resource *surface_resource,
 9-               struct wl_resource *parent_resource)
10+get_subsurface(struct wl_client *client, struct wl_resource *resource,
11+               uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource)
12 {
13 	struct subsurface *subsurface;
14 
15@@ -46,29 +43,25 @@ get_subsurface(struct wl_client *client,
16 }
17 
18 static struct wl_subcompositor_interface subcompositor_implementation = {
19-	.get_subsurface = &get_subsurface,
20+	.get_subsurface = get_subsurface,
21 };
22 
23 static void
24-bind_subcompositor(struct wl_client *client, void *data,
25-                   uint32_t version, uint32_t id)
26+bind_subcompositor(struct wl_client *client, void *data, uint32_t version, uint32_t id)
27 {
28 	struct wl_resource *resource;
29 
30 	if (version > 1)
31 		version = 1;
32 
33-	resource = wl_resource_create(client, &wl_subcompositor_interface,
34-	                              version, id);
35-	wl_resource_set_implementation(resource, &subcompositor_implementation,
36-	                               NULL, NULL);
37+	resource = wl_resource_create(client, &wl_subcompositor_interface, version, id);
38+	wl_resource_set_implementation(resource, &subcompositor_implementation, NULL, NULL);
39 }
40 
41 bool
42-subcompositor_initialize()
43+subcompositor_initialize(void)
44 {
45-	global = wl_global_create(swc.display, &wl_subcompositor_interface, 1,
46-	                          NULL, &bind_subcompositor);
47+	global = wl_global_create(swc.display, &wl_subcompositor_interface, 1, NULL, &bind_subcompositor);
48 
49 	if (!global)
50 		return false;
51@@ -77,7 +70,7 @@ subcompositor_initialize()
52 }
53 
54 void
55-subcompositor_finalize()
56+subcompositor_finalize(void)
57 {
58 	wl_global_destroy(global);
59 }
+2, -3
 1@@ -24,8 +24,7 @@
 2 #ifndef SWC_SUBCOMPOSITOR_H
 3 #define SWC_SUBCOMPOSITOR_H
 4 
 5-bool subcompositor_initialize();
 6-
 7-void subcompositor_finalize();
 8+bool subcompositor_initialize(void);
 9+void subcompositor_finalize(void);
10 
11 #endif
+12, -23
 1@@ -33,25 +33,19 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 2 }
 3 
 4 static void
 5-set_position(struct wl_client *client,
 6-             struct wl_resource *resource,
 7-             int32_t x, int32_t y)
 8+set_position(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y)
 9 {
10 	/* TODO: Implement. */
11 }
12 
13 static void
14-place_above(struct wl_client *client,
15-            struct wl_resource *resource,
16-            struct wl_resource *sibling_resource)
17+place_above(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling_resource)
18 {
19 	/* TODO: Implement. */
20 }
21 
22 static void
23-place_below(struct wl_client *client,
24-            struct wl_resource *resource,
25-            struct wl_resource *sibling_resource)
26+place_below(struct wl_client *client, struct wl_resource *resource, struct wl_resource *sibling_resource)
27 {
28 	/* TODO: Implement. */
29 }
30@@ -69,40 +63,35 @@ set_desync(struct wl_client *client, struct wl_resource *resource)
31 }
32 
33 static struct wl_subsurface_interface subsurface_implementation = {
34-	.destroy = &destroy,
35-	.set_position = &set_position,
36-	.place_above = &place_above,
37-	.place_below = &place_below,
38-	.set_sync = &set_sync,
39-	.set_desync = &set_desync,
40+	.destroy = destroy,
41+	.set_position = set_position,
42+	.place_above = place_above,
43+	.place_below = place_below,
44+	.set_sync = set_sync,
45+	.set_desync = set_desync,
46 };
47 
48 static void
49 subsurface_destroy(struct wl_resource *resource)
50 {
51 	struct subsurface *subsurface = wl_resource_get_user_data(resource);
52-
53 	free(subsurface);
54 }
55 
56 struct subsurface *
57-subsurface_new(struct wl_client *client,
58-               uint32_t version, uint32_t id)
59+subsurface_new(struct wl_client *client, uint32_t version, uint32_t id)
60 {
61 	struct subsurface *subsurface;
62 
63 	if (!(subsurface = malloc(sizeof *subsurface)))
64 		goto error0;
65 
66-	subsurface->resource = wl_resource_create(client, &wl_subsurface_interface,
67-	                                          version, id);
68+	subsurface->resource = wl_resource_create(client, &wl_subsurface_interface, version, id);
69 
70 	if (!subsurface->resource)
71 		goto error1;
72 
73-	wl_resource_set_implementation(subsurface->resource,
74-	                               &subsurface_implementation,
75-	                               subsurface, &subsurface_destroy);
76+	wl_resource_set_implementation(subsurface->resource, &subsurface_implementation, subsurface, &subsurface_destroy);
77 
78 	return subsurface;
79 
+1, -2
1@@ -32,7 +32,6 @@ struct subsurface {
2 	struct wl_resource *resource;
3 };
4 
5-struct subsurface *subsurface_new(struct wl_client *client,
6-                                  uint32_t version, uint32_t id);
7+struct subsurface *subsurface_new(struct wl_client *client, uint32_t version, uint32_t id);
8 
9 #endif
+45, -86
  1@@ -65,10 +65,8 @@ state_finalize(struct surface_state *state)
  2 {
  3 	struct wl_resource *resource, *tmp;
  4 
  5-	if (state->buffer) {
  6-		/* Remove any buffer listeners */
  7+	if (state->buffer)
  8 		wl_list_remove(&state->buffer_destroy_listener.link);
  9-	}
 10 
 11 	pixman_region32_fini(&state->damage);
 12 	pixman_region32_fini(&state->opaque);
 13@@ -84,22 +82,15 @@ state_finalize(struct surface_state *state)
 14  * to manage the destroy listeners we have for the new and old buffer.
 15  */
 16 static void
 17-state_set_buffer(struct surface_state *state,
 18-                 struct wl_resource *resource)
 19+state_set_buffer(struct surface_state *state, struct wl_resource *resource)
 20 {
 21 	struct wld_buffer *buffer = resource ? wayland_buffer_get(resource) : NULL;
 22 
 23-	if (state->buffer) {
 24-		/* No longer need to worry about the old buffer being destroyed. */
 25+	if (state->buffer)
 26 		wl_list_remove(&state->buffer_destroy_listener.link);
 27-	}
 28 
 29-	if (buffer) {
 30-		/* Need to watch the new buffer for destruction so we can remove it
 31-         * from state. */
 32-		wl_resource_add_destroy_listener(resource,
 33-		                                 &state->buffer_destroy_listener);
 34-	}
 35+	if (buffer)
 36+		wl_resource_add_destroy_listener(resource, &state->buffer_destroy_listener);
 37 
 38 	state->buffer = buffer;
 39 	state->buffer_resource = resource;
 40@@ -111,8 +102,7 @@ handle_frame(struct view_handler *handler, uint32_t time)
 41 	struct surface *surface = wl_container_of(handler, surface, view_handler);
 42 	struct wl_resource *resource, *tmp;
 43 
 44-	wl_list_for_each_safe (resource, tmp,
 45-	                       &surface->state.frame_callbacks, link) {
 46+	wl_list_for_each_safe (resource, tmp, &surface->state.frame_callbacks, link) {
 47 		wl_callback_send_done(resource, time);
 48 		wl_resource_destroy(resource);
 49 	}
 50@@ -121,8 +111,7 @@ handle_frame(struct view_handler *handler, uint32_t time)
 51 }
 52 
 53 static void
 54-handle_screens(struct view_handler *handler,
 55-               uint32_t entered, uint32_t left)
 56+handle_screens(struct view_handler *handler, uint32_t entered, uint32_t left)
 57 {
 58 	struct surface *surface = wl_container_of(handler, surface, view_handler);
 59 	struct screen *screen;
 60@@ -150,8 +139,8 @@ handle_screens(struct view_handler *handler,
 61 }
 62 
 63 static const struct view_handler_impl view_handler_impl = {
 64-	.frame = &handle_frame,
 65-	.screens = &handle_screens,
 66+	.frame = handle_frame,
 67+	.screens = handle_screens,
 68 };
 69 
 70 static void
 71@@ -174,39 +163,28 @@ attach(struct wl_client *client, struct wl_resource *resource,
 72 }
 73 
 74 static void
 75-damage(struct wl_client *client, struct wl_resource *resource,
 76-       int32_t x, int32_t y, int32_t width, int32_t height)
 77+damage(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
 78 {
 79 	struct surface *surface = wl_resource_get_user_data(resource);
 80 
 81 	surface->pending.commit |= SURFACE_COMMIT_DAMAGE;
 82-
 83-	pixman_region32_union_rect(&surface->pending.state.damage,
 84-	                           &surface->pending.state.damage,
 85-	                           x, y, width, height);
 86+	pixman_region32_union_rect(&surface->pending.state.damage, &surface->pending.state.damage, x, y, width, height);
 87 }
 88 
 89 static void
 90-frame(struct wl_client *client, struct wl_resource *resource,
 91-      uint32_t id)
 92+frame(struct wl_client *client, struct wl_resource *resource, uint32_t id)
 93 {
 94 	struct surface *surface = wl_resource_get_user_data(resource);
 95 	struct wl_resource *callback_resource;
 96 
 97 	surface->pending.commit |= SURFACE_COMMIT_FRAME;
 98-
 99-	callback_resource = wl_resource_create(client, &wl_callback_interface,
100-	                                       1, id);
101-	wl_resource_set_implementation(callback_resource, NULL, NULL,
102-	                               &remove_resource);
103-	wl_list_insert(surface->pending.state.frame_callbacks.prev,
104-	               wl_resource_get_link(callback_resource));
105+	callback_resource = wl_resource_create(client, &wl_callback_interface, 1, id);
106+	wl_resource_set_implementation(callback_resource, NULL, NULL, &remove_resource);
107+	wl_list_insert(surface->pending.state.frame_callbacks.prev, wl_resource_get_link(callback_resource));
108 }
109 
110 static void
111-set_opaque_region(struct wl_client *client,
112-                  struct wl_resource *resource,
113-                  struct wl_resource *region_resource)
114+set_opaque_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource)
115 {
116 	struct surface *surface = wl_resource_get_user_data(resource);
117 
118@@ -214,16 +192,14 @@ set_opaque_region(struct wl_client *client,
119 
120 	if (region_resource) {
121 		struct region *region = wl_resource_get_user_data(region_resource);
122-
123 		pixman_region32_copy(&surface->pending.state.opaque, &region->region);
124-	} else
125+	} else {
126 		pixman_region32_clear(&surface->pending.state.opaque);
127+	}
128 }
129 
130 static void
131-set_input_region(struct wl_client *client,
132-                 struct wl_resource *resource,
133-                 struct wl_resource *region_resource)
134+set_input_region(struct wl_client *client, struct wl_resource *resource, struct wl_resource *region_resource)
135 {
136 	struct surface *surface = wl_resource_get_user_data(resource);
137 
138@@ -231,19 +207,16 @@ set_input_region(struct wl_client *client,
139 
140 	if (region_resource) {
141 		struct region *region = wl_resource_get_user_data(region_resource);
142-
143 		pixman_region32_copy(&surface->pending.state.input, &region->region);
144-	} else
145+	} else {
146 		pixman_region32_reset(&surface->pending.state.input, &infinite_extents);
147+	}
148 }
149 
150 static inline void
151-trim_region(pixman_region32_t *region,
152-            struct wld_buffer *buffer)
153+trim_region(pixman_region32_t *region, struct wld_buffer *buffer)
154 {
155-	pixman_region32_intersect_rect(region, region, 0, 0,
156-	                               buffer ? buffer->width : 0,
157-	                               buffer ? buffer->height : 0);
158+	pixman_region32_intersect_rect(region, region, 0, 0, buffer ? buffer->width : 0, buffer ? buffer->height : 0);
159 }
160 
161 static void
162@@ -254,40 +227,31 @@ commit(struct wl_client *client, struct wl_resource *resource)
163 
164 	/* Attach */
165 	if (surface->pending.commit & SURFACE_COMMIT_ATTACH) {
166-		if (surface->state.buffer
167-		    && surface->state.buffer != surface->pending.state.buffer) {
168+		if (surface->state.buffer && surface->state.buffer != surface->pending.state.buffer)
169 			wl_buffer_send_release(surface->state.buffer_resource);
170-		}
171 
172-		state_set_buffer(&surface->state,
173-		                 surface->pending.state.buffer_resource);
174+		state_set_buffer(&surface->state, surface->pending.state.buffer_resource);
175 	}
176 
177 	buffer = surface->state.buffer;
178 
179 	/* Damage */
180 	if (surface->pending.commit & SURFACE_COMMIT_DAMAGE) {
181-		pixman_region32_union(&surface->state.damage, &surface->state.damage,
182-		                      &surface->pending.state.damage);
183+		pixman_region32_union(&surface->state.damage, &surface->state.damage, &surface->pending.state.damage);
184 		pixman_region32_clear(&surface->pending.state.damage);
185 	}
186 
187 	/* Opaque */
188-	if (surface->pending.commit & SURFACE_COMMIT_OPAQUE) {
189-		pixman_region32_copy(&surface->state.opaque,
190-		                     &surface->pending.state.opaque);
191-	}
192+	if (surface->pending.commit & SURFACE_COMMIT_OPAQUE)
193+		pixman_region32_copy(&surface->state.opaque, &surface->pending.state.opaque);
194 
195 	/* Input */
196-	if (surface->pending.commit & SURFACE_COMMIT_INPUT) {
197-		pixman_region32_copy(&surface->state.input,
198-		                     &surface->pending.state.input);
199-	}
200+	if (surface->pending.commit & SURFACE_COMMIT_INPUT)
201+		pixman_region32_copy(&surface->state.input, &surface->pending.state.input);
202 
203 	/* Frame */
204 	if (surface->pending.commit & SURFACE_COMMIT_FRAME) {
205-		wl_list_insert_list(&surface->state.frame_callbacks,
206-		                    &surface->pending.state.frame_callbacks);
207+		wl_list_insert_list(&surface->state.frame_callbacks, &surface->pending.state.frame_callbacks);
208 		wl_list_init(&surface->pending.state.frame_callbacks);
209 	}
210 
211@@ -304,29 +268,27 @@ commit(struct wl_client *client, struct wl_resource *resource)
212 }
213 
214 void
215-set_buffer_transform(struct wl_client *client,
216-                     struct wl_resource *surface, int32_t transform)
217+set_buffer_transform(struct wl_client *client, struct wl_resource *surface, int32_t transform)
218 {
219 	/* TODO: Implement */
220 }
221 
222 void
223-set_buffer_scale(struct wl_client *client, struct wl_resource *surface,
224-                 int32_t scale)
225+set_buffer_scale(struct wl_client *client, struct wl_resource *surface, int32_t scale)
226 {
227 	/* TODO: Implement */
228 }
229 
230 static struct wl_surface_interface surface_implementation = {
231-	.destroy = &destroy,
232-	.attach = &attach,
233-	.damage = &damage,
234-	.frame = &frame,
235-	.set_opaque_region = &set_opaque_region,
236-	.set_input_region = &set_input_region,
237-	.commit = &commit,
238-	.set_buffer_transform = &set_buffer_transform,
239-	.set_buffer_scale = &set_buffer_scale
240+	.destroy = destroy,
241+	.attach = attach,
242+	.damage = damage,
243+	.frame = frame,
244+	.set_opaque_region = set_opaque_region,
245+	.set_input_region = set_input_region,
246+	.commit = commit,
247+	.set_buffer_transform = set_buffer_transform,
248+	.set_buffer_scale = set_buffer_scale,
249 };
250 
251 static void
252@@ -351,8 +313,7 @@ surface_destroy(struct wl_resource *resource)
253  * @return The newly allocated surface.
254  */
255 struct surface *
256-surface_new(struct wl_client *client,
257-            uint32_t version, uint32_t id)
258+surface_new(struct wl_client *client, uint32_t version, uint32_t id)
259 {
260 	struct surface *surface;
261 
262@@ -370,10 +331,8 @@ surface_new(struct wl_client *client,
263 	state_initialize(&surface->pending.state);
264 
265 	/* Add the surface to the client. */
266-	surface->resource = wl_resource_create(client, &wl_surface_interface,
267-	                                       version, id);
268-	wl_resource_set_implementation(surface->resource, &surface_implementation,
269-	                               surface, &surface_destroy);
270+	surface->resource = wl_resource_create(client, &wl_surface_interface, version, id);
271+	wl_resource_set_implementation(surface->resource, &surface_implementation, surface, &surface_destroy);
272 
273 	return surface;
274 }
+2, -5
 1@@ -60,8 +60,7 @@ struct surface {
 2 
 3 	struct surface_state state;
 4 
 5-	struct
 6-	    {
 7+	struct {
 8 		struct surface_state state;
 9 		uint32_t commit;
10 		int32_t x, y;
11@@ -71,9 +70,7 @@ struct surface {
12 	struct view_handler view_handler;
13 };
14 
15-struct surface *surface_new(struct wl_client *client,
16-                            uint32_t version, uint32_t id);
17-
18+struct surface *surface_new(struct wl_client *client, uint32_t version, uint32_t id);
19 void surface_set_view(struct surface *surface, struct view *view);
20 
21 #endif
+14, -25
 1@@ -41,7 +41,7 @@
 2 #include "window.h"
 3 #include "xdg_shell.h"
 4 #ifdef ENABLE_XWAYLAND
 5-#include "xserver.h"
 6+# include "xserver.h"
 7 #endif
 8 
 9 extern struct swc_launch swc_launch;
10@@ -72,27 +72,20 @@ setup_compositor(void)
11 {
12 	pixman_region32_t pointer_region;
13 	struct screen *screen;
14-	struct swc_rectangle *geometry;
15-
16-	wl_list_insert(&swc.seat->keyboard->handlers,
17-	               &swc.bindings->keyboard_handler->link);
18-	wl_list_insert(&swc.seat->pointer->handlers,
19-	               &swc.bindings->pointer_handler->link);
20-	wl_list_insert(&swc.seat->pointer->handlers,
21-	               &swc.compositor->pointer_handler->link);
22-	wl_list_insert(&swc.seat->pointer->handlers,
23-	               &screens_pointer_handler.link);
24-	wl_signal_add(&swc.seat->pointer->focus.event_signal,
25-	              &window_enter_listener);
26+	struct swc_rectangle *geom;
27+
28+	wl_list_insert(&swc.seat->keyboard->handlers, &swc.bindings->keyboard_handler->link);
29+	wl_list_insert(&swc.seat->pointer->handlers, &swc.bindings->pointer_handler->link);
30+	wl_list_insert(&swc.seat->pointer->handlers, &swc.compositor->pointer_handler->link);
31+	wl_list_insert(&swc.seat->pointer->handlers, &screens_pointer_handler.link);
32+	wl_signal_add(&swc.seat->pointer->focus.event_signal, &window_enter_listener);
33 
34 	/* Calculate pointer region */
35 	pixman_region32_init(&pointer_region);
36 
37 	wl_list_for_each (screen, &swc.screens, link) {
38-		geometry = &screen->base.geometry;
39-		pixman_region32_union_rect(&pointer_region, &pointer_region,
40-		                           geometry->x, geometry->y,
41-		                           geometry->width, geometry->height);
42+		geom = &screen->base.geometry;
43+		pixman_region32_union_rect(&pointer_region, &pointer_region, geom->x, geom->y, geom->width, geom->height);
44 	}
45 
46 	pointer_set_region(swc.seat->pointer, &pointer_region);
47@@ -113,14 +106,11 @@ swc_deactivate(void)
48 	send_event(&swc.event_signal, SWC_EVENT_DEACTIVATED, NULL);
49 }
50 
51-EXPORT
52-bool
53-swc_initialize(struct wl_display *display,
54-               struct wl_event_loop *event_loop,
55-               const struct swc_manager *manager)
56+EXPORT bool
57+swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, const struct swc_manager *manager)
58 {
59 	swc.display = display;
60-	swc.event_loop = event_loop ?: wl_display_get_event_loop(display);
61+	swc.event_loop = event_loop ? event_loop : wl_display_get_event_loop(display);
62 	swc.manager = manager;
63 	const char *default_seat = "seat0";
64 	wl_signal_init(&swc.event_signal);
65@@ -226,8 +216,7 @@ error0:
66 	return false;
67 }
68 
69-EXPORT
70-void
71+EXPORT void
72 swc_finalize(void)
73 {
74 #ifdef ENABLE_XWAYLAND
+58, -71
  1@@ -41,50 +41,48 @@ struct swc_rectangle {
  2 
  3 struct swc_screen_handler {
  4 	/**
  5-     * Called when the screen is about to be destroyed.
  6-     *
  7-     * After this is called, the screen is no longer valid.
  8-     */
  9+	 * Called when the screen is about to be destroyed.
 10+	 *
 11+	 * After this is called, the screen is no longer valid.
 12+	 */
 13 	void (*destroy)(void *data);
 14 
 15 	/**
 16-     * Called when the total area of the screen has changed.
 17-     */
 18+	 * Called when the total area of the screen has changed.
 19+	 */
 20 	void (*geometry_changed)(void *data);
 21 
 22 	/**
 23-     * Called when the geometry of the screen available for laying out windows
 24-     * has changed.
 25-     *
 26-     * A window manager should respond by making sure all visible windows are
 27-     * within this area.
 28-     */
 29+	 * Called when the geometry of the screen available for laying out windows has
 30+	 * changed.
 31+	 *
 32+	 * A window manager should respond by making sure all visible windows are
 33+	 * within this area.
 34+	 */
 35 	void (*usable_geometry_changed)(void *data);
 36 
 37 	/**
 38-     * Called when the pointer enters the screen.
 39-     */
 40+	 * Called when the pointer enters the screen.
 41+	 */
 42 	void (*entered)(void *data);
 43 };
 44 
 45 struct swc_screen {
 46 	/**
 47-     * The total area of the screen.
 48-     */
 49+	 * The total area of the screen.
 50+	 */
 51 	struct swc_rectangle geometry;
 52 
 53 	/**
 54-     * The area of the screen available for placing windows.
 55-     */
 56+	 * The area of the screen available for placing windows.
 57+	 */
 58 	struct swc_rectangle usable_geometry;
 59 };
 60 
 61 /**
 62  * Set the handler associated with this screen.
 63  */
 64-void swc_screen_set_handler(struct swc_screen *screen,
 65-                            const struct swc_screen_handler *handler,
 66-                            void *data);
 67+void swc_screen_set_handler(struct swc_screen *screen, const struct swc_screen_handler *handler, void *data);
 68 
 69 /* }}} */
 70 
 71@@ -92,51 +90,51 @@ void swc_screen_set_handler(struct swc_screen *screen,
 72 
 73 struct swc_window_handler {
 74 	/**
 75-     * Called when the window is about to be destroyed.
 76-     *
 77-     * After this is called, the window is no longer valid.
 78-     */
 79+	 * Called when the window is about to be destroyed.
 80+	 *
 81+	 * After this is called, the window is no longer valid.
 82+	 */
 83 	void (*destroy)(void *data);
 84 
 85 	/**
 86-     * Called when the window's title changes.
 87-     */
 88+	 * Called when the window's title changes.
 89+	 */
 90 	void (*title_changed)(void *data);
 91 
 92 	/**
 93-     * Called when the window's application identifier changes.
 94-     */
 95+	 * Called when the window's application identifier changes.
 96+	 */
 97 	void (*app_id_changed)(void *data);
 98 
 99 	/**
100-     * Called when the window's parent changes.
101-     *
102-     * This can occur when the window becomes a transient for another window, or
103-     * becomes a toplevel window.
104-     */
105+	 * Called when the window's parent changes.
106+	 *
107+	 * This can occur when the window becomes a transient for another window, or
108+	 * becomes a toplevel window.
109+	 */
110 	void (*parent_changed)(void *data);
111 
112 	/**
113-     * Called when the pointer enters the window.
114-     */
115+	 * Called when the pointer enters the window.
116+	 */
117 	void (*entered)(void *data);
118 
119 	/**
120-     * Called when the window wants to initiate an interactive move, but the
121-     * window is not in stacked mode.
122-     *
123-     * The window manager may respond by changing the window's mode, after which
124-     * the interactive move will be honored.
125-     */
126+	 * Called when the window wants to initiate an interactive move, but the
127+	 * window is not in stacked mode.
128+	 *
129+	 * The window manager may respond by changing the window's mode, after which
130+	 * the interactive move will be honored.
131+	 */
132 	void (*move)(void *data);
133 
134 	/**
135-     * Called when the window wants to initiate an interactive resize, but the
136-     * window is not in stacked mode.
137-     *
138-     * The window manager may respond by changing the window's mode, after which
139-     * the interactive resize will be honored.
140-     */
141+	 * Called when the window wants to initiate an interactive resize, but the
142+	 * window is not in stacked mode.
143+	 *
144+	 * The window manager may respond by changing the window's mode, after which
145+	 * the interactive resize will be honored.
146+	 */
147 	void (*resize)(void *data);
148 };
149 
150@@ -150,9 +148,7 @@ struct swc_window {
151 /**
152  * Set the handler associated with this window.
153  */
154-void swc_window_set_handler(struct swc_window *window,
155-                            const struct swc_window_handler *handler,
156-                            void *data);
157+void swc_window_set_handler(struct swc_window *window, const struct swc_window_handler *handler, void *data);
158 
159 /**
160  * Request that the specified window close.
161@@ -201,8 +197,7 @@ void swc_window_set_tiled(struct swc_window *window);
162 /**
163  * Sets the window to fullscreen mode.
164  */
165-void swc_window_set_fullscreen(struct swc_window *window,
166-                               struct swc_screen *screen);
167+void swc_window_set_fullscreen(struct swc_window *window, struct swc_screen *screen);
168 
169 /**
170  * Set the window's position.
171@@ -218,8 +213,7 @@ void swc_window_set_position(struct swc_window *window, int32_t x, int32_t y);
172  * The width and height refer to the dimension of the actual contents of the
173  * window and should be adjusted for the border size.
174  */
175-void swc_window_set_size(struct swc_window *window,
176-                         uint32_t width, uint32_t height);
177+void swc_window_set_size(struct swc_window *window, uint32_t width, uint32_t height);
178 
179 /**
180  * Set the window's size and position.
181@@ -227,8 +221,7 @@ void swc_window_set_size(struct swc_window *window,
182  * This is a convenience function that is equivalent to calling
183  * swc_window_set_size and then swc_window_set_position.
184  */
185-void swc_window_set_geometry(struct swc_window *window,
186-                             const struct swc_rectangle *geometry);
187+void swc_window_set_geometry(struct swc_window *window, const struct swc_rectangle *geometry);
188 
189 /**
190  * Set the window's border color and width.
191@@ -236,8 +229,7 @@ void swc_window_set_geometry(struct swc_window *window,
192  * NOTE: The window's geometry remains unchanged, and should be updated if a
193  *       fixed top-left corner of the border is desired.
194  */
195-void swc_window_set_border(struct swc_window *window,
196-                           uint32_t color, uint32_t width);
197+void swc_window_set_border(struct swc_window *window, uint32_t color, uint32_t width);
198 
199 /**
200  * Begin an interactive move of the specified window.
201@@ -284,17 +276,14 @@ enum swc_binding_type {
202 	SWC_BINDING_BUTTON,
203 };
204 
205-typedef void (*swc_binding_handler)(void *data, uint32_t time,
206-                                    uint32_t value, uint32_t state);
207+typedef void (*swc_binding_handler)(void *data, uint32_t time, uint32_t value, uint32_t state);
208 
209 /**
210  * Register a new input binding.
211  *
212  * Returns 0 on success, negative error code otherwise.
213  */
214-int swc_add_binding(enum swc_binding_type type,
215-                    uint32_t modifiers, uint32_t value,
216-                    swc_binding_handler handler, void *data);
217+int swc_add_binding(enum swc_binding_type type, uint32_t modifiers, uint32_t value, swc_binding_handler handler, void *data);
218 
219 /* }}} */
220 
221@@ -304,13 +293,13 @@ int swc_add_binding(enum swc_binding_type type,
222  */
223 struct swc_manager {
224 	/**
225-     * Called when a new screen is created.
226-     */
227+	 * Called when a new screen is created.
228+	 */
229 	void (*new_screen)(struct swc_screen *screen);
230 
231 	/**
232-     * Called when a new window is created.
233-     */
234+	 * Called when a new window is created.
235+	 */
236 	void (*new_window)(struct swc_window *window);
237 };
238 
239@@ -318,9 +307,7 @@ struct swc_manager {
240  * Initializes the compositor using the specified display, event_loop, and
241  * manager.
242  */
243-bool swc_initialize(struct wl_display *display,
244-                    struct wl_event_loop *event_loop,
245-                    const struct swc_manager *manager);
246+bool swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, const struct swc_manager *manager);
247 
248 /**
249  * Stops the compositor, releasing any used resources.
+2, -1
 1@@ -26,7 +26,8 @@
 2 #include <wayland-server.h>
 3 
 4 pixman_box32_t infinite_extents = {
 5-	.x1 = INT32_MIN, .y1 = INT32_MIN, .x2 = INT32_MAX, .y2 = INT32_MAX
 6+	.x1 = INT32_MIN, .y1 = INT32_MIN,
 7+	.x2 = INT32_MAX, .y2 = INT32_MAX,
 8 };
 9 
10 void
+5, -7
 1@@ -44,9 +44,9 @@
 2 #define MESSAGE_SOURCE
 3 #endif
 4 
 5-#define MESSAGE(type, format, ...)                                \
 6-	do {                                                      \
 7-		MESSAGE_SOURCE                                    \
 8+#define MESSAGE(type, format, ...) \
 9+	do { \
10+		MESSAGE_SOURCE \
11 		fprintf(stderr, type ": " format, ##__VA_ARGS__); \
12 	} while (false)
13 
14@@ -84,8 +84,7 @@ rectangle_contains_point(const struct swc_rectangle *rectangle, int32_t x, int32
15 }
16 
17 static inline bool
18-rectangle_overlap(const struct swc_rectangle *r1,
19-                  const struct swc_rectangle *r2)
20+rectangle_overlap(const struct swc_rectangle *r1, const struct swc_rectangle *r2)
21 {
22 	return (MAX(r1->x + r1->width, r2->x + r2->width) - MIN(r1->x, r2->x)
23 	        < r1->width + r2->width)
24@@ -94,8 +93,7 @@ rectangle_overlap(const struct swc_rectangle *r1,
25 }
26 
27 static inline void
28-array_remove(struct wl_array *array,
29-             void *item, size_t size)
30+array_remove(struct wl_array *array, void *item, size_t size)
31 {
32 	size_t bytes = array->size - ((intptr_t)item + size - (intptr_t)array->data);
33 	if (bytes > 0)
+8, -12
 1@@ -29,12 +29,12 @@
 2 
 3 #include <wld/wld.h>
 4 
 5-#define HANDLE(view, handler, method, ...)                                     \
 6-	do {                                                                   \
 7-		wl_list_for_each (handler, &view->handlers, link) {            \
 8-			if (handler->impl->method)                             \
 9+#define HANDLE(view, handler, method, ...) \
10+	do { \
11+		wl_list_for_each (handler, &view->handlers, link) { \
12+			if (handler->impl->method) \
13 				handler->impl->method(handler, ##__VA_ARGS__); \
14-		}                                                              \
15+		} \
16 	} while (0)
17 
18 void
19@@ -113,8 +113,7 @@ view_set_size(struct view *view, uint32_t width, uint32_t height)
20 	if (view->geometry.width == width && view->geometry.height == height)
21 		return false;
22 
23-	uint32_t old_width = view->geometry.width,
24-	         old_height = view->geometry.height;
25+	uint32_t old_width = view->geometry.width, old_height = view->geometry.height;
26 
27 	view->geometry.width = width;
28 	view->geometry.height = height;
29@@ -126,8 +125,7 @@ view_set_size(struct view *view, uint32_t width, uint32_t height)
30 bool
31 view_set_size_from_buffer(struct view *view, struct wld_buffer *buffer)
32 {
33-	return view_set_size(view, buffer ? buffer->width : 0,
34-	                     buffer ? buffer->height : 0);
35+	return view_set_size(view, buffer ? buffer->width : 0, buffer ? buffer->height : 0);
36 }
37 
38 void
39@@ -136,8 +134,7 @@ view_set_screens(struct view *view, uint32_t screens)
40 	if (view->screens == screens)
41 		return;
42 
43-	uint32_t entered = screens & ~view->screens,
44-	         left = view->screens & ~screens;
45+	uint32_t entered = screens & ~view->screens, left = view->screens & ~screens;
46 	struct view_handler *handler;
47 
48 	view->screens = screens;
49@@ -162,6 +159,5 @@ void
50 view_frame(struct view *view, uint32_t time)
51 {
52 	struct view_handler *handler;
53-
54 	HANDLE(view, handler, frame, time);
55 }
+2, -4
 1@@ -72,11 +72,9 @@ struct view_handler_impl {
 2 	/* Called after the view's position changes. */
 3 	void (*move)(struct view_handler *handler);
 4 	/* Called after the view's size changes. */
 5-	void (*resize)(struct view_handler *handler,
 6-	               uint32_t old_width, uint32_t old_height);
 7+	void (*resize)(struct view_handler *handler, uint32_t old_width, uint32_t old_height);
 8 	/* Called when the set of screens the view is visible on changes. */
 9-	void (*screens)(struct view_handler *handler,
10-	                uint32_t left, uint32_t entered);
11+	void (*screens)(struct view_handler *handler, uint32_t left, uint32_t entered);
12 };
13 
14 /**
+4, -9
 1@@ -36,16 +36,14 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 2 }
 3 
 4 static const struct wl_buffer_interface buffer_implementation = {
 5-	.destroy = &destroy
 6+	.destroy = destroy,
 7 };
 8 
 9 struct wld_buffer *
10 wayland_buffer_get(struct wl_resource *resource)
11 {
12-	if (wl_resource_instance_of(resource, &wl_buffer_interface,
13-	                            &buffer_implementation)) {
14+	if (wl_resource_instance_of(resource, &wl_buffer_interface, &buffer_implementation))
15 		return wl_resource_get_user_data(resource);
16-	}
17 
18 	return NULL;
19 }
20@@ -54,13 +52,11 @@ static void
21 destroy_buffer(struct wl_resource *resource)
22 {
23 	struct wld_buffer *buffer = wl_resource_get_user_data(resource);
24-
25 	wld_buffer_unreference(buffer);
26 }
27 
28 struct wl_resource *
29-wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id,
30-                               struct wld_buffer *buffer)
31+wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id, struct wld_buffer *buffer)
32 {
33 	struct wl_resource *resource;
34 
35@@ -71,8 +67,7 @@ wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint3
36 		return NULL;
37 	}
38 
39-	wl_resource_set_implementation(resource, &buffer_implementation,
40-	                               buffer, &destroy_buffer);
41+	wl_resource_set_implementation(resource, &buffer_implementation, buffer, &destroy_buffer);
42 
43 	return resource;
44 }
+1, -3
 1@@ -30,8 +30,6 @@ struct wl_client;
 2 struct wl_resource;
 3 
 4 struct wld_buffer *wayland_buffer_get(struct wl_resource *resource);
 5-
 6-struct wl_resource *wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id,
 7-                                                   struct wld_buffer *buffer);
 8+struct wl_resource *wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id, struct wld_buffer *buffer);
 9 
10 #endif
+61, -106
  1@@ -56,29 +56,28 @@ handle_window_enter(struct wl_listener *listener, void *data)
  2 }
  3 
  4 struct wl_listener window_enter_listener = {
  5-	.notify = &handle_window_enter
  6+	.notify = handle_window_enter,
  7 };
  8 
  9 static void
 10-begin_interaction(struct window_pointer_interaction *interaction,
 11-                  struct button *button)
 12+begin_interaction(struct window_pointer_interaction *interaction, struct button *button)
 13 {
 14 	if (button) {
 15 		/* Store the serial of the button press so we are able to cancel the
 16-         * interaction if the window changes from stacked mode. */
 17+		 * interaction if the window changes from stacked mode. */
 18 		interaction->serial = button->press.serial;
 19 		interaction->original_handler = button->handler;
 20 		button->handler = &interaction->handler;
 21-	} else
 22+	} else {
 23 		interaction->original_handler = NULL;
 24+	}
 25 
 26 	interaction->active = true;
 27 	wl_list_insert(&swc.seat->pointer->handlers, &interaction->handler.link);
 28 }
 29 
 30 static void
 31-end_interaction(struct window_pointer_interaction *interaction,
 32-                struct button *button)
 33+end_interaction(struct window_pointer_interaction *interaction, struct button *button)
 34 {
 35 	if (!interaction->active)
 36 		return;
 37@@ -93,9 +92,7 @@ end_interaction(struct window_pointer_interaction *interaction,
 38 			}
 39 		}
 40 
 41-		interaction->original_handler->button(interaction->original_handler,
 42-		                                      get_time(), button,
 43-		                                      WL_POINTER_BUTTON_STATE_RELEASED);
 44+		interaction->original_handler->button(interaction->original_handler, get_time(), button, WL_POINTER_BUTTON_STATE_RELEASED);
 45 	}
 46 
 47 remove:
 48@@ -115,11 +112,8 @@ flush(struct window *window)
 49 	}
 50 }
 51 
 52-EXPORT
 53-void
 54-swc_window_set_handler(struct swc_window *base,
 55-                       const struct swc_window_handler *handler,
 56-                       void *data)
 57+EXPORT void
 58+swc_window_set_handler(struct swc_window *base, const struct swc_window_handler *handler, void *data)
 59 {
 60 	struct window *window = INTERNAL(base);
 61 
 62@@ -127,8 +121,7 @@ swc_window_set_handler(struct swc_window *base,
 63 	window->handler_data = data;
 64 }
 65 
 66-EXPORT
 67-void
 68+EXPORT void
 69 swc_window_close(struct swc_window *base)
 70 {
 71 	struct window *window = INTERNAL(base);
 72@@ -137,44 +130,39 @@ swc_window_close(struct swc_window *base)
 73 		window->impl->close(window);
 74 }
 75 
 76-EXPORT
 77-void
 78+EXPORT void
 79 swc_window_show(struct swc_window *window)
 80 {
 81 	compositor_view_show(INTERNAL(window)->view);
 82 }
 83 
 84-EXPORT
 85-void
 86+EXPORT void
 87 swc_window_hide(struct swc_window *window)
 88 {
 89 	compositor_view_hide(INTERNAL(window)->view);
 90 }
 91 
 92-EXPORT
 93-void
 94+EXPORT void
 95 swc_window_focus(struct swc_window *base)
 96 {
 97 	struct window *window = INTERNAL(base);
 98-	struct compositor_view *new_focus = window ? window->view : NULL,
 99-	                       *old_focus = swc.seat->keyboard->focus.view;
100+	struct compositor_view *new = window ? window->view : NULL, *old = swc.seat->keyboard->focus.view;
101 
102-	if (new_focus == old_focus)
103+	if (new == old)
104 		return;
105 
106 	/* Focus the new window before unfocusing the old one in case both are X11
107-     * windows so the xwl_window implementation can handle this transition
108-     * correctly. */
109+	 * windows so the xwl_window implementation can handle this transition
110+	 * correctly. */
111 	if (window && window->impl->focus)
112 		window->impl->focus(window);
113-	if (old_focus && old_focus->window && old_focus->window->impl->unfocus)
114-		old_focus->window->impl->unfocus(old_focus->window);
115+	if (old && old->window && old->window->impl->unfocus)
116+		old->window->impl->unfocus(old->window);
117 
118-	keyboard_set_focus(swc.seat->keyboard, new_focus);
119+	keyboard_set_focus(swc.seat->keyboard, new);
120 }
121 
122-EXPORT
123-void
124+EXPORT void
125 swc_window_set_stacked(struct swc_window *base)
126 {
127 	struct window *window = INTERNAL(base);
128@@ -188,8 +176,7 @@ swc_window_set_stacked(struct swc_window *base)
129 	window->mode = WINDOW_MODE_STACKED;
130 }
131 
132-EXPORT
133-void
134+EXPORT void
135 swc_window_set_tiled(struct swc_window *base)
136 {
137 	struct window *window = INTERNAL(base);
138@@ -201,10 +188,8 @@ swc_window_set_tiled(struct swc_window *base)
139 	window->mode = WINDOW_MODE_TILED;
140 }
141 
142-EXPORT
143-void
144-swc_window_set_fullscreen(struct swc_window *base,
145-                          struct swc_screen *screen)
146+EXPORT void
147+swc_window_set_fullscreen(struct swc_window *base, struct swc_screen *screen)
148 {
149 	struct window *window = INTERNAL(base);
150 
151@@ -215,8 +200,7 @@ swc_window_set_fullscreen(struct swc_window *base,
152 	window->mode = WINDOW_MODE_FULLSCREEN;
153 }
154 
155-EXPORT
156-void
157+EXPORT void
158 swc_window_set_position(struct swc_window *base, int32_t x, int32_t y)
159 {
160 	struct window *window = INTERNAL(base);
161@@ -236,19 +220,15 @@ swc_window_set_position(struct swc_window *base, int32_t x, int32_t y)
162 		flush(window);
163 }
164 
165-EXPORT
166-void
167-swc_window_set_size(struct swc_window *base,
168-                    uint32_t width, uint32_t height)
169+EXPORT void
170+swc_window_set_size(struct swc_window *base, uint32_t width, uint32_t height)
171 {
172 	struct window *window = INTERNAL(base);
173-	struct swc_rectangle *geometry = &window->view->base.geometry;
174+	struct swc_rectangle *geom = &window->view->base.geometry;
175 
176-	if ((window->configure.pending
177-	     && width == window->configure.width
178-	     && height == window->configure.height)
179-	    || (!window->configure.pending
180-	        && width == geometry->width && height == geometry->height)) {
181+	if ((window->configure.pending && width == window->configure.width && height == window->configure.height)
182+	 || (!window->configure.pending && width == geom->width && height == geom->height))
183+	{
184 		return;
185 	}
186 
187@@ -261,19 +241,15 @@ swc_window_set_size(struct swc_window *base,
188 	}
189 }
190 
191-EXPORT
192-void
193-swc_window_set_geometry(struct swc_window *window,
194-                        const struct swc_rectangle *geometry)
195+EXPORT void
196+swc_window_set_geometry(struct swc_window *window, const struct swc_rectangle *geometry)
197 {
198 	swc_window_set_size(window, geometry->width, geometry->height);
199 	swc_window_set_position(window, geometry->x, geometry->y);
200 }
201 
202-EXPORT
203-void
204-swc_window_set_border(struct swc_window *window,
205-                      uint32_t border_color, uint32_t border_width)
206+EXPORT void
207+swc_window_set_border(struct swc_window *window, uint32_t border_color, uint32_t border_width)
208 {
209 	struct compositor_view *view = INTERNAL(window)->view;
210 
211@@ -281,49 +257,43 @@ swc_window_set_border(struct swc_window *window,
212 	compositor_view_set_border_width(view, border_width);
213 }
214 
215-EXPORT
216-void
217+EXPORT void
218 swc_window_begin_move(struct swc_window *window)
219 {
220 	window_begin_move(INTERNAL(window), NULL);
221 }
222 
223-EXPORT
224-void
225+EXPORT void
226 swc_window_end_move(struct swc_window *window)
227 {
228 	end_interaction(&INTERNAL(window)->move.interaction, NULL);
229 }
230 
231-EXPORT
232-void
233+EXPORT void
234 swc_window_begin_resize(struct swc_window *window, uint32_t edges)
235 {
236 	window_begin_resize(INTERNAL(window), edges, NULL);
237 }
238 
239-EXPORT
240-void
241+EXPORT void
242 swc_window_end_resize(struct swc_window *window)
243 {
244 	end_interaction(&INTERNAL(window)->resize.interaction, NULL);
245 }
246 
247 static bool
248-move_motion(struct pointer_handler *handler, uint32_t time,
249-            wl_fixed_t fx, wl_fixed_t fy)
250+move_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t fx, wl_fixed_t fy)
251 {
252 	struct window *window = wl_container_of(handler, window, move.interaction.handler);
253+	int32_t x = wl_fixed_to_int(fx) + window->move.offset.x,
254+	        y = wl_fixed_to_int(fy) + window->move.offset.y;
255 
256-	view_move(&window->view->base, wl_fixed_to_int(fx) + window->move.offset.x,
257-	          wl_fixed_to_int(fy) + window->move.offset.y);
258-
259+	view_move(&window->view->base, x, y);
260 	return true;
261 }
262 
263 static bool
264-resize_motion(struct pointer_handler *handler, uint32_t time,
265-              wl_fixed_t fx, wl_fixed_t fy)
266+resize_motion(struct pointer_handler *handler, uint32_t time, wl_fixed_t fx, wl_fixed_t fy)
267 {
268 	struct window *window = wl_container_of(handler, window, resize.interaction.handler);
269 	const struct swc_rectangle *geometry = &window->view->base.geometry;
270@@ -345,15 +315,12 @@ resize_motion(struct pointer_handler *handler, uint32_t time,
271 }
272 
273 static bool
274-handle_button(struct pointer_handler *handler, uint32_t time,
275-              struct button *button, uint32_t state)
276+handle_button(struct pointer_handler *handler, uint32_t time, struct button *button, uint32_t state)
277 {
278 	struct window_pointer_interaction *interaction = wl_container_of(handler, interaction, handler);
279 
280-	if (state != WL_POINTER_BUTTON_STATE_RELEASED
281-	    || !interaction->original_handler) {
282+	if (state != WL_POINTER_BUTTON_STATE_RELEASED || !interaction->original_handler)
283 		return false;
284-	}
285 
286 	end_interaction(interaction, button);
287 	return true;
288@@ -370,13 +337,11 @@ handle_attach(struct view_handler *handler)
289 }
290 
291 static void
292-handle_resize(struct view_handler *handler,
293-              uint32_t old_width, uint32_t old_height)
294+handle_resize(struct view_handler *handler, uint32_t old_width, uint32_t old_height)
295 {
296 	struct window *window = wl_container_of(handler, window, view_handler);
297 
298-	if (window->resize.interaction.active
299-	    && window->resize.edges & (SWC_WINDOW_EDGE_TOP | SWC_WINDOW_EDGE_LEFT)) {
300+	if (window->resize.interaction.active && window->resize.edges & (SWC_WINDOW_EDGE_TOP | SWC_WINDOW_EDGE_LEFT)) {
301 		const struct swc_rectangle *geometry = &window->view->base.geometry;
302 		int32_t x = geometry->x, y = geometry->y;
303 
304@@ -390,13 +355,12 @@ handle_resize(struct view_handler *handler,
305 }
306 
307 static const struct view_handler_impl view_handler_impl = {
308-	.attach = &handle_attach,
309-	.resize = &handle_resize,
310+	.attach = handle_attach,
311+	.resize = handle_resize,
312 };
313 
314 bool
315-window_initialize(struct window *window, const struct window_impl *impl,
316-                  struct surface *surface)
317+window_initialize(struct window *window, const struct window_impl *impl, struct surface *surface)
318 {
319 	DEBUG("Initializing window, %p\n", window);
320 
321@@ -416,16 +380,16 @@ window_initialize(struct window *window, const struct window_impl *impl,
322 	window->move.pending = false;
323 	window->move.interaction.active = false;
324 	window->move.interaction.handler = (struct pointer_handler){
325-		.motion = &move_motion,
326-		.button = &handle_button
327+		.motion = move_motion,
328+		.button = handle_button,
329 	};
330 	window->configure.pending = false;
331 	window->configure.width = 0;
332 	window->configure.height = 0;
333 	window->resize.interaction.active = false;
334 	window->resize.interaction.handler = (struct pointer_handler){
335-		.motion = &resize_motion,
336-		.button = &handle_button
337+		.motion = resize_motion,
338+		.button = handle_button,
339 	};
340 
341 	wl_list_insert(&window->view->base.handlers, &window->view_handler.link);
342@@ -518,16 +482,13 @@ window_begin_move(struct window *window, struct button *button)
343 }
344 
345 void
346-window_begin_resize(struct window *window, uint32_t edges,
347-                    struct button *button)
348+window_begin_resize(struct window *window, uint32_t edges, struct button *button)
349 {
350 	if (window->mode != WINDOW_MODE_STACKED && window->handler->resize)
351 		window->handler->resize(window->handler_data);
352 
353-	if (window->mode != WINDOW_MODE_STACKED
354-	    || window->resize.interaction.active) {
355+	if (window->mode != WINDOW_MODE_STACKED || window->resize.interaction.active)
356 		return;
357-	}
358 
359 	struct swc_rectangle *geometry = &window->view->base.geometry;
360 	int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
361@@ -536,17 +497,11 @@ window_begin_resize(struct window *window, uint32_t edges,
362 	begin_interaction(&window->resize.interaction, button);
363 
364 	if (!edges) {
365-		edges |= (px < geometry->x + geometry->width / 2)
366-		             ? SWC_WINDOW_EDGE_LEFT
367-		             : SWC_WINDOW_EDGE_RIGHT;
368-		edges |= (py < geometry->y + geometry->height / 2)
369-		             ? SWC_WINDOW_EDGE_TOP
370-		             : SWC_WINDOW_EDGE_BOTTOM;
371+		edges |= (px < geometry->x + geometry->width / 2) ? SWC_WINDOW_EDGE_LEFT : SWC_WINDOW_EDGE_RIGHT;
372+		edges |= (py < geometry->y + geometry->height / 2) ? SWC_WINDOW_EDGE_TOP : SWC_WINDOW_EDGE_BOTTOM;
373 	}
374 
375-	window->resize.offset.x = geometry->x - px
376-	                          + ((edges & SWC_WINDOW_EDGE_RIGHT) ? geometry->width : 0);
377-	window->resize.offset.y = geometry->y - py
378-	                          + ((edges & SWC_WINDOW_EDGE_BOTTOM) ? geometry->height : 0);
379+	window->resize.offset.x = geometry->x - px + ((edges & SWC_WINDOW_EDGE_RIGHT) ? geometry->width : 0);
380+	window->resize.offset.y = geometry->y - py + ((edges & SWC_WINDOW_EDGE_BOTTOM) ? geometry->height : 0);
381 	window->resize.edges = edges;
382 }
+6, -20
 1@@ -53,8 +53,7 @@ struct window {
 2 	bool managed;
 3 	unsigned mode;
 4 
 5-	struct
 6-	    {
 7+	struct {
 8 		struct window_pointer_interaction interaction;
 9 		struct {
10 			int32_t x, y;
11@@ -64,8 +63,7 @@ struct window {
12 		int32_t x, y;
13 	} move;
14 
15-	struct
16-	    {
17+	struct {
18 		struct window_pointer_interaction interaction;
19 		struct {
20 			int32_t x, y;
21@@ -73,8 +71,7 @@ struct window {
22 		uint32_t edges;
23 	} resize;
24 
25-	struct
26-	    {
27+	struct {
28 		bool pending, acknowledged;
29 		uint32_t width, height;
30 	} configure;
31@@ -91,25 +88,14 @@ struct window_impl {
32 
33 extern struct wl_listener window_enter_listener;
34 
35-bool window_initialize(struct window *window, const struct window_impl *impl,
36-                       struct surface *surface);
37-
38+bool window_initialize(struct window *window, const struct window_impl *impl, struct surface *surface);
39 void window_finalize(struct window *window);
40-
41 void window_manage(struct window *window);
42-
43 void window_unmanage(struct window *window);
44-
45-void window_set_title(struct window *window,
46-                      const char *title, size_t length);
47-
48+void window_set_title(struct window *window, const char *title, size_t length);
49 void window_set_app_id(struct window *window, const char *app_id);
50-
51 void window_set_parent(struct window *window, struct window *parent);
52-
53 void window_begin_move(struct window *window, struct button *button);
54-
55-void window_begin_resize(struct window *window, uint32_t edges,
56-                         struct button *button);
57+void window_begin_resize(struct window *window, uint32_t edges, struct button *button);
58 
59 #endif
+7, -15
 1@@ -43,14 +43,13 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 2 }
 3 
 4 static const struct xdg_popup_interface xdg_popup_implementation = {
 5-	.destroy = &destroy
 6+	.destroy = destroy,
 7 };
 8 
 9 static void
10 handle_surface_destroy(struct wl_listener *listener, void *data)
11 {
12 	struct xdg_popup *popup = wl_container_of(listener, popup, surface_destroy_listener);
13-
14 	wl_resource_destroy(popup->resource);
15 }
16 
17@@ -65,11 +64,8 @@ destroy_popup(struct wl_resource *resource)
18 }
19 
20 struct xdg_popup *
21-xdg_popup_new(struct wl_client *client,
22-              uint32_t version, uint32_t id,
23-              struct surface *surface,
24-              struct surface *parent_surface,
25-              int32_t x, int32_t y)
26+xdg_popup_new(struct wl_client *client, uint32_t version,
27+              uint32_t id, struct surface *surface, struct surface *parent_surface, int32_t x, int32_t y)
28 {
29 	struct xdg_popup *popup;
30 	struct compositor_view *parent = compositor_view(parent_surface->view);
31@@ -82,23 +78,19 @@ xdg_popup_new(struct wl_client *client,
32 	if (!popup)
33 		goto error0;
34 
35-	popup->resource = wl_resource_create(client, &xdg_popup_interface,
36-	                                     version, id);
37+	popup->resource = wl_resource_create(client, &xdg_popup_interface, version, id);
38 
39 	if (!popup->resource)
40 		goto error1;
41 
42 	popup->surface_destroy_listener.notify = &handle_surface_destroy;
43-	wl_resource_add_destroy_listener(surface->resource,
44-	                                 &popup->surface_destroy_listener);
45-	wl_resource_set_implementation(popup->resource, &xdg_popup_implementation,
46-	                               popup, &destroy_popup);
47+	wl_resource_add_destroy_listener(surface->resource, &popup->surface_destroy_listener);
48+	wl_resource_set_implementation(popup->resource, &xdg_popup_implementation, popup, &destroy_popup);
49 
50 	if (!(popup->view = compositor_create_view(surface)))
51 		goto error2;
52 
53-	view_move(&popup->view->base,
54-	          parent->base.geometry.x + x, parent->base.geometry.y + y);
55+	view_move(&popup->view->base, parent->base.geometry.x + x, parent->base.geometry.y + y);
56 	compositor_view_set_parent(popup->view, parent);
57 
58 	return popup;
+2, -5
 1@@ -29,10 +29,7 @@
 2 struct surface;
 3 struct wl_client;
 4 
 5-struct xdg_popup *xdg_popup_new(struct wl_client *client,
 6-                                uint32_t version, uint32_t id,
 7-                                struct surface *surface,
 8-                                struct surface *parent,
 9-                                int32_t x, int32_t y);
10+struct xdg_popup *xdg_popup_new(struct wl_client *client, uint32_t version, uint32_t id,
11+                                struct surface *surface, struct surface *parent, int32_t x, int32_t y);
12 
13 #endif
+19, -36
  1@@ -35,8 +35,7 @@
  2 static_assert(XDG_SHELL_VERSION == XDG_SHELL_VERSION_CURRENT,
  3               "xdg_shell implementation does not match protocol version");
  4 
  5-static struct
  6-    {
  7+static struct {
  8 	struct wl_global *global;
  9 } shell;
 10 
 11@@ -47,64 +46,53 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 12 }
 13 
 14 static void
 15-use_unstable_version(struct wl_client *client,
 16-                     struct wl_resource *resource, int32_t version)
 17+use_unstable_version(struct wl_client *client, struct wl_resource *resource, int32_t version)
 18 {
 19 }
 20 
 21 static void
 22-get_xdg_surface(struct wl_client *client,
 23-                struct wl_resource *resource, uint32_t id,
 24-                struct wl_resource *surface_resource)
 25+get_xdg_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource)
 26 {
 27 	struct surface *surface = wl_resource_get_user_data(surface_resource);
 28 	struct xdg_surface *xdg_surface;
 29 
 30-	xdg_surface = xdg_surface_new(client, wl_resource_get_version(resource), id,
 31-	                              surface);
 32+	xdg_surface = xdg_surface_new(client, wl_resource_get_version(resource), id, surface);
 33 
 34 	if (!xdg_surface)
 35 		wl_resource_post_no_memory(resource);
 36 }
 37 
 38 static void
 39-get_xdg_popup(struct wl_client *client,
 40-              struct wl_resource *resource, uint32_t id,
 41-              struct wl_resource *surface_resource,
 42-              struct wl_resource *parent_resource,
 43-              struct wl_resource *seat_resource,
 44-              uint32_t serial, int32_t x, int32_t y)
 45+get_xdg_popup(struct wl_client *client, struct wl_resource *resource,
 46+              uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource,
 47+              struct wl_resource *seat_resource, uint32_t serial, int32_t x, int32_t y)
 48 {
 49 	struct surface *surface = wl_resource_get_user_data(surface_resource);
 50 	struct surface *parent = wl_resource_get_user_data(parent_resource);
 51 	struct xdg_popup *popup;
 52 
 53-	popup = xdg_popup_new(client, wl_resource_get_version(resource), id,
 54-	                      surface, parent, x, y);
 55+	popup = xdg_popup_new(client, wl_resource_get_version(resource), id, surface, parent, x, y);
 56 
 57 	if (!popup)
 58 		wl_resource_post_no_memory(resource);
 59 }
 60 
 61 static void
 62-pong(struct wl_client *client, struct wl_resource *resource,
 63-     uint32_t serial)
 64+pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
 65 {
 66 }
 67 
 68 static const struct xdg_shell_interface shell_implementation = {
 69-	.destroy = &destroy,
 70-	.use_unstable_version = &use_unstable_version,
 71-	.get_xdg_surface = &get_xdg_surface,
 72-	.get_xdg_popup = &get_xdg_popup,
 73-	.pong = &pong
 74+	.destroy = destroy,
 75+	.use_unstable_version = use_unstable_version,
 76+	.get_xdg_surface = get_xdg_surface,
 77+	.get_xdg_popup = get_xdg_popup,
 78+	.pong = pong,
 79 };
 80 
 81 static int
 82 unversioned_dispatch(const void *implementation, void *target,
 83-                     uint32_t opcode,
 84-                     const struct wl_message *message,
 85-                     union wl_argument *arguments)
 86+                     uint32_t opcode, const struct wl_message *message, union wl_argument *arguments)
 87 {
 88 	struct wl_resource *resource = target;
 89 
 90@@ -116,8 +104,7 @@ unversioned_dispatch(const void *implementation, void *target,
 91 
 92 	if (arguments[0].i != XDG_SHELL_VERSION) {
 93 		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
 94-		                       "incompatible xdg_shell versions, "
 95-		                       "server: %d, client: %d",
 96+		                       "incompatible xdg_shell versions, server: %d, client: %d",
 97 		                       XDG_SHELL_VERSION, arguments[0].i);
 98 		return 0;
 99 	}
100@@ -127,8 +114,7 @@ unversioned_dispatch(const void *implementation, void *target,
101 }
102 
103 static void
104-bind_shell(struct wl_client *client, void *data,
105-           uint32_t version, uint32_t id)
106+bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
107 {
108 	struct wl_resource *resource;
109 
110@@ -136,16 +122,13 @@ bind_shell(struct wl_client *client, void *data,
111 		version = 1;
112 
113 	resource = wl_resource_create(client, &xdg_shell_interface, version, id);
114-	wl_resource_set_dispatcher(resource, &unversioned_dispatch,
115-	                           NULL, NULL, NULL);
116+	wl_resource_set_dispatcher(resource, &unversioned_dispatch, NULL, NULL, NULL);
117 }
118 
119 bool
120 xdg_shell_initialize(void)
121 {
122-	shell.global = wl_global_create(swc.display, &xdg_shell_interface, 1,
123-	                                NULL, &bind_shell);
124-
125+	shell.global = wl_global_create(swc.display, &xdg_shell_interface, 1, NULL, &bind_shell);
126 	return shell.global;
127 }
128 
+35, -63
  1@@ -82,9 +82,7 @@ configure(struct window *window, uint32_t width, uint32_t height)
  2 
  3 	window->configure.acknowledged = false;
  4 	xdg_surface->configure_serial = wl_display_next_serial(swc.display);
  5-	xdg_surface_send_configure(xdg_surface->resource, width, height,
  6-	                           &xdg_surface->states,
  7-	                           xdg_surface->configure_serial);
  8+	xdg_surface_send_configure(xdg_surface->resource, width, height, &xdg_surface->states, xdg_surface->configure_serial);
  9 }
 10 
 11 static void
 12@@ -152,11 +150,9 @@ destroy(struct wl_client *client, struct wl_resource *resource)
 13 }
 14 
 15 static void
 16-set_parent(struct wl_client *client, struct wl_resource *resource,
 17-           struct wl_resource *parent_resource)
 18+set_parent(struct wl_client *client, struct wl_resource *resource, struct wl_resource *parent_resource)
 19 {
 20-	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource),
 21-	                   *parent_surface;
 22+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource), *parent_surface;
 23 	struct window *parent_window = NULL;
 24 
 25 	if (parent_resource) {
 26@@ -168,34 +164,27 @@ set_parent(struct wl_client *client, struct wl_resource *resource,
 27 }
 28 
 29 static void
 30-set_title(struct wl_client *client, struct wl_resource *resource,
 31-          const char *title)
 32+set_title(struct wl_client *client, struct wl_resource *resource, const char *title)
 33 {
 34 	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
 35-
 36 	window_set_title(&xdg_surface->window, title, -1);
 37 }
 38 
 39 static void
 40-set_app_id(struct wl_client *client, struct wl_resource *resource,
 41-           const char *app_id)
 42+set_app_id(struct wl_client *client, struct wl_resource *resource, const char *app_id)
 43 {
 44 	struct xdg_surface *surface = wl_resource_get_user_data(resource);
 45-
 46 	window_set_app_id(&surface->window, app_id);
 47 }
 48 
 49 static void
 50-show_window_menu(struct wl_client *client,
 51-                 struct wl_resource *resource,
 52-                 struct wl_resource *seat_resource,
 53-                 uint32_t serial, int32_t x, int32_t y)
 54+show_window_menu(struct wl_client *client, struct wl_resource *resource,
 55+                 struct wl_resource *seat_resource, uint32_t serial, int32_t x, int32_t y)
 56 {
 57 }
 58 
 59 static void
 60-move(struct wl_client *client, struct wl_resource *resource,
 61-     struct wl_resource *seat_resource, uint32_t serial)
 62+move(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial)
 63 {
 64 	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
 65 	struct button *button;
 66@@ -208,8 +197,7 @@ move(struct wl_client *client, struct wl_resource *resource,
 67 
 68 static void
 69 resize(struct wl_client *client, struct wl_resource *resource,
 70-       struct wl_resource *seat_resource, uint32_t serial,
 71-       uint32_t edges)
 72+       struct wl_resource *seat_resource, uint32_t serial, uint32_t edges)
 73 {
 74 	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
 75 	struct button *button;
 76@@ -221,8 +209,7 @@ resize(struct wl_client *client, struct wl_resource *resource,
 77 }
 78 
 79 static void
 80-ack_configure(struct wl_client *client,
 81-              struct wl_resource *resource, uint32_t serial)
 82+ack_configure(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
 83 {
 84 	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
 85 
 86@@ -231,72 +218,63 @@ ack_configure(struct wl_client *client,
 87 }
 88 
 89 static void
 90-set_window_geometry(struct wl_client *client,
 91-                    struct wl_resource *resource,
 92-                    int32_t x, int32_t y,
 93-                    int32_t width, int32_t height)
 94+set_window_geometry(struct wl_client *client, struct wl_resource *resource,
 95+                    int32_t x, int32_t y, int32_t width, int32_t height)
 96 {
 97 	/* TODO: Implement set_window_geometry. */
 98 }
 99 
100 static void
101-set_maximized(struct wl_client *client,
102-              struct wl_resource *resource)
103+set_maximized(struct wl_client *client, struct wl_resource *resource)
104 {
105 	/* TODO: Implement set_maximized. */
106 }
107 
108 static void
109-unset_maximized(struct wl_client *client,
110-                struct wl_resource *resource)
111+unset_maximized(struct wl_client *client, struct wl_resource *resource)
112 {
113 	/* TODO: Implement unset_maximized. */
114 }
115 
116 static void
117-set_fullscreen(struct wl_client *client,
118-               struct wl_resource *resource,
119-               struct wl_resource *output_resource)
120+set_fullscreen(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource)
121 {
122 	/* TODO: Implement set_fullscreen. */
123 }
124 
125 static void
126-unset_fullscreen(struct wl_client *client,
127-                 struct wl_resource *resource)
128+unset_fullscreen(struct wl_client *client, struct wl_resource *resource)
129 {
130 	/* TODO: Implement unset_fullscreen. */
131 }
132 
133 static void
134-set_minimized(struct wl_client *client,
135-              struct wl_resource *resource)
136+set_minimized(struct wl_client *client, struct wl_resource *resource)
137 {
138 	/* TODO: Implement set_minimized. */
139 }
140 
141 static const struct xdg_surface_interface xdg_surface_implementation = {
142-	.destroy = &destroy,
143-	.set_parent = &set_parent,
144-	.set_title = &set_title,
145-	.set_app_id = &set_app_id,
146-	.show_window_menu = &show_window_menu,
147-	.move = &move,
148-	.resize = &resize,
149-	.ack_configure = &ack_configure,
150-	.set_window_geometry = &set_window_geometry,
151-	.set_maximized = &set_maximized,
152-	.unset_maximized = &unset_maximized,
153-	.set_fullscreen = &set_fullscreen,
154-	.unset_fullscreen = &unset_fullscreen,
155-	.set_minimized = &set_minimized,
156+	.destroy = destroy,
157+	.set_parent = set_parent,
158+	.set_title = set_title,
159+	.set_app_id = set_app_id,
160+	.show_window_menu = show_window_menu,
161+	.move = move,
162+	.resize = resize,
163+	.ack_configure = ack_configure,
164+	.set_window_geometry = set_window_geometry,
165+	.set_maximized = set_maximized,
166+	.unset_maximized = unset_maximized,
167+	.set_fullscreen = set_fullscreen,
168+	.unset_fullscreen = unset_fullscreen,
169+	.set_minimized = set_minimized,
170 };
171 
172 static void
173 handle_surface_destroy(struct wl_listener *listener, void *data)
174 {
175 	struct xdg_surface *xdg_surface = wl_container_of(listener, xdg_surface, surface_destroy_listener);
176-
177 	wl_resource_destroy(xdg_surface->resource);
178 }
179 
180@@ -311,9 +289,7 @@ destroy_xdg_surface(struct wl_resource *resource)
181 }
182 
183 struct xdg_surface *
184-xdg_surface_new(struct wl_client *client,
185-                uint32_t version, uint32_t id,
186-                struct surface *surface)
187+xdg_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface)
188 {
189 	struct xdg_surface *xdg_surface;
190 
191@@ -322,8 +298,7 @@ xdg_surface_new(struct wl_client *client,
192 	if (!xdg_surface)
193 		goto error0;
194 
195-	xdg_surface->resource = wl_resource_create(client, &xdg_surface_interface,
196-	                                           version, id);
197+	xdg_surface->resource = wl_resource_create(client, &xdg_surface_interface, version, id);
198 
199 	if (!xdg_surface->resource)
200 		goto error1;
201@@ -331,11 +306,8 @@ xdg_surface_new(struct wl_client *client,
202 	window_initialize(&xdg_surface->window, &xdg_surface_window_impl, surface);
203 	xdg_surface->surface_destroy_listener.notify = &handle_surface_destroy;
204 	wl_array_init(&xdg_surface->states);
205-	wl_resource_add_destroy_listener(surface->resource,
206-	                                 &xdg_surface->surface_destroy_listener);
207-	wl_resource_set_implementation(xdg_surface->resource,
208-	                               &xdg_surface_implementation,
209-	                               xdg_surface, &destroy_xdg_surface);
210+	wl_resource_add_destroy_listener(surface->resource, &xdg_surface->surface_destroy_listener);
211+	wl_resource_set_implementation(xdg_surface->resource, &xdg_surface_implementation, xdg_surface, &destroy_xdg_surface);
212 	window_manage(&xdg_surface->window);
213 
214 	return xdg_surface;
+1, -3
 1@@ -29,8 +29,6 @@
 2 struct surface;
 3 struct wl_client;
 4 
 5-struct xdg_surface *xdg_surface_new(struct wl_client *client,
 6-                                    uint32_t version, uint32_t id,
 7-                                    struct surface *surface);
 8+struct xdg_surface *xdg_surface_new(struct wl_client *client, uint32_t version, uint32_t id, struct surface *surface);
 9 
10 #endif
+3, -6
 1@@ -103,8 +103,7 @@ xkb_update_keymap(struct xkb *xkb)
 2 {
 3 	const char *keymap_directory = getenv("XDG_RUNTIME_DIR") ?: "/tmp";
 4 	char *keymap_string;
 5-	char keymap_path[strlen(keymap_directory) + 1
 6-	                 + sizeof keymap_file_template];
 7+	char keymap_path[strlen(keymap_directory) + 1 + sizeof keymap_file_template];
 8 
 9 	xkb->indices.ctrl = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_CTRL);
10 	xkb->indices.alt = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_ALT);
11@@ -113,8 +112,7 @@ xkb_update_keymap(struct xkb *xkb)
12 
13 	/* In order to send the keymap to clients, we must first convert it to a
14      * string and then mmap it to a file. */
15-	keymap_string = xkb_keymap_get_as_string(xkb->keymap.map,
16-	                                         XKB_KEYMAP_FORMAT_TEXT_V1);
17+	keymap_string = xkb_keymap_get_as_string(xkb->keymap.map, XKB_KEYMAP_FORMAT_TEXT_V1);
18 
19 	if (!keymap_string) {
20 		WARNING("Could not get XKB keymap as a string\n");
21@@ -138,8 +136,7 @@ xkb_update_keymap(struct xkb *xkb)
22 		goto error2;
23 	}
24 
25-	xkb->keymap.area = mmap(NULL, xkb->keymap.size, PROT_READ | PROT_WRITE,
26-	                        MAP_SHARED, xkb->keymap.fd, 0);
27+	xkb->keymap.area = mmap(NULL, xkb->keymap.size, PROT_READ | PROT_WRITE, MAP_SHARED, xkb->keymap.fd, 0);
28 
29 	if (xkb->keymap.area == MAP_FAILED) {
30 		WARNING("Could not mmap XKB keymap string\n");
+2, -5
 1@@ -34,16 +34,14 @@ struct xkb {
 2 	struct xkb_context *context;
 3 	struct xkb_state *state;
 4 
 5-	struct
 6-	    {
 7+	struct {
 8 		struct xkb_keymap *map;
 9 		int fd;
10 		uint32_t size;
11 		char *area;
12 	} keymap;
13 
14-	struct
15-	    {
16+	struct {
17 		uint32_t ctrl, alt, super, shift;
18 	} indices;
19 };
20@@ -51,7 +49,6 @@ struct xkb {
21 bool xkb_initialize(struct xkb *xkb);
22 void xkb_finalize(struct xkb *xkb);
23 bool xkb_reset_state(struct xkb *xkb);
24-
25 bool xkb_update_keymap(struct xkb *xkb);
26 
27 #endif
+14, -23
  1@@ -44,8 +44,7 @@
  2 #define SOCKET_DIR "/tmp/.X11-unix"
  3 #define SOCKET_FMT SOCKET_DIR "/X%d"
  4 
  5-static struct
  6-    {
  7+static struct {
  8 	struct wl_resource *resource;
  9 	struct wl_event_source *usr1_source;
 10 	int display;
 11@@ -65,7 +64,7 @@ open_socket(struct sockaddr_un *addr, size_t path_size)
 12 		goto error0;
 13 
 14 	/* Unlink the socket location in case it was being used by a process which
 15-     * left around a stale lockfile. */
 16+	 * left around a stale lockfile. */
 17 	unlink(addr->sun_path);
 18 
 19 	if (bind(fd, (struct sockaddr *)addr, size) < 0)
 20@@ -90,7 +89,7 @@ open_display(void)
 21 {
 22 	char lock_name[64], pid[12];
 23 	int lock_fd;
 24-	struct sockaddr_un addr = {.sun_family = AF_LOCAL };
 25+	struct sockaddr_un addr = {.sun_family = AF_LOCAL};
 26 	size_t path_size;
 27 
 28 	xserver.display = 0;
 29@@ -149,20 +148,17 @@ begin:
 30 
 31 	/* Bind to abstract socket */
 32 	addr.sun_path[0] = '\0';
 33-	path_size = snprintf(addr.sun_path + 1, sizeof addr.sun_path - 1,
 34-	                     SOCKET_FMT, xserver.display);
 35+	path_size = snprintf(addr.sun_path + 1, sizeof addr.sun_path - 1, SOCKET_FMT, xserver.display);
 36 	if ((xserver.abstract_fd = open_socket(&addr, path_size)) < 0)
 37 		goto retry1;
 38 
 39 	/* Bind to unix socket */
 40 	mkdir(SOCKET_DIR, 0777);
 41-	path_size = snprintf(addr.sun_path, sizeof addr.sun_path,
 42-	                     SOCKET_FMT, xserver.display);
 43+	path_size = snprintf(addr.sun_path, sizeof addr.sun_path, SOCKET_FMT, xserver.display);
 44 	if ((xserver.unix_fd = open_socket(&addr, path_size)) < 0)
 45 		goto retry2;
 46 
 47-	snprintf(xserver.display_name, sizeof xserver.display_name,
 48-	         ":%d", xserver.display);
 49+	snprintf(xserver.display_name, sizeof xserver.display_name, ":%d", xserver.display);
 50 	setenv("DISPLAY", xserver.display_name, true);
 51 
 52 	return true;
 53@@ -208,8 +204,7 @@ xserver_initialize(void)
 54 		goto error0;
 55 	}
 56 
 57-	xserver.usr1_source = wl_event_loop_add_signal(swc.event_loop, SIGUSR1,
 58-	                                               &handle_usr1, NULL);
 59+	xserver.usr1_source = wl_event_loop_add_signal(swc.event_loop, SIGUSR1, &handle_usr1, NULL);
 60 
 61 	if (!xserver.usr1_source) {
 62 		ERROR("Failed to create SIGUSR1 event source\n");
 63@@ -241,27 +236,24 @@ xserver_initialize(void)
 64 		unsigned index;
 65 		struct sigaction action = {.sa_handler = SIG_IGN };
 66 
 67-		/* Unset the FD_CLOEXEC flag on the FDs that will get passed to
 68-             * Xwayland. */
 69+		/* Unset the FD_CLOEXEC flag on the FDs that will get passed to Xwayland. */
 70 		for (index = 0; index < ARRAY_LENGTH(fds); ++index) {
 71 			if (fcntl(fds[index], F_SETFD, 0) != 0) {
 72 				ERROR("fcntl() failed: %s\n", strerror(errno));
 73 				goto fail;
 74 			}
 75 
 76-			if (snprintf(strings[index], sizeof strings[index],
 77-			             "%d", fds[index]) >= sizeof strings[index]) {
 78+			if (snprintf(strings[index], sizeof strings[index], "%d", fds[index]) >= sizeof strings[index]) {
 79 				ERROR("FD is too large\n");
 80 				goto fail;
 81 			}
 82 		}
 83 
 84-		/* Ignore the USR1 signal so that Xwayland will send a USR1 signal
 85-             * to the parent process (us) after it finishes initializing. See
 86-             * Xserver(1) for more details. */
 87+		/* Ignore the USR1 signal so that Xwayland will send a USR1 signal to the
 88+		 * parent process (us) after it finishes initializing. See Xserver(1) for
 89+		 * more details. */
 90 		if (sigaction(SIGUSR1, &action, NULL) != 0) {
 91-			ERROR("Failed to set SIGUSR1 handler to SIG_IGN: %s\n",
 92-			      strerror(errno));
 93+			ERROR("Failed to set SIGUSR1 handler to SIG_IGN: %s\n", strerror(errno));
 94 			goto fail;
 95 		}
 96 
 97@@ -279,8 +271,7 @@ xserver_initialize(void)
 98 		exit(EXIT_FAILURE);
 99 	}
100 	case -1:
101-		ERROR("fork() failed when trying to start X server: %s\n",
102-		      strerror(errno));
103+		ERROR("fork() failed when trying to start X server: %s\n", strerror(errno));
104 		goto error5;
105 	}
106 
+43, -61
  1@@ -56,8 +56,7 @@ enum atom {
  2 	ATOM_WM_S0,
  3 };
  4 
  5-static struct
  6-    {
  7+static struct {
  8 	xcb_connection_t *connection;
  9 	xcb_ewmh_connection_t ewmh;
 10 	xcb_screen_t *screen;
 11@@ -72,10 +71,10 @@ static struct
 12 	} atoms[4];
 13 } xwm = {
 14 	.atoms = {
 15-	        [ATOM_WL_SURFACE_ID] = "WL_SURFACE_ID",
 16-	        [ATOM_WM_DELETE_WINDOW] = "WM_DELETE_WINDOW",
 17-	        [ATOM_WM_PROTOCOLS] = "WM_PROTOCOLS",
 18-	        [ATOM_WM_S0] = "WM_S0",
 19+		[ATOM_WL_SURFACE_ID] = "WL_SURFACE_ID",
 20+		[ATOM_WM_DELETE_WINDOW] = "WM_DELETE_WINDOW",
 21+		[ATOM_WM_PROTOCOLS] = "WM_PROTOCOLS",
 22+		[ATOM_WM_S0] = "WM_S0",
 23 	}
 24 };
 25 
 26@@ -87,14 +86,12 @@ update_name(struct xwl_window *xwl_window)
 27 
 28 	wm_name_cookie = xcb_ewmh_get_wm_name(&xwm.ewmh, xwl_window->id);
 29 
 30-	if (xcb_ewmh_get_wm_name_reply(&xwm.ewmh, wm_name_cookie,
 31-	                               &wm_name_reply, NULL)) {
 32-		window_set_title(&xwl_window->window,
 33-		                 wm_name_reply.strings, wm_name_reply.strings_len);
 34-
 35+	if (xcb_ewmh_get_wm_name_reply(&xwm.ewmh, wm_name_cookie, &wm_name_reply, NULL)) {
 36+		window_set_title(&xwl_window->window, wm_name_reply.strings, wm_name_reply.strings_len);
 37 		xcb_ewmh_get_utf8_strings_reply_wipe(&wm_name_reply);
 38-	} else
 39+	} else {
 40 		window_set_title(&xwl_window->window, NULL, 0);
 41+	}
 42 }
 43 
 44 static void
 45@@ -104,9 +101,7 @@ update_protocols(struct xwl_window *xwl_window)
 46 	xcb_icccm_get_wm_protocols_reply_t reply;
 47 	unsigned index;
 48 
 49-	cookie = xcb_icccm_get_wm_protocols(xwm.connection, xwl_window->id,
 50-	                                    xwm.atoms[ATOM_WM_PROTOCOLS].value);
 51-
 52+	cookie = xcb_icccm_get_wm_protocols(xwm.connection, xwl_window->id, xwm.atoms[ATOM_WM_PROTOCOLS].value);
 53 	xwl_window->supports_delete = true;
 54 
 55 	if (!xcb_icccm_get_wm_protocols_reply(xwm.connection, cookie, &reply, NULL))
 56@@ -134,8 +129,7 @@ find_window(struct wl_list *list, xcb_window_t id)
 57 }
 58 
 59 static struct xwl_window *
 60-find_window_by_surface_id(struct wl_list *list,
 61-                          uint32_t id)
 62+find_window_by_surface_id(struct wl_list *list, uint32_t id)
 63 {
 64 	struct xwl_window *window;
 65 
 66@@ -181,8 +175,7 @@ focus(struct window *window)
 67 {
 68 	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
 69 
 70-	xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE,
 71-	                    xwl_window->id, XCB_CURRENT_TIME);
 72+	xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, xwl_window->id, XCB_CURRENT_TIME);
 73 	xcb_flush(xwm.connection);
 74 	xwm.focus = xwl_window;
 75 }
 76@@ -192,13 +185,12 @@ unfocus(struct window *window)
 77 {
 78 	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
 79 
 80-	/* If the window we are unfocusing is the latest xwl_window to be focused,
 81-     * we know we have transitioned to some other window type, so the X11 focus
 82-     * can be set to XCB_NONE. Otherwise, we have transitioned to another X11
 83-     * window, and the X11 focus has already been updated. */
 84+	/* If the window we are unfocusing is the latest xwl_window to be focused, we
 85+	 * know we have transitioned to some other window type, so the X11 focus can
 86+	 * be set to XCB_NONE. Otherwise, we have transitioned to another X11 window,
 87+	 * and the X11 focus has already been updated. */
 88 	if (xwl_window == xwm.focus) {
 89-		xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, XCB_NONE,
 90-		                    XCB_CURRENT_TIME);
 91+		xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, XCB_NONE, XCB_CURRENT_TIME);
 92 		xcb_flush(xwm.connection);
 93 	}
 94 }
 95@@ -215,25 +207,25 @@ close(struct window *window)
 96 			.window = xwl_window->id,
 97 			.type = xwm.atoms[ATOM_WM_PROTOCOLS].value,
 98 			.data.data32 = {
 99-			    xwm.atoms[ATOM_WM_DELETE_WINDOW].value,
100-			    XCB_CURRENT_TIME,
101+				xwm.atoms[ATOM_WM_DELETE_WINDOW].value,
102+				XCB_CURRENT_TIME,
103 			},
104 		};
105 
106-		xcb_send_event(xwm.connection, false, xwl_window->id,
107-		               XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
108-	} else
109+		xcb_send_event(xwm.connection, false, xwl_window->id, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
110+	} else {
111 		xcb_kill_client(xwm.connection, xwl_window->id);
112+	}
113 
114 	xcb_flush(xwm.connection);
115 }
116 
117 static const struct window_impl xwl_window_handler = {
118-	.move = &move,
119-	.configure = &configure,
120-	.focus = &focus,
121-	.unfocus = &unfocus,
122-	.close = &close,
123+	.move = move,
124+	.configure = configure,
125+	.focus = focus,
126+	.unfocus = unfocus,
127+	.close = close,
128 };
129 
130 static void
131@@ -258,8 +250,7 @@ manage_window(struct xwl_window *xwl_window)
132 	xcb_get_geometry_cookie_t geometry_cookie;
133 	xcb_get_geometry_reply_t *geometry_reply;
134 
135-	resource = wl_client_get_object(swc.xserver->client,
136-	                                xwl_window->surface_id);
137+	resource = wl_client_get_object(swc.xserver->client, xwl_window->surface_id);
138 
139 	if (!resource)
140 		return false;
141@@ -269,24 +260,21 @@ manage_window(struct xwl_window *xwl_window)
142 
143 	window_initialize(&xwl_window->window, &xwl_window_handler, surface);
144 	xwl_window->surface_destroy_listener.notify = &handle_surface_destroy;
145-	wl_resource_add_destroy_listener(surface->resource,
146-	                                 &xwl_window->surface_destroy_listener);
147+	wl_resource_add_destroy_listener(surface->resource, &xwl_window->surface_destroy_listener);
148 
149-	if ((geometry_reply = xcb_get_geometry_reply(xwm.connection,
150-	                                             geometry_cookie, NULL))) {
151+	if ((geometry_reply = xcb_get_geometry_reply(xwm.connection, geometry_cookie, NULL))) {
152 		view_move(surface->view, geometry_reply->x, geometry_reply->y);
153 		free(geometry_reply);
154 	}
155 
156-	if (xwl_window->override_redirect)
157+	if (xwl_window->override_redirect) {
158 		compositor_view_show(xwl_window->window.view);
159-	else {
160+	} else {
161 		uint32_t mask, values[1];
162 
163 		mask = XCB_CW_EVENT_MASK;
164 		values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
165-		xcb_change_window_attributes(xwm.connection, xwl_window->id,
166-		                             mask, values);
167+		xcb_change_window_attributes(xwm.connection, xwl_window->id, mask, values);
168 		mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
169 		values[0] = 0;
170 		xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
171@@ -307,8 +295,7 @@ handle_new_surface(struct wl_listener *listener, void *data)
172 	struct surface *surface = data;
173 	struct xwl_window *window;
174 
175-	window = find_window_by_surface_id(&xwm.unpaired_windows,
176-	                                   wl_resource_get_id(surface->resource));
177+	window = find_window_by_surface_id(&xwm.unpaired_windows, wl_resource_get_id(surface->resource));
178 
179 	if (!window)
180 		return;
181@@ -343,8 +330,9 @@ destroy_notify(xcb_destroy_notify_event_t *event)
182 	if ((xwl_window = find_window(&xwm.windows, event->window))) {
183 		wl_list_remove(&xwl_window->surface_destroy_listener.link);
184 		window_finalize(&xwl_window->window);
185-	} else if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window)))
186+	} else if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window))) {
187 		return;
188+	}
189 
190 	wl_list_remove(&xwl_window->link);
191 	free(xwl_window);
192@@ -369,10 +357,9 @@ property_notify(xcb_property_notify_event_t *event)
193 	if (!(xwl_window = find_window(&xwm.windows, event->window)))
194 		return;
195 
196-	if (event->atom == xwm.ewmh._NET_WM_NAME
197-	    && event->state == XCB_PROPERTY_NEW_VALUE) {
198+	if (event->atom == xwm.ewmh._NET_WM_NAME && event->state == XCB_PROPERTY_NEW_VALUE)
199 		update_name(xwl_window);
200-	} else if (event->atom == xwm.atoms[ATOM_WM_PROTOCOLS].value)
201+	else if (event->atom == xwm.atoms[ATOM_WM_PROTOCOLS].value)
202 		update_protocols(xwl_window);
203 }
204 
205@@ -459,8 +446,7 @@ xwm_initialize(int fd)
206 
207 	for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index) {
208 		name = xwm.atoms[index].name;
209-		xwm.atoms[index].cookie = xcb_intern_atom(xwm.connection, 0,
210-		                                          strlen(name), name);
211+		xwm.atoms[index].cookie = xcb_intern_atom(xwm.connection, 0, strlen(name), name);
212 	}
213 
214 	setup = xcb_get_setup(xwm.connection);
215@@ -469,12 +455,10 @@ xwm_initialize(int fd)
216 
217 	/* Try to select for substructure redirect. */
218 	mask = XCB_CW_EVENT_MASK;
219-	values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY
220-	            | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
221+	values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
222 	change_attributes_cookie = xcb_change_window_attributes(xwm.connection, xwm.screen->root, mask, values);
223 
224-	xwm.source = wl_event_loop_add_fd(swc.event_loop, fd, WL_EVENT_READABLE,
225-	                                  &connection_data, NULL);
226+	xwm.source = wl_event_loop_add_fd(swc.event_loop, fd, WL_EVENT_READABLE, &connection_data, NULL);
227 	wl_list_init(&xwm.windows);
228 	wl_list_init(&xwm.unpaired_windows);
229 
230@@ -517,8 +501,7 @@ xwm_initialize(int fd)
231 	}
232 
233 	for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index) {
234-		atom_reply = xcb_intern_atom_reply(xwm.connection,
235-		                                   xwm.atoms[index].cookie, &error);
236+		atom_reply = xcb_intern_atom_reply(xwm.connection, xwm.atoms[index].cookie, &error);
237 
238 		if (error) {
239 			ERROR("xwm: Failed to get atom reply: %u\n", error->error_code);
240@@ -529,8 +512,7 @@ xwm_initialize(int fd)
241 		free(atom_reply);
242 	}
243 
244-	xcb_set_selection_owner(xwm.connection, xwm.window,
245-	                        xwm.atoms[ATOM_WM_S0].value, XCB_CURRENT_TIME);
246+	xcb_set_selection_owner(xwm.connection, xwm.window, xwm.atoms[ATOM_WM_S0].value, XCB_CURRENT_TIME);
247 	xcb_flush(xwm.connection);
248 
249 	wl_signal_add(&swc.compositor->signal.new_surface, &new_surface_listener);