commit 0cac681

Michael Forney  ·  2015-05-18 05:40:08 +0000 UTC
parent 7c9f127
Add .clang-format and run clang-format
82 files changed,  +6952, -7078
+24, -0
 1@@ -0,0 +1,24 @@
 2+# clang-format isn't authoritative for the style decisions in this project, but
 3+# these rules mostly align with the suggested style, and clang-format can be
 4+# used fix any potential style-mistakes.
 5+AllowShortBlocksOnASingleLine: false
 6+AllowShortCaseLabelsOnASingleLine: false
 7+AllowShortFunctionsOnASingleLine: false
 8+AllowShortIfStatementsOnASingleLine: false
 9+AllowShortLoopsOnASingleLine: false
10+AlwaysBreakAfterDefinitionReturnType: true
11+BinPackArguments: true
12+BinPackParameters: true
13+BreakBeforeBinaryOperators: NonAssignment
14+BreakBeforeBraces: Linux
15+ColumnLimit: 0
16+Cpp11BracedListStyle: false
17+ForEachMacros: [wl_list_for_each, wl_array_for_each, wl_list_for_each_safe, wl_list_for_each_reverse, wl_resource_for_each]
18+IndentWidth: 8
19+MaxEmptyLinesToKeep: 1
20+PointerAlignment: Right
21+SpaceAfterCStyleCast: false
22+TabWidth: 8
23+UseTab: ForIndentation
24+...
25+# vim: ft=yaml
+77, -80
  1@@ -53,24 +53,24 @@ struct glyph {
  2 static struct {
  3 	int count;
  4 	struct glyph *glyphs;
  5-} extracted_font = {0, NULL};
  6+} extracted_font = { 0, NULL };
  7 
  8-#define PCF_PROPERTIES		    (1<<0)
  9-#define PCF_ACCELERATORS	    (1<<1)
 10-#define PCF_METRICS		    (1<<2)
 11-#define PCF_BITMAPS		    (1<<3)
 12-#define PCF_INK_METRICS		    (1<<4)
 13-#define PCF_BDF_ENCODINGS	    (1<<5)
 14-#define PCF_SWIDTHS		    (1<<6)
 15-#define PCF_GLYPH_NAMES		    (1<<7)
 16-#define PCF_BDF_ACCELERATORS	    (1<<8)
 17+#define PCF_PROPERTIES (1 << 0)
 18+#define PCF_ACCELERATORS (1 << 1)
 19+#define PCF_METRICS (1 << 2)
 20+#define PCF_BITMAPS (1 << 3)
 21+#define PCF_INK_METRICS (1 << 4)
 22+#define PCF_BDF_ENCODINGS (1 << 5)
 23+#define PCF_SWIDTHS (1 << 6)
 24+#define PCF_GLYPH_NAMES (1 << 7)
 25+#define PCF_BDF_ACCELERATORS (1 << 8)
 26 
 27-#define PCF_DEFAULT_FORMAT	0x00000000
 28-#define PCF_INKBOUNDS		0x00000200
 29-#define PCF_ACCEL_W_INKBOUNDS	0x00000100
 30-#define PCF_COMPRESSED_METRICS	0x00000100
 31+#define PCF_DEFAULT_FORMAT 0x00000000
 32+#define PCF_INKBOUNDS 0x00000200
 33+#define PCF_ACCEL_W_INKBOUNDS 0x00000100
 34+#define PCF_COMPRESSED_METRICS 0x00000100
 35 
 36-#define PCF_FORMAT_MASK		0xffffff00
 37+#define PCF_FORMAT_MASK 0xffffff00
 38 
 39 struct pcf_header {
 40 	char header[4];
 41@@ -137,12 +137,12 @@ handle_compressed_metrics(int32_t count, struct compressed_metrics *m)
 42 	for (i = 0; i < count; ++i) {
 43 		struct glyph *glyph = &extracted_font.glyphs[i];
 44 		glyph->left_bearing =
 45-			((int16_t) m[i].left_sided_bearing) - 0x80;
 46+		    ((int16_t)m[i].left_sided_bearing) - 0x80;
 47 		glyph->right_bearing =
 48-			((int16_t) m[i].right_side_bearing) - 0x80;
 49-		glyph->width = ((int16_t) m[i].character_width) - 0x80;
 50-		glyph->ascent = ((int16_t) m[i].character_ascent) - 0x80;
 51-		glyph->descent = ((int16_t) m[i].character_descent) - 0x80;
 52+		    ((int16_t)m[i].right_side_bearing) - 0x80;
 53+		glyph->width = ((int16_t)m[i].character_width) - 0x80;
 54+		glyph->ascent = ((int16_t)m[i].character_ascent) - 0x80;
 55+		glyph->descent = ((int16_t)m[i].character_descent) - 0x80;
 56 
 57 		/* computed stuff */
 58 		glyph->height = glyph->ascent + glyph->descent;
 59@@ -160,8 +160,7 @@ handle_metrics(void *metricbuf)
 60 
 61 	if ((metrics->format & PCF_FORMAT_MASK) == PCF_DEFAULT_FORMAT) {
 62 		fprintf(stderr, "todo...\n");
 63-	} else if ((metrics->format & PCF_FORMAT_MASK) ==
 64-		   PCF_COMPRESSED_METRICS) {
 65+	} else if ((metrics->format & PCF_FORMAT_MASK) == PCF_COMPRESSED_METRICS) {
 66 		handle_compressed_metrics(
 67 		    metrics->compressed.count,
 68 		    &metrics->compressed.compressed_metrics[0]);
 69@@ -182,13 +181,13 @@ handle_glyph_names(struct glyph_names *names)
 70 
 71 	fprintf(stderr, "glyph names format %x\n", names->format);
 72 
 73-	char *names_start = ((char *) names) + sizeof(struct glyph_names)
 74-		+ (names->glyph_count + 1) * sizeof(int32_t);
 75+	char *names_start = ((char *)names) + sizeof(struct glyph_names)
 76+	                    + (names->glyph_count + 1) * sizeof(int32_t);
 77 
 78 	int i;
 79 	for (i = 0; i < names->glyph_count; ++i) {
 80 		int32_t start = names->offsets[i];
 81-		int32_t end = names->offsets[i+1];
 82+		int32_t end = names->offsets[i + 1];
 83 		char *name = names_start + start;
 84 		extracted_font.glyphs[i].name = calloc(1, end - start + 1);
 85 		memcpy(extracted_font.glyphs[i].name, name, end - start);
 86@@ -211,8 +210,8 @@ handle_bitmaps(struct bitmaps *bitmaps)
 87 		abort();
 88 	}
 89 
 90-	char *bitmaps_start = ((char*) bitmaps) + sizeof(struct bitmaps)
 91-		+ (bitmaps->glyph_count + 4) * sizeof(int32_t);
 92+	char *bitmaps_start = ((char *)bitmaps) + sizeof(struct bitmaps)
 93+	                      + (bitmaps->glyph_count + 4) * sizeof(int32_t);
 94 
 95 	for (unsigned i = 0; i < bitmaps->glyph_count; ++i) {
 96 		int32_t offset = bitmaps->offsets[i];
 97@@ -233,11 +232,11 @@ handle_pcf(void *fontbuf)
 98 		struct toc_entry *entry = &header->tables[i];
 99 		fprintf(stderr, "type: %d\n", entry->type);
100 		if (entry->type == PCF_METRICS) {
101-			handle_metrics((void *)((uintptr_t) fontbuf + entry->offset));
102+			handle_metrics((void *)((uintptr_t)fontbuf + entry->offset));
103 		} else if (entry->type == PCF_GLYPH_NAMES) {
104-			handle_glyph_names((void *)((uintptr_t) fontbuf + entry->offset));
105+			handle_glyph_names((void *)((uintptr_t)fontbuf + entry->offset));
106 		} else if (entry->type == PCF_BITMAPS) {
107-			handle_bitmaps((void *)((uintptr_t) fontbuf + entry->offset));
108+			handle_bitmaps((void *)((uintptr_t)fontbuf + entry->offset));
109 		}
110 	}
111 }
112@@ -248,12 +247,11 @@ get_glyph_pixel(struct glyph *glyph, int x, int y)
113 	int absx = glyph->hotx + x;
114 	int absy = glyph->hoty + y;
115 
116-	if (absx < 0 || absx >= glyph->width ||
117-	    absy < 0 || absy >= glyph->height)
118+	if (absx < 0 || absx >= glyph->width || absy < 0 || absy >= glyph->height)
119 		return 0;
120 
121 	int stride = (glyph->width + 31) / 32 * 4;
122-	unsigned char block = glyph->data[absy * stride + (absx/8)];
123+	unsigned char block = glyph->data[absy * stride + (absx / 8)];
124 	int idx = absx % 8;
125 	return (block >> idx) & 1;
126 }
127@@ -277,8 +275,8 @@ add_pixel(uint32_t pixel)
128 	if (data_buffer.size == data_buffer.capacity) {
129 		data_buffer.capacity *= 2;
130 		data_buffer.data =
131-			realloc(data_buffer.data,
132-				sizeof(uint32_t) * data_buffer.capacity);
133+		    realloc(data_buffer.data,
134+		            sizeof(uint32_t) * data_buffer.capacity);
135 	}
136 	data_buffer.data[data_buffer.size++] = pixel;
137 }
138@@ -292,14 +290,14 @@ struct reconstructed_glyph {
139 
140 static void
141 reconstruct_glyph(struct glyph *cursor, struct glyph *mask, char *name,
142-		  struct reconstructed_glyph *glyph)
143+                  struct reconstructed_glyph *glyph)
144 {
145 	int minx = min(-cursor->hotx, -mask->hotx);
146 	int maxx = max(cursor->right_bearing, mask->right_bearing);
147 
148 	int miny = min(-cursor->hoty, -mask->hoty);
149 	int maxy = max(cursor->height - cursor->hoty,
150-		       mask->height - mask->hoty);
151+	               mask->height - mask->hoty);
152 
153 	int width = maxx - minx;
154 	int height = maxy - miny;
155@@ -330,28 +328,28 @@ reconstruct_glyph(struct glyph *cursor, struct glyph *mask, char *name,
156 
157 /* From http://cgit.freedesktop.org/xorg/lib/libXfont/tree/src/builtins/fonts.c */
158 static const char cursor_licence[] =
159-	"/*\n"
160- 	"* Copyright 1999 SuSE, Inc.\n"
161- 	"*\n"
162- 	"* Permission to use, copy, modify, distribute, and sell this software and its\n"
163- 	"* documentation for any purpose is hereby granted without fee, provided that\n"
164- 	"* the above copyright notice appear in all copies and that both that\n"
165- 	"* copyright notice and this permission notice appear in supporting\n"
166- 	"* documentation, and that the name of SuSE not be used in advertising or\n"
167- 	"* publicity pertaining to distribution of the software without specific,\n"
168- 	"* written prior permission.  SuSE makes no representations about the\n"
169- 	"* suitability of this software for any purpose.  It is provided \"as is\"\n"
170- 	"* without express or implied warranty.\n"
171- 	"*\n"
172- 	"* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL\n"
173- 	"* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE\n"
174- 	"* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n"
175- 	"* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n"
176- 	"* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n"
177- 	"* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
178- 	"*\n"
179- 	"* Author:  Keith Packard, SuSE, Inc.\n"
180- 	"*/\n";
181+    "/*\n"
182+    "* Copyright 1999 SuSE, Inc.\n"
183+    "*\n"
184+    "* Permission to use, copy, modify, distribute, and sell this software and its\n"
185+    "* documentation for any purpose is hereby granted without fee, provided that\n"
186+    "* the above copyright notice appear in all copies and that both that\n"
187+    "* copyright notice and this permission notice appear in supporting\n"
188+    "* documentation, and that the name of SuSE not be used in advertising or\n"
189+    "* publicity pertaining to distribution of the software without specific,\n"
190+    "* written prior permission.  SuSE makes no representations about the\n"
191+    "* suitability of this software for any purpose.  It is provided \"as is\"\n"
192+    "* without express or implied warranty.\n"
193+    "*\n"
194+    "* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL\n"
195+    "* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE\n"
196+    "* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n"
197+    "* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\n"
198+    "* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n"
199+    "* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
200+    "*\n"
201+    "* Author:  Keith Packard, SuSE, Inc.\n"
202+    "*/\n";
203 
204 static void
205 write_output_file(FILE *file, struct reconstructed_glyph *glyphs, int n)
206@@ -384,17 +382,17 @@ write_output_file(FILE *file, struct reconstructed_glyph *glyphs, int n)
207 	fputs("};\n\n", file);
208 
209 	fprintf(file,
210-		"static struct cursor {\n"
211-		"\tint width, height;\n"
212-		"\tint hotspot_x, hotspot_y;\n"
213-		"\tsize_t offset;\n"
214-		"} cursor_metadata[] = {\n");
215+	        "static struct cursor {\n"
216+	        "\tint width, height;\n"
217+	        "\tint hotspot_x, hotspot_y;\n"
218+	        "\tsize_t offset;\n"
219+	        "} cursor_metadata[] = {\n");
220 
221 	for (i = 0; i < n; ++i)
222 		fprintf(file, "\t{ %d, %d, %d, %d, %zu }, /* %s */\n",
223-			glyphs[i].width, glyphs[i].height,
224-			glyphs[i].hotspot_x, glyphs[i].hotspot_y,
225-			glyphs[i].offset, glyphs[i].name);
226+		        glyphs[i].width, glyphs[i].height,
227+		        glyphs[i].hotspot_x, glyphs[i].hotspot_y,
228+		        glyphs[i].offset, glyphs[i].name);
229 
230 	fputs("};\n", file);
231 }
232@@ -410,9 +408,7 @@ find_mask_glyph(char *name)
233 	for (i = 0; i < extracted_font.count; ++i) {
234 		struct glyph *g = &extracted_font.glyphs[i];
235 		int l2 = strlen(g->name);
236-		if ((l2 == len + masklen) &&
237-		    (memcmp(g->name, name, len) == 0) &&
238-		    (memcmp(g->name + len, mask, masklen) == 0)) {
239+		if ((l2 == len + masklen) && (memcmp(g->name, name, len) == 0) && (memcmp(g->name + len, mask, masklen) == 0)) {
240 			return g;
241 		}
242 	}
243@@ -421,8 +417,8 @@ find_mask_glyph(char *name)
244 
245 static void
246 find_cursor_and_mask(const char *name,
247-		     struct glyph **cursor,
248-		     struct glyph **mask)
249+                     struct glyph **cursor,
250+                     struct glyph **mask)
251 {
252 	int i;
253 	char mask_name[100];
254@@ -463,31 +459,32 @@ output_interesting_cursors(FILE *file)
255 	int i;
256 	int n = sizeof(interesting_cursors) / sizeof(interesting_cursors[0]);
257 	struct reconstructed_glyph *glyphs =
258-		malloc(n * sizeof(*glyphs));
259+	    malloc(n * sizeof(*glyphs));
260 
261 	for (i = 0; i < n; ++i) {
262 		struct glyph *cursor, *mask;
263 		find_cursor_and_mask(interesting_cursors[i].source_name,
264-				     &cursor, &mask);
265+		                     &cursor, &mask);
266 		if (!cursor) {
267 			fprintf(stderr, "no cursor for %s\n",
268-			       interesting_cursors[i].source_name);
269+			        interesting_cursors[i].source_name);
270 			abort();
271 		}
272 		if (!mask) {
273 			fprintf(stderr, "no mask for %s\n",
274-			       interesting_cursors[i].source_name);
275+			        interesting_cursors[i].source_name);
276 			abort();
277 		}
278 		reconstruct_glyph(cursor, mask,
279-				  interesting_cursors[i].target_name,
280-				  &glyphs[i]);
281+		                  interesting_cursors[i].target_name,
282+		                  &glyphs[i]);
283 	}
284 
285 	write_output_file(file, glyphs, n);
286 }
287 
288-int main(int argc, char *argv[])
289+int
290+main(int argc, char *argv[])
291 {
292 	if (argc != 3) {
293 		fprintf(stderr, "Usage: %s input.pcf output.h\n", argv[0]);
294@@ -500,7 +497,7 @@ int main(int argc, char *argv[])
295 	fstat(fd, &filestat);
296 
297 	void *fontbuf = mmap(NULL, filestat.st_size, PROT_READ,
298-			     MAP_PRIVATE, fd, 0);
299+	                     MAP_PRIVATE, fd, 0);
300 
301 	handle_pcf(fontbuf);
302 
+164, -161
  1@@ -27,246 +27,249 @@
  2 #include <wayland-server.h>
  3 #include <xkbcommon/xkbcommon.h>
  4 
  5-struct screen
  6-{
  7-    struct swc_screen * swc;
  8-    struct wl_list windows;
  9-    unsigned num_windows;
 10+struct screen {
 11+	struct swc_screen *swc;
 12+	struct wl_list windows;
 13+	unsigned num_windows;
 14 };
 15 
 16-struct window
 17-{
 18-    struct swc_window * swc;
 19-    struct screen * screen;
 20-    struct wl_list link;
 21+struct window {
 22+	struct swc_window *swc;
 23+	struct screen *screen;
 24+	struct wl_list link;
 25 };
 26 
 27-static const char * terminal_command[] = { "st-wl", NULL };
 28-static const char * dmenu_command[] = { "dmenu_run-wl", NULL };
 29+static const char *terminal_command[] = { "st-wl", NULL };
 30+static const char *dmenu_command[] = { "dmenu_run-wl", NULL };
 31 static const uint32_t border_width = 1;
 32 static const uint32_t border_color_active = 0xff333388;
 33 static const uint32_t border_color_normal = 0xff888888;
 34 
 35-static struct screen * active_screen;
 36-static struct window * focused_window;
 37-static struct wl_display * display;
 38-static struct wl_event_loop * event_loop;
 39+static struct screen *active_screen;
 40+static struct window *focused_window;
 41+static struct wl_display *display;
 42+static struct wl_event_loop *event_loop;
 43 
 44 /* This is a basic grid arrange function that tries to give each window an
 45  * equal space. */
 46-static void arrange(struct screen * screen)
 47+static void
 48+arrange(struct screen *screen)
 49 {
 50-    struct window * window = NULL;
 51-    unsigned num_columns, num_rows, column_index, row_index;
 52-    struct swc_rectangle geometry;
 53-    struct swc_rectangle * screen_geometry = &screen->swc->usable_geometry;
 54-
 55-    if (screen->num_windows == 0) return;
 56-
 57-    num_columns = ceil(sqrt(screen->num_windows));
 58-    num_rows = screen->num_windows / num_columns + 1;
 59-    window = wl_container_of(screen->windows.next, window, link);
 60-
 61-    for (column_index = 0; &window->link != &screen->windows; ++column_index)
 62-    {
 63-        geometry.x = screen_geometry->x + border_width
 64-            + screen_geometry->width * column_index / num_columns;
 65-        geometry.width = screen_geometry->width / num_columns
 66-            - 2 * border_width;
 67-
 68-        if (column_index == screen->num_windows % num_columns)
 69-            --num_rows;
 70-
 71-        for (row_index = 0; row_index < num_rows; ++row_index)
 72-        {
 73-            geometry.y = screen_geometry->y + border_width
 74-                + screen_geometry->height * row_index / num_rows;
 75-            geometry.height = screen_geometry->height / num_rows
 76-                - 2 * border_width;
 77-
 78-            swc_window_set_geometry(window->swc, &geometry);
 79-            window = wl_container_of(window->link.next, window, link);
 80-        }
 81-    }
 82+	struct window *window = NULL;
 83+	unsigned num_columns, num_rows, column_index, row_index;
 84+	struct swc_rectangle geometry;
 85+	struct swc_rectangle *screen_geometry = &screen->swc->usable_geometry;
 86+
 87+	if (screen->num_windows == 0)
 88+		return;
 89+
 90+	num_columns = ceil(sqrt(screen->num_windows));
 91+	num_rows = screen->num_windows / num_columns + 1;
 92+	window = wl_container_of(screen->windows.next, window, link);
 93+
 94+	for (column_index = 0; &window->link != &screen->windows; ++column_index) {
 95+		geometry.x = screen_geometry->x + border_width
 96+		             + screen_geometry->width * column_index / num_columns;
 97+		geometry.width = screen_geometry->width / num_columns
 98+		                 - 2 * border_width;
 99+
100+		if (column_index == screen->num_windows % num_columns)
101+			--num_rows;
102+
103+		for (row_index = 0; row_index < num_rows; ++row_index) {
104+			geometry.y = screen_geometry->y + border_width
105+			             + screen_geometry->height * row_index / num_rows;
106+			geometry.height = screen_geometry->height / num_rows
107+			                  - 2 * border_width;
108+
109+			swc_window_set_geometry(window->swc, &geometry);
110+			window = wl_container_of(window->link.next, window, link);
111+		}
112+	}
113 }
114 
115-static void screen_add_window(struct screen * screen, struct window * window)
116+static void
117+screen_add_window(struct screen *screen, struct window *window)
118 {
119-    window->screen = screen;
120-    wl_list_insert(&screen->windows, &window->link);
121-    ++screen->num_windows;
122-    swc_window_show(window->swc);
123-    arrange(screen);
124+	window->screen = screen;
125+	wl_list_insert(&screen->windows, &window->link);
126+	++screen->num_windows;
127+	swc_window_show(window->swc);
128+	arrange(screen);
129 }
130 
131-static void screen_remove_window(struct screen * screen, struct window * window)
132+static void
133+screen_remove_window(struct screen *screen, struct window *window)
134 {
135-    window->screen = NULL;
136-    wl_list_remove(&window->link);
137-    --screen->num_windows;
138-    swc_window_hide(window->swc);
139-    arrange(screen);
140+	window->screen = NULL;
141+	wl_list_remove(&window->link);
142+	--screen->num_windows;
143+	swc_window_hide(window->swc);
144+	arrange(screen);
145 }
146 
147-static void focus(struct window * window)
148+static void
149+focus(struct window *window)
150 {
151-    if (focused_window)
152-    {
153-        swc_window_set_border(focused_window->swc,
154-                              border_color_normal, border_width);
155-    }
156-
157-    if (window)
158-    {
159-        swc_window_set_border(window->swc, border_color_active, border_width);
160-        swc_window_focus(window->swc);
161-    }
162-    else
163-        swc_window_focus(NULL);
164-
165-    focused_window = window;
166+	if (focused_window) {
167+		swc_window_set_border(focused_window->swc,
168+		                      border_color_normal, border_width);
169+	}
170+
171+	if (window) {
172+		swc_window_set_border(window->swc, border_color_active, border_width);
173+		swc_window_focus(window->swc);
174+	} else
175+		swc_window_focus(NULL);
176+
177+	focused_window = window;
178 }
179 
180-static void screen_usable_geometry_changed(void * data)
181+static void
182+screen_usable_geometry_changed(void *data)
183 {
184-    struct screen * screen = data;
185+	struct screen *screen = data;
186 
187-    /* If the usable geometry of the screen changes, for example when a panel is
188+	/* If the usable geometry of the screen changes, for example when a panel is
189      * docked to the edge of the screen, we need to rearrange the windows to
190      * ensure they are all within the new usable geometry. */
191-    arrange(screen);
192+	arrange(screen);
193 }
194 
195-static void screen_entered(void * data)
196+static void
197+screen_entered(void *data)
198 {
199-    struct screen * screen = data;
200+	struct screen *screen = data;
201 
202-    active_screen = screen;
203+	active_screen = screen;
204 }
205 
206 static const struct swc_screen_handler screen_handler = {
207-    .usable_geometry_changed = &screen_usable_geometry_changed,
208-    .entered = &screen_entered,
209+	.usable_geometry_changed = &screen_usable_geometry_changed,
210+	.entered = &screen_entered,
211 };
212 
213-static void window_destroy(void * data)
214+static void
215+window_destroy(void *data)
216 {
217-    struct window * window = data, * next_focus;
218+	struct window *window = data, *next_focus;
219 
220-    if (focused_window == window)
221-    {
222-        /* Try to find a new focus nearby the old one. */
223-        next_focus = wl_container_of(window->link.next, window, link);
224+	if (focused_window == window) {
225+		/* Try to find a new focus nearby the old one. */
226+		next_focus = wl_container_of(window->link.next, window, link);
227 
228-        if (&next_focus->link == &window->screen->windows)
229-        {
230-            next_focus = wl_container_of(window->link.prev,
231-                                         window, link);
232+		if (&next_focus->link == &window->screen->windows) {
233+			next_focus = wl_container_of(window->link.prev,
234+			                             window, link);
235 
236-            if (&next_focus->link == &window->screen->windows)
237-                next_focus = NULL;
238-        }
239+			if (&next_focus->link == &window->screen->windows)
240+				next_focus = NULL;
241+		}
242 
243-        focus(next_focus);
244-    }
245+		focus(next_focus);
246+	}
247 
248-    screen_remove_window(window->screen, window);
249-    free(window);
250+	screen_remove_window(window->screen, window);
251+	free(window);
252 }
253 
254-static void window_entered(void * data)
255+static void
256+window_entered(void *data)
257 {
258-    struct window * window = data;
259+	struct window *window = data;
260 
261-    focus(window);
262+	focus(window);
263 }
264 
265 static const struct swc_window_handler window_handler = {
266-    .destroy = &window_destroy,
267-    .entered = &window_entered,
268+	.destroy = &window_destroy,
269+	.entered = &window_entered,
270 };
271 
272-static void new_screen(struct swc_screen * swc)
273+static void
274+new_screen(struct swc_screen *swc)
275 {
276-    struct screen * screen;
277+	struct screen *screen;
278 
279-    screen = malloc(sizeof *screen);
280+	screen = malloc(sizeof *screen);
281 
282-    if (!screen)
283-        return;
284+	if (!screen)
285+		return;
286 
287-    screen->swc = swc;
288-    screen->num_windows = 0;
289-    wl_list_init(&screen->windows);
290-    swc_screen_set_handler(swc, &screen_handler, screen);
291-    active_screen = screen;
292+	screen->swc = swc;
293+	screen->num_windows = 0;
294+	wl_list_init(&screen->windows);
295+	swc_screen_set_handler(swc, &screen_handler, screen);
296+	active_screen = screen;
297 }
298 
299-static void new_window(struct swc_window * swc)
300+static void
301+new_window(struct swc_window *swc)
302 {
303-    struct window * window;
304+	struct window *window;
305 
306-    window = malloc(sizeof *window);
307+	window = malloc(sizeof *window);
308 
309-    if (!window)
310-        return;
311+	if (!window)
312+		return;
313 
314-    window->swc = swc;
315-    window->screen = NULL;
316-    swc_window_set_handler(swc, &window_handler, window);
317-    swc_window_set_tiled(swc);
318-    screen_add_window(active_screen, window);
319-    focus(window);
320+	window->swc = swc;
321+	window->screen = NULL;
322+	swc_window_set_handler(swc, &window_handler, window);
323+	swc_window_set_tiled(swc);
324+	screen_add_window(active_screen, window);
325+	focus(window);
326 }
327 
328 const struct swc_manager manager = { &new_screen, &new_window };
329 
330-static void spawn(void * data, uint32_t time, uint32_t value, uint32_t state)
331+static void
332+spawn(void *data, uint32_t time, uint32_t value, uint32_t state)
333 {
334-    char * const * command = data;
335+	char *const *command = data;
336 
337-    if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
338-        return;
339+	if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
340+		return;
341 
342-    if (fork() == 0)
343-    {
344-        execvp(command[0], command);
345-        exit(EXIT_FAILURE);
346-    }
347+	if (fork() == 0) {
348+		execvp(command[0], command);
349+		exit(EXIT_FAILURE);
350+	}
351 }
352 
353-static void quit(void * data, uint32_t time, uint32_t value, uint32_t state)
354+static void
355+quit(void *data, uint32_t time, uint32_t value, uint32_t state)
356 {
357-    if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
358-        return;
359+	if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
360+		return;
361 
362-    wl_display_terminate(display);
363+	wl_display_terminate(display);
364 }
365 
366-int main(int argc, char * argv[])
367+int
368+main(int argc, char *argv[])
369 {
370-    display = wl_display_create();
371+	display = wl_display_create();
372 
373-    if (!display)
374-        return EXIT_FAILURE;
375+	if (!display)
376+		return EXIT_FAILURE;
377 
378-    if (wl_display_add_socket(display, NULL) != 0)
379-        return EXIT_FAILURE;
380+	if (wl_display_add_socket(display, NULL) != 0)
381+		return EXIT_FAILURE;
382 
383-    if (!swc_initialize(display, NULL, &manager))
384-        return EXIT_FAILURE;
385+	if (!swc_initialize(display, NULL, &manager))
386+		return EXIT_FAILURE;
387 
388-    swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_Return,
389-                    &spawn, terminal_command);
390-    swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_r,
391-                    &spawn, dmenu_command);
392-    swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_q,
393-                    &quit, NULL);
394+	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_Return,
395+	                &spawn, terminal_command);
396+	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_r,
397+	                &spawn, dmenu_command);
398+	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_q,
399+	                &quit, NULL);
400 
401-    event_loop = wl_display_get_event_loop(display);
402-    wl_display_run(display);
403-    wl_display_destroy(display);
404+	event_loop = wl_display_get_event_loop(display);
405+	wl_display_run(display);
406+	wl_display_destroy(display);
407 
408-    return EXIT_SUCCESS;
409+	return EXIT_SUCCESS;
410 }
411-
+426, -440
  1@@ -45,528 +45,514 @@
  2 #include <xf86drm.h>
  3 
  4 #ifndef DRM_MAJOR
  5-# define DRM_MAJOR 226
  6+#define DRM_MAJOR 226
  7 #endif
  8 #ifndef EVIOCREVOKE
  9-# define EVIOCREVOKE _IOW('E', 0x91, int)
 10+#define EVIOCREVOKE _IOW('E', 0x91, int)
 11 #endif
 12 
 13-#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
 14+#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array)[0])
 15 
 16 pid_t child_pid = -1;
 17 
 18 static struct
 19-{
 20-    int socket;
 21-    int input_fds[128];
 22-    unsigned num_input_fds;
 23-    int drm_fds[16];
 24-    unsigned num_drm_fds;
 25-    int tty_fd;
 26-    bool active;
 27+    {
 28+	int socket;
 29+	int input_fds[128];
 30+	unsigned num_input_fds;
 31+	int drm_fds[16];
 32+	unsigned num_drm_fds;
 33+	int tty_fd;
 34+	bool active;
 35 } launcher;
 36 
 37 static struct
 38-{
 39-    bool altered;
 40-    int vt;
 41-    long kb_mode;
 42-    long console_mode;
 43+    {
 44+	bool altered;
 45+	int vt;
 46+	long kb_mode;
 47+	long console_mode;
 48 } original_vt_state;
 49 
 50 static bool nflag;
 51 
 52-static void __attribute__((noreturn,format(printf,1,2)))
 53-    die(const char * format, ...);
 54+static void __attribute__((noreturn, format(printf, 1, 2)))
 55+die(const char *format, ...);
 56 
 57-static void __attribute__((noreturn)) usage(const char * name)
 58+static void __attribute__((noreturn)) usage(const char *name)
 59 {
 60-    fprintf(stderr, "Usage: %s [-n] [-s <server-socket>] [-t <tty-device>] "
 61-                    "[--] <server> [server arguments...]\n", name);
 62-    exit(2);
 63+	fprintf(stderr, "Usage: %s [-n] [-s <server-socket>] [-t <tty-device>] "
 64+	                "[--] <server> [server arguments...]\n",
 65+	        name);
 66+	exit(2);
 67 }
 68 
 69-static void start_devices(void)
 70+static void
 71+start_devices(void)
 72 {
 73-    unsigned index;
 74+	unsigned index;
 75 
 76-    for (index = 0; index < launcher.num_drm_fds; ++index)
 77-    {
 78-        if (drmSetMaster(launcher.drm_fds[index]) < 0)
 79-            die("Failed to set DRM master");
 80-    }
 81+	for (index = 0; index < launcher.num_drm_fds; ++index) {
 82+		if (drmSetMaster(launcher.drm_fds[index]) < 0)
 83+			die("Failed to set DRM master");
 84+	}
 85 }
 86 
 87-static void stop_devices(bool fatal)
 88+static void
 89+stop_devices(bool fatal)
 90 {
 91-    unsigned index;
 92+	unsigned index;
 93 
 94-    for (index = 0; index < launcher.num_drm_fds; ++index)
 95-    {
 96-        if (drmDropMaster(launcher.drm_fds[index]) < 0 && fatal)
 97-            die("Failed to drop DRM master");
 98-    }
 99+	for (index = 0; index < launcher.num_drm_fds; ++index) {
100+		if (drmDropMaster(launcher.drm_fds[index]) < 0 && fatal)
101+			die("Failed to drop DRM master");
102+	}
103 
104-    for (index = 0; index < launcher.num_input_fds; ++index)
105-    {
106-        if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1
107-            && errno != ENODEV && fatal)
108-        {
109-            die("FATAL: Your kernel does not support EVIOCREVOKE; "
110-                "input devices cannot be revoked: %s", strerror(errno));
111-        }
112+	for (index = 0; index < launcher.num_input_fds; ++index) {
113+		if (ioctl(launcher.input_fds[index], EVIOCREVOKE, 0) == -1
114+		    && errno != ENODEV && fatal) {
115+			die("FATAL: Your kernel does not support EVIOCREVOKE; "
116+			    "input devices cannot be revoked: %s",
117+			    strerror(errno));
118+		}
119 
120-        close(launcher.input_fds[index]);
121-    }
122+		close(launcher.input_fds[index]);
123+	}
124 
125-    launcher.num_input_fds = 0;
126+	launcher.num_input_fds = 0;
127 }
128 
129-static void cleanup(void)
130+static void
131+cleanup(void)
132 {
133-    struct vt_mode mode = { .mode = VT_AUTO };
134+	struct vt_mode mode = {.mode = VT_AUTO };
135 
136-    if (!original_vt_state.altered)
137-        return;
138+	if (!original_vt_state.altered)
139+		return;
140 
141-    /* Cleanup VT */
142-    fprintf(stderr, "Restoring VT to original state\n");
143-    ioctl(launcher.tty_fd, VT_SETMODE, &mode);
144-    ioctl(launcher.tty_fd, KDSETMODE, original_vt_state.console_mode);
145-    ioctl(launcher.tty_fd, KDSKBMODE, original_vt_state.kb_mode);
146+	/* Cleanup VT */
147+	fprintf(stderr, "Restoring VT to original state\n");
148+	ioctl(launcher.tty_fd, VT_SETMODE, &mode);
149+	ioctl(launcher.tty_fd, KDSETMODE, original_vt_state.console_mode);
150+	ioctl(launcher.tty_fd, KDSKBMODE, original_vt_state.kb_mode);
151 
152-    /* Stop devices before switching the VT to make sure we have released the
153+	/* Stop devices before switching the VT to make sure we have released the
154      * DRM device before the next session tries to claim it. */
155-    stop_devices(false);
156-    ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
157+	stop_devices(false);
158+	ioctl(launcher.tty_fd, VT_ACTIVATE, original_vt_state.vt);
159 
160-    kill(child_pid, SIGTERM);
161+	kill(child_pid, SIGTERM);
162 }
163 
164-void __attribute__((noreturn,format(printf,1,2)))
165-    die(const char * format, ...)
166+void __attribute__((noreturn, format(printf, 1, 2)))
167+die(const char *format, ...)
168 {
169-    va_list args;
170+	va_list args;
171 
172-    fputs("FATAL: ", stderr);
173-    va_start(args, format);
174-    vfprintf(stderr, format, args);
175-    va_end(args);
176+	fputs("FATAL: ", stderr);
177+	va_start(args, format);
178+	vfprintf(stderr, format, args);
179+	va_end(args);
180 
181-    if (errno != 0)
182-        fprintf(stderr, ": %s", strerror(errno));
183+	if (errno != 0)
184+		fprintf(stderr, ": %s", strerror(errno));
185 
186-    fputc('\n', stderr);
187+	fputc('\n', stderr);
188 
189-    if (child_pid)
190-        cleanup();
191+	if (child_pid)
192+		cleanup();
193 
194-    exit(EXIT_FAILURE);
195+	exit(EXIT_FAILURE);
196 }
197 
198-static void activate(void)
199+static void
200+activate(void)
201 {
202-    struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_ACTIVATE };
203+	struct swc_launch_event event = {.type = SWC_LAUNCH_EVENT_ACTIVATE };
204 
205-    start_devices();
206-    send(launcher.socket, &event, sizeof event, 0);
207-    launcher.active = true;
208+	start_devices();
209+	send(launcher.socket, &event, sizeof event, 0);
210+	launcher.active = true;
211 }
212 
213-static void deactivate(void)
214+static void
215+deactivate(void)
216 {
217-    struct swc_launch_event event = { .type = SWC_LAUNCH_EVENT_DEACTIVATE };
218+	struct swc_launch_event event = {.type = SWC_LAUNCH_EVENT_DEACTIVATE };
219 
220-    send(launcher.socket, &event, sizeof event, 0);
221-    stop_devices(true);
222-    launcher.active = false;
223+	send(launcher.socket, &event, sizeof event, 0);
224+	stop_devices(true);
225+	launcher.active = false;
226 }
227 
228-static void handle_chld(int signal)
229+static void
230+handle_chld(int signal)
231 {
232-    int status;
233+	int status;
234 
235-    wait(&status);
236-    fprintf(stderr, "Server exited with status %d\n", WEXITSTATUS(status));
237-    cleanup();
238-    exit(WEXITSTATUS(status));
239+	wait(&status);
240+	fprintf(stderr, "Server exited with status %d\n", WEXITSTATUS(status));
241+	cleanup();
242+	exit(WEXITSTATUS(status));
243 }
244 
245-static void handle_usr1(int signal)
246+static void
247+handle_usr1(int signal)
248 {
249-    deactivate();
250-    ioctl(launcher.tty_fd, VT_RELDISP, 1);
251+	deactivate();
252+	ioctl(launcher.tty_fd, VT_RELDISP, 1);
253 }
254 
255-static void handle_usr2(int signal)
256+static void
257+handle_usr2(int signal)
258 {
259-    ioctl(launcher.tty_fd, VT_RELDISP, VT_ACKACQ);
260-    activate();
261+	ioctl(launcher.tty_fd, VT_RELDISP, VT_ACKACQ);
262+	activate();
263 }
264 
265-static void forward_signal(int signal)
266+static void
267+forward_signal(int signal)
268 {
269-    kill(child_pid, signal);
270+	kill(child_pid, signal);
271 }
272 
273-static void handle_socket_data(int socket)
274+static void
275+handle_socket_data(int socket)
276 {
277-    char buffer[BUFSIZ];
278-    struct swc_launch_request * request = (void *) &buffer;
279-    struct swc_launch_event response;
280-    int fd = -1;
281-    struct stat st;
282-    ssize_t size;
283-
284-    size = receive_fd(socket, &fd, buffer, sizeof buffer);
285-
286-    if (size == -1 || size == 0)
287-        return;
288-
289-    response.type = SWC_LAUNCH_EVENT_RESPONSE;
290-    response.serial = request->serial;
291-
292-    switch (request->type)
293-    {
294-        case SWC_LAUNCH_REQUEST_OPEN_DEVICE:
295-            if (request->path[size - __builtin_offsetof(typeof(*request),
296-                                                        path) - 1] != '\0')
297-            {
298-                fprintf(stderr, "Path is not NULL terminated\n");
299-                goto fail;
300-            }
301-
302-            if (stat(request->path, &st) == -1)
303-            {
304-                fprintf(stderr, "Could not stat %s\n", request->path);
305-                goto fail;
306-            }
307-
308-            switch (major(st.st_rdev))
309-            {
310-                case INPUT_MAJOR:
311-                    if (!launcher.active)
312-                        goto fail;
313-
314-                    if (launcher.num_input_fds
315-                        == ARRAY_LENGTH(launcher.input_fds))
316-                    {
317-                        fprintf(stderr, "Too many input devices opened\n");
318-                        goto fail;
319-                    }
320-                    break;
321-                case DRM_MAJOR:
322-                    if (launcher.num_drm_fds
323-                        == ARRAY_LENGTH(launcher.drm_fds))
324-                    {
325-                        fprintf(stderr, "Too many DRM devices opened\n");
326-                        goto fail;
327-                    }
328-                    break;
329-                default:
330-                    fprintf(stderr, "Device is not an input device\n");
331-                    goto fail;
332-            }
333-
334-            fd = open(request->path, request->flags);
335-
336-            if (fd == -1)
337-            {
338-                fprintf(stderr, "Could not open device %s\n", request->path);
339-                goto fail;
340-            }
341-
342-            switch (major(st.st_rdev))
343-            {
344-                case INPUT_MAJOR:
345-                    launcher.input_fds[launcher.num_input_fds++] = fd;
346-                    break;
347-                case DRM_MAJOR:
348-                    launcher.drm_fds[launcher.num_drm_fds++] = fd;
349-                    break;
350-            }
351-
352-            break;
353-        case SWC_LAUNCH_REQUEST_ACTIVATE_VT:
354-            if (!launcher.active)
355-                goto fail;
356-
357-            if (ioctl(launcher.tty_fd, VT_ACTIVATE, request->vt) == -1)
358-            {
359-                fprintf(stderr, "Could not activate VT %d: %s\n",
360-                        request->vt, strerror(errno));
361-            }
362-            break;
363-        default:
364-            fprintf(stderr, "Unknown request %u\n", request->type);
365-            goto fail;
366-    }
367-
368-    response.success = true;
369-    goto done;
370-
371-  fail:
372-    response.success = false;
373-    fd = -1;
374-  done:
375-    send_fd(socket, fd, &response, sizeof response);
376+	char buffer[BUFSIZ];
377+	struct swc_launch_request *request = (void *)&buffer;
378+	struct swc_launch_event response;
379+	int fd = -1;
380+	struct stat st;
381+	ssize_t size;
382+
383+	size = receive_fd(socket, &fd, buffer, sizeof buffer);
384+
385+	if (size == -1 || size == 0)
386+		return;
387+
388+	response.type = SWC_LAUNCH_EVENT_RESPONSE;
389+	response.serial = request->serial;
390+
391+	switch (request->type) {
392+	case SWC_LAUNCH_REQUEST_OPEN_DEVICE:
393+		if (request->path[size - __builtin_offsetof(typeof(*request),
394+		                                            path) - 1] != '\0') {
395+			fprintf(stderr, "Path is not NULL terminated\n");
396+			goto fail;
397+		}
398+
399+		if (stat(request->path, &st) == -1) {
400+			fprintf(stderr, "Could not stat %s\n", request->path);
401+			goto fail;
402+		}
403+
404+		switch (major(st.st_rdev)) {
405+		case INPUT_MAJOR:
406+			if (!launcher.active)
407+				goto fail;
408+
409+			if (launcher.num_input_fds
410+			    == ARRAY_LENGTH(launcher.input_fds)) {
411+				fprintf(stderr, "Too many input devices opened\n");
412+				goto fail;
413+			}
414+			break;
415+		case DRM_MAJOR:
416+			if (launcher.num_drm_fds
417+			    == ARRAY_LENGTH(launcher.drm_fds)) {
418+				fprintf(stderr, "Too many DRM devices opened\n");
419+				goto fail;
420+			}
421+			break;
422+		default:
423+			fprintf(stderr, "Device is not an input device\n");
424+			goto fail;
425+		}
426+
427+		fd = open(request->path, request->flags);
428+
429+		if (fd == -1) {
430+			fprintf(stderr, "Could not open device %s\n", request->path);
431+			goto fail;
432+		}
433+
434+		switch (major(st.st_rdev)) {
435+		case INPUT_MAJOR:
436+			launcher.input_fds[launcher.num_input_fds++] = fd;
437+			break;
438+		case DRM_MAJOR:
439+			launcher.drm_fds[launcher.num_drm_fds++] = fd;
440+			break;
441+		}
442+
443+		break;
444+	case SWC_LAUNCH_REQUEST_ACTIVATE_VT:
445+		if (!launcher.active)
446+			goto fail;
447+
448+		if (ioctl(launcher.tty_fd, VT_ACTIVATE, request->vt) == -1) {
449+			fprintf(stderr, "Could not activate VT %d: %s\n",
450+			        request->vt, strerror(errno));
451+		}
452+		break;
453+	default:
454+		fprintf(stderr, "Unknown request %u\n", request->type);
455+		goto fail;
456+	}
457+
458+	response.success = true;
459+	goto done;
460+
461+fail:
462+	response.success = false;
463+	fd = -1;
464+done:
465+	send_fd(socket, fd, &response, sizeof response);
466 }
467 
468-static void find_vt(char * vt, size_t size)
469+static void
470+find_vt(char *vt, size_t size)
471 {
472-    char * vt_num_string;
473-
474-    if ((vt_num_string = getenv("XDG_VTNR")))
475-    {
476-        if (snprintf(vt, size, "/dev/tty%s", vt_num_string) >= size)
477-            die("XDG_VTNR is too long");
478-    }
479-    else
480-    {
481-        int tty0_fd, vt_num;
482-
483-        tty0_fd = open("/dev/tty0", O_RDWR);
484-        if (tty0_fd == -1)
485-            die("Could not open /dev/tty0 to find unused VT");
486-        if (ioctl(tty0_fd, VT_OPENQRY, &vt_num) != 0)
487-            die("Could not find unused VT");
488-        close(tty0_fd);
489-        if (snprintf(vt, size, "/dev/tty%d", vt_num) >= size)
490-            die("VT number is too large");
491-    }
492+	char *vt_num_string;
493+
494+	if ((vt_num_string = getenv("XDG_VTNR"))) {
495+		if (snprintf(vt, size, "/dev/tty%s", vt_num_string) >= size)
496+			die("XDG_VTNR is too long");
497+	} else {
498+		int tty0_fd, vt_num;
499+
500+		tty0_fd = open("/dev/tty0", O_RDWR);
501+		if (tty0_fd == -1)
502+			die("Could not open /dev/tty0 to find unused VT");
503+		if (ioctl(tty0_fd, VT_OPENQRY, &vt_num) != 0)
504+			die("Could not find unused VT");
505+		close(tty0_fd);
506+		if (snprintf(vt, size, "/dev/tty%d", vt_num) >= size)
507+			die("VT number is too large");
508+	}
509 }
510 
511-static int open_tty(const char * tty_name)
512+static int
513+open_tty(const char *tty_name)
514 {
515-    char * stdin_tty;
516+	char *stdin_tty;
517 
518-    /* Check if we are running on the desired VT */
519-    if ((stdin_tty = ttyname(STDIN_FILENO)) && strcmp(tty_name, stdin_tty) == 0)
520-        return STDIN_FILENO;
521-    else
522-    {
523-        int fd;
524+	/* Check if we are running on the desired VT */
525+	if ((stdin_tty = ttyname(STDIN_FILENO)) && strcmp(tty_name, stdin_tty) == 0)
526+		return STDIN_FILENO;
527+	else {
528+		int fd;
529 
530-        /* Open the new TTY. */
531-        fd = open(tty_name, O_RDWR | O_NOCTTY);
532+		/* Open the new TTY. */
533+		fd = open(tty_name, O_RDWR | O_NOCTTY);
534 
535-        if (fd < 0)
536-            die("Could not open %s", tty_name);
537+		if (fd < 0)
538+			die("Could not open %s", tty_name);
539 
540-        return fd;
541-    }
542+		return fd;
543+	}
544 }
545 
546-static void setup_tty(int fd)
547+static void
548+setup_tty(int fd)
549 {
550-    struct stat st;
551-    int vt;
552-    struct vt_stat state;
553-    struct vt_mode mode = {
554-        .mode = VT_PROCESS,
555-        .relsig = SIGUSR1,
556-        .acqsig = SIGUSR2
557-    };
558-
559-    if (fstat(fd, &st) == -1)
560-        die("Could not stat TTY fd");
561-
562-    vt = minor(st.st_rdev);
563-
564-    if (major(st.st_rdev) != TTY_MAJOR || vt == 0)
565-        die("Not a valid VT");
566-
567-    if (ioctl(fd, VT_GETSTATE, &state) == -1)
568-        die("Could not get the current VT state");
569-
570-    original_vt_state.vt = state.v_active;
571-
572-    if (ioctl(fd, KDGKBMODE, &original_vt_state.kb_mode))
573-        die("Could not get keyboard mode");
574-
575-    if (ioctl(fd, KDGETMODE, &original_vt_state.console_mode))
576-        die("Could not get console mode");
577-
578-    if (ioctl(fd, KDSKBMODE, K_OFF) == -1)
579-        die("Could not set keyboard mode to K_OFF");
580-
581-    if (ioctl(fd, KDSETMODE, KD_GRAPHICS) == -1)
582-    {
583-        perror("Could not set console mode to KD_GRAPHICS");
584-        goto error0;
585-    }
586-
587-    if (ioctl(fd, VT_SETMODE, &mode) == -1)
588-    {
589-        perror("Could not set VT mode");
590-        goto error1;
591-    }
592-
593-    if (vt == original_vt_state.vt)
594-        activate();
595-    else if (!nflag)
596-    {
597-        if (ioctl(fd, VT_ACTIVATE, vt) == -1)
598-        {
599-            perror("Could not activate VT");
600-            goto error2;
601-        }
602-
603-        if (ioctl(fd, VT_WAITACTIVE, vt) == -1)
604-        {
605-            perror("Could not wait for VT to become active");
606-            goto error2;
607-        }
608-    }
609-
610-    original_vt_state.altered = true;
611-
612-    return;
613-
614-  error2:
615-    mode = (struct vt_mode) { .mode = VT_AUTO };
616-    ioctl(fd, VT_SETMODE, &mode);
617-  error1:
618-    ioctl(fd, KDSETMODE, original_vt_state.console_mode);
619-  error0:
620-    ioctl(fd, KDSKBMODE, original_vt_state.kb_mode);
621-    exit(EXIT_FAILURE);
622+	struct stat st;
623+	int vt;
624+	struct vt_stat state;
625+	struct vt_mode mode = {
626+		.mode = VT_PROCESS,
627+		.relsig = SIGUSR1,
628+		.acqsig = SIGUSR2
629+	};
630+
631+	if (fstat(fd, &st) == -1)
632+		die("Could not stat TTY fd");
633+
634+	vt = minor(st.st_rdev);
635+
636+	if (major(st.st_rdev) != TTY_MAJOR || vt == 0)
637+		die("Not a valid VT");
638+
639+	if (ioctl(fd, VT_GETSTATE, &state) == -1)
640+		die("Could not get the current VT state");
641+
642+	original_vt_state.vt = state.v_active;
643+
644+	if (ioctl(fd, KDGKBMODE, &original_vt_state.kb_mode))
645+		die("Could not get keyboard mode");
646+
647+	if (ioctl(fd, KDGETMODE, &original_vt_state.console_mode))
648+		die("Could not get console mode");
649+
650+	if (ioctl(fd, KDSKBMODE, K_OFF) == -1)
651+		die("Could not set keyboard mode to K_OFF");
652+
653+	if (ioctl(fd, KDSETMODE, KD_GRAPHICS) == -1) {
654+		perror("Could not set console mode to KD_GRAPHICS");
655+		goto error0;
656+	}
657+
658+	if (ioctl(fd, VT_SETMODE, &mode) == -1) {
659+		perror("Could not set VT mode");
660+		goto error1;
661+	}
662+
663+	if (vt == original_vt_state.vt)
664+		activate();
665+	else if (!nflag) {
666+		if (ioctl(fd, VT_ACTIVATE, vt) == -1) {
667+			perror("Could not activate VT");
668+			goto error2;
669+		}
670+
671+		if (ioctl(fd, VT_WAITACTIVE, vt) == -1) {
672+			perror("Could not wait for VT to become active");
673+			goto error2;
674+		}
675+	}
676+
677+	original_vt_state.altered = true;
678+
679+	return;
680+
681+error2:
682+	mode = (struct vt_mode){.mode = VT_AUTO };
683+	ioctl(fd, VT_SETMODE, &mode);
684+error1:
685+	ioctl(fd, KDSETMODE, original_vt_state.console_mode);
686+error0:
687+	ioctl(fd, KDSKBMODE, original_vt_state.kb_mode);
688+	exit(EXIT_FAILURE);
689 }
690 
691-int main(int argc, char * argv[])
692+int
693+main(int argc, char *argv[])
694 {
695-    int option;
696-    int sockets[2];
697-    char * vt = NULL, vt_buf[64];
698-    struct sigaction action = { 0 };
699-    sigset_t set;
700-
701-    while ((option = getopt(argc, argv, "ns:t:")) != -1)
702-    {
703-        switch (option)
704-        {
705-            case 'n':
706-                nflag = true;
707-                break;
708-            case 's':
709-                setenv("WAYLAND_DISPLAY", optarg, true);
710-                break;
711-            case 't':
712-                vt = optarg;
713-                break;
714-            default:
715-                usage(argv[0]);
716-        }
717-    }
718-
719-    if (argc - optind < 1)
720-        usage(argv[0]);
721-
722-    if (socketpair(AF_LOCAL, SOCK_SEQPACKET, 0, sockets) == -1)
723-        die("Could not create socket pair");
724-
725-    launcher.socket = sockets[0];
726-
727-    if (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1)
728-        die("Could not set CLOEXEC on socket");
729-
730-    action.sa_handler = &handle_chld;
731-    if (sigaction(SIGCHLD, &action, NULL) == -1)
732-        die("Failed to register signal handler for SIGCHLD");
733-
734-    action.sa_handler = &handle_usr1;
735-    if (sigaction(SIGUSR1, &action, NULL) == -1)
736-        die("Failed to register signal handler for SIGUSR1");
737-
738-    action.sa_handler = &handle_usr2;
739-    if (sigaction(SIGUSR2, &action, NULL) == -1)
740-        die("Failed to register signal handler for SIGUSR2");
741-
742-    action.sa_handler = &forward_signal;
743-    if (sigaction(SIGINT, &action, NULL) == -1)
744-        die("Failed to register signal handler for SIGINT");
745-    if (sigaction(SIGTERM, &action, NULL) == -1)
746-        die("Failed to register signal handler for SIGTERM");
747-
748-    sigfillset(&set);
749-    sigdelset(&set, SIGCHLD);
750-    sigdelset(&set, SIGUSR1);
751-    sigdelset(&set, SIGUSR2);
752-    sigdelset(&set, SIGINT);
753-    sigdelset(&set, SIGTERM);
754-    sigprocmask(SIG_SETMASK, &set, NULL);
755-
756-    if (!vt)
757-    {
758-        find_vt(vt_buf, sizeof vt_buf);
759-        vt = vt_buf;
760-    }
761-
762-    fprintf(stderr, "Running on %s\n", vt);
763-    launcher.tty_fd = open_tty(vt);
764-    setup_tty(launcher.tty_fd);
765-
766-    child_pid = fork();
767-
768-    /* Child */
769-    if (child_pid == 0)
770-    {
771-        char string[64];
772-
773-        /* Reset signal handlers to defaults */
774-        action.sa_handler = SIG_DFL;
775-        if (sigaction(SIGCHLD, &action, NULL) == -1)
776-            die("Failed to set default signal handler for SIGCHLD");
777-        if (sigaction(SIGUSR1, &action, NULL) == -1)
778-            die("Failed to set default signal handler for SIGUSR1");
779-        if (sigaction(SIGUSR2, &action, NULL) == -1)
780-            die("Failed to set default signal handler for SIGUSR2");
781-        if (sigaction(SIGINT, &action, NULL) == -1)
782-            die("Failed to set default signal handler for SIGINT");
783-        if (sigaction(SIGTERM, &action, NULL) == -1)
784-            die("Failed to set default signal handler for SIGTERM");
785-
786-        /* Set empty signal mask */
787-        sigemptyset(&set);
788-        sigprocmask(SIG_SETMASK, &set, NULL);
789-
790-        sprintf(string, "%d", sockets[1]);
791-        setenv(SWC_LAUNCH_SOCKET_ENV, string, 1);
792-
793-        sprintf(string, "%d", launcher.tty_fd);
794-        setenv(SWC_LAUNCH_TTY_FD_ENV, string, 1);
795-
796-        if (setuid(getuid()) != 0 || setgid(getgid()) != 0)
797-            die("Failed to drop permission before executing display server");
798-
799-        execvp(argv[optind], argv + optind);
800-        die("Could not exec %s", argv[optind]);
801-    }
802-    /* Parent */
803-    else
804-    {
805-        struct pollfd pollfd;
806-        int ret;
807-
808-        pollfd.fd = sockets[0];
809-        pollfd.events = POLLIN;
810-
811-        while (true)
812-        {
813-            ret = poll(&pollfd, 1, -1);
814-
815-            if (ret == -1)
816-            {
817-                if (errno == EINTR)
818-                    continue;
819-                else
820-                    die("Error while polling on socket fd");
821-            }
822-
823-            handle_socket_data(pollfd.fd);
824-        }
825-    }
826-
827-    return EXIT_SUCCESS;
828+	int option;
829+	int sockets[2];
830+	char *vt = NULL, vt_buf[64];
831+	struct sigaction action = { 0 };
832+	sigset_t set;
833+
834+	while ((option = getopt(argc, argv, "ns:t:")) != -1) {
835+		switch (option) {
836+		case 'n':
837+			nflag = true;
838+			break;
839+		case 's':
840+			setenv("WAYLAND_DISPLAY", optarg, true);
841+			break;
842+		case 't':
843+			vt = optarg;
844+			break;
845+		default:
846+			usage(argv[0]);
847+		}
848+	}
849+
850+	if (argc - optind < 1)
851+		usage(argv[0]);
852+
853+	if (socketpair(AF_LOCAL, SOCK_SEQPACKET, 0, sockets) == -1)
854+		die("Could not create socket pair");
855+
856+	launcher.socket = sockets[0];
857+
858+	if (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1)
859+		die("Could not set CLOEXEC on socket");
860+
861+	action.sa_handler = &handle_chld;
862+	if (sigaction(SIGCHLD, &action, NULL) == -1)
863+		die("Failed to register signal handler for SIGCHLD");
864+
865+	action.sa_handler = &handle_usr1;
866+	if (sigaction(SIGUSR1, &action, NULL) == -1)
867+		die("Failed to register signal handler for SIGUSR1");
868+
869+	action.sa_handler = &handle_usr2;
870+	if (sigaction(SIGUSR2, &action, NULL) == -1)
871+		die("Failed to register signal handler for SIGUSR2");
872+
873+	action.sa_handler = &forward_signal;
874+	if (sigaction(SIGINT, &action, NULL) == -1)
875+		die("Failed to register signal handler for SIGINT");
876+	if (sigaction(SIGTERM, &action, NULL) == -1)
877+		die("Failed to register signal handler for SIGTERM");
878+
879+	sigfillset(&set);
880+	sigdelset(&set, SIGCHLD);
881+	sigdelset(&set, SIGUSR1);
882+	sigdelset(&set, SIGUSR2);
883+	sigdelset(&set, SIGINT);
884+	sigdelset(&set, SIGTERM);
885+	sigprocmask(SIG_SETMASK, &set, NULL);
886+
887+	if (!vt) {
888+		find_vt(vt_buf, sizeof vt_buf);
889+		vt = vt_buf;
890+	}
891+
892+	fprintf(stderr, "Running on %s\n", vt);
893+	launcher.tty_fd = open_tty(vt);
894+	setup_tty(launcher.tty_fd);
895+
896+	child_pid = fork();
897+
898+	/* Child */
899+	if (child_pid == 0) {
900+		char string[64];
901+
902+		/* Reset signal handlers to defaults */
903+		action.sa_handler = SIG_DFL;
904+		if (sigaction(SIGCHLD, &action, NULL) == -1)
905+			die("Failed to set default signal handler for SIGCHLD");
906+		if (sigaction(SIGUSR1, &action, NULL) == -1)
907+			die("Failed to set default signal handler for SIGUSR1");
908+		if (sigaction(SIGUSR2, &action, NULL) == -1)
909+			die("Failed to set default signal handler for SIGUSR2");
910+		if (sigaction(SIGINT, &action, NULL) == -1)
911+			die("Failed to set default signal handler for SIGINT");
912+		if (sigaction(SIGTERM, &action, NULL) == -1)
913+			die("Failed to set default signal handler for SIGTERM");
914+
915+		/* Set empty signal mask */
916+		sigemptyset(&set);
917+		sigprocmask(SIG_SETMASK, &set, NULL);
918+
919+		sprintf(string, "%d", sockets[1]);
920+		setenv(SWC_LAUNCH_SOCKET_ENV, string, 1);
921+
922+		sprintf(string, "%d", launcher.tty_fd);
923+		setenv(SWC_LAUNCH_TTY_FD_ENV, string, 1);
924+
925+		if (setuid(getuid()) != 0 || setgid(getgid()) != 0)
926+			die("Failed to drop permission before executing display server");
927+
928+		execvp(argv[optind], argv + optind);
929+		die("Could not exec %s", argv[optind]);
930+	}
931+	/* Parent */
932+	else {
933+		struct pollfd pollfd;
934+		int ret;
935+
936+		pollfd.fd = sockets[0];
937+		pollfd.events = POLLIN;
938+
939+		while (true) {
940+			ret = poll(&pollfd, 1, -1);
941+
942+			if (ret == -1) {
943+				if (errno == EINTR)
944+					continue;
945+				else
946+					die("Error while polling on socket fd");
947+			}
948+
949+			handle_socket_data(pollfd.fd);
950+		}
951+	}
952+
953+	return EXIT_SUCCESS;
954 }
955-
+76, -82
  1@@ -4,90 +4,84 @@
  2 #include <stdio.h>
  3 #include <string.h>
  4 
  5-ssize_t send_fd(int socket, int fd, const void * buffer, ssize_t buffer_size)
  6+ssize_t
  7+send_fd(int socket, int fd, const void *buffer, ssize_t buffer_size)
  8 {
  9-    char control[CMSG_SPACE(sizeof(int))];
 10-    struct iovec iov = {
 11-        .iov_base = (void *) buffer,
 12-        .iov_len = buffer_size
 13-    };
 14-    struct msghdr message = {
 15-        .msg_name = NULL,
 16-        .msg_namelen = 0,
 17-        .msg_iov = &iov,
 18-        .msg_iovlen = 1,
 19-    };
 20-    struct cmsghdr * cmsg;
 21-
 22-    if (fd != -1)
 23-    {
 24-        message.msg_control = control,
 25-        message.msg_controllen = sizeof control;
 26-
 27-        cmsg = CMSG_FIRSTHDR(&message);
 28-        cmsg->cmsg_len = CMSG_LEN(sizeof fd);
 29-        cmsg->cmsg_level = SOL_SOCKET;
 30-        cmsg->cmsg_type = SCM_RIGHTS;
 31-
 32-        memcpy(CMSG_DATA(cmsg), &fd, sizeof fd);
 33-    }
 34-    else
 35-    {
 36-        message.msg_control = NULL;
 37-        message.msg_controllen = 0;
 38-    }
 39-
 40-    return sendmsg(socket, &message, 0);
 41+	char control[CMSG_SPACE(sizeof(int))];
 42+	struct iovec iov = {
 43+		.iov_base = (void *)buffer,
 44+		.iov_len = buffer_size
 45+	};
 46+	struct msghdr message = {
 47+		.msg_name = NULL,
 48+		.msg_namelen = 0,
 49+		.msg_iov = &iov,
 50+		.msg_iovlen = 1,
 51+	};
 52+	struct cmsghdr *cmsg;
 53+
 54+	if (fd != -1) {
 55+		message.msg_control = control,
 56+		message.msg_controllen = sizeof control;
 57+
 58+		cmsg = CMSG_FIRSTHDR(&message);
 59+		cmsg->cmsg_len = CMSG_LEN(sizeof fd);
 60+		cmsg->cmsg_level = SOL_SOCKET;
 61+		cmsg->cmsg_type = SCM_RIGHTS;
 62+
 63+		memcpy(CMSG_DATA(cmsg), &fd, sizeof fd);
 64+	} else {
 65+		message.msg_control = NULL;
 66+		message.msg_controllen = 0;
 67+	}
 68+
 69+	return sendmsg(socket, &message, 0);
 70 }
 71 
 72-ssize_t receive_fd(int socket, int * fd, void * buffer,
 73-                   ssize_t buffer_size)
 74+ssize_t
 75+receive_fd(int socket, int *fd, void *buffer,
 76+           ssize_t buffer_size)
 77 {
 78-    ssize_t size;
 79-
 80-    if (fd)
 81-    {
 82-        char control[CMSG_SPACE(sizeof(int))];
 83-        struct iovec iov = {
 84-            .iov_base = buffer,
 85-            .iov_len = buffer_size
 86-        };
 87-        struct msghdr message = {
 88-            .msg_name = NULL,
 89-            .msg_namelen = 0,
 90-            .msg_iov = &iov,
 91-            .msg_iovlen = 1,
 92-            .msg_control = &control,
 93-            .msg_controllen = sizeof control
 94-        };
 95-        struct cmsghdr * cmsg;
 96-
 97-        size = recvmsg(socket, &message, 0);
 98-
 99-        if (size < 0)
100-            goto nofd;
101-
102-        cmsg = CMSG_FIRSTHDR(&message);
103-
104-        if (!cmsg || cmsg->cmsg_len != CMSG_LEN(sizeof(int))
105-            || cmsg->cmsg_level != SOL_SOCKET
106-            || cmsg->cmsg_type != SCM_RIGHTS)
107-        {
108-            goto nofd;
109-        }
110-
111-        memcpy(fd, CMSG_DATA(cmsg), sizeof *fd);
112-    }
113-    else
114-    {
115-        size = recv(socket, buffer, buffer_size, 0);
116-    }
117-
118-    goto done;
119-
120-  nofd:
121-    *fd = -1;
122-  done:
123-    return size;
124+	ssize_t size;
125+
126+	if (fd) {
127+		char control[CMSG_SPACE(sizeof(int))];
128+		struct iovec iov = {
129+			.iov_base = buffer,
130+			.iov_len = buffer_size
131+		};
132+		struct msghdr message = {
133+			.msg_name = NULL,
134+			.msg_namelen = 0,
135+			.msg_iov = &iov,
136+			.msg_iovlen = 1,
137+			.msg_control = &control,
138+			.msg_controllen = sizeof control
139+		};
140+		struct cmsghdr *cmsg;
141+
142+		size = recvmsg(socket, &message, 0);
143+
144+		if (size < 0)
145+			goto nofd;
146+
147+		cmsg = CMSG_FIRSTHDR(&message);
148+
149+		if (!cmsg || cmsg->cmsg_len != CMSG_LEN(sizeof(int))
150+		    || cmsg->cmsg_level != SOL_SOCKET
151+		    || cmsg->cmsg_type != SCM_RIGHTS) {
152+			goto nofd;
153+		}
154+
155+		memcpy(fd, CMSG_DATA(cmsg), sizeof *fd);
156+	} else {
157+		size = recv(socket, buffer, buffer_size, 0);
158+	}
159+
160+	goto done;
161+
162+nofd:
163+	*fd = -1;
164+done:
165+	return size;
166 }
167-
+32, -39
 1@@ -31,53 +31,46 @@
 2 #define SWC_LAUNCH_SOCKET_ENV "SWC_LAUNCH_SOCKET"
 3 #define SWC_LAUNCH_TTY_FD_ENV "SWC_LAUNCH_TTY_FD"
 4 
 5-struct swc_launch_request
 6-{
 7-    enum
 8-    {
 9-        SWC_LAUNCH_REQUEST_OPEN_DEVICE,
10-        SWC_LAUNCH_REQUEST_ACTIVATE_VT,
11-    } type;
12+struct swc_launch_request {
13+	enum {
14+		SWC_LAUNCH_REQUEST_OPEN_DEVICE,
15+		SWC_LAUNCH_REQUEST_ACTIVATE_VT,
16+	} type;
17 
18-    uint32_t serial;
19+	uint32_t serial;
20 
21-    union
22-    {
23-        struct /* OPEN_DEVICE */
24-        {
25-            int flags;
26-            char path[];
27-        };
28-        struct /* ACTIVATE_VT */
29-        {
30-            unsigned vt;
31-        };
32-    };
33+	union {
34+		struct /* OPEN_DEVICE */
35+		    {
36+			int flags;
37+			char path[];
38+		};
39+		struct /* ACTIVATE_VT */
40+		    {
41+			unsigned vt;
42+		};
43+	};
44 };
45 
46-struct swc_launch_event
47-{
48-    enum
49-    {
50-        SWC_LAUNCH_EVENT_RESPONSE,
51-        SWC_LAUNCH_EVENT_ACTIVATE,
52-        SWC_LAUNCH_EVENT_DEACTIVATE,
53-    } type;
54+struct swc_launch_event {
55+	enum {
56+		SWC_LAUNCH_EVENT_RESPONSE,
57+		SWC_LAUNCH_EVENT_ACTIVATE,
58+		SWC_LAUNCH_EVENT_DEACTIVATE,
59+	} type;
60 
61-    union
62-    {
63-        struct /* RESPONSE */
64-        {
65-            uint32_t serial;
66-            bool success;
67-        };
68-    };
69+	union {
70+		struct /* RESPONSE */
71+		    {
72+			uint32_t serial;
73+			bool success;
74+		};
75+	};
76 };
77 
78-ssize_t send_fd(int socket, int fd, const void * buffer, ssize_t buffer_size);
79+ssize_t send_fd(int socket, int fd, const void *buffer, ssize_t buffer_size);
80 
81-ssize_t receive_fd(int socket, int * fd, void * buffer,
82+ssize_t receive_fd(int socket, int *fd, void *buffer,
83                    ssize_t buffer_size);
84 
85 #endif
86-
+106, -105
  1@@ -32,163 +32,164 @@
  2 #include <errno.h>
  3 #include <wayland-util.h>
  4 
  5-struct binding
  6-{
  7-    uint32_t value;
  8-    uint32_t modifiers;
  9-    swc_binding_handler handler;
 10-    void * data;
 11+struct binding {
 12+	uint32_t value;
 13+	uint32_t modifiers;
 14+	swc_binding_handler handler;
 15+	void *data;
 16 };
 17 
 18-static bool handle_key(struct keyboard * keyboard, uint32_t time,
 19-                       struct key * key, uint32_t state);
 20+static bool handle_key(struct keyboard *keyboard, uint32_t time,
 21+                       struct key *key, uint32_t state);
 22 
 23 static struct keyboard_handler key_binding_handler = {
 24-    .key = &handle_key
 25+	.key = &handle_key
 26 };
 27 
 28-static bool handle_button(struct pointer_handler * handler, uint32_t time,
 29-                          struct button * button, uint32_t state);
 30+static bool handle_button(struct pointer_handler *handler, uint32_t time,
 31+                          struct button *button, uint32_t state);
 32 
 33 static struct pointer_handler button_binding_handler = {
 34-    .button = &handle_button
 35+	.button = &handle_button
 36 };
 37 
 38 static struct wl_array key_bindings, button_bindings;
 39 
 40 const struct swc_bindings swc_bindings = {
 41-    .keyboard_handler = &key_binding_handler,
 42-    .pointer_handler = &button_binding_handler
 43+	.keyboard_handler = &key_binding_handler,
 44+	.pointer_handler = &button_binding_handler
 45 };
 46 
 47-static struct binding * find_binding(struct wl_array * bindings,
 48-                                     uint32_t modifiers, uint32_t value)
 49+static struct binding *
 50+find_binding(struct wl_array *bindings,
 51+             uint32_t modifiers, uint32_t value)
 52 {
 53-    struct binding * binding;
 54-
 55-    wl_array_for_each(binding, bindings)
 56-    {
 57-        if (binding->value == value && (binding->modifiers == modifiers
 58-                                        || binding->modifiers == SWC_MOD_ANY))
 59-        {
 60-            return binding;
 61-        }
 62-    }
 63-
 64-    return NULL;
 65+	struct binding *binding;
 66+
 67+	wl_array_for_each (binding, bindings) {
 68+		if (binding->value == value && (binding->modifiers == modifiers
 69+		                                || binding->modifiers == SWC_MOD_ANY)) {
 70+			return binding;
 71+		}
 72+	}
 73+
 74+	return NULL;
 75 }
 76 
 77-static struct binding * find_key_binding(uint32_t modifiers, uint32_t key)
 78+static struct binding *
 79+find_key_binding(uint32_t modifiers, uint32_t key)
 80 {
 81-    struct binding * binding;
 82-    struct xkb * xkb = &swc.seat->keyboard->xkb;
 83-    xkb_keysym_t keysym;
 84+	struct binding *binding;
 85+	struct xkb *xkb = &swc.seat->keyboard->xkb;
 86+	xkb_keysym_t keysym;
 87 
 88-    /* First try the keysym the keymap generates in it's current state. */
 89-    keysym = xkb_state_key_get_one_sym(xkb->state, XKB_KEY(key));
 90-    binding = find_binding(&key_bindings, modifiers, keysym);
 91+	/* First try the keysym the keymap generates in it's current state. */
 92+	keysym = xkb_state_key_get_one_sym(xkb->state, XKB_KEY(key));
 93+	binding = find_binding(&key_bindings, modifiers, keysym);
 94 
 95-    if (binding)
 96-        return binding;
 97+	if (binding)
 98+		return binding;
 99 
100-    xkb_layout_index_t layout;
101-    const xkb_keysym_t * keysyms;
102+	xkb_layout_index_t layout;
103+	const xkb_keysym_t *keysyms;
104 
105-    /* Then try the keysym associated with shift-level 0 for the key. */
106-    layout = xkb_state_key_get_layout(xkb->state, XKB_KEY(key));
107-    xkb_keymap_key_get_syms_by_level(xkb->keymap.map, XKB_KEY(key),
108-                                     layout, 0, &keysyms);
109+	/* Then try the keysym associated with shift-level 0 for the key. */
110+	layout = xkb_state_key_get_layout(xkb->state, XKB_KEY(key));
111+	xkb_keymap_key_get_syms_by_level(xkb->keymap.map, XKB_KEY(key),
112+	                                 layout, 0, &keysyms);
113 
114-    if (!keysyms)
115-        return NULL;
116+	if (!keysyms)
117+		return NULL;
118 
119-    binding = find_binding(&key_bindings, modifiers, keysyms[0]);
120+	binding = find_binding(&key_bindings, modifiers, keysyms[0]);
121 
122-    return binding;
123+	return binding;
124 }
125 
126-static struct binding * find_button_binding(uint32_t modifiers, uint32_t value)
127+static struct binding *
128+find_button_binding(uint32_t modifiers, uint32_t value)
129 {
130-    return find_binding(&button_bindings, modifiers, value);
131+	return find_binding(&button_bindings, modifiers, value);
132 }
133 
134-static bool handle_binding
135-    (uint32_t time, struct press * press, uint32_t state,
136-     struct binding * (* find_binding)(uint32_t, uint32_t))
137+static bool
138+handle_binding(uint32_t time, struct press *press, uint32_t state,
139+               struct binding *(*find_binding)(uint32_t, uint32_t))
140 {
141-    struct binding * binding;
142+	struct binding *binding;
143 
144-    if (state)
145-    {
146-        binding = find_binding(swc.seat->keyboard->modifiers, press->value);
147+	if (state) {
148+		binding = find_binding(swc.seat->keyboard->modifiers, press->value);
149 
150-        if (!binding)
151-            return false;
152+		if (!binding)
153+			return false;
154 
155-        press->data = binding;
156-    }
157-    else
158-        binding = press->data;
159+		press->data = binding;
160+	} else
161+		binding = press->data;
162 
163-    binding->handler(binding->data, time, binding->value, state);
164+	binding->handler(binding->data, time, binding->value, state);
165 
166-    return true;
167+	return true;
168 }
169 
170-bool handle_key(struct keyboard * keyboard, uint32_t time,
171-                struct key * key, uint32_t state)
172+bool
173+handle_key(struct keyboard *keyboard, uint32_t time,
174+           struct key *key, uint32_t state)
175 {
176-    return handle_binding(time, &key->press, state, &find_key_binding);
177+	return handle_binding(time, &key->press, state, &find_key_binding);
178 }
179 
180-bool handle_button(struct pointer_handler * handler, uint32_t time,
181-                   struct button * button, uint32_t state)
182+bool
183+handle_button(struct pointer_handler *handler, uint32_t time,
184+              struct button *button, uint32_t state)
185 {
186-    return handle_binding(time, &button->press, state, &find_button_binding);
187+	return handle_binding(time, &button->press, state, &find_button_binding);
188 }
189 
190-bool bindings_initialize(void)
191+bool
192+bindings_initialize(void)
193 {
194-    wl_array_init(&key_bindings);
195-    wl_array_init(&button_bindings);
196+	wl_array_init(&key_bindings);
197+	wl_array_init(&button_bindings);
198 
199-    return true;
200+	return true;
201 }
202 
203-void bindings_finalize(void)
204+void
205+bindings_finalize(void)
206 {
207-    wl_array_release(&key_bindings);
208-    wl_array_release(&button_bindings);
209+	wl_array_release(&key_bindings);
210+	wl_array_release(&button_bindings);
211 }
212 
213 EXPORT
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
218+swc_add_binding(enum swc_binding_type type,
219+                uint32_t modifiers, uint32_t value,
220+                swc_binding_handler handler, void *data)
221 {
222-    struct binding * binding;
223-    struct wl_array * bindings;
224-
225-    switch (type)
226-    {
227-        case SWC_BINDING_KEY:
228-            bindings = &key_bindings;
229-            break;
230-        case SWC_BINDING_BUTTON:
231-            bindings = &button_bindings;
232-            break;
233-        default:
234-            return -EINVAL;
235-    }
236-
237-    if (!(binding = wl_array_add(bindings, sizeof *binding)))
238-        return -ENOMEM;
239-
240-    binding->value = value;
241-    binding->modifiers = modifiers;
242-    binding->handler = handler;
243-    binding->data = data;
244-
245-    return 0;
246+	struct binding *binding;
247+	struct wl_array *bindings;
248+
249+	switch (type) {
250+	case SWC_BINDING_KEY:
251+		bindings = &key_bindings;
252+		break;
253+	case SWC_BINDING_BUTTON:
254+		bindings = &button_bindings;
255+		break;
256+	default:
257+		return -EINVAL;
258+	}
259+
260+	if (!(binding = wl_array_add(bindings, sizeof *binding)))
261+		return -ENOMEM;
262+
263+	binding->value = value;
264+	binding->modifiers = modifiers;
265+	binding->handler = handler;
266+	binding->data = data;
267+
268+	return 0;
269 }
270-
+3, -5
 1@@ -26,14 +26,12 @@
 2 
 3 #include <stdbool.h>
 4 
 5-struct swc_bindings
 6-{
 7-    struct keyboard_handler * keyboard_handler;
 8-    struct pointer_handler * pointer_handler;
 9+struct swc_bindings {
10+	struct keyboard_handler *keyboard_handler;
11+	struct pointer_handler *pointer_handler;
12 };
13 
14 bool bindings_initialize(void);
15 void bindings_finalize(void);
16 
17 #endif
18-
+553, -556
   1@@ -52,274 +52,267 @@
   2 #include <wld/drm.h>
   3 #include <xkbcommon/xkbcommon-keysyms.h>
   4 
   5-struct target
   6-{
   7-    struct wld_surface * surface;
   8-    struct wld_buffer * next_buffer, * current_buffer;
   9-    struct view * view;
  10-    struct view_handler view_handler;
  11-    uint32_t mask;
  12-
  13-    struct wl_listener screen_destroy_listener;
  14+struct target {
  15+	struct wld_surface *surface;
  16+	struct wld_buffer *next_buffer, *current_buffer;
  17+	struct view *view;
  18+	struct view_handler view_handler;
  19+	uint32_t mask;
  20+
  21+	struct wl_listener screen_destroy_listener;
  22 };
  23 
  24-static bool handle_motion(struct pointer_handler * handler, uint32_t time,
  25+static bool handle_motion(struct pointer_handler *handler, uint32_t time,
  26                           wl_fixed_t x, wl_fixed_t y);
  27-static void perform_update(void * data);
  28+static void perform_update(void *data);
  29 
  30 static struct pointer_handler pointer_handler = {
  31-    .motion = &handle_motion
  32+	.motion = &handle_motion
  33 };
  34 
  35 static struct
  36-{
  37-    struct wl_list views;
  38-    pixman_region32_t damage, opaque;
  39-    struct wl_listener swc_listener;
  40+    {
  41+	struct wl_list views;
  42+	pixman_region32_t damage, opaque;
  43+	struct wl_listener swc_listener;
  44 
  45-    /* A mask of screens that have been repainted but are waiting on a page
  46+	/* A mask of screens that have been repainted but are waiting on a page
  47      * flip. */
  48-    uint32_t pending_flips;
  49+	uint32_t pending_flips;
  50 
  51-    /* A mask of screens that are scheduled to be repainted on the next
  52+	/* A mask of screens that are scheduled to be repainted on the next
  53      * idle. */
  54-    uint32_t scheduled_updates;
  55+	uint32_t scheduled_updates;
  56 
  57-    bool updating;
  58-    struct wl_global * global;
  59+	bool updating;
  60+	struct wl_global *global;
  61 } compositor;
  62 
  63 struct swc_compositor swc_compositor = {
  64-    .pointer_handler = &pointer_handler
  65+	.pointer_handler = &pointer_handler
  66 };
  67 
  68-static void handle_screen_destroy(struct wl_listener * listener, void * data)
  69+static void
  70+handle_screen_destroy(struct wl_listener *listener, void *data)
  71 {
  72-    struct target * target
  73-        = wl_container_of(listener, target, screen_destroy_listener);
  74+	struct target *target = wl_container_of(listener, target, screen_destroy_listener);
  75 
  76-    wld_destroy_surface(target->surface);
  77-    free(target);
  78+	wld_destroy_surface(target->surface);
  79+	free(target);
  80 }
  81 
  82-static struct target * target_get(struct screen * screen)
  83+static struct target *
  84+target_get(struct screen *screen)
  85 {
  86-    struct wl_listener * listener
  87-        = wl_signal_get(&screen->destroy_signal, &handle_screen_destroy);
  88-    struct target * target;
  89+	struct wl_listener *listener = wl_signal_get(&screen->destroy_signal, &handle_screen_destroy);
  90+	struct target *target;
  91 
  92-    return listener ? wl_container_of(listener, target, screen_destroy_listener)
  93-                    : NULL;
  94+	return listener ? wl_container_of(listener, target, screen_destroy_listener)
  95+	                : NULL;
  96 }
  97 
  98-static void handle_screen_frame(struct view_handler * handler, uint32_t time)
  99+static void
 100+handle_screen_frame(struct view_handler *handler, uint32_t time)
 101 {
 102-    struct target * target = wl_container_of(handler, target, view_handler);
 103-    struct compositor_view * view;
 104+	struct target *target = wl_container_of(handler, target, view_handler);
 105+	struct compositor_view *view;
 106 
 107-    compositor.pending_flips &= ~target->mask;
 108+	compositor.pending_flips &= ~target->mask;
 109 
 110-    wl_list_for_each(view, &compositor.views, link)
 111-    {
 112-        if (view->visible && view->base.screens & target->mask)
 113-            view_frame(&view->base, time);
 114-    }
 115+	wl_list_for_each (view, &compositor.views, link) {
 116+		if (view->visible && view->base.screens & target->mask)
 117+			view_frame(&view->base, time);
 118+	}
 119 
 120-    if (target->current_buffer)
 121-        wld_surface_release(target->surface, target->current_buffer);
 122+	if (target->current_buffer)
 123+		wld_surface_release(target->surface, target->current_buffer);
 124 
 125-    target->current_buffer = target->next_buffer;
 126+	target->current_buffer = target->next_buffer;
 127 
 128-    /* If we had scheduled updates that couldn't run because we were
 129+	/* If we had scheduled updates that couldn't run because we were
 130      * waiting on a page flip, run them now. If the compositor is
 131      * currently updating, then the frame finished immediately, and we
 132      * can be sure that there are no pending updates. */
 133-    if (compositor.scheduled_updates && !compositor.updating)
 134-        perform_update(NULL);
 135+	if (compositor.scheduled_updates && !compositor.updating)
 136+		perform_update(NULL);
 137 }
 138 
 139 static const struct view_handler_impl screen_view_handler = {
 140-    .frame = &handle_screen_frame,
 141+	.frame = &handle_screen_frame,
 142 };
 143 
 144-static int target_swap_buffers(struct target * target)
 145+static int
 146+target_swap_buffers(struct target *target)
 147 {
 148-    target->next_buffer = wld_surface_take(target->surface);
 149-    return view_attach(target->view, target->next_buffer);
 150+	target->next_buffer = wld_surface_take(target->surface);
 151+	return view_attach(target->view, target->next_buffer);
 152 }
 153 
 154-static struct target * target_new(struct screen * screen)
 155+static struct target *
 156+target_new(struct screen *screen)
 157 {
 158-    struct target * target;
 159+	struct target *target;
 160 
 161-    if (!(target = malloc(sizeof *target)))
 162-        goto error0;
 163+	if (!(target = malloc(sizeof *target)))
 164+		goto error0;
 165 
 166-    target->surface = wld_create_surface(swc.drm->context,
 167-                                         screen->base.geometry.width,
 168-                                         screen->base.geometry.height,
 169-                                         WLD_FORMAT_XRGB8888,
 170-                                         WLD_DRM_FLAG_SCANOUT);
 171+	target->surface = wld_create_surface(swc.drm->context,
 172+	                                     screen->base.geometry.width,
 173+	                                     screen->base.geometry.height,
 174+	                                     WLD_FORMAT_XRGB8888,
 175+	                                     WLD_DRM_FLAG_SCANOUT);
 176 
 177-    if (!target->surface)
 178-        goto error1;
 179+	if (!target->surface)
 180+		goto error1;
 181 
 182-    target->view = &screen->planes.framebuffer.view;
 183-    target->view_handler.impl = &screen_view_handler;
 184-    wl_list_insert(&target->view->handlers, &target->view_handler.link);
 185-    target->current_buffer = NULL;
 186-    target->mask = screen_mask(screen);
 187+	target->view = &screen->planes.framebuffer.view;
 188+	target->view_handler.impl = &screen_view_handler;
 189+	wl_list_insert(&target->view->handlers, &target->view_handler.link);
 190+	target->current_buffer = NULL;
 191+	target->mask = screen_mask(screen);
 192 
 193-    target->screen_destroy_listener.notify = &handle_screen_destroy;
 194-    wl_signal_add(&screen->destroy_signal, &target->screen_destroy_listener);
 195+	target->screen_destroy_listener.notify = &handle_screen_destroy;
 196+	wl_signal_add(&screen->destroy_signal, &target->screen_destroy_listener);
 197 
 198-    return target;
 199+	return target;
 200 
 201-  error1:
 202-    free(target);
 203-  error0:
 204-    return NULL;
 205+error1:
 206+	free(target);
 207+error0:
 208+	return NULL;
 209 }
 210 
 211 /* Rendering {{{ */
 212 
 213-static void repaint_view(struct target * target, struct compositor_view * view,
 214-                         pixman_region32_t * damage)
 215+static void
 216+repaint_view(struct target *target, struct compositor_view *view,
 217+             pixman_region32_t *damage)
 218 {
 219-    pixman_region32_t view_region, view_damage, border_damage;
 220-    const struct swc_rectangle * geometry = &view->base.geometry;
 221+	pixman_region32_t view_region, view_damage, border_damage;
 222+	const struct swc_rectangle *geometry = &view->base.geometry;
 223 
 224-    if (!view->base.buffer)
 225-        return;
 226+	if (!view->base.buffer)
 227+		return;
 228 
 229-    pixman_region32_init_rect(&view_region, geometry->x, geometry->y,
 230-                              geometry->width, geometry->height);
 231-    pixman_region32_init_with_extents(&view_damage, &view->extents);
 232-    pixman_region32_init(&border_damage);
 233+	pixman_region32_init_rect(&view_region, geometry->x, geometry->y,
 234+	                          geometry->width, geometry->height);
 235+	pixman_region32_init_with_extents(&view_damage, &view->extents);
 236+	pixman_region32_init(&border_damage);
 237 
 238-    pixman_region32_intersect(&view_damage, &view_damage, damage);
 239-    pixman_region32_subtract(&view_damage, &view_damage, &view->clip);
 240-    pixman_region32_subtract(&border_damage, &view_damage, &view_region);
 241-    pixman_region32_intersect(&view_damage, &view_damage, &view_region);
 242+	pixman_region32_intersect(&view_damage, &view_damage, damage);
 243+	pixman_region32_subtract(&view_damage, &view_damage, &view->clip);
 244+	pixman_region32_subtract(&border_damage, &view_damage, &view_region);
 245+	pixman_region32_intersect(&view_damage, &view_damage, &view_region);
 246 
 247-    pixman_region32_fini(&view_region);
 248+	pixman_region32_fini(&view_region);
 249 
 250-    if (pixman_region32_not_empty(&view_damage))
 251-    {
 252-        pixman_region32_translate(&view_damage, -geometry->x, -geometry->y);
 253-        wld_copy_region(swc.drm->renderer, view->buffer,
 254-                        geometry->x - target->view->geometry.x,
 255-                        geometry->y - target->view->geometry.y, &view_damage);
 256-    }
 257+	if (pixman_region32_not_empty(&view_damage)) {
 258+		pixman_region32_translate(&view_damage, -geometry->x, -geometry->y);
 259+		wld_copy_region(swc.drm->renderer, view->buffer,
 260+		                geometry->x - target->view->geometry.x,
 261+		                geometry->y - target->view->geometry.y, &view_damage);
 262+	}
 263 
 264-    pixman_region32_fini(&view_damage);
 265+	pixman_region32_fini(&view_damage);
 266 
 267-    /* Draw border */
 268-    if (pixman_region32_not_empty(&border_damage))
 269-    {
 270-        pixman_region32_translate(&border_damage,
 271-                                  -target->view->geometry.x,
 272-                                  -target->view->geometry.y);
 273-        wld_fill_region(swc.drm->renderer, view->border.color, &border_damage);
 274-    }
 275+	/* Draw border */
 276+	if (pixman_region32_not_empty(&border_damage)) {
 277+		pixman_region32_translate(&border_damage,
 278+		                          -target->view->geometry.x,
 279+		                          -target->view->geometry.y);
 280+		wld_fill_region(swc.drm->renderer, view->border.color, &border_damage);
 281+	}
 282 
 283-    pixman_region32_fini(&border_damage);
 284+	pixman_region32_fini(&border_damage);
 285 }
 286 
 287-static void renderer_repaint(struct target * target,
 288-                             pixman_region32_t * damage,
 289-                             pixman_region32_t * base_damage,
 290-                             struct wl_list * views)
 291+static void
 292+renderer_repaint(struct target *target,
 293+                 pixman_region32_t *damage,
 294+                 pixman_region32_t *base_damage,
 295+                 struct wl_list *views)
 296 {
 297-    struct compositor_view * view;
 298+	struct compositor_view *view;
 299 
 300-    DEBUG("Rendering to target { x: %d, y: %d, w: %u, h: %u }\n",
 301-          target->view->geometry.x, target->view->geometry.y,
 302-          target->view->geometry.width, target->view->geometry.height);
 303+	DEBUG("Rendering to target { x: %d, y: %d, w: %u, h: %u }\n",
 304+	      target->view->geometry.x, target->view->geometry.y,
 305+	      target->view->geometry.width, target->view->geometry.height);
 306 
 307-    wld_set_target_surface(swc.drm->renderer, target->surface);
 308+	wld_set_target_surface(swc.drm->renderer, target->surface);
 309 
 310-    /* Paint base damage black. */
 311-    if (pixman_region32_not_empty(base_damage))
 312-    {
 313-        pixman_region32_translate(base_damage,
 314-                                  -target->view->geometry.x,
 315-                                  -target->view->geometry.y);
 316-        wld_fill_region(swc.drm->renderer, 0xff000000, base_damage);
 317-    }
 318+	/* Paint base damage black. */
 319+	if (pixman_region32_not_empty(base_damage)) {
 320+		pixman_region32_translate(base_damage,
 321+		                          -target->view->geometry.x,
 322+		                          -target->view->geometry.y);
 323+		wld_fill_region(swc.drm->renderer, 0xff000000, base_damage);
 324+	}
 325 
 326-    wl_list_for_each_reverse(view, views, link)
 327-    {
 328-        if (view->visible && view->base.screens & target->mask)
 329-            repaint_view(target, view, damage);
 330-    }
 331+	wl_list_for_each_reverse (view, views, link) {
 332+		if (view->visible && view->base.screens & target->mask)
 333+			repaint_view(target, view, damage);
 334+	}
 335 
 336-    wld_flush(swc.drm->renderer);
 337+	wld_flush(swc.drm->renderer);
 338 }
 339 
 340-static int renderer_attach(struct compositor_view * view,
 341-                           struct wld_buffer * client_buffer)
 342+static int
 343+renderer_attach(struct compositor_view *view,
 344+                struct wld_buffer *client_buffer)
 345 {
 346-    struct wld_buffer * buffer;
 347-    bool was_proxy = view->buffer != view->base.buffer;
 348-    bool needs_proxy = client_buffer
 349-        && !(wld_capabilities(swc.drm->renderer,
 350-                              client_buffer) & WLD_CAPABILITY_READ);
 351-    bool resized = view->buffer && client_buffer
 352-        && (view->buffer->width != client_buffer->width
 353-            || view->buffer->height != client_buffer->height);
 354+	struct wld_buffer *buffer;
 355+	bool was_proxy = view->buffer != view->base.buffer;
 356+	bool needs_proxy = client_buffer
 357+	                   && !(wld_capabilities(swc.drm->renderer,
 358+	                                         client_buffer) & WLD_CAPABILITY_READ);
 359+	bool resized = view->buffer && client_buffer
 360+	               && (view->buffer->width != client_buffer->width
 361+	                   || view->buffer->height != client_buffer->height);
 362 
 363-    if (client_buffer)
 364-    {
 365-        /* Create a proxy buffer if necessary (for example a hardware buffer
 366+	if (client_buffer) {
 367+		/* Create a proxy buffer if necessary (for example a hardware buffer
 368          * backing a SHM buffer). */
 369-        if (needs_proxy)
 370-        {
 371-            if (!was_proxy || resized)
 372-            {
 373-                DEBUG("Creating a proxy buffer\n");
 374-                buffer = wld_create_buffer(swc.drm->context,
 375-                                           client_buffer->width,
 376-                                           client_buffer->height,
 377-                                           client_buffer->format, WLD_FLAG_MAP);
 378-
 379-                if (!buffer)
 380-                    return -ENOMEM;
 381-            }
 382-            else
 383-            {
 384-                /* Otherwise we can keep the original proxy buffer. */
 385-                buffer = view->buffer;
 386-            }
 387-        }
 388-        else
 389-            buffer = client_buffer;
 390-    }
 391-    else
 392-        buffer = NULL;
 393-
 394-    /* If we no longer need a proxy buffer, or the original buffer is of a
 395+		if (needs_proxy) {
 396+			if (!was_proxy || resized) {
 397+				DEBUG("Creating a proxy buffer\n");
 398+				buffer = wld_create_buffer(swc.drm->context,
 399+				                           client_buffer->width,
 400+				                           client_buffer->height,
 401+				                           client_buffer->format, WLD_FLAG_MAP);
 402+
 403+				if (!buffer)
 404+					return -ENOMEM;
 405+			} else {
 406+				/* Otherwise we can keep the original proxy buffer. */
 407+				buffer = view->buffer;
 408+			}
 409+		} else
 410+			buffer = client_buffer;
 411+	} else
 412+		buffer = NULL;
 413+
 414+	/* If we no longer need a proxy buffer, or the original buffer is of a
 415      * different size, destroy the old proxy image. */
 416-    if (view->buffer && ((!needs_proxy && was_proxy)
 417-                         || (needs_proxy && resized)))
 418-    {
 419-        wld_buffer_unreference(view->buffer);
 420-    }
 421+	if (view->buffer && ((!needs_proxy && was_proxy)
 422+	                     || (needs_proxy && resized))) {
 423+		wld_buffer_unreference(view->buffer);
 424+	}
 425 
 426-    view->buffer = buffer;
 427+	view->buffer = buffer;
 428 
 429-    return 0;
 430+	return 0;
 431 }
 432 
 433-static void renderer_flush_view(struct compositor_view * view)
 434+static void
 435+renderer_flush_view(struct compositor_view *view)
 436 {
 437-    if (view->buffer == view->base.buffer)
 438-        return;
 439+	if (view->buffer == view->base.buffer)
 440+		return;
 441 
 442-    wld_set_target_buffer(swc.shm->renderer, view->buffer);
 443-    wld_copy_region(swc.shm->renderer, view->base.buffer,
 444-                    0, 0, &view->surface->state.damage);
 445-    wld_flush(swc.shm->renderer);
 446+	wld_set_target_buffer(swc.shm->renderer, view->buffer);
 447+	wld_copy_region(swc.shm->renderer, view->base.buffer,
 448+	                0, 0, &view->surface->state.damage);
 449+	wld_flush(swc.shm->renderer);
 450 }
 451 
 452 /* }}} */
 453@@ -330,553 +323,557 @@ static void renderer_flush_view(struct compositor_view * view)
 454  * Adds damage from the region below a view, taking into account it's clip
 455  * region, to the region specified by `damage'.
 456  */
 457-static void damage_below_view(struct compositor_view * view)
 458+static void
 459+damage_below_view(struct compositor_view *view)
 460 {
 461-    pixman_region32_t damage_below;
 462+	pixman_region32_t damage_below;
 463 
 464-    pixman_region32_init_with_extents(&damage_below, &view->extents);
 465-    pixman_region32_subtract(&damage_below, &damage_below, &view->clip);
 466-    pixman_region32_union(&compositor.damage, &compositor.damage,
 467-                          &damage_below);
 468-    pixman_region32_fini(&damage_below);
 469+	pixman_region32_init_with_extents(&damage_below, &view->extents);
 470+	pixman_region32_subtract(&damage_below, &damage_below, &view->clip);
 471+	pixman_region32_union(&compositor.damage, &compositor.damage,
 472+	                      &damage_below);
 473+	pixman_region32_fini(&damage_below);
 474 }
 475 
 476 /**
 477  * Completely damages the surface and its border.
 478  */
 479-static void damage_view(struct compositor_view * view)
 480+static void
 481+damage_view(struct compositor_view *view)
 482 {
 483-    damage_below_view(view);
 484-    view->border.damaged = true;
 485+	damage_below_view(view);
 486+	view->border.damaged = true;
 487 }
 488 
 489-static void update_extents(struct compositor_view * view)
 490+static void
 491+update_extents(struct compositor_view *view)
 492 {
 493-    view->extents.x1 = view->base.geometry.x - view->border.width;
 494-    view->extents.y1 = view->base.geometry.y - view->border.width;
 495-    view->extents.x2 = view->base.geometry.x + view->base.geometry.width
 496-        + view->border.width;
 497-    view->extents.y2 = view->base.geometry.y + view->base.geometry.height
 498-        + view->border.width;
 499+	view->extents.x1 = view->base.geometry.x - view->border.width;
 500+	view->extents.y1 = view->base.geometry.y - view->border.width;
 501+	view->extents.x2 = view->base.geometry.x + view->base.geometry.width
 502+	                   + view->border.width;
 503+	view->extents.y2 = view->base.geometry.y + view->base.geometry.height
 504+	                   + view->border.width;
 505 
 506-    /* Damage border. */
 507-    view->border.damaged = true;
 508+	/* Damage border. */
 509+	view->border.damaged = true;
 510 }
 511 
 512-static void schedule_updates(uint32_t screens)
 513+static void
 514+schedule_updates(uint32_t screens)
 515 {
 516-    if (compositor.scheduled_updates == 0)
 517-        wl_event_loop_add_idle(swc.event_loop, &perform_update, NULL);
 518+	if (compositor.scheduled_updates == 0)
 519+		wl_event_loop_add_idle(swc.event_loop, &perform_update, NULL);
 520 
 521-    if (screens == -1)
 522-    {
 523-        struct screen * screen;
 524+	if (screens == -1) {
 525+		struct screen *screen;
 526 
 527-        screens = 0;
 528-        wl_list_for_each(screen, &swc.screens, link)
 529-            screens |= screen_mask(screen);
 530-    }
 531+		screens = 0;
 532+		wl_list_for_each (screen, &swc.screens, link)
 533+			screens |= screen_mask(screen);
 534+	}
 535 
 536-    compositor.scheduled_updates |= screens;
 537+	compositor.scheduled_updates |= screens;
 538 }
 539 
 540-static bool update(struct view * base)
 541+static bool
 542+update(struct view *base)
 543 {
 544-    struct compositor_view * view = (void *) base;
 545+	struct compositor_view *view = (void *)base;
 546 
 547-    if (!swc.active || !view->visible)
 548-        return false;
 549+	if (!swc.active || !view->visible)
 550+		return false;
 551 
 552-    schedule_updates(view->base.screens);
 553+	schedule_updates(view->base.screens);
 554 
 555-    return true;
 556+	return true;
 557 }
 558 
 559-static int attach(struct view * base, struct wld_buffer * buffer)
 560+static int
 561+attach(struct view *base, struct wld_buffer *buffer)
 562 {
 563-    struct compositor_view * view = (void *) base;
 564-    int ret;
 565+	struct compositor_view *view = (void *)base;
 566+	int ret;
 567 
 568-    if ((ret = renderer_attach(view, buffer)) < 0)
 569-        return ret;
 570+	if ((ret = renderer_attach(view, buffer)) < 0)
 571+		return ret;
 572 
 573-    if (view->visible && view->base.buffer)
 574-    {
 575-        damage_below_view(view);
 576-        update(&view->base);
 577-    }
 578+	if (view->visible && view->base.buffer) {
 579+		damage_below_view(view);
 580+		update(&view->base);
 581+	}
 582 
 583-    if (view_set_size_from_buffer(&view->base, buffer))
 584-    {
 585-        update_extents(view);
 586+	if (view_set_size_from_buffer(&view->base, buffer)) {
 587+		update_extents(view);
 588 
 589-        if (view->visible && buffer)
 590-        {
 591-            view_update_screens(&view->base);
 592-            damage_below_view(view);
 593-            update(&view->base);
 594-        }
 595-    }
 596+		if (view->visible && buffer) {
 597+			view_update_screens(&view->base);
 598+			damage_below_view(view);
 599+			update(&view->base);
 600+		}
 601+	}
 602 
 603-    return 0;
 604+	return 0;
 605 }
 606 
 607-static bool move(struct view * base, int32_t x, int32_t y)
 608+static bool
 609+move(struct view *base, int32_t x, int32_t y)
 610 {
 611-    struct compositor_view * view = (void *) base;
 612+	struct compositor_view *view = (void *)base;
 613 
 614-    if (view->visible)
 615-    {
 616-        damage_below_view(view);
 617-        update(&view->base);
 618-    }
 619+	if (view->visible) {
 620+		damage_below_view(view);
 621+		update(&view->base);
 622+	}
 623 
 624-    if (view_set_position(&view->base, x, y))
 625-    {
 626-        update_extents(view);
 627+	if (view_set_position(&view->base, x, y)) {
 628+		update_extents(view);
 629 
 630-        if (view->visible)
 631-        {
 632-            /* Assume worst-case no clipping until we draw the next frame (in
 633+		if (view->visible) {
 634+			/* Assume worst-case no clipping until we draw the next frame (in
 635              * case the surface gets moved again before that). */
 636-            pixman_region32_init(&view->clip);
 637+			pixman_region32_init(&view->clip);
 638 
 639-            view_update_screens(&view->base);
 640-            damage_below_view(view);
 641-            update(&view->base);
 642-        }
 643-    }
 644+			view_update_screens(&view->base);
 645+			damage_below_view(view);
 646+			update(&view->base);
 647+		}
 648+	}
 649 
 650-    return true;
 651+	return true;
 652 }
 653 
 654 const static struct view_impl view_impl = {
 655-    .update = &update,
 656-    .attach = &attach,
 657-    .move = &move
 658+	.update = &update,
 659+	.attach = &attach,
 660+	.move = &move
 661 };
 662 
 663-struct compositor_view * compositor_create_view(struct surface * surface)
 664+struct compositor_view *
 665+compositor_create_view(struct surface *surface)
 666 {
 667-    struct compositor_view * view;
 668+	struct compositor_view *view;
 669 
 670-    view = malloc(sizeof *view);
 671+	view = malloc(sizeof *view);
 672 
 673-    if (!view)
 674-        return NULL;
 675+	if (!view)
 676+		return NULL;
 677 
 678-    view_initialize(&view->base, &view_impl);
 679-    view->surface = surface;
 680-    view->buffer = NULL;
 681-    view->window = NULL;
 682-    view->parent = NULL;
 683-    view->visible = false;
 684-    view->extents.x1 = 0;
 685-    view->extents.y1 = 0;
 686-    view->extents.x2 = 0;
 687-    view->extents.y2 = 0;
 688-    view->border.width = 0;
 689-    view->border.color = 0x000000;
 690-    view->border.damaged = false;
 691-    pixman_region32_init(&view->clip);
 692-    wl_signal_init(&view->destroy_signal);
 693-    surface_set_view(surface, &view->base);
 694-    wl_list_insert(&compositor.views, &view->link);
 695+	view_initialize(&view->base, &view_impl);
 696+	view->surface = surface;
 697+	view->buffer = NULL;
 698+	view->window = NULL;
 699+	view->parent = NULL;
 700+	view->visible = false;
 701+	view->extents.x1 = 0;
 702+	view->extents.y1 = 0;
 703+	view->extents.x2 = 0;
 704+	view->extents.y2 = 0;
 705+	view->border.width = 0;
 706+	view->border.color = 0x000000;
 707+	view->border.damaged = false;
 708+	pixman_region32_init(&view->clip);
 709+	wl_signal_init(&view->destroy_signal);
 710+	surface_set_view(surface, &view->base);
 711+	wl_list_insert(&compositor.views, &view->link);
 712 
 713-    return view;
 714+	return view;
 715 }
 716 
 717-void compositor_view_destroy(struct compositor_view * view)
 718+void
 719+compositor_view_destroy(struct compositor_view *view)
 720 {
 721-    wl_signal_emit(&view->destroy_signal, NULL);
 722-    compositor_view_hide(view);
 723-    surface_set_view(view->surface, NULL);
 724-    view_finalize(&view->base);
 725-    pixman_region32_fini(&view->clip);
 726-    wl_list_remove(&view->link);
 727-    free(view);
 728+	wl_signal_emit(&view->destroy_signal, NULL);
 729+	compositor_view_hide(view);
 730+	surface_set_view(view->surface, NULL);
 731+	view_finalize(&view->base);
 732+	pixman_region32_fini(&view->clip);
 733+	wl_list_remove(&view->link);
 734+	free(view);
 735 }
 736 
 737-struct compositor_view * compositor_view(struct view * view)
 738+struct compositor_view *
 739+compositor_view(struct view *view)
 740 {
 741-    return view->impl == &view_impl ? (struct compositor_view *) view : NULL;
 742+	return view->impl == &view_impl ? (struct compositor_view *)view : NULL;
 743 }
 744 
 745-void compositor_view_set_parent(struct compositor_view * view,
 746-                                struct compositor_view * parent)
 747+void
 748+compositor_view_set_parent(struct compositor_view *view,
 749+                           struct compositor_view *parent)
 750 {
 751-    view->parent = view;
 752+	view->parent = view;
 753 
 754-    if (parent->visible)
 755-        compositor_view_show(view);
 756-    else
 757-        compositor_view_hide(view);
 758+	if (parent->visible)
 759+		compositor_view_show(view);
 760+	else
 761+		compositor_view_hide(view);
 762 }
 763 
 764-void compositor_view_show(struct compositor_view * view)
 765+void
 766+compositor_view_show(struct compositor_view *view)
 767 {
 768-    struct compositor_view * other;
 769+	struct compositor_view *other;
 770 
 771-    if (view->visible)
 772-        return;
 773+	if (view->visible)
 774+		return;
 775 
 776-    view->visible = true;
 777-    view_update_screens(&view->base);
 778+	view->visible = true;
 779+	view_update_screens(&view->base);
 780 
 781-    /* Assume worst-case no clipping until we draw the next frame (in case the
 782+	/* Assume worst-case no clipping until we draw the next frame (in case the
 783      * surface gets moved before that. */
 784-    pixman_region32_clear(&view->clip);
 785-    damage_view(view);
 786-    update(&view->base);
 787+	pixman_region32_clear(&view->clip);
 788+	damage_view(view);
 789+	update(&view->base);
 790 
 791-    wl_list_for_each(other, &compositor.views, link)
 792-    {
 793-        if (other->parent == view)
 794-            compositor_view_show(other);
 795-    }
 796+	wl_list_for_each (other, &compositor.views, link) {
 797+		if (other->parent == view)
 798+			compositor_view_show(other);
 799+	}
 800 }
 801 
 802-void compositor_view_hide(struct compositor_view * view)
 803+void
 804+compositor_view_hide(struct compositor_view *view)
 805 {
 806-    struct compositor_view * other;
 807+	struct compositor_view *other;
 808 
 809-    if (!view->visible)
 810-        return;
 811+	if (!view->visible)
 812+		return;
 813 
 814-    /* Update all the screens the view was on. */
 815-    update(&view->base);
 816-    damage_below_view(view);
 817+	/* Update all the screens the view was on. */
 818+	update(&view->base);
 819+	damage_below_view(view);
 820 
 821-    view_set_screens(&view->base, 0);
 822-    view->visible = false;
 823+	view_set_screens(&view->base, 0);
 824+	view->visible = false;
 825 
 826-    wl_list_for_each(other, &compositor.views, link)
 827-    {
 828-        if (other->parent == view)
 829-            compositor_view_hide(other);
 830-    }
 831+	wl_list_for_each (other, &compositor.views, link) {
 832+		if (other->parent == view)
 833+			compositor_view_hide(other);
 834+	}
 835 }
 836 
 837-void compositor_view_set_border_width(struct compositor_view * view,
 838-                                      uint32_t width)
 839+void
 840+compositor_view_set_border_width(struct compositor_view *view,
 841+                                 uint32_t width)
 842 {
 843-    if (view->border.width == width)
 844-        return;
 845+	if (view->border.width == width)
 846+		return;
 847 
 848-    view->border.width = width;
 849-    view->border.damaged = true;
 850+	view->border.width = width;
 851+	view->border.damaged = true;
 852 
 853-    /* XXX: Damage above surface for transparent surfaces? */
 854+	/* XXX: Damage above surface for transparent surfaces? */
 855 
 856-    update_extents(view);
 857-    update(&view->base);
 858+	update_extents(view);
 859+	update(&view->base);
 860 }
 861 
 862-void compositor_view_set_border_color(struct compositor_view * view,
 863-                                      uint32_t color)
 864+void
 865+compositor_view_set_border_color(struct compositor_view *view,
 866+                                 uint32_t color)
 867 {
 868-    if (view->border.color == color)
 869-        return;
 870+	if (view->border.color == color)
 871+		return;
 872 
 873-    view->border.color = color;
 874-    view->border.damaged = true;
 875+	view->border.color = color;
 876+	view->border.damaged = true;
 877 
 878-    /* XXX: Damage above surface for transparent surfaces? */
 879+	/* XXX: Damage above surface for transparent surfaces? */
 880 
 881-    update(&view->base);
 882+	update(&view->base);
 883 }
 884 
 885 /* }}} */
 886 
 887-static void calculate_damage(void)
 888+static void
 889+calculate_damage(void)
 890 {
 891-    struct compositor_view * view;
 892-    pixman_region32_t surface_opaque, * surface_damage;
 893+	struct compositor_view *view;
 894+	pixman_region32_t surface_opaque, *surface_damage;
 895 
 896-    pixman_region32_clear(&compositor.opaque);
 897-    pixman_region32_init(&surface_opaque);
 898+	pixman_region32_clear(&compositor.opaque);
 899+	pixman_region32_init(&surface_opaque);
 900 
 901-    /* Go through views top-down to calculate clipping regions. */
 902-    wl_list_for_each(view, &compositor.views, link)
 903-    {
 904-        if (!view->visible)
 905-            continue;
 906+	/* Go through views top-down to calculate clipping regions. */
 907+	wl_list_for_each (view, &compositor.views, link) {
 908+		if (!view->visible)
 909+			continue;
 910 
 911-        /* Clip the surface by the opaque region covering it. */
 912-        pixman_region32_copy(&view->clip, &compositor.opaque);
 913+		/* Clip the surface by the opaque region covering it. */
 914+		pixman_region32_copy(&view->clip, &compositor.opaque);
 915 
 916-        /* Translate the opaque region to global coordinates. */
 917-        pixman_region32_copy(&surface_opaque, &view->surface->state.opaque);
 918-        pixman_region32_translate(&surface_opaque,
 919-                                  view->base.geometry.x, view->base.geometry.y);
 920+		/* Translate the opaque region to global coordinates. */
 921+		pixman_region32_copy(&surface_opaque, &view->surface->state.opaque);
 922+		pixman_region32_translate(&surface_opaque,
 923+		                          view->base.geometry.x, view->base.geometry.y);
 924 
 925-        /* Add the surface's opaque region to the accumulated opaque
 926+		/* Add the surface's opaque region to the accumulated opaque
 927          * region. */
 928-        pixman_region32_union(&compositor.opaque, &compositor.opaque,
 929-                              &surface_opaque);
 930+		pixman_region32_union(&compositor.opaque, &compositor.opaque,
 931+		                      &surface_opaque);
 932 
 933-        surface_damage = &view->surface->state.damage;
 934+		surface_damage = &view->surface->state.damage;
 935 
 936-        if (pixman_region32_not_empty(surface_damage))
 937-        {
 938-            renderer_flush_view(view);
 939+		if (pixman_region32_not_empty(surface_damage)) {
 940+			renderer_flush_view(view);
 941 
 942-            /* Translate surface damage to global coordinates. */
 943-            pixman_region32_translate
 944-                (surface_damage, view->base.geometry.x, view->base.geometry.y);
 945+			/* Translate surface damage to global coordinates. */
 946+			pixman_region32_translate(surface_damage, view->base.geometry.x, view->base.geometry.y);
 947 
 948-            /* Add the surface damage to the compositor damage. */
 949-            pixman_region32_union(&compositor.damage, &compositor.damage,
 950-                                  surface_damage);
 951-            pixman_region32_clear(surface_damage);
 952-        }
 953+			/* Add the surface damage to the compositor damage. */
 954+			pixman_region32_union(&compositor.damage, &compositor.damage,
 955+			                      surface_damage);
 956+			pixman_region32_clear(surface_damage);
 957+		}
 958 
 959-        if (view->border.damaged)
 960-        {
 961-            pixman_region32_t border_region, view_region;
 962+		if (view->border.damaged) {
 963+			pixman_region32_t border_region, view_region;
 964 
 965-            pixman_region32_init_with_extents(&border_region, &view->extents);
 966-            pixman_region32_init_rect
 967-                (&view_region, view->base.geometry.x, view->base.geometry.y,
 968-                 view->base.geometry.width, view->base.geometry.height);
 969+			pixman_region32_init_with_extents(&border_region, &view->extents);
 970+			pixman_region32_init_rect(&view_region, view->base.geometry.x, view->base.geometry.y,
 971+			                          view->base.geometry.width, view->base.geometry.height);
 972 
 973-            pixman_region32_subtract(&border_region, &border_region,
 974-                                     &view_region);
 975+			pixman_region32_subtract(&border_region, &border_region,
 976+			                         &view_region);
 977 
 978-            pixman_region32_union(&compositor.damage, &compositor.damage,
 979-                                  &border_region);
 980+			pixman_region32_union(&compositor.damage, &compositor.damage,
 981+			                      &border_region);
 982 
 983-            pixman_region32_fini(&border_region);
 984-            pixman_region32_fini(&view_region);
 985+			pixman_region32_fini(&border_region);
 986+			pixman_region32_fini(&view_region);
 987 
 988-            view->border.damaged = false;
 989-        }
 990-    }
 991+			view->border.damaged = false;
 992+		}
 993+	}
 994 
 995-    pixman_region32_fini(&surface_opaque);
 996+	pixman_region32_fini(&surface_opaque);
 997 }
 998 
 999-static void update_screen(struct screen * screen)
1000+static void
1001+update_screen(struct screen *screen)
1002 {
1003-    struct target * target;
1004-    const struct swc_rectangle * geometry = &screen->base.geometry;
1005-    pixman_region32_t damage, * total_damage;
1006+	struct target *target;
1007+	const struct swc_rectangle *geometry = &screen->base.geometry;
1008+	pixman_region32_t damage, *total_damage;
1009 
1010-    if (!(compositor.scheduled_updates & screen_mask(screen)))
1011-        return;
1012+	if (!(compositor.scheduled_updates & screen_mask(screen)))
1013+		return;
1014 
1015-    if (!(target = target_get(screen)))
1016-        return;
1017+	if (!(target = target_get(screen)))
1018+		return;
1019 
1020-    pixman_region32_init(&damage);
1021-    pixman_region32_intersect_rect(&damage, &compositor.damage,
1022-                                   geometry->x, geometry->y,
1023-                                   geometry->width, geometry->height);
1024-    pixman_region32_translate(&damage, -geometry->x, -geometry->y);
1025-    total_damage = wld_surface_damage(target->surface, &damage);
1026+	pixman_region32_init(&damage);
1027+	pixman_region32_intersect_rect(&damage, &compositor.damage,
1028+	                               geometry->x, geometry->y,
1029+	                               geometry->width, geometry->height);
1030+	pixman_region32_translate(&damage, -geometry->x, -geometry->y);
1031+	total_damage = wld_surface_damage(target->surface, &damage);
1032 
1033-    /* Don't repaint the screen if it is waiting for a page flip. */
1034-    if (compositor.pending_flips & screen_mask(screen))
1035-    {
1036-        pixman_region32_fini(&damage);
1037-        return;
1038-    }
1039-
1040-    pixman_region32_t base_damage;
1041-    pixman_region32_copy(&damage, total_damage);
1042-    pixman_region32_translate(&damage, geometry->x, geometry->y);
1043-    pixman_region32_init(&base_damage);
1044-    pixman_region32_subtract(&base_damage, &damage, &compositor.opaque);
1045-    renderer_repaint(target, &damage, &base_damage, &compositor.views);
1046-    pixman_region32_fini(&damage);
1047-    pixman_region32_fini(&base_damage);
1048-
1049-    switch (target_swap_buffers(target))
1050-    {
1051-        case -EACCES:
1052-            /* If we get an EACCES, it is because this session is being
1053+	/* Don't repaint the screen if it is waiting for a page flip. */
1054+	if (compositor.pending_flips & screen_mask(screen)) {
1055+		pixman_region32_fini(&damage);
1056+		return;
1057+	}
1058+
1059+	pixman_region32_t base_damage;
1060+	pixman_region32_copy(&damage, total_damage);
1061+	pixman_region32_translate(&damage, geometry->x, geometry->y);
1062+	pixman_region32_init(&base_damage);
1063+	pixman_region32_subtract(&base_damage, &damage, &compositor.opaque);
1064+	renderer_repaint(target, &damage, &base_damage, &compositor.views);
1065+	pixman_region32_fini(&damage);
1066+	pixman_region32_fini(&base_damage);
1067+
1068+	switch (target_swap_buffers(target)) {
1069+	case -EACCES:
1070+		/* If we get an EACCES, it is because this session is being
1071              * deactivated, but we haven't yet received the deactivate signal
1072              * from swc-launch. */
1073-            swc_deactivate();
1074-            break;
1075-        case 0:
1076-            compositor.pending_flips |= screen_mask(screen);
1077-            break;
1078-    }
1079+		swc_deactivate();
1080+		break;
1081+	case 0:
1082+		compositor.pending_flips |= screen_mask(screen);
1083+		break;
1084+	}
1085 }
1086 
1087-static void perform_update(void * data)
1088+static void
1089+perform_update(void *data)
1090 {
1091-    struct screen * screen;
1092-    uint32_t updates = compositor.scheduled_updates
1093-                     & ~compositor.pending_flips;
1094+	struct screen *screen;
1095+	uint32_t updates = compositor.scheduled_updates
1096+	                   & ~compositor.pending_flips;
1097 
1098-    if (!swc.active || !updates)
1099-        return;
1100+	if (!swc.active || !updates)
1101+		return;
1102 
1103-    DEBUG("Performing update\n");
1104+	DEBUG("Performing update\n");
1105 
1106-    compositor.updating = true;
1107-    calculate_damage();
1108+	compositor.updating = true;
1109+	calculate_damage();
1110 
1111-    wl_list_for_each(screen, &swc.screens, link)
1112-        update_screen(screen);
1113+	wl_list_for_each (screen, &swc.screens, link)
1114+		update_screen(screen);
1115 
1116-    /* XXX: Should assert that all damage was covered by some output */
1117-    pixman_region32_clear(&compositor.damage);
1118-    compositor.scheduled_updates &= ~updates;
1119-    compositor.updating = false;
1120+	/* XXX: Should assert that all damage was covered by some output */
1121+	pixman_region32_clear(&compositor.damage);
1122+	compositor.scheduled_updates &= ~updates;
1123+	compositor.updating = false;
1124 }
1125 
1126-bool handle_motion(struct pointer_handler * handler, uint32_t time,
1127-                   wl_fixed_t fx, wl_fixed_t fy)
1128+bool
1129+handle_motion(struct pointer_handler *handler, uint32_t time,
1130+              wl_fixed_t fx, wl_fixed_t fy)
1131 {
1132-    struct compositor_view * view;
1133-    bool found = false;
1134-    int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
1135+	struct compositor_view *view;
1136+	bool found = false;
1137+	int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
1138 
1139-    wl_list_for_each(view, &compositor.views, link)
1140-    {
1141-        if (!view->visible)
1142-            continue;
1143+	wl_list_for_each (view, &compositor.views, link) {
1144+		if (!view->visible)
1145+			continue;
1146 
1147-        if (rectangle_contains_point(&view->base.geometry, x, y)
1148-            && pixman_region32_contains_point(&view->surface->state.input,
1149-                                              x - view->base.geometry.x,
1150-                                              y - view->base.geometry.y, NULL))
1151-        {
1152-            found = true;
1153-            break;
1154-        }
1155-    }
1156+		if (rectangle_contains_point(&view->base.geometry, x, y)
1157+		    && pixman_region32_contains_point(&view->surface->state.input,
1158+		                                      x - view->base.geometry.x,
1159+		                                      y - view->base.geometry.y, NULL)) {
1160+			found = true;
1161+			break;
1162+		}
1163+	}
1164 
1165-    pointer_set_focus(swc.seat->pointer, found ? view : NULL);
1166+	pointer_set_focus(swc.seat->pointer, found ? view : NULL);
1167 
1168-    return false;
1169+	return false;
1170 }
1171 
1172-static void handle_terminate(void * data, uint32_t time,
1173-                             uint32_t value, uint32_t state)
1174+static void
1175+handle_terminate(void *data, uint32_t time,
1176+                 uint32_t value, uint32_t state)
1177 {
1178-    if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
1179-        wl_display_terminate(swc.display);
1180+	if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
1181+		wl_display_terminate(swc.display);
1182 }
1183 
1184-static void handle_switch_vt(void * data, uint32_t time,
1185-                             uint32_t value, uint32_t state)
1186+static void
1187+handle_switch_vt(void *data, uint32_t time,
1188+                 uint32_t value, uint32_t state)
1189 {
1190-    uint8_t vt = value - XKB_KEY_XF86Switch_VT_1 + 1;
1191+	uint8_t vt = value - XKB_KEY_XF86Switch_VT_1 + 1;
1192 
1193-    if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
1194-        launch_activate_vt(vt);
1195+	if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
1196+		launch_activate_vt(vt);
1197 }
1198 
1199-static void handle_swc_event(struct wl_listener * listener, void * data)
1200+static void
1201+handle_swc_event(struct wl_listener *listener, void *data)
1202 {
1203-    struct event * event = data;
1204+	struct event *event = data;
1205 
1206-    switch (event->type)
1207-    {
1208-        case SWC_EVENT_ACTIVATED:
1209-            schedule_updates(-1);
1210-            break;
1211-        case SWC_EVENT_DEACTIVATED:
1212-            compositor.scheduled_updates = 0;
1213-            break;
1214-    }
1215+	switch (event->type) {
1216+	case SWC_EVENT_ACTIVATED:
1217+		schedule_updates(-1);
1218+		break;
1219+	case SWC_EVENT_DEACTIVATED:
1220+		compositor.scheduled_updates = 0;
1221+		break;
1222+	}
1223 }
1224 
1225-static void create_surface(struct wl_client * client,
1226-                           struct wl_resource * resource, uint32_t id)
1227+static void
1228+create_surface(struct wl_client *client,
1229+               struct wl_resource *resource, uint32_t id)
1230 {
1231-    struct surface * surface;
1232+	struct surface *surface;
1233 
1234-    /* Initialize surface. */
1235-    surface = surface_new(client, wl_resource_get_version(resource), id);
1236+	/* Initialize surface. */
1237+	surface = surface_new(client, wl_resource_get_version(resource), id);
1238 
1239-    if (!surface)
1240-    {
1241-        wl_resource_post_no_memory(resource);
1242-        return;
1243-    }
1244+	if (!surface) {
1245+		wl_resource_post_no_memory(resource);
1246+		return;
1247+	}
1248 
1249-    wl_signal_emit(&swc_compositor.signal.new_surface, surface);
1250+	wl_signal_emit(&swc_compositor.signal.new_surface, surface);
1251 }
1252 
1253-static void create_region(struct wl_client * client,
1254-                          struct wl_resource * resource, uint32_t id)
1255+static void
1256+create_region(struct wl_client *client,
1257+              struct wl_resource *resource, uint32_t id)
1258 {
1259-    struct region * region;
1260+	struct region *region;
1261 
1262-    region = region_new(client, wl_resource_get_version(resource), id);
1263+	region = region_new(client, wl_resource_get_version(resource), id);
1264 
1265-    if (!region)
1266-        wl_resource_post_no_memory(resource);
1267+	if (!region)
1268+		wl_resource_post_no_memory(resource);
1269 }
1270 
1271 static struct wl_compositor_interface compositor_implementation = {
1272-    .create_surface = &create_surface,
1273-    .create_region = &create_region
1274+	.create_surface = &create_surface,
1275+	.create_region = &create_region
1276 };
1277 
1278-static void bind_compositor(struct wl_client * client, void * data,
1279-                            uint32_t version, uint32_t id)
1280+static void
1281+bind_compositor(struct wl_client *client, void *data,
1282+                uint32_t version, uint32_t id)
1283 {
1284-    struct wl_resource * resource;
1285+	struct wl_resource *resource;
1286 
1287-    if (version > 3)
1288-        version = 3;
1289+	if (version > 3)
1290+		version = 3;
1291 
1292-    resource = wl_resource_create(client, &wl_compositor_interface,
1293-                                  version, id);
1294-    wl_resource_set_implementation(resource, &compositor_implementation,
1295-                                   NULL, NULL);
1296+	resource = wl_resource_create(client, &wl_compositor_interface,
1297+	                              version, id);
1298+	wl_resource_set_implementation(resource, &compositor_implementation,
1299+	                               NULL, NULL);
1300 }
1301 
1302-bool compositor_initialize(void)
1303+bool
1304+compositor_initialize(void)
1305 {
1306-    struct screen * screen;
1307-    uint32_t keysym;
1308+	struct screen *screen;
1309+	uint32_t keysym;
1310 
1311-    compositor.global = wl_global_create
1312-        (swc.display, &wl_compositor_interface, 3, NULL, &bind_compositor);
1313+	compositor.global = wl_global_create(swc.display, &wl_compositor_interface, 3, NULL, &bind_compositor);
1314 
1315-    if (!compositor.global)
1316-        return false;
1317+	if (!compositor.global)
1318+		return false;
1319 
1320-    compositor.scheduled_updates = 0;
1321-    compositor.pending_flips = 0;
1322-    compositor.updating = false;
1323-    pixman_region32_init(&compositor.damage);
1324-    pixman_region32_init(&compositor.opaque);
1325-    wl_list_init(&compositor.views);
1326-    wl_signal_init(&swc_compositor.signal.new_surface);
1327-    compositor.swc_listener.notify = &handle_swc_event;
1328-    wl_signal_add(&swc.event_signal, &compositor.swc_listener);
1329+	compositor.scheduled_updates = 0;
1330+	compositor.pending_flips = 0;
1331+	compositor.updating = false;
1332+	pixman_region32_init(&compositor.damage);
1333+	pixman_region32_init(&compositor.opaque);
1334+	wl_list_init(&compositor.views);
1335+	wl_signal_init(&swc_compositor.signal.new_surface);
1336+	compositor.swc_listener.notify = &handle_swc_event;
1337+	wl_signal_add(&swc.event_signal, &compositor.swc_listener);
1338 
1339-    wl_list_for_each(screen, &swc.screens, link)
1340-        target_new(screen);
1341-    if (swc.active)
1342-        schedule_updates(-1);
1343+	wl_list_for_each (screen, &swc.screens, link)
1344+		target_new(screen);
1345+	if (swc.active)
1346+		schedule_updates(-1);
1347 
1348-    swc_add_binding(SWC_BINDING_KEY, SWC_MOD_CTRL | SWC_MOD_ALT,
1349-                    XKB_KEY_BackSpace, &handle_terminate, NULL);
1350+	swc_add_binding(SWC_BINDING_KEY, SWC_MOD_CTRL | SWC_MOD_ALT,
1351+	                XKB_KEY_BackSpace, &handle_terminate, NULL);
1352 
1353-    for (keysym = XKB_KEY_XF86Switch_VT_1;
1354-         keysym <= XKB_KEY_XF86Switch_VT_12;
1355-         ++keysym)
1356-    {
1357-        swc_add_binding(SWC_BINDING_KEY, SWC_MOD_ANY, keysym,
1358-                        &handle_switch_vt, NULL);
1359-    }
1360+	for (keysym = XKB_KEY_XF86Switch_VT_1;
1361+	     keysym <= XKB_KEY_XF86Switch_VT_12;
1362+	     ++keysym) {
1363+		swc_add_binding(SWC_BINDING_KEY, SWC_MOD_ANY, keysym,
1364+		                &handle_switch_vt, NULL);
1365+	}
1366 
1367-    return true;
1368+	return true;
1369 }
1370 
1371-void compositor_finalize(void)
1372+void
1373+compositor_finalize(void)
1374 {
1375-    pixman_region32_fini(&compositor.damage);
1376-    pixman_region32_fini(&compositor.opaque);
1377-    wl_global_destroy(compositor.global);
1378+	pixman_region32_fini(&compositor.damage);
1379+	pixman_region32_fini(&compositor.opaque);
1380+	wl_global_destroy(compositor.global);
1381 }
1382-
+36, -39
  1@@ -29,72 +29,69 @@
  2 #include <stdbool.h>
  3 #include <pixman.h>
  4 
  5-struct swc_compositor
  6-{
  7-    struct pointer_handler * const pointer_handler;
  8-    struct
  9-    {
 10-        /**
 11+struct swc_compositor {
 12+	struct pointer_handler *const pointer_handler;
 13+	struct
 14+	    {
 15+		/**
 16          * Emitted when a new surface is created.
 17          *
 18          * The data argument of the signal refers to the surface that has been
 19          * created.
 20          */
 21-        struct wl_signal new_surface;
 22-    } signal;
 23+		struct wl_signal new_surface;
 24+	} signal;
 25 };
 26 
 27 bool compositor_initialize(void);
 28 void compositor_finalize(void);
 29 
 30-struct compositor_view
 31-{
 32-    struct view base;
 33-    struct surface * surface;
 34-    struct wld_buffer * buffer;
 35-    struct window * window;
 36-    struct compositor_view * parent;
 37+struct compositor_view {
 38+	struct view base;
 39+	struct surface *surface;
 40+	struct wld_buffer *buffer;
 41+	struct window *window;
 42+	struct compositor_view *parent;
 43 
 44-    /* Whether or not the view is visible (mapped). */
 45-    bool visible;
 46+	/* Whether or not the view is visible (mapped). */
 47+	bool visible;
 48 
 49-    /* The box that the surface covers (including it's border). */
 50-    pixman_box32_t extents;
 51+	/* The box that the surface covers (including it's border). */
 52+	pixman_box32_t extents;
 53 
 54-    /* The region that is covered by opaque regions of surfaces above this
 55+	/* The region that is covered by opaque regions of surfaces above this
 56      * surface. */
 57-    pixman_region32_t clip;
 58+	pixman_region32_t clip;
 59 
 60-    struct
 61-    {
 62-        uint32_t width;
 63-        uint32_t color;
 64-        bool damaged;
 65-    } border;
 66+	struct
 67+	    {
 68+		uint32_t width;
 69+		uint32_t color;
 70+		bool damaged;
 71+	} border;
 72 
 73-    struct wl_list link;
 74-    struct wl_signal destroy_signal;
 75+	struct wl_list link;
 76+	struct wl_signal destroy_signal;
 77 };
 78 
 79-struct compositor_view * compositor_create_view(struct surface * surface);
 80+struct compositor_view *compositor_create_view(struct surface *surface);
 81 
 82-void compositor_view_destroy(struct compositor_view * view);
 83+void compositor_view_destroy(struct compositor_view *view);
 84 
 85 /**
 86  * Returns view as a compositor_view, or NULL if view is not a compositor_view.
 87  */
 88-struct compositor_view * compositor_view(struct view * view);
 89+struct compositor_view *compositor_view(struct view *view);
 90 
 91-void compositor_view_set_parent(struct compositor_view * view,
 92-                                struct compositor_view * parent);
 93+void compositor_view_set_parent(struct compositor_view *view,
 94+                                struct compositor_view *parent);
 95 
 96-void compositor_view_show(struct compositor_view * view);
 97-void compositor_view_hide(struct compositor_view * view);
 98+void compositor_view_show(struct compositor_view *view);
 99+void compositor_view_hide(struct compositor_view *view);
100 
101-void compositor_view_set_border_color(struct compositor_view * view,
102+void compositor_view_set_border_color(struct compositor_view *view,
103                                       uint32_t color);
104-void compositor_view_set_border_width(struct compositor_view * view,
105+void compositor_view_set_border_width(struct compositor_view *view,
106                                       uint32_t width);
107 
108 #endif
109-
+59, -66
  1@@ -34,96 +34,89 @@
  2 #include <wld/drm.h>
  3 #include <xf86drmMode.h>
  4 
  5-static bool update(struct view * view)
  6+static bool
  7+update(struct view *view)
  8 {
  9-    return true;
 10+	return true;
 11 }
 12 
 13-static int attach(struct view * view, struct wld_buffer * buffer)
 14+static int
 15+attach(struct view *view, struct wld_buffer *buffer)
 16 {
 17-    struct cursor_plane * plane = wl_container_of(view, plane, view);
 18+	struct cursor_plane *plane = wl_container_of(view, plane, view);
 19 
 20-    if (buffer)
 21-    {
 22-        union wld_object object;
 23+	if (buffer) {
 24+		union wld_object object;
 25 
 26-        if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object))
 27-        {
 28-            ERROR("Could not get export buffer to DRM handle\n");
 29-            /* XXX: Not the best error code, but we don't know better until wld
 30+		if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object)) {
 31+			ERROR("Could not get export buffer to DRM handle\n");
 32+			/* XXX: Not the best error code, but we don't know better until wld
 33              * returns an actual error code. */
 34-            return -EINVAL;
 35-        }
 36-
 37-        if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32,
 38-                                           buffer->width, buffer->height) < 0)
 39-        {
 40-            ERROR("Could not set cursor: %s\n", strerror(errno));
 41-            return -errno;
 42-        }
 43-    }
 44-    else if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc,
 45-                                            0, 0, 0) < 0)
 46-    {
 47-        ERROR("Could not unset cursor: %s\n", strerror(errno));
 48-        return -errno;
 49-    }
 50-
 51-    view_set_size_from_buffer(view, buffer);
 52-    return 0;
 53+			return -EINVAL;
 54+		}
 55+
 56+		if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32, buffer->width, buffer->height) < 0) {
 57+			ERROR("Could not set cursor: %s\n", strerror(errno));
 58+			return -errno;
 59+		}
 60+	} else if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0) < 0) {
 61+		ERROR("Could not unset cursor: %s\n", strerror(errno));
 62+		return -errno;
 63+	}
 64+
 65+	view_set_size_from_buffer(view, buffer);
 66+	return 0;
 67 }
 68 
 69-static bool move(struct view * view, int32_t x, int32_t y)
 70+static bool
 71+move(struct view *view, int32_t x, int32_t y)
 72 {
 73-    struct cursor_plane * plane = wl_container_of(view, plane, view);
 74+	struct cursor_plane *plane = wl_container_of(view, plane, view);
 75 
 76-    if (swc.active && drmModeMoveCursor(swc.drm->fd, plane->crtc,
 77-                                        x - plane->origin->x,
 78-                                        y - plane->origin->y) != 0)
 79-    {
 80-        ERROR("Could not move cursor: %s\n", strerror(errno));
 81-        return false;
 82-    }
 83+	if (swc.active && drmModeMoveCursor(swc.drm->fd, plane->crtc, x - plane->origin->x, y - plane->origin->y) != 0) {
 84+		ERROR("Could not move cursor: %s\n", strerror(errno));
 85+		return false;
 86+	}
 87 
 88-    view_set_position(view, x, y);
 89+	view_set_position(view, x, y);
 90 
 91-    return true;
 92+	return true;
 93 }
 94 
 95 static const struct view_impl view_impl = {
 96-    .update = &update,
 97-    .attach = &attach,
 98-    .move = &move
 99+	.update = &update,
100+	.attach = &attach,
101+	.move = &move
102 };
103 
104-static void handle_swc_event(struct wl_listener * listener, void * data)
105+static void
106+handle_swc_event(struct wl_listener *listener, void *data)
107 {
108-    struct event * event = data;
109-    struct cursor_plane * plane
110-        = wl_container_of(listener, plane, swc_listener);
111-
112-    switch (event->type)
113-    {
114-        case SWC_EVENT_ACTIVATED:
115-            move(&plane->view, plane->view.geometry.x, plane->view.geometry.y);
116-            attach(&plane->view, plane->view.buffer);
117-            break;
118-    }
119+	struct event *event = data;
120+	struct cursor_plane *plane = wl_container_of(listener, plane, swc_listener);
121+
122+	switch (event->type) {
123+	case SWC_EVENT_ACTIVATED:
124+		move(&plane->view, plane->view.geometry.x, plane->view.geometry.y);
125+		attach(&plane->view, plane->view.buffer);
126+		break;
127+	}
128 }
129 
130-bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
131-                             const struct swc_rectangle * origin)
132+bool
133+cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc,
134+                        const struct swc_rectangle *origin)
135 {
136-    plane->origin = origin;
137-    plane->crtc = crtc;
138-    plane->swc_listener.notify = &handle_swc_event;
139-    wl_signal_add(&swc.event_signal, &plane->swc_listener);
140-    view_initialize(&plane->view, &view_impl);
141+	plane->origin = origin;
142+	plane->crtc = crtc;
143+	plane->swc_listener.notify = &handle_swc_event;
144+	wl_signal_add(&swc.event_signal, &plane->swc_listener);
145+	view_initialize(&plane->view, &view_impl);
146 
147-    return true;
148+	return true;
149 }
150 
151-void cursor_plane_finalize(struct cursor_plane * plane)
152+void
153+cursor_plane_finalize(struct cursor_plane *plane)
154 {
155 }
156-
+8, -10
 1@@ -26,18 +26,16 @@
 2 
 3 #include "view.h"
 4 
 5-struct cursor_plane
 6-{
 7-    struct view view;
 8-    const struct swc_rectangle * origin;
 9-    uint32_t crtc;
10-    struct wl_listener swc_listener;
11+struct cursor_plane {
12+	struct view view;
13+	const struct swc_rectangle *origin;
14+	uint32_t crtc;
15+	struct wl_listener swc_listener;
16 };
17 
18-bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
19-                             const struct swc_rectangle * origin);
20+bool cursor_plane_initialize(struct cursor_plane *plane, uint32_t crtc,
21+                             const struct swc_rectangle *origin);
22 
23-void cursor_plane_finalize(struct cursor_plane * plane);
24+void cursor_plane_finalize(struct cursor_plane *plane);
25 
26 #endif
27-
+99, -92
  1@@ -29,85 +29,90 @@
  2 #include <unistd.h>
  3 #include <wayland-server.h>
  4 
  5-struct data
  6-{
  7-    struct wl_array mime_types;
  8-    struct wl_resource * source;
  9-    struct wl_list offers;
 10+struct data {
 11+	struct wl_array mime_types;
 12+	struct wl_resource *source;
 13+	struct wl_list offers;
 14 };
 15 
 16-static void offer_accept(struct wl_client * client,
 17-                         struct wl_resource * offer,
 18-                         uint32_t serial, const char * mime_type)
 19+static void
 20+offer_accept(struct wl_client *client,
 21+             struct wl_resource *offer,
 22+             uint32_t serial, const char *mime_type)
 23 {
 24-    struct data * data = wl_resource_get_user_data(offer);
 25+	struct data *data = wl_resource_get_user_data(offer);
 26 
 27-    /* Protect against expired data_offers being used. */
 28-    if (!data)
 29-        return;
 30+	/* Protect against expired data_offers being used. */
 31+	if (!data)
 32+		return;
 33 
 34-    wl_data_source_send_target(data->source, mime_type);
 35+	wl_data_source_send_target(data->source, mime_type);
 36 }
 37 
 38-static void offer_receive(struct wl_client * client,
 39-                          struct wl_resource * offer,
 40-                          const char * mime_type, int fd)
 41+static void
 42+offer_receive(struct wl_client *client,
 43+              struct wl_resource *offer,
 44+              const char *mime_type, int fd)
 45 {
 46-    struct data * data = wl_resource_get_user_data(offer);
 47+	struct data *data = wl_resource_get_user_data(offer);
 48 
 49-    /* Protect against expired data_offers being used. */
 50-    if (!data)
 51-        return;
 52+	/* Protect against expired data_offers being used. */
 53+	if (!data)
 54+		return;
 55 
 56-    wl_data_source_send_send(data->source, mime_type, fd);
 57-    close(fd);
 58+	wl_data_source_send_send(data->source, mime_type, fd);
 59+	close(fd);
 60 }
 61 
 62-static void offer_destroy(struct wl_client * client,
 63-                          struct wl_resource * offer)
 64+static void
 65+offer_destroy(struct wl_client *client,
 66+              struct wl_resource *offer)
 67 {
 68-    wl_resource_destroy(offer);
 69+	wl_resource_destroy(offer);
 70 }
 71 
 72 static struct wl_data_offer_interface data_offer_implementation = {
 73-    .accept = &offer_accept,
 74-    .receive = &offer_receive,
 75-    .destroy = &offer_destroy
 76+	.accept = &offer_accept,
 77+	.receive = &offer_receive,
 78+	.destroy = &offer_destroy
 79 };
 80 
 81-static void source_offer(struct wl_client * client,
 82-                         struct wl_resource * source,
 83-                         const char * mime_type)
 84+static void
 85+source_offer(struct wl_client *client,
 86+             struct wl_resource *source,
 87+             const char *mime_type)
 88 {
 89-    struct data * data = wl_resource_get_user_data(source);
 90-    char ** destination;
 91+	struct data *data = wl_resource_get_user_data(source);
 92+	char **destination;
 93 
 94-    destination = wl_array_add(&data->mime_types, sizeof *destination);
 95-    *destination = strdup(mime_type);
 96+	destination = wl_array_add(&data->mime_types, sizeof *destination);
 97+	*destination = strdup(mime_type);
 98 }
 99 
100-static void source_destroy(struct wl_client * client,
101-                           struct wl_resource * source)
102+static void
103+source_destroy(struct wl_client *client,
104+               struct wl_resource *source)
105 {
106-    wl_resource_destroy(source);
107+	wl_resource_destroy(source);
108 }
109 
110 static struct wl_data_source_interface data_source_implementation = {
111-    .offer = &source_offer,
112-    .destroy = &source_destroy
113+	.offer = &source_offer,
114+	.destroy = &source_destroy
115 };
116 
117-static void data_destroy(struct wl_resource * source)
118+static void
119+data_destroy(struct wl_resource *source)
120 {
121-    struct data * data = wl_resource_get_user_data(source);
122-    struct wl_resource * offer;
123-    char ** mime_type;
124+	struct data *data = wl_resource_get_user_data(source);
125+	struct wl_resource *offer;
126+	char **mime_type;
127 
128-    wl_array_for_each(mime_type, &data->mime_types)
129-        free(*mime_type);
130-    wl_array_release(&data->mime_types);
131+	wl_array_for_each (mime_type, &data->mime_types)
132+		free(*mime_type);
133+	wl_array_release(&data->mime_types);
134 
135-    /* After this data_source is destroyed, each of the data_offer objects
136+	/* After this data_source is destroyed, each of the data_offer objects
137      * associated with the data_source has a pointer to a free'd struct. We
138      * can't destroy the resources because this results in a segfault on the
139      * client when it correctly tries to call data_source.destroy. However, a
140@@ -115,73 +120,75 @@ static void data_destroy(struct wl_resource * source)
141      * data_offer, which would crash the server.
142      *
143      * So, we clear the user data on each of the offers to protect us. */
144-    wl_resource_for_each(offer, &data->offers)
145-    {
146-        wl_resource_set_user_data(offer, NULL);
147-        wl_resource_set_destructor(offer, NULL);
148-    }
149+	wl_resource_for_each (offer, &data->offers) {
150+		wl_resource_set_user_data(offer, NULL);
151+		wl_resource_set_destructor(offer, NULL);
152+	}
153 
154-    free(data);
155+	free(data);
156 }
157 
158-static struct data * data_new(void)
159+static struct data *
160+data_new(void)
161 {
162-    struct data * data;
163+	struct data *data;
164 
165-    data = malloc(sizeof *data);
166+	data = malloc(sizeof *data);
167 
168-    if (!data)
169-        return NULL;
170+	if (!data)
171+		return NULL;
172 
173-    wl_array_init(&data->mime_types);
174-    wl_list_init(&data->offers);
175+	wl_array_init(&data->mime_types);
176+	wl_list_init(&data->offers);
177 
178-    return data;
179+	return data;
180 }
181 
182-struct wl_resource * data_source_new(struct wl_client * client,
183-                                     uint32_t version, uint32_t id)
184+struct wl_resource *
185+data_source_new(struct wl_client *client,
186+                uint32_t version, uint32_t id)
187 {
188-    struct data * data;
189+	struct data *data;
190 
191-    data = data_new();
192+	data = data_new();
193 
194-    if (!data)
195-        return NULL;
196+	if (!data)
197+		return NULL;
198 
199-    /* Add the data source to the client. */
200-    data->source = wl_resource_create(client, &wl_data_source_interface,
201-                                      version, id);
202+	/* Add the data source to the client. */
203+	data->source = wl_resource_create(client, &wl_data_source_interface,
204+	                                  version, id);
205 
206-    /* Destroy the data object when the source disappears. */
207-    wl_resource_set_implementation(data->source, &data_source_implementation,
208-                                   data, &data_destroy);
209+	/* Destroy the data object when the source disappears. */
210+	wl_resource_set_implementation(data->source, &data_source_implementation,
211+	                               data, &data_destroy);
212 
213-    return data->source;
214+	return data->source;
215 }
216 
217-struct wl_resource * data_offer_new(struct wl_client * client,
218-                                    struct wl_resource * source,
219-                                    uint32_t version)
220+struct wl_resource *
221+data_offer_new(struct wl_client *client,
222+               struct wl_resource *source,
223+               uint32_t version)
224 {
225-    struct data * data = wl_resource_get_user_data(source);
226-    struct wl_resource * offer;
227+	struct data *data = wl_resource_get_user_data(source);
228+	struct wl_resource *offer;
229 
230-    offer = wl_resource_create(client, &wl_data_offer_interface, version, 0);
231-    wl_resource_set_implementation(offer, &data_offer_implementation,
232-                                   data, &remove_resource);
233-    wl_list_insert(&data->offers, wl_resource_get_link(offer));
234+	offer = wl_resource_create(client, &wl_data_offer_interface, version, 0);
235+	wl_resource_set_implementation(offer, &data_offer_implementation,
236+	                               data, &remove_resource);
237+	wl_list_insert(&data->offers, wl_resource_get_link(offer));
238 
239-    return offer;
240+	return offer;
241 }
242 
243-void data_send_mime_types(struct wl_resource * source,
244-                          struct wl_resource * offer)
245+void
246+data_send_mime_types(struct wl_resource *source,
247+                     struct wl_resource *offer)
248 {
249-    struct data * data = wl_resource_get_user_data(source);
250-    char ** mime_type;
251+	struct data *data = wl_resource_get_user_data(source);
252+	char **mime_type;
253 
254-    wl_array_for_each(mime_type, &data->mime_types)
255-        wl_data_offer_send_offer(offer, *mime_type);
256+	wl_array_for_each (mime_type, &data->mime_types)
257+		wl_data_offer_send_offer(offer, *mime_type);
258 }
259-
+7, -8
 1@@ -28,15 +28,14 @@
 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+struct wl_resource *data_source_new(struct wl_client *client,
 8+                                    uint32_t version, uint32_t id);
 9 
10-struct wl_resource * data_offer_new(struct wl_client * client,
11-                                    struct wl_resource * source,
12-                                    uint32_t version);
13+struct wl_resource *data_offer_new(struct wl_client *client,
14+                                   struct wl_resource *source,
15+                                   uint32_t version);
16 
17-void data_send_mime_types(struct wl_resource * source,
18-                          struct wl_resource * offer);
19+void data_send_mime_types(struct wl_resource *source,
20+                          struct wl_resource *offer);
21 
22 #endif
23-
+76, -72
  1@@ -25,116 +25,120 @@
  2 #include "data.h"
  3 #include "util.h"
  4 
  5-static void start_drag(struct wl_client * client, struct wl_resource * resource,
  6-                       struct wl_resource * source_resource,
  7-                       struct wl_resource * origin_resource,
  8-                       struct wl_resource * icon_resource, uint32_t serial)
  9+static void
 10+start_drag(struct wl_client *client, struct wl_resource *resource,
 11+           struct wl_resource *source_resource,
 12+           struct wl_resource *origin_resource,
 13+           struct wl_resource *icon_resource, uint32_t serial)
 14 {
 15-    /* XXX: Implement */
 16+	/* XXX: Implement */
 17 }
 18 
 19-static void set_selection(struct wl_client * client,
 20-                          struct wl_resource * resource,
 21-                          struct wl_resource * data_source, uint32_t serial)
 22+static void
 23+set_selection(struct wl_client *client,
 24+              struct wl_resource *resource,
 25+              struct wl_resource *data_source, uint32_t serial)
 26 {
 27-    struct data_device * data_device = wl_resource_get_user_data(resource);
 28+	struct data_device *data_device = wl_resource_get_user_data(resource);
 29 
 30-    /* Check if this data source is already the current selection. */
 31-    if (data_source == data_device->selection)
 32-        return;
 33+	/* Check if this data source is already the current selection. */
 34+	if (data_source == data_device->selection)
 35+		return;
 36 
 37-    if (data_device->selection)
 38-    {
 39-        wl_data_source_send_cancelled(data_device->selection);
 40-        wl_list_remove(&data_device->selection_destroy_listener.link);
 41-    }
 42+	if (data_device->selection) {
 43+		wl_data_source_send_cancelled(data_device->selection);
 44+		wl_list_remove(&data_device->selection_destroy_listener.link);
 45+	}
 46 
 47-    data_device->selection = data_source;
 48+	data_device->selection = data_source;
 49 
 50-    if (data_source)
 51-    {
 52-        wl_resource_add_destroy_listener
 53-            (data_source, &data_device->selection_destroy_listener);
 54-    }
 55+	if (data_source) {
 56+		wl_resource_add_destroy_listener(data_source, &data_device->selection_destroy_listener);
 57+	}
 58 
 59-    send_event(&data_device->event_signal,
 60-               DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 61+	send_event(&data_device->event_signal,
 62+	           DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 63 }
 64 
 65 static struct wl_data_device_interface data_device_implementation = {
 66-    .start_drag = &start_drag,
 67-    .set_selection = &set_selection
 68+	.start_drag = &start_drag,
 69+	.set_selection = &set_selection
 70 };
 71 
 72-static void handle_selection_destroy(struct wl_listener * listener, void * data)
 73+static void
 74+handle_selection_destroy(struct wl_listener *listener, void *data)
 75 {
 76-    struct data_device * data_device
 77-        = wl_container_of(listener, data_device, selection_destroy_listener);
 78+	struct data_device *data_device = wl_container_of(listener, data_device, selection_destroy_listener);
 79 
 80-    data_device->selection = NULL;
 81-    send_event(&data_device->event_signal,
 82-               DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 83+	data_device->selection = NULL;
 84+	send_event(&data_device->event_signal,
 85+	           DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL);
 86 }
 87 
 88-bool data_device_initialize(struct data_device * data_device)
 89+bool
 90+data_device_initialize(struct data_device *data_device)
 91 {
 92-    data_device->selection_destroy_listener.notify = &handle_selection_destroy;
 93-    wl_signal_init(&data_device->event_signal);
 94-    wl_list_init(&data_device->resources);
 95+	data_device->selection_destroy_listener.notify = &handle_selection_destroy;
 96+	wl_signal_init(&data_device->event_signal);
 97+	wl_list_init(&data_device->resources);
 98 
 99-    return true;
100+	return true;
101 }
102 
103-void data_device_finalize(struct data_device * data_device)
104+void
105+data_device_finalize(struct data_device *data_device)
106 {
107-    struct wl_resource * resource, * tmp;
108+	struct wl_resource *resource, *tmp;
109 
110-    wl_list_for_each_safe(resource, tmp, &data_device->resources, link)
111-        wl_resource_destroy(resource);
112+	wl_list_for_each_safe (resource, tmp, &data_device->resources, link)
113+		wl_resource_destroy(resource);
114 }
115 
116-void data_device_bind(struct data_device * data_device,
117-                      struct wl_client * client, uint32_t version, uint32_t id)
118+void
119+data_device_bind(struct data_device *data_device,
120+                 struct wl_client *client, uint32_t version, uint32_t id)
121 {
122-    struct wl_resource * resource;
123+	struct wl_resource *resource;
124 
125-    resource = wl_resource_create(client, &wl_data_device_interface,
126-                                  version, id);
127-    wl_resource_set_implementation(resource, &data_device_implementation,
128-                                   data_device, &remove_resource);
129-    wl_list_insert(&data_device->resources, &resource->link);
130+	resource = wl_resource_create(client, &wl_data_device_interface,
131+	                              version, id);
132+	wl_resource_set_implementation(resource, &data_device_implementation,
133+	                               data_device, &remove_resource);
134+	wl_list_insert(&data_device->resources, &resource->link);
135 }
136 
137-static struct wl_resource * new_offer(struct wl_resource * resource,
138-                                      struct wl_client * client,
139-                                      struct wl_resource * source)
140+static struct wl_resource *
141+new_offer(struct wl_resource *resource,
142+          struct wl_client *client,
143+          struct wl_resource *source)
144 {
145-    struct wl_resource * offer;
146+	struct wl_resource *offer;
147 
148-    offer = data_offer_new(client, source, wl_resource_get_version(resource));
149-    wl_data_device_send_data_offer(resource, offer);
150-    data_send_mime_types(source, offer);
151+	offer = data_offer_new(client, source, wl_resource_get_version(resource));
152+	wl_data_device_send_data_offer(resource, offer);
153+	data_send_mime_types(source, offer);
154 
155-    return offer;
156+	return offer;
157 }
158 
159-void data_device_offer_selection(struct data_device * data_device,
160-                                 struct wl_client * client)
161+void
162+data_device_offer_selection(struct data_device *data_device,
163+                            struct wl_client *client)
164 {
165-    struct wl_resource * resource;
166-    struct wl_resource * offer;
167+	struct wl_resource *resource;
168+	struct wl_resource *offer;
169 
170-    /* Look for the client's data_device resource. */
171-    resource = wl_resource_find_for_client(&data_device->resources, client);
172+	/* Look for the client's data_device resource. */
173+	resource = wl_resource_find_for_client(&data_device->resources, client);
174 
175-    /* If the client does not have a data device, there is nothing to do. */
176-    if (!resource)
177-        return;
178+	/* If the client does not have a data device, there is nothing to do. */
179+	if (!resource)
180+		return;
181 
182-    /* If we don't have a selection, send NULL to the client. */
183-    offer = data_device->selection
184-        ? new_offer(resource, client, data_device->selection) : NULL;
185+	/* If we don't have a selection, send NULL to the client. */
186+	offer = data_device->selection
187+	            ? new_offer(resource, client, data_device->selection)
188+	            : NULL;
189 
190-    wl_data_device_send_selection(resource, offer);
191+	wl_data_device_send_selection(resource, offer);
192 }
193-
+14, -17
 1@@ -29,29 +29,26 @@
 2 #include <stdbool.h>
 3 #include <wayland-server.h>
 4 
 5-enum
 6-{
 7-    DATA_DEVICE_EVENT_SELECTION_CHANGED
 8+enum {
 9+	DATA_DEVICE_EVENT_SELECTION_CHANGED
10 };
11 
12-struct data_device
13-{
14-    /* The data source corresponding to the current selection. */
15-    struct wl_resource * selection;
16-    struct wl_listener selection_destroy_listener;
17+struct data_device {
18+	/* The data source corresponding to the current selection. */
19+	struct wl_resource *selection;
20+	struct wl_listener selection_destroy_listener;
21 
22-    struct wl_signal event_signal;
23-    struct wl_list resources;
24+	struct wl_signal event_signal;
25+	struct wl_list resources;
26 };
27 
28-bool data_device_initialize(struct data_device * data_device);
29-void data_device_finalize(struct data_device * data_device);
30+bool data_device_initialize(struct data_device *data_device);
31+void data_device_finalize(struct data_device *data_device);
32 
33-void data_device_bind(struct data_device * data_device,
34-                      struct wl_client * client, uint32_t version, uint32_t id);
35+void data_device_bind(struct data_device *data_device,
36+                      struct wl_client *client, uint32_t version, uint32_t id);
37 
38-void data_device_offer_selection(struct data_device * data_device,
39-                                 struct wl_client * client);
40+void data_device_offer_selection(struct data_device *data_device,
41+                                 struct wl_client *client);
42 
43 #endif
44-
+36, -34
 1@@ -28,61 +28,63 @@
 2 #include "seat.h"
 3 
 4 static struct
 5-{
 6-    struct wl_global * global;
 7+    {
 8+	struct wl_global *global;
 9 } data_device_manager;
10 
11-static void create_data_source(struct wl_client * client,
12-                               struct wl_resource * resource, uint32_t id)
13+static void
14+create_data_source(struct wl_client *client,
15+                   struct wl_resource *resource, uint32_t id)
16 {
17-    struct wl_resource * data_source;
18+	struct wl_resource *data_source;
19 
20-    data_source = data_source_new(client,
21-                                  wl_resource_get_version(resource), id);
22+	data_source = data_source_new(client,
23+	                              wl_resource_get_version(resource), id);
24 
25-    if (!data_source)
26-        wl_resource_post_no_memory(resource);
27+	if (!data_source)
28+		wl_resource_post_no_memory(resource);
29 }
30 
31-static void get_data_device(struct wl_client * client,
32-                            struct wl_resource * resource, uint32_t id,
33-                            struct wl_resource * seat_resource)
34+static void
35+get_data_device(struct wl_client *client,
36+                struct wl_resource *resource, uint32_t id,
37+                struct wl_resource *seat_resource)
38 {
39-    data_device_bind(swc.seat->data_device, client,
40-                     wl_resource_get_version(resource), id);
41+	data_device_bind(swc.seat->data_device, client,
42+	                 wl_resource_get_version(resource), id);
43 }
44 
45 static struct wl_data_device_manager_interface
46     data_device_manager_implementation = {
47-    .create_data_source = &create_data_source,
48-    .get_data_device = &get_data_device
49-};
50+	    .create_data_source = &create_data_source,
51+	    .get_data_device = &get_data_device
52+    };
53 
54-static void bind_data_device_manager(struct wl_client * client, void * data,
55-                                     uint32_t version, uint32_t id)
56+static void
57+bind_data_device_manager(struct wl_client *client, void *data,
58+                         uint32_t version, uint32_t id)
59 {
60-    struct wl_resource * resource;
61+	struct wl_resource *resource;
62 
63-    if (version > 1)
64-        version = 1;
65+	if (version > 1)
66+		version = 1;
67 
68-    resource = wl_resource_create(client, &wl_data_device_manager_interface,
69-                                  version, id);
70-    wl_resource_set_implementation
71-        (resource, &data_device_manager_implementation, NULL, NULL);
72+	resource = wl_resource_create(client, &wl_data_device_manager_interface,
73+	                              version, id);
74+	wl_resource_set_implementation(resource, &data_device_manager_implementation, NULL, NULL);
75 }
76 
77-bool data_device_manager_initialize(void)
78+bool
79+data_device_manager_initialize(void)
80 {
81-    data_device_manager.global
82-        = wl_global_create(swc.display, &wl_data_device_manager_interface, 1,
83-                           NULL, &bind_data_device_manager);
84+	data_device_manager.global = wl_global_create(swc.display, &wl_data_device_manager_interface, 1,
85+	                                              NULL, &bind_data_device_manager);
86 
87-    return data_device_manager.global != NULL;
88+	return data_device_manager.global != NULL;
89 }
90 
91-void data_device_manager_finalize(void)
92+void
93+data_device_manager_finalize(void)
94 {
95-    wl_global_destroy(data_device_manager.global);
96+	wl_global_destroy(data_device_manager.global);
97 }
98-
+0, -1
1@@ -30,4 +30,3 @@ bool data_device_manager_initialize(void);
2 void data_device_manager_finalize(void);
3 
4 #endif
5-
+299, -309
  1@@ -47,384 +47,374 @@
  2 struct swc_drm swc_drm;
  3 
  4 static struct
  5-{
  6-    char path[128];
  7+    {
  8+	char path[128];
  9 
 10-    uint32_t taken_ids;
 11+	uint32_t taken_ids;
 12 
 13-    struct wl_global * global;
 14-    struct wl_event_source * event_source;
 15+	struct wl_global *global;
 16+	struct wl_event_source *event_source;
 17 } drm;
 18 
 19-static void authenticate(struct wl_client * client,
 20-                         struct wl_resource * resource, uint32_t magic)
 21+static void
 22+authenticate(struct wl_client *client,
 23+             struct wl_resource *resource, uint32_t magic)
 24 {
 25-    wl_drm_send_authenticated(resource);
 26+	wl_drm_send_authenticated(resource);
 27 }
 28 
 29-static void create_buffer(struct wl_client * client,
 30-                          struct wl_resource * resource, uint32_t id,
 31-                          uint32_t name, int32_t width, int32_t height,
 32-                          uint32_t stride, uint32_t format)
 33+static void
 34+create_buffer(struct wl_client *client,
 35+              struct wl_resource *resource, uint32_t id,
 36+              uint32_t name, int32_t width, int32_t height,
 37+              uint32_t stride, uint32_t format)
 38 {
 39-    wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_NAME,
 40-                           "GEM names are not supported, "
 41-                           "use a PRIME fd instead");
 42+	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_NAME,
 43+	                       "GEM names are not supported, "
 44+	                       "use a PRIME fd instead");
 45 }
 46 
 47-static void create_planar_buffer(struct wl_client * client,
 48-                                 struct wl_resource * resource, uint32_t id,
 49-                                 uint32_t name, int32_t width, int32_t height,
 50-                                 uint32_t format,
 51-                                 int32_t offset0, int32_t stride0,
 52-                                 int32_t offset1, int32_t stride1,
 53-                                 int32_t offset2, int32_t stride2)
 54+static void
 55+create_planar_buffer(struct wl_client *client,
 56+                     struct wl_resource *resource, uint32_t id,
 57+                     uint32_t name, int32_t width, int32_t height,
 58+                     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-    wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT,
 64-                           "planar buffers are not supported\n");
 65+	wl_resource_post_error(resource, WL_DRM_ERROR_INVALID_FORMAT,
 66+	                       "planar buffers are not supported\n");
 67 }
 68 
 69-static void create_prime_buffer(struct wl_client * client,
 70-                                struct wl_resource * resource, uint32_t id,
 71-                                int32_t fd, int32_t width, int32_t height,
 72-                                uint32_t format,
 73-                                int32_t offset0, int32_t stride0,
 74-                                int32_t offset1, int32_t stride1,
 75-                                int32_t offset2, int32_t stride2)
 76+static void
 77+create_prime_buffer(struct wl_client *client,
 78+                    struct wl_resource *resource, uint32_t id,
 79+                    int32_t fd, int32_t width, int32_t height,
 80+                    uint32_t format,
 81+                    int32_t offset0, int32_t stride0,
 82+                    int32_t offset1, int32_t stride1,
 83+                    int32_t offset2, int32_t stride2)
 84 {
 85-    struct wld_buffer * buffer;
 86-    struct wl_resource * buffer_resource;
 87-    union wld_object object = { .i = fd };
 88+	struct wld_buffer *buffer;
 89+	struct wl_resource *buffer_resource;
 90+	union wld_object object = {.i = fd };
 91 
 92-    buffer = wld_import_buffer(swc.drm->context, WLD_DRM_OBJECT_PRIME_FD,
 93-                               object, width, height, format, stride0);
 94-    close(fd);
 95+	buffer = wld_import_buffer(swc.drm->context, WLD_DRM_OBJECT_PRIME_FD,
 96+	                           object, width, height, format, stride0);
 97+	close(fd);
 98 
 99-    if (!buffer)
100-        goto error0;
101+	if (!buffer)
102+		goto error0;
103 
104-    buffer_resource = wayland_buffer_create_resource
105-        (client, wl_resource_get_version(resource), id, buffer);
106+	buffer_resource = wayland_buffer_create_resource(client, wl_resource_get_version(resource), id, buffer);
107 
108-    if (!buffer_resource)
109-        goto error1;
110+	if (!buffer_resource)
111+		goto error1;
112 
113-    return;
114+	return;
115 
116-  error1:
117-    wld_buffer_unreference(buffer);
118-  error0:
119-    wl_resource_post_no_memory(resource);
120+error1:
121+	wld_buffer_unreference(buffer);
122+error0:
123+	wl_resource_post_no_memory(resource);
124 }
125 
126 static const struct wl_drm_interface drm_implementation = {
127-        .authenticate = &authenticate,
128-        .create_buffer = &create_buffer,
129-        .create_planar_buffer = &create_planar_buffer,
130-        .create_prime_buffer = &create_prime_buffer
131+	.authenticate = &authenticate,
132+	.create_buffer = &create_buffer,
133+	.create_planar_buffer = &create_planar_buffer,
134+	.create_prime_buffer = &create_prime_buffer
135 };
136 
137-static int select_card(const struct dirent * entry)
138+static int
139+select_card(const struct dirent *entry)
140 {
141-    unsigned num;
142+	unsigned num;
143 
144-    return sscanf(entry->d_name, "card%u", &num) == 1;
145+	return sscanf(entry->d_name, "card%u", &num) == 1;
146 }
147 
148-static bool find_primary_drm_device(char * path, size_t size)
149+static bool
150+find_primary_drm_device(char *path, size_t size)
151 {
152-    struct dirent ** cards, * card = NULL;
153-    int num_cards, ret;
154-    unsigned index;
155-    FILE * file;
156-    unsigned char boot_vga;
157+	struct dirent **cards, *card = NULL;
158+	int num_cards, ret;
159+	unsigned index;
160+	FILE *file;
161+	unsigned char boot_vga;
162 
163-    num_cards = scandir("/dev/dri", &cards, &select_card, &alphasort);
164+	num_cards = scandir("/dev/dri", &cards, &select_card, &alphasort);
165 
166-    if (num_cards == -1)
167-        return false;
168+	if (num_cards == -1)
169+		return false;
170 
171-    for (index = 0; index < num_cards; ++index)
172-    {
173-        snprintf(path, size, "/sys/class/drm/%s/device/boot_vga",
174-                 cards[index]->d_name);
175-
176-        if ((file = fopen(path, "r")))
177-        {
178-            ret = fscanf(file, "%hhu", &boot_vga);
179-            fclose(file);
180-
181-            if (ret == 1 && boot_vga)
182-            {
183-                free(card);
184-                card = cards[index];
185-                DEBUG("/dev/dri/%s is the primary GPU\n", card->d_name);
186-                break;
187-            }
188-        }
189-
190-        if (!card)
191-            card = cards[index];
192-        else
193-            free(cards[index]);
194-    }
195-
196-    free(cards);
197-
198-    if (!card)
199-        return false;
200-
201-    if (snprintf(path, size, "/dev/dri/%s", card->d_name) >= size)
202-        return false;
203-
204-    free(card);
205-    return true;
206+	for (index = 0; index < num_cards; ++index) {
207+		snprintf(path, size, "/sys/class/drm/%s/device/boot_vga",
208+		         cards[index]->d_name);
209+
210+		if ((file = fopen(path, "r"))) {
211+			ret = fscanf(file, "%hhu", &boot_vga);
212+			fclose(file);
213+
214+			if (ret == 1 && boot_vga) {
215+				free(card);
216+				card = cards[index];
217+				DEBUG("/dev/dri/%s is the primary GPU\n", card->d_name);
218+				break;
219+			}
220+		}
221+
222+		if (!card)
223+			card = cards[index];
224+		else
225+			free(cards[index]);
226+	}
227+
228+	free(cards);
229+
230+	if (!card)
231+		return false;
232+
233+	if (snprintf(path, size, "/dev/dri/%s", card->d_name) >= size)
234+		return false;
235+
236+	free(card);
237+	return true;
238 }
239 
240-static bool find_available_crtc(drmModeRes * resources,
241-                                drmModeConnector * connector,
242-                                uint32_t taken_crtcs, uint32_t * crtc)
243+static bool
244+find_available_crtc(drmModeRes *resources,
245+                    drmModeConnector *connector,
246+                    uint32_t taken_crtcs, uint32_t *crtc)
247 {
248-    uint32_t encoder_index, crtc_index;
249-    uint32_t possible_crtcs;
250-    drmModeEncoder * encoder;
251-
252-    for (encoder_index = 0;
253-         encoder_index < connector->count_encoders;
254-         ++encoder_index)
255-    {
256-        encoder = drmModeGetEncoder(swc.drm->fd,
257-                                    connector->encoders[encoder_index]);
258-        possible_crtcs = encoder->possible_crtcs;
259-        drmModeFreeEncoder(encoder);
260-
261-        for (crtc_index = 0; crtc_index < resources->count_crtcs; ++crtc_index)
262-        {
263-            if ((possible_crtcs & (1 << crtc_index))
264-                && !(taken_crtcs & (1 << crtc_index)))
265-            {
266-                *crtc = crtc_index;
267-                return true;
268-            }
269-        }
270-    }
271-
272-    return false;
273+	uint32_t encoder_index, crtc_index;
274+	uint32_t possible_crtcs;
275+	drmModeEncoder *encoder;
276+
277+	for (encoder_index = 0;
278+	     encoder_index < connector->count_encoders;
279+	     ++encoder_index) {
280+		encoder = drmModeGetEncoder(swc.drm->fd,
281+		                            connector->encoders[encoder_index]);
282+		possible_crtcs = encoder->possible_crtcs;
283+		drmModeFreeEncoder(encoder);
284+
285+		for (crtc_index = 0; crtc_index < resources->count_crtcs; ++crtc_index) {
286+			if ((possible_crtcs & (1 << crtc_index))
287+			    && !(taken_crtcs & (1 << crtc_index))) {
288+				*crtc = crtc_index;
289+				return true;
290+			}
291+		}
292+	}
293+
294+	return false;
295 }
296 
297-static bool find_available_id(uint32_t * id)
298+static bool
299+find_available_id(uint32_t *id)
300 {
301-    uint32_t index = __builtin_ffsl(~drm.taken_ids);
302+	uint32_t index = __builtin_ffsl(~drm.taken_ids);
303 
304-    if (index == 0)
305-        return false;
306+	if (index == 0)
307+		return false;
308 
309-    *id = index - 1;
310-    return true;
311+	*id = index - 1;
312+	return true;
313 }
314 
315-static void handle_vblank(int fd, unsigned int sequence, unsigned int sec,
316-                          unsigned int usec, void * data)
317+static void
318+handle_vblank(int fd, unsigned int sequence, unsigned int sec,
319+              unsigned int usec, void *data)
320 {
321 }
322 
323-static void handle_page_flip(int fd, unsigned int sequence, unsigned int sec,
324-                             unsigned int usec, void * data)
325+static void
326+handle_page_flip(int fd, unsigned int sequence, unsigned int sec,
327+                 unsigned int usec, void *data)
328 {
329-    struct drm_handler * handler = data;
330+	struct drm_handler *handler = data;
331 
332-    handler->page_flip(handler, sec * 1000 + usec / 1000);
333+	handler->page_flip(handler, sec * 1000 + usec / 1000);
334 }
335 
336 static drmEventContext event_context = {
337-    .version = DRM_EVENT_CONTEXT_VERSION,
338-    .vblank_handler = &handle_vblank,
339-    .page_flip_handler = &handle_page_flip
340+	.version = DRM_EVENT_CONTEXT_VERSION,
341+	.vblank_handler = &handle_vblank,
342+	.page_flip_handler = &handle_page_flip
343 };
344 
345-static int handle_data(int fd, uint32_t mask, void * data)
346+static int
347+handle_data(int fd, uint32_t mask, void *data)
348 {
349-    drmHandleEvent(fd, &event_context);
350+	drmHandleEvent(fd, &event_context);
351 
352-    return 1;
353+	return 1;
354 }
355 
356-static void bind_drm(struct wl_client * client, void * data, uint32_t version,
357-                     uint32_t id)
358+static void
359+bind_drm(struct wl_client *client, void *data, uint32_t version,
360+         uint32_t id)
361 {
362-    struct wl_resource * resource;
363+	struct wl_resource *resource;
364 
365-    if (version > 2)
366-        version = 2;
367+	if (version > 2)
368+		version = 2;
369 
370-    resource = wl_resource_create(client, &wl_drm_interface, version, id);
371-    wl_resource_set_implementation(resource, &drm_implementation, NULL, NULL);
372+	resource = wl_resource_create(client, &wl_drm_interface, version, id);
373+	wl_resource_set_implementation(resource, &drm_implementation, NULL, NULL);
374 
375-    if (version >= 2)
376-        wl_drm_send_capabilities(resource, WL_DRM_CAPABILITY_PRIME);
377+	if (version >= 2)
378+		wl_drm_send_capabilities(resource, WL_DRM_CAPABILITY_PRIME);
379 
380-    wl_drm_send_device(resource, drm.path);
381-    wl_drm_send_format(resource, WL_DRM_FORMAT_XRGB8888);
382-    wl_drm_send_format(resource, WL_DRM_FORMAT_ARGB8888);
383+	wl_drm_send_device(resource, drm.path);
384+	wl_drm_send_format(resource, WL_DRM_FORMAT_XRGB8888);
385+	wl_drm_send_format(resource, WL_DRM_FORMAT_ARGB8888);
386 }
387 
388-bool drm_initialize(void)
389+bool
390+drm_initialize(void)
391 {
392-    struct stat master, render;
393-
394-    if (!find_primary_drm_device(drm.path, sizeof drm.path))
395-    {
396-        ERROR("Could not find DRM device\n");
397-        goto error0;
398-    }
399-
400-    drm.taken_ids = 0;
401-    swc.drm->fd = launch_open_device(drm.path, O_RDWR | O_CLOEXEC);
402-
403-    if (swc.drm->fd == -1)
404-    {
405-        ERROR("Could not open DRM device at %s\n", drm.path);
406-        goto error0;
407-    }
408-
409-    if (fstat(swc.drm->fd, &master) != 0)
410-    {
411-        ERROR("Could not fstat DRM FD: %s\n", strerror(errno));
412-        goto error1;
413-    }
414-
415-    if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d",
416-                 minor(master.st_rdev) + 0x80) >= sizeof drm.path)
417-    {
418-        ERROR("Render node path is too long");
419-        goto error1;
420-    }
421-
422-    if (stat(drm.path, &render) != 0)
423-    {
424-        ERROR("Could not stat render node for primary DRM device: %s\n",
425-              strerror(errno));
426-        goto error1;
427-    }
428-
429-    if (master.st_mode != render.st_mode
430-        || minor(master.st_rdev) + 0x80 != minor(render.st_rdev))
431-    {
432-        ERROR("Render node does not have expected mode or minor number\n");
433-        goto error1;
434-    }
435-
436-    if (!(swc.drm->context = wld_drm_create_context(swc.drm->fd)))
437-    {
438-        ERROR("Could not create WLD DRM context\n");
439-        goto error1;
440-    }
441-
442-    if (!(swc.drm->renderer = wld_create_renderer(swc.drm->context)))
443-    {
444-        ERROR("Could not create WLD DRM renderer\n");
445-        goto error2;
446-    }
447-
448-    drm.event_source = wl_event_loop_add_fd
449-        (swc.event_loop, swc.drm->fd, WL_EVENT_READABLE, &handle_data, NULL);
450-
451-    if (!drm.event_source)
452-    {
453-        ERROR("Could not create DRM event source\n");
454-        goto error3;
455-    }
456-
457-    if (!wld_drm_is_dumb(swc.drm->context))
458-    {
459-        drm.global = wl_global_create(swc.display, &wl_drm_interface, 2,
460-                                      NULL, &bind_drm);
461-
462-        if (!drm.global)
463-        {
464-            ERROR("Could not create wl_drm global\n");
465-            goto error4;
466-        }
467-    }
468-
469-    return true;
470-
471-  error4:
472-    wl_event_source_remove(drm.event_source);
473-  error3:
474-    wld_destroy_renderer(swc.drm->renderer);
475-  error2:
476-    wld_destroy_context(swc.drm->context);
477-  error1:
478-    close(swc.drm->fd);
479-  error0:
480-    return false;
481+	struct stat master, render;
482+
483+	if (!find_primary_drm_device(drm.path, sizeof drm.path)) {
484+		ERROR("Could not find DRM device\n");
485+		goto error0;
486+	}
487+
488+	drm.taken_ids = 0;
489+	swc.drm->fd = launch_open_device(drm.path, O_RDWR | O_CLOEXEC);
490+
491+	if (swc.drm->fd == -1) {
492+		ERROR("Could not open DRM device at %s\n", drm.path);
493+		goto error0;
494+	}
495+
496+	if (fstat(swc.drm->fd, &master) != 0) {
497+		ERROR("Could not fstat DRM FD: %s\n", strerror(errno));
498+		goto error1;
499+	}
500+
501+	if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d",
502+	             minor(master.st_rdev) + 0x80) >= sizeof drm.path) {
503+		ERROR("Render node path is too long");
504+		goto error1;
505+	}
506+
507+	if (stat(drm.path, &render) != 0) {
508+		ERROR("Could not stat render node for primary DRM device: %s\n",
509+		      strerror(errno));
510+		goto error1;
511+	}
512+
513+	if (master.st_mode != render.st_mode
514+	    || minor(master.st_rdev) + 0x80 != minor(render.st_rdev)) {
515+		ERROR("Render node does not have expected mode or minor number\n");
516+		goto error1;
517+	}
518+
519+	if (!(swc.drm->context = wld_drm_create_context(swc.drm->fd))) {
520+		ERROR("Could not create WLD DRM context\n");
521+		goto error1;
522+	}
523+
524+	if (!(swc.drm->renderer = wld_create_renderer(swc.drm->context))) {
525+		ERROR("Could not create WLD DRM renderer\n");
526+		goto error2;
527+	}
528+
529+	drm.event_source = wl_event_loop_add_fd(swc.event_loop, swc.drm->fd, WL_EVENT_READABLE, &handle_data, NULL);
530+
531+	if (!drm.event_source) {
532+		ERROR("Could not create DRM event source\n");
533+		goto error3;
534+	}
535+
536+	if (!wld_drm_is_dumb(swc.drm->context)) {
537+		drm.global = wl_global_create(swc.display, &wl_drm_interface, 2,
538+		                              NULL, &bind_drm);
539+
540+		if (!drm.global) {
541+			ERROR("Could not create wl_drm global\n");
542+			goto error4;
543+		}
544+	}
545+
546+	return true;
547+
548+error4:
549+	wl_event_source_remove(drm.event_source);
550+error3:
551+	wld_destroy_renderer(swc.drm->renderer);
552+error2:
553+	wld_destroy_context(swc.drm->context);
554+error1:
555+	close(swc.drm->fd);
556+error0:
557+	return false;
558 }
559 
560-void drm_finalize(void)
561+void
562+drm_finalize(void)
563 {
564-    if (drm.global)
565-        wl_global_destroy(drm.global);
566-    wl_event_source_remove(drm.event_source);
567-    wld_destroy_renderer(swc.drm->renderer);
568-    wld_destroy_context(swc.drm->context);
569-    close(swc.drm->fd);
570+	if (drm.global)
571+		wl_global_destroy(drm.global);
572+	wl_event_source_remove(drm.event_source);
573+	wld_destroy_renderer(swc.drm->renderer);
574+	wld_destroy_context(swc.drm->context);
575+	close(swc.drm->fd);
576 }
577 
578-bool drm_create_screens(struct wl_list * screens)
579+bool
580+drm_create_screens(struct wl_list *screens)
581 {
582-    drmModeRes * resources;
583-    drmModeConnector * connector;
584-    uint32_t index;
585-    struct output * output;
586-    uint32_t taken_crtcs = 0;
587-
588-    if (!(resources = drmModeGetResources(swc.drm->fd)))
589-    {
590-        ERROR("Could not get DRM resources\n");
591-        return false;
592-    }
593-
594-    for (index = 0; index < resources->count_connectors;
595-         ++index, drmModeFreeConnector(connector))
596-    {
597-        connector = drmModeGetConnector(swc.drm->fd,
598-                                        resources->connectors[index]);
599-
600-        if (connector->connection == DRM_MODE_CONNECTED)
601-        {
602-            uint32_t crtc_index;
603-            uint32_t id;
604-
605-            if (!find_available_crtc(resources, connector, taken_crtcs,
606-                                     &crtc_index))
607-            {
608-                WARNING("Could not find CRTC for connector %u\n", index);
609-                continue;
610-            }
611-
612-            if (!find_available_id(&id))
613-            {
614-                WARNING("No more available output IDs\n");
615-                drmModeFreeConnector(connector);
616-                break;
617-            }
618-
619-            if (!(output = output_new(connector)))
620-                continue;
621-
622-            output->screen = screen_new(resources->crtcs[crtc_index], output);
623-            output->screen->id = id;
624-
625-            taken_crtcs |= 1 << crtc_index;
626-            drm.taken_ids |= 1 << id;
627-
628-            wl_list_insert(screens, &output->screen->link);
629-        }
630-    }
631-
632-    drmModeFreeResources(resources);
633-
634-    return true;
635+	drmModeRes *resources;
636+	drmModeConnector *connector;
637+	uint32_t index;
638+	struct output *output;
639+	uint32_t taken_crtcs = 0;
640+
641+	if (!(resources = drmModeGetResources(swc.drm->fd))) {
642+		ERROR("Could not get DRM resources\n");
643+		return false;
644+	}
645+
646+	for (index = 0; index < resources->count_connectors;
647+	     ++index, drmModeFreeConnector(connector)) {
648+		connector = drmModeGetConnector(swc.drm->fd,
649+		                                resources->connectors[index]);
650+
651+		if (connector->connection == DRM_MODE_CONNECTED) {
652+			uint32_t crtc_index;
653+			uint32_t id;
654+
655+			if (!find_available_crtc(resources, connector, taken_crtcs,
656+			                         &crtc_index)) {
657+				WARNING("Could not find CRTC for connector %u\n", index);
658+				continue;
659+			}
660+
661+			if (!find_available_id(&id)) {
662+				WARNING("No more available output IDs\n");
663+				drmModeFreeConnector(connector);
664+				break;
665+			}
666+
667+			if (!(output = output_new(connector)))
668+				continue;
669+
670+			output->screen = screen_new(resources->crtcs[crtc_index], output);
671+			output->screen->id = id;
672+
673+			taken_crtcs |= 1 << crtc_index;
674+			drm.taken_ids |= 1 << id;
675+
676+			wl_list_insert(screens, &output->screen->link);
677+		}
678+	}
679+
680+	drmModeFreeResources(resources);
681+
682+	return true;
683 }
684-
+7, -10
 1@@ -5,22 +5,19 @@
 2 #include <stdint.h>
 3 #include <wayland-server.h>
 4 
 5-struct drm_handler
 6-{
 7-    void (* page_flip)(struct drm_handler * handler, uint32_t time);
 8+struct drm_handler {
 9+	void (*page_flip)(struct drm_handler *handler, uint32_t time);
10 };
11 
12-struct swc_drm
13-{
14-    int fd;
15-    struct wld_context * context;
16-    struct wld_renderer * renderer;
17+struct swc_drm {
18+	int fd;
19+	struct wld_context *context;
20+	struct wld_renderer *renderer;
21 };
22 
23 bool drm_initialize(void);
24 void drm_finalize(void);
25 
26-bool drm_create_screens(struct wl_list * screens);
27+bool drm_create_screens(struct wl_list *screens);
28 
29 #endif
30-
+227, -235
  1@@ -43,279 +43,271 @@
  2 #define AXIS_STEP_DISTANCE 10
  3 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
  4 
  5-static inline uint32_t timeval_to_msec(struct timeval * time)
  6+static inline uint32_t
  7+timeval_to_msec(struct timeval *time)
  8 {
  9-    return time->tv_sec * 1000 + time->tv_usec / 1000;
 10+	return time->tv_sec * 1000 + time->tv_usec / 1000;
 11 }
 12 
 13-static void handle_key_event(struct evdev_device * device,
 14-                             struct input_event * input_event)
 15+static void
 16+handle_key_event(struct evdev_device *device,
 17+                 struct input_event *input_event)
 18 {
 19-    uint32_t time = timeval_to_msec(&input_event->time);
 20-    uint32_t state;
 21-
 22-    if ((input_event->code >= BTN_MISC && input_event->code <= BTN_GEAR_UP)
 23-        || input_event->code >= BTN_TRIGGER_HAPPY)
 24-    {
 25-        state = input_event->value ? WL_POINTER_BUTTON_STATE_PRESSED
 26-                                   : WL_POINTER_BUTTON_STATE_RELEASED;
 27-        device->handler->button(time, input_event->code, state);
 28-    }
 29-    else
 30-    {
 31-        state = input_event->value ? WL_KEYBOARD_KEY_STATE_PRESSED
 32-                                   : WL_KEYBOARD_KEY_STATE_RELEASED;
 33-        device->handler->key(time, input_event->code, state);
 34-    }
 35+	uint32_t time = timeval_to_msec(&input_event->time);
 36+	uint32_t state;
 37+
 38+	if ((input_event->code >= BTN_MISC && input_event->code <= BTN_GEAR_UP)
 39+	    || input_event->code >= BTN_TRIGGER_HAPPY) {
 40+		state = input_event->value ? WL_POINTER_BUTTON_STATE_PRESSED
 41+		                           : WL_POINTER_BUTTON_STATE_RELEASED;
 42+		device->handler->button(time, input_event->code, state);
 43+	} else {
 44+		state = input_event->value ? WL_KEYBOARD_KEY_STATE_PRESSED
 45+		                           : WL_KEYBOARD_KEY_STATE_RELEASED;
 46+		device->handler->key(time, input_event->code, state);
 47+	}
 48 }
 49 
 50-static void handle_rel_event(struct evdev_device * device,
 51-                             struct input_event * input_event)
 52+static void
 53+handle_rel_event(struct evdev_device *device,
 54+                 struct input_event *input_event)
 55 {
 56-    uint32_t time = timeval_to_msec(&input_event->time);
 57-    uint32_t axis, amount;
 58-
 59-    switch (input_event->code)
 60-    {
 61-        case REL_X:
 62-            device->motion.rel.dx += input_event->value;
 63-            device->motion.rel.pending = true;
 64-            return;
 65-        case REL_Y:
 66-            device->motion.rel.dy += input_event->value;
 67-            device->motion.rel.pending = true;
 68-            return;
 69-        case REL_WHEEL:
 70-            axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
 71-            amount = -AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
 72-            break;
 73-        case REL_HWHEEL:
 74-            axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
 75-            amount = AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
 76-            break;
 77-        default: return;
 78-    }
 79-
 80-    device->handler->axis(time, axis, amount);
 81+	uint32_t time = timeval_to_msec(&input_event->time);
 82+	uint32_t axis, amount;
 83+
 84+	switch (input_event->code) {
 85+	case REL_X:
 86+		device->motion.rel.dx += input_event->value;
 87+		device->motion.rel.pending = true;
 88+		return;
 89+	case REL_Y:
 90+		device->motion.rel.dy += input_event->value;
 91+		device->motion.rel.pending = true;
 92+		return;
 93+	case REL_WHEEL:
 94+		axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
 95+		amount = -AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
 96+		break;
 97+	case REL_HWHEEL:
 98+		axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
 99+		amount = AXIS_STEP_DISTANCE * wl_fixed_from_int(input_event->value);
100+		break;
101+	default:
102+		return;
103+	}
104+
105+	device->handler->axis(time, axis, amount);
106 }
107 
108-static void handle_abs_event(struct evdev_device * device,
109-                             struct input_event * input_event)
110+static void
111+handle_abs_event(struct evdev_device *device,
112+                 struct input_event *input_event)
113 {
114 }
115 
116-static void (* event_handlers[])(struct evdev_device * device,
117-                                 struct input_event * input_event) = {
118-    [EV_KEY] = &handle_key_event,
119-    [EV_REL] = &handle_rel_event,
120-    [EV_ABS] = &handle_abs_event
121+static void (*event_handlers[])(struct evdev_device *device,
122+                                struct input_event *input_event) = {
123+	    [EV_KEY] = &handle_key_event,
124+	    [EV_REL] = &handle_rel_event,
125+	    [EV_ABS] = &handle_abs_event
126 };
127 
128-static bool is_motion_event(struct input_event * event)
129+static bool
130+is_motion_event(struct input_event *event)
131 {
132-    return (event->type == EV_REL && (event->code == REL_X || event->code == REL_Y))
133-        || (event->type == EV_ABS && (event->code == ABS_X || event->code == ABS_Y));
134+	return (event->type == EV_REL && (event->code == REL_X || event->code == REL_Y))
135+	       || (event->type == EV_ABS && (event->code == ABS_X || event->code == ABS_Y));
136 }
137 
138-static void handle_motion_events(struct evdev_device * device,
139-                                 uint32_t time)
140+static void
141+handle_motion_events(struct evdev_device *device,
142+                     uint32_t time)
143 {
144-    if (device->motion.rel.pending)
145-    {
146-        wl_fixed_t dx = wl_fixed_from_int(device->motion.rel.dx);
147-        wl_fixed_t dy = wl_fixed_from_int(device->motion.rel.dy);
148+	if (device->motion.rel.pending) {
149+		wl_fixed_t dx = wl_fixed_from_int(device->motion.rel.dx);
150+		wl_fixed_t dy = wl_fixed_from_int(device->motion.rel.dy);
151 
152-        device->handler->relative_motion(time, dx, dy);
153+		device->handler->relative_motion(time, dx, dy);
154 
155-        device->motion.rel.pending = false;
156-        device->motion.rel.dx = 0;
157-        device->motion.rel.dy = 0;
158-    }
159+		device->motion.rel.pending = false;
160+		device->motion.rel.dx = 0;
161+		device->motion.rel.dy = 0;
162+	}
163 }
164 
165-static void handle_event(struct evdev_device * device,
166-                         struct input_event * event)
167+static void
168+handle_event(struct evdev_device *device,
169+             struct input_event *event)
170 {
171-    if (!is_motion_event(event))
172-        handle_motion_events(device, timeval_to_msec(&event->time));
173-
174-    if (event->type < ARRAY_SIZE(event_handlers)
175-        && event_handlers[event->type])
176-    {
177-        event_handlers[event->type](device, event);
178-    }
179+	if (!is_motion_event(event))
180+		handle_motion_events(device, timeval_to_msec(&event->time));
181+
182+	if (event->type < ARRAY_SIZE(event_handlers)
183+	    && event_handlers[event->type]) {
184+		event_handlers[event->type](device, event);
185+	}
186 }
187 
188-static void close_device(struct evdev_device * device)
189+static void
190+close_device(struct evdev_device *device)
191 {
192-    wl_event_source_remove(device->source);
193-    close(device->fd);
194-    device->source = NULL;
195-    device->fd = -1;
196+	wl_event_source_remove(device->source);
197+	close(device->fd);
198+	device->source = NULL;
199+	device->fd = -1;
200 }
201 
202-static int handle_data(int fd, uint32_t mask, void * data)
203+static int
204+handle_data(int fd, uint32_t mask, void *data)
205 {
206-    struct evdev_device * device = data;
207-    struct input_event event;
208-    unsigned flags = device->needs_sync ? LIBEVDEV_READ_FLAG_FORCE_SYNC
209-                                        : LIBEVDEV_READ_FLAG_NORMAL;
210-    int ret;
211-
212-    device->needs_sync = false;
213-
214-    while (true)
215-    {
216-        ret = libevdev_next_event(device->dev, flags, &event);
217-
218-        if (ret < 0)
219-            goto done;
220-        else if (ret == LIBEVDEV_READ_STATUS_SUCCESS)
221-            handle_event(device, &event);
222-        else
223-        {
224-            while (ret == LIBEVDEV_READ_STATUS_SYNC)
225-            {
226-                ret = libevdev_next_event(device->dev, LIBEVDEV_READ_FLAG_SYNC,
227-                                          &event);
228-
229-                if (ret < 0)
230-                    goto done;
231-
232-                handle_event(device, &event);
233-            }
234-        }
235-    }
236-
237-  done:
238-    if (ret == -ENODEV)
239-        close_device(device);
240-
241-    handle_motion_events(device, timeval_to_msec(&event.time));
242-
243-    return 1;
244+	struct evdev_device *device = data;
245+	struct input_event event;
246+	unsigned flags = device->needs_sync ? LIBEVDEV_READ_FLAG_FORCE_SYNC
247+	                                    : LIBEVDEV_READ_FLAG_NORMAL;
248+	int ret;
249+
250+	device->needs_sync = false;
251+
252+	while (true) {
253+		ret = libevdev_next_event(device->dev, flags, &event);
254+
255+		if (ret < 0)
256+			goto done;
257+		else if (ret == LIBEVDEV_READ_STATUS_SUCCESS)
258+			handle_event(device, &event);
259+		else {
260+			while (ret == LIBEVDEV_READ_STATUS_SYNC) {
261+				ret = libevdev_next_event(device->dev, LIBEVDEV_READ_FLAG_SYNC,
262+				                          &event);
263+
264+				if (ret < 0)
265+					goto done;
266+
267+				handle_event(device, &event);
268+			}
269+		}
270+	}
271+
272+done:
273+	if (ret == -ENODEV)
274+		close_device(device);
275+
276+	handle_motion_events(device, timeval_to_msec(&event.time));
277+
278+	return 1;
279 }
280 
281-struct evdev_device * evdev_device_new
282-    (const char * path, const struct evdev_device_handler * handler)
283+struct evdev_device *
284+evdev_device_new(const char *path, const struct evdev_device_handler *handler)
285 {
286-    struct evdev_device * device;
287-
288-    if (!(device = malloc(sizeof *device)))
289-        goto error0;
290-
291-    device->fd = launch_open_device(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
292-
293-    if (device->fd == -1)
294-    {
295-        ERROR("Failed to open input device at %s\n", path);
296-        goto error1;
297-    }
298-
299-    if (!(device->path = strdup(path)))
300-        goto error2;
301-
302-    if (libevdev_new_from_fd(device->fd, &device->dev) != 0)
303-    {
304-        ERROR("Failed to create libevdev device\n");
305-        goto error3;
306-    }
307-
308-    device->source = wl_event_loop_add_fd
309-        (swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
310-
311-    if (!device->source)
312-    {
313-        ERROR("Failed to add event source\n");
314-        goto error4;
315-    }
316-
317-    DEBUG("Adding device %s\n", libevdev_get_name(device->dev));
318-
319-    device->needs_sync = false;
320-    device->handler = handler;
321-    device->capabilities = 0;
322-    memset(&device->motion, 0, sizeof device->motion);
323-
324-    if (libevdev_has_event_code(device->dev, EV_KEY, KEY_ENTER))
325-    {
326-        device->capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
327-        DEBUG("\tThis device is a keyboard\n");
328-    }
329-
330-    if (libevdev_has_event_code(device->dev, EV_REL, REL_X)
331-        && libevdev_has_event_code(device->dev, EV_REL, REL_Y)
332-        && libevdev_has_event_code(device->dev, EV_KEY, BTN_MOUSE))
333-    {
334-        device->capabilities |= WL_SEAT_CAPABILITY_POINTER;
335-        DEBUG("\tThis device is a pointer\n");
336-    }
337-
338-    /* XXX: touch devices */
339-
340-    return device;
341-
342-  error4:
343-    libevdev_free(device->dev);
344-  error3:
345-    free(device->path);
346-  error2:
347-    close(device->fd);
348-  error1:
349-    free(device);
350-  error0:
351-    return NULL;
352+	struct evdev_device *device;
353+
354+	if (!(device = malloc(sizeof *device)))
355+		goto error0;
356+
357+	device->fd = launch_open_device(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
358+
359+	if (device->fd == -1) {
360+		ERROR("Failed to open input device at %s\n", path);
361+		goto error1;
362+	}
363+
364+	if (!(device->path = strdup(path)))
365+		goto error2;
366+
367+	if (libevdev_new_from_fd(device->fd, &device->dev) != 0) {
368+		ERROR("Failed to create libevdev device\n");
369+		goto error3;
370+	}
371+
372+	device->source = wl_event_loop_add_fd(swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
373+
374+	if (!device->source) {
375+		ERROR("Failed to add event source\n");
376+		goto error4;
377+	}
378+
379+	DEBUG("Adding device %s\n", libevdev_get_name(device->dev));
380+
381+	device->needs_sync = false;
382+	device->handler = handler;
383+	device->capabilities = 0;
384+	memset(&device->motion, 0, sizeof device->motion);
385+
386+	if (libevdev_has_event_code(device->dev, EV_KEY, KEY_ENTER)) {
387+		device->capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
388+		DEBUG("\tThis device is a keyboard\n");
389+	}
390+
391+	if (libevdev_has_event_code(device->dev, EV_REL, REL_X)
392+	    && libevdev_has_event_code(device->dev, EV_REL, REL_Y)
393+	    && libevdev_has_event_code(device->dev, EV_KEY, BTN_MOUSE)) {
394+		device->capabilities |= WL_SEAT_CAPABILITY_POINTER;
395+		DEBUG("\tThis device is a pointer\n");
396+	}
397+
398+	/* XXX: touch devices */
399+
400+	return device;
401+
402+error4:
403+	libevdev_free(device->dev);
404+error3:
405+	free(device->path);
406+error2:
407+	close(device->fd);
408+error1:
409+	free(device);
410+error0:
411+	return NULL;
412 }
413 
414-void evdev_device_destroy(struct evdev_device * device)
415+void
416+evdev_device_destroy(struct evdev_device *device)
417 {
418-    if (device->source)
419-        close_device(device);
420+	if (device->source)
421+		close_device(device);
422 
423-    libevdev_free(device->dev);
424-    free(device->path);
425-    free(device);
426+	libevdev_free(device->dev);
427+	free(device->path);
428+	free(device);
429 }
430 
431-bool evdev_device_reopen(struct evdev_device * device)
432+bool
433+evdev_device_reopen(struct evdev_device *device)
434 {
435-    if (device->source)
436-        close_device(device);
437-
438-    device->fd = launch_open_device(device->path,
439-                                    O_RDWR | O_NONBLOCK | O_CLOEXEC);
440-
441-    if (device->fd == -1)
442-    {
443-        WARNING("Failed to reopen input device at %s: %s\n",
444-                device->path, strerror(errno));
445-        goto error0;
446-    }
447-
448-    if (libevdev_change_fd(device->dev, device->fd) == -1)
449-    {
450-        ERROR("Failed to update libevdev fd\n");
451-        goto error1;
452-    }
453-
454-    /* According to libevdev documentation, after changing the fd for the
455+	if (device->source)
456+		close_device(device);
457+
458+	device->fd = launch_open_device(device->path,
459+	                                O_RDWR | O_NONBLOCK | O_CLOEXEC);
460+
461+	if (device->fd == -1) {
462+		WARNING("Failed to reopen input device at %s: %s\n",
463+		        device->path, strerror(errno));
464+		goto error0;
465+	}
466+
467+	if (libevdev_change_fd(device->dev, device->fd) == -1) {
468+		ERROR("Failed to update libevdev fd\n");
469+		goto error1;
470+	}
471+
472+	/* According to libevdev documentation, after changing the fd for the
473      * device, you should force a sync to bring it's state up to date. */
474-    device->needs_sync = true;
475-    device->source = wl_event_loop_add_fd
476-        (swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
477-
478-    if (!device->source)
479-    {
480-        ERROR("Failed to create event source\n");
481-        goto error1;
482-    }
483-
484-    return true;
485-
486-  error1:
487-    close(device->fd);
488-    device->fd = -1;
489-  error0:
490-    return false;
491-}
492+	device->needs_sync = true;
493+	device->source = wl_event_loop_add_fd(swc.event_loop, device->fd, WL_EVENT_READABLE, handle_data, device);
494+
495+	if (!device->source) {
496+		ERROR("Failed to create event source\n");
497+		goto error1;
498+	}
499 
500+	return true;
501+
502+error1:
503+	close(device->fd);
504+	device->fd = -1;
505+error0:
506+	return false;
507+}
+40, -44
 1@@ -35,55 +35,51 @@
 2 struct evdev_device;
 3 struct wl_event_loop;
 4 
 5-struct evdev_device_handler
 6-{
 7-    void (* key)(uint32_t time, uint32_t key, uint32_t state);
 8-    void (* button)(uint32_t time, uint32_t key, uint32_t state);
 9-    void (* axis)(uint32_t time, uint32_t axis, wl_fixed_t amount);
10-    void (* relative_motion)(uint32_t time, wl_fixed_t dx, wl_fixed_t dy);
11+struct evdev_device_handler {
12+	void (*key)(uint32_t time, uint32_t key, uint32_t state);
13+	void (*button)(uint32_t time, uint32_t key, uint32_t state);
14+	void (*axis)(uint32_t time, uint32_t axis, wl_fixed_t amount);
15+	void (*relative_motion)(uint32_t time, wl_fixed_t dx, wl_fixed_t dy);
16 };
17 
18-struct evdev_device
19-{
20-    char * path;
21-    int fd;
22-    struct libevdev * dev;
23-    bool needs_sync;
24-
25-    const struct evdev_device_handler * handler;
26-
27-    struct
28-    {
29-        struct
30-        {
31-            struct
32-            {
33-                struct input_absinfo x, y;
34-            } info;
35-
36-            int32_t x, y;
37-            bool pending;
38-        } abs;
39-
40-        struct
41-        {
42-            int32_t dx, dy;
43-            bool pending;
44-        } rel;
45-    } motion;
46-
47-    uint32_t capabilities;
48-
49-    struct wl_event_source * source;
50-    struct wl_list link;
51+struct evdev_device {
52+	char *path;
53+	int fd;
54+	struct libevdev *dev;
55+	bool needs_sync;
56+
57+	const struct evdev_device_handler *handler;
58+
59+	struct
60+	    {
61+		struct
62+		    {
63+			struct
64+			    {
65+				struct input_absinfo x, y;
66+			} info;
67+
68+			int32_t x, y;
69+			bool pending;
70+		} abs;
71+
72+		struct
73+		    {
74+			int32_t dx, dy;
75+			bool pending;
76+		} rel;
77+	} motion;
78+
79+	uint32_t capabilities;
80+
81+	struct wl_event_source *source;
82+	struct wl_list link;
83 };
84 
85-struct evdev_device * evdev_device_new
86-    (const char * path, const struct evdev_device_handler * handler);
87+struct evdev_device *evdev_device_new(const char *path, const struct evdev_device_handler *handler);
88 
89-void evdev_device_destroy(struct evdev_device * device);
90+void evdev_device_destroy(struct evdev_device *device);
91 
92-bool evdev_device_reopen(struct evdev_device * device);
93+bool evdev_device_reopen(struct evdev_device *device);
94 
95 #endif
96-
+10, -11
 1@@ -10,32 +10,31 @@
 2  * An event is the data passed to the listeners of the event_signals of various
 3  * objects.
 4  */
 5-struct event
 6-{
 7-    /**
 8+struct 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+	uint32_t type;
17 
18-    /**
19+	/**
20      * Data specific to the event type.
21      *
22      * Unless explicitly stated in the description of the event type, this
23      * value is undefined.
24      */
25-    void * data;
26+	void *data;
27 };
28 
29-static inline void send_event(struct wl_signal * signal, uint32_t type,
30-                              void * event_data)
31+static inline void
32+send_event(struct wl_signal *signal, uint32_t type,
33+           void *event_data)
34 {
35-    struct event event = { .type = type, .data = event_data };
36+	struct event event = {.type = type, .data = event_data };
37 
38-    wl_signal_emit(signal, &event);
39+	wl_signal_emit(signal, &event);
40 }
41 
42 #endif
43-
+157, -167
  1@@ -34,210 +34,200 @@
  2 #include <xf86drm.h>
  3 #include <xf86drmMode.h>
  4 
  5-enum
  6-{
  7-    WLD_USER_OBJECT_FRAMEBUFFER = WLD_USER_ID
  8+enum {
  9+	WLD_USER_OBJECT_FRAMEBUFFER = WLD_USER_ID
 10 };
 11 
 12-struct framebuffer
 13-{
 14-    struct wld_exporter exporter;
 15-    struct wld_destructor destructor;
 16-    uint32_t id;
 17+struct framebuffer {
 18+	struct wld_exporter exporter;
 19+	struct wld_destructor destructor;
 20+	uint32_t id;
 21 };
 22 
 23-static bool framebuffer_export(struct wld_exporter * exporter,
 24-                               struct wld_buffer * buffer,
 25-                               uint32_t type, union wld_object * object)
 26+static bool
 27+framebuffer_export(struct wld_exporter *exporter,
 28+                   struct wld_buffer *buffer,
 29+                   uint32_t type, union wld_object *object)
 30 {
 31-    struct framebuffer * framebuffer
 32-        = wl_container_of(exporter, framebuffer, exporter);
 33-
 34-    switch (type)
 35-    {
 36-        case WLD_USER_OBJECT_FRAMEBUFFER:
 37-            object->u32 = framebuffer->id;
 38-            break;
 39-        default: return false;
 40-    }
 41-
 42-    return true;
 43+	struct framebuffer *framebuffer = wl_container_of(exporter, framebuffer, exporter);
 44+
 45+	switch (type) {
 46+	case WLD_USER_OBJECT_FRAMEBUFFER:
 47+		object->u32 = framebuffer->id;
 48+		break;
 49+	default:
 50+		return false;
 51+	}
 52+
 53+	return true;
 54 }
 55 
 56-static void framebuffer_destroy(struct wld_destructor * destructor)
 57+static void
 58+framebuffer_destroy(struct wld_destructor *destructor)
 59 {
 60-    struct framebuffer * framebuffer
 61-        = wl_container_of(destructor, framebuffer, destructor);
 62+	struct framebuffer *framebuffer = wl_container_of(destructor, framebuffer, destructor);
 63 
 64-    drmModeRmFB(swc.drm->fd, framebuffer->id);
 65-    free(framebuffer);
 66+	drmModeRmFB(swc.drm->fd, framebuffer->id);
 67+	free(framebuffer);
 68 }
 69 
 70-static bool update(struct view * view)
 71+static bool
 72+update(struct view *view)
 73 {
 74-    return true;
 75+	return true;
 76 }
 77 
 78-static void send_frame(void * data)
 79+static void
 80+send_frame(void *data)
 81 {
 82-    struct framebuffer_plane * plane = data;
 83+	struct framebuffer_plane *plane = data;
 84 
 85-    view_frame(&plane->view, get_time());
 86+	view_frame(&plane->view, get_time());
 87 }
 88 
 89-static int attach(struct view * view, struct wld_buffer * buffer)
 90+static int
 91+attach(struct view *view, struct wld_buffer *buffer)
 92 {
 93-    struct framebuffer_plane * plane = wl_container_of(view, plane, view);
 94-    union wld_object object;
 95-    int ret;
 96-
 97-    if (!wld_export(buffer, WLD_USER_OBJECT_FRAMEBUFFER, &object))
 98-    {
 99-        struct framebuffer * framebuffer;
100-
101-        if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object))
102-        {
103-            ERROR("Could not get buffer handle\n");
104-            return -EINVAL;
105-        }
106-
107-        if (!(framebuffer = malloc(sizeof *framebuffer)))
108-            return -ENOMEM;
109-
110-        ret = drmModeAddFB(swc.drm->fd, buffer->width, buffer->height, 24, 32,
111-                           buffer->pitch, object.u32, &framebuffer->id);
112-
113-        if (ret < 0)
114-        {
115-            free(framebuffer);
116-            return ret;
117-        }
118-
119-        framebuffer->exporter.export = &framebuffer_export;
120-        wld_buffer_add_exporter(buffer, &framebuffer->exporter);
121-        framebuffer->destructor.destroy = &framebuffer_destroy;
122-        wld_buffer_add_destructor(buffer, &framebuffer->destructor);
123-
124-        object.u32 = framebuffer->id;
125-    }
126-
127-    if (plane->need_modeset)
128-    {
129-        ret = drmModeSetCrtc(swc.drm->fd, plane->crtc, object.u32, 0, 0,
130-                             plane->connectors.data, plane->connectors.size / 4,
131-                             &plane->mode.info);
132-
133-        if (ret == 0)
134-        {
135-            wl_event_loop_add_idle(swc.event_loop, &send_frame, plane);
136-            plane->need_modeset = false;
137-        }
138-        else
139-        {
140-            ERROR("Could not set CRTC to next framebuffer: %s\n",
141-                  strerror(-ret));
142-            return ret;
143-        }
144-    }
145-    else
146-    {
147-        ret = drmModePageFlip(swc.drm->fd, plane->crtc, object.u32,
148-                              DRM_MODE_PAGE_FLIP_EVENT, &plane->drm_handler);
149-
150-        if (ret < 0)
151-        {
152-            ERROR("Page flip failed: %s\n", strerror(errno));
153-            return ret;
154-        }
155-    }
156-
157-    return 0;
158+	struct framebuffer_plane *plane = wl_container_of(view, plane, view);
159+	union wld_object object;
160+	int ret;
161+
162+	if (!wld_export(buffer, WLD_USER_OBJECT_FRAMEBUFFER, &object)) {
163+		struct framebuffer *framebuffer;
164+
165+		if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object)) {
166+			ERROR("Could not get buffer handle\n");
167+			return -EINVAL;
168+		}
169+
170+		if (!(framebuffer = malloc(sizeof *framebuffer)))
171+			return -ENOMEM;
172+
173+		ret = drmModeAddFB(swc.drm->fd, buffer->width, buffer->height, 24, 32,
174+		                   buffer->pitch, object.u32, &framebuffer->id);
175+
176+		if (ret < 0) {
177+			free(framebuffer);
178+			return ret;
179+		}
180+
181+		framebuffer->exporter.export = &framebuffer_export;
182+		wld_buffer_add_exporter(buffer, &framebuffer->exporter);
183+		framebuffer->destructor.destroy = &framebuffer_destroy;
184+		wld_buffer_add_destructor(buffer, &framebuffer->destructor);
185+
186+		object.u32 = framebuffer->id;
187+	}
188+
189+	if (plane->need_modeset) {
190+		ret = drmModeSetCrtc(swc.drm->fd, plane->crtc, object.u32, 0, 0,
191+		                     plane->connectors.data, plane->connectors.size / 4,
192+		                     &plane->mode.info);
193+
194+		if (ret == 0) {
195+			wl_event_loop_add_idle(swc.event_loop, &send_frame, plane);
196+			plane->need_modeset = false;
197+		} else {
198+			ERROR("Could not set CRTC to next framebuffer: %s\n",
199+			      strerror(-ret));
200+			return ret;
201+		}
202+	} else {
203+		ret = drmModePageFlip(swc.drm->fd, plane->crtc, object.u32,
204+		                      DRM_MODE_PAGE_FLIP_EVENT, &plane->drm_handler);
205+
206+		if (ret < 0) {
207+			ERROR("Page flip failed: %s\n", strerror(errno));
208+			return ret;
209+		}
210+	}
211+
212+	return 0;
213 }
214 
215-static bool move(struct view * view, int32_t x, int32_t y)
216+static bool
217+move(struct view *view, int32_t x, int32_t y)
218 {
219-    view_set_position(view, x, y);
220+	view_set_position(view, x, y);
221 
222-    return true;
223+	return true;
224 }
225 
226 const static struct view_impl view_impl = {
227-    .update = &update,
228-    .attach = &attach,
229-    .move = &move
230+	.update = &update,
231+	.attach = &attach,
232+	.move = &move
233 };
234 
235-static void handle_page_flip(struct drm_handler * handler, uint32_t time)
236+static void
237+handle_page_flip(struct drm_handler *handler, uint32_t time)
238 {
239-    struct framebuffer_plane * plane
240-        = wl_container_of(handler, plane, drm_handler);
241+	struct framebuffer_plane *plane = wl_container_of(handler, plane, drm_handler);
242 
243-    view_frame(&plane->view, time);
244+	view_frame(&plane->view, time);
245 }
246 
247-static void handle_swc_event(struct wl_listener * listener, void * data)
248+static void
249+handle_swc_event(struct wl_listener *listener, void *data)
250 {
251-    struct event * event = data;
252-    struct framebuffer_plane * plane
253-        = wl_container_of(listener, plane, swc_listener);
254-
255-    switch (event->type)
256-    {
257-        case SWC_EVENT_ACTIVATED:
258-            plane->need_modeset = true;
259-            break;
260-    }
261+	struct event *event = data;
262+	struct framebuffer_plane *plane = wl_container_of(listener, plane, swc_listener);
263+
264+	switch (event->type) {
265+	case SWC_EVENT_ACTIVATED:
266+		plane->need_modeset = true;
267+		break;
268+	}
269 }
270 
271-bool framebuffer_plane_initialize(struct framebuffer_plane * plane,
272-                                  uint32_t crtc, struct mode * mode,
273-                                  uint32_t * connectors,
274-                                  uint32_t num_connectors)
275+bool
276+framebuffer_plane_initialize(struct framebuffer_plane *plane,
277+                             uint32_t crtc, struct mode *mode,
278+                             uint32_t *connectors,
279+                             uint32_t num_connectors)
280 {
281-    uint32_t * plane_connectors;
282-
283-    if (!(plane->original_crtc_state = drmModeGetCrtc(swc.drm->fd, crtc)))
284-    {
285-        ERROR("Failed to get CRTC state for CRTC %u: %s\n",
286-              crtc, strerror(errno));
287-        goto error0;
288-    }
289-
290-    wl_array_init(&plane->connectors);
291-    plane_connectors = wl_array_add(&plane->connectors,
292-                                    num_connectors * sizeof connectors[0]);
293-
294-    if (!plane_connectors)
295-    {
296-        ERROR("Failed to allocate connector array\n");
297-        goto error1;
298-    }
299-
300-    memcpy(plane_connectors, connectors, num_connectors * sizeof connectors[0]);
301-    plane->crtc = crtc;
302-    plane->need_modeset = true;
303-    view_initialize(&plane->view, &view_impl);
304-    plane->view.geometry.width = mode->width;
305-    plane->view.geometry.height = mode->height;
306-    plane->drm_handler.page_flip = &handle_page_flip;
307-    plane->swc_listener.notify = &handle_swc_event;
308-    plane->mode = *mode;
309-    wl_signal_add(&swc.event_signal, &plane->swc_listener);
310-
311-    return true;
312-
313-  error1:
314-    drmModeFreeCrtc(plane->original_crtc_state);
315-  error0:
316-    return false;
317+	uint32_t *plane_connectors;
318+
319+	if (!(plane->original_crtc_state = drmModeGetCrtc(swc.drm->fd, crtc))) {
320+		ERROR("Failed to get CRTC state for CRTC %u: %s\n",
321+		      crtc, strerror(errno));
322+		goto error0;
323+	}
324+
325+	wl_array_init(&plane->connectors);
326+	plane_connectors = wl_array_add(&plane->connectors,
327+	                                num_connectors * sizeof connectors[0]);
328+
329+	if (!plane_connectors) {
330+		ERROR("Failed to allocate connector array\n");
331+		goto error1;
332+	}
333+
334+	memcpy(plane_connectors, connectors, num_connectors * sizeof connectors[0]);
335+	plane->crtc = crtc;
336+	plane->need_modeset = true;
337+	view_initialize(&plane->view, &view_impl);
338+	plane->view.geometry.width = mode->width;
339+	plane->view.geometry.height = mode->height;
340+	plane->drm_handler.page_flip = &handle_page_flip;
341+	plane->swc_listener.notify = &handle_swc_event;
342+	plane->mode = *mode;
343+	wl_signal_add(&swc.event_signal, &plane->swc_listener);
344+
345+	return true;
346+
347+error1:
348+	drmModeFreeCrtc(plane->original_crtc_state);
349+error0:
350+	return false;
351 }
352 
353-void framebuffer_plane_finalize(struct framebuffer_plane * plane)
354+void
355+framebuffer_plane_finalize(struct framebuffer_plane *plane)
356 {
357-    wl_array_release(&plane->connectors);
358-    drmModeCrtcPtr crtc = plane->original_crtc_state;
359-    drmModeSetCrtc(swc.drm->fd, crtc->crtc_id, crtc->buffer_id,
360-                   crtc->x, crtc->y, NULL, 0, &crtc->mode);
361-    drmModeFreeCrtc(crtc);
362+	wl_array_release(&plane->connectors);
363+	drmModeCrtcPtr crtc = plane->original_crtc_state;
364+	drmModeSetCrtc(swc.drm->fd, crtc->crtc_id, crtc->buffer_id,
365+	               crtc->x, crtc->y, NULL, 0, &crtc->mode);
366+	drmModeFreeCrtc(crtc);
367 }
368-
+13, -15
 1@@ -29,24 +29,22 @@
 2 #include "surface.h"
 3 #include "view.h"
 4 
 5-struct framebuffer_plane
 6-{
 7-    uint32_t crtc;
 8-    drmModeCrtcPtr original_crtc_state;
 9-    struct mode mode;
10-    struct view view;
11-    struct wl_array connectors;
12-    bool need_modeset;
13-    struct drm_handler drm_handler;
14-    struct wl_listener swc_listener;
15+struct framebuffer_plane {
16+	uint32_t crtc;
17+	drmModeCrtcPtr original_crtc_state;
18+	struct mode mode;
19+	struct view view;
20+	struct wl_array connectors;
21+	bool need_modeset;
22+	struct drm_handler drm_handler;
23+	struct wl_listener swc_listener;
24 };
25 
26-bool framebuffer_plane_initialize(struct framebuffer_plane * plane,
27-                                  uint32_t crtc, struct mode * mode,
28-                                  uint32_t * connectors,
29+bool framebuffer_plane_initialize(struct framebuffer_plane *plane,
30+                                  uint32_t crtc, struct mode *mode,
31+                                  uint32_t *connectors,
32                                   uint32_t num_connectors);
33 
34-void framebuffer_plane_finalize(struct framebuffer_plane * plane);
35+void framebuffer_plane_finalize(struct framebuffer_plane *plane);
36 
37 #endif
38-
+81, -80
  1@@ -27,122 +27,123 @@
  2 #include "surface.h"
  3 #include "util.h"
  4 
  5-static inline void focus(struct input_focus * input_focus,
  6-                         struct compositor_view * view)
  7+static inline void
  8+focus(struct input_focus *input_focus,
  9+      struct compositor_view *view)
 10 {
 11-    struct wl_resource * resource = NULL;
 12+	struct wl_resource *resource = NULL;
 13 
 14-    if (view)
 15-    {
 16-        struct wl_client * client;
 17+	if (view) {
 18+		struct wl_client *client;
 19 
 20-        client = wl_resource_get_client(view->surface->resource);
 21-        resource = wl_resource_find_for_client(&input_focus->resources, client);
 22+		client = wl_resource_get_client(view->surface->resource);
 23+		resource = wl_resource_find_for_client(&input_focus->resources, client);
 24 
 25-        wl_signal_add(&view->destroy_signal,
 26-                      &input_focus->view_destroy_listener);
 27+		wl_signal_add(&view->destroy_signal,
 28+		              &input_focus->view_destroy_listener);
 29 
 30-        if (resource)
 31-            input_focus->handler->enter(input_focus->handler, resource, view);
 32-    }
 33+		if (resource)
 34+			input_focus->handler->enter(input_focus->handler, resource, view);
 35+	}
 36 
 37-    input_focus->view = view;
 38-    input_focus->resource = resource;
 39+	input_focus->view = view;
 40+	input_focus->resource = resource;
 41 }
 42 
 43-static inline void unfocus(struct input_focus * input_focus)
 44+static inline void
 45+unfocus(struct input_focus *input_focus)
 46 {
 47-    if (input_focus->view)
 48-        wl_list_remove(&input_focus->view_destroy_listener.link);
 49-
 50-    if (input_focus->resource)
 51-    {
 52-        input_focus->handler->leave(input_focus->handler, input_focus->resource,
 53-                                    input_focus->view);
 54-    }
 55+	if (input_focus->view)
 56+		wl_list_remove(&input_focus->view_destroy_listener.link);
 57+
 58+	if (input_focus->resource) {
 59+		input_focus->handler->leave(input_focus->handler, input_focus->resource,
 60+		                            input_focus->view);
 61+	}
 62 }
 63 
 64-static void handle_focus_view_destroy(struct wl_listener * listener,
 65-                                      void * data)
 66+static void
 67+handle_focus_view_destroy(struct wl_listener *listener,
 68+                          void *data)
 69 {
 70-    struct input_focus * input_focus
 71-        = wl_container_of(listener, input_focus, view_destroy_listener);
 72+	struct input_focus *input_focus = wl_container_of(listener, input_focus, view_destroy_listener);
 73 
 74-    input_focus->resource = NULL;
 75-    input_focus->view = NULL;
 76+	input_focus->resource = NULL;
 77+	input_focus->view = NULL;
 78 }
 79 
 80-bool input_focus_initialize(struct input_focus * input_focus,
 81-                            struct input_focus_handler * handler)
 82+bool
 83+input_focus_initialize(struct input_focus *input_focus,
 84+                       struct input_focus_handler *handler)
 85 {
 86-    input_focus->resource = NULL;
 87-    input_focus->view = NULL;
 88-    input_focus->view_destroy_listener.notify = &handle_focus_view_destroy;
 89-    input_focus->handler = handler;
 90+	input_focus->resource = NULL;
 91+	input_focus->view = NULL;
 92+	input_focus->view_destroy_listener.notify = &handle_focus_view_destroy;
 93+	input_focus->handler = handler;
 94 
 95-    wl_list_init(&input_focus->resources);
 96-    wl_signal_init(&input_focus->event_signal);
 97+	wl_list_init(&input_focus->resources);
 98+	wl_signal_init(&input_focus->event_signal);
 99 
100-    return true;
101+	return true;
102 }
103 
104-void input_focus_finalize(struct input_focus * input_focus)
105+void
106+input_focus_finalize(struct input_focus *input_focus)
107 {
108-    /* XXX: Destroy resources? */
109+	/* XXX: Destroy resources? */
110 }
111 
112-void input_focus_add_resource(struct input_focus * input_focus,
113-                              struct wl_resource * resource)
114+void
115+input_focus_add_resource(struct input_focus *input_focus,
116+                         struct wl_resource *resource)
117 {
118-    /* If this new input resource corresponds to our focus, set it as our
119+	/* If this new input resource corresponds to our focus, set it as our
120      * focus. */
121-    if (input_focus->view)
122-    {
123-        struct wl_client * client, * surface_client;
124-
125-        client = wl_resource_get_client(resource);
126-        surface_client = wl_resource_get_client
127-            (input_focus->view->surface->resource);
128-
129-        if (client == surface_client)
130-        {
131-            input_focus->handler->enter(input_focus->handler, resource,
132-                                        input_focus->view);
133-            input_focus->resource = resource;
134-        }
135-    }
136-
137-    wl_list_insert(&input_focus->resources, wl_resource_get_link(resource));
138+	if (input_focus->view) {
139+		struct wl_client *client, *surface_client;
140+
141+		client = wl_resource_get_client(resource);
142+		surface_client = wl_resource_get_client(input_focus->view->surface->resource);
143+
144+		if (client == surface_client) {
145+			input_focus->handler->enter(input_focus->handler, resource,
146+			                            input_focus->view);
147+			input_focus->resource = resource;
148+		}
149+	}
150+
151+	wl_list_insert(&input_focus->resources, wl_resource_get_link(resource));
152 }
153 
154-void input_focus_remove_resource(struct input_focus * input_focus,
155-                                 struct wl_resource * resource)
156+void
157+input_focus_remove_resource(struct input_focus *input_focus,
158+                            struct wl_resource *resource)
159 {
160-    if (resource == input_focus->resource)
161-        input_focus->resource = NULL;
162+	if (resource == input_focus->resource)
163+		input_focus->resource = NULL;
164 
165-    remove_resource(resource);
166+	remove_resource(resource);
167 }
168 
169-void input_focus_set(struct input_focus * input_focus,
170-                     struct compositor_view * view)
171+void
172+input_focus_set(struct input_focus *input_focus,
173+                struct compositor_view *view)
174 {
175-    struct input_focus_event_data data;
176+	struct input_focus_event_data data;
177 
178-    if (view == input_focus->view)
179-        return;
180+	if (view == input_focus->view)
181+		return;
182 
183-    data.old = input_focus->view;
184-    data.new = view;
185+	data.old = input_focus->view;
186+	data.new = view;
187 
188-    /* Unfocus previously focused view. */
189-    unfocus(input_focus);
190+	/* Unfocus previously focused view. */
191+	unfocus(input_focus);
192 
193-    /* Focus new view, if given. */
194-    focus(input_focus, view);
195+	/* Focus new view, if given. */
196+	focus(input_focus, view);
197 
198-    send_event(&input_focus->event_signal, INPUT_FOCUS_EVENT_CHANGED, &data);
199+	send_event(&input_focus->event_signal, INPUT_FOCUS_EVENT_CHANGED, &data);
200 
201-    return;
202+	return;
203 }
204-
+31, -37
 1@@ -29,64 +29,58 @@
 2 
 3 /* Focus {{{ */
 4 
 5-enum
 6-{
 7-    INPUT_FOCUS_EVENT_CHANGED
 8+enum {
 9+	INPUT_FOCUS_EVENT_CHANGED
10 };
11 
12-struct input_focus_event_data
13-{
14-    struct compositor_view * old, * new;
15+struct input_focus_event_data {
16+	struct compositor_view *old, *new;
17 };
18 
19-struct input_focus_handler
20-{
21-    void (* enter)(struct input_focus_handler * handler,
22-                   struct wl_resource * resource,
23-                   struct compositor_view * view);
24-    void (* leave)(struct input_focus_handler * handler,
25-                   struct wl_resource * resource,
26-                   struct compositor_view * view);
27+struct input_focus_handler {
28+	void (*enter)(struct input_focus_handler *handler,
29+	              struct wl_resource *resource,
30+	              struct compositor_view *view);
31+	void (*leave)(struct input_focus_handler *handler,
32+	              struct wl_resource *resource,
33+	              struct compositor_view *view);
34 };
35 
36-struct input_focus
37-{
38-    struct wl_resource * resource;
39-    struct compositor_view * view;
40-    struct wl_listener view_destroy_listener;
41+struct input_focus {
42+	struct wl_resource *resource;
43+	struct compositor_view *view;
44+	struct wl_listener view_destroy_listener;
45 
46-    struct input_focus_handler * handler;
47-    struct wl_list resources;
48+	struct input_focus_handler *handler;
49+	struct wl_list resources;
50 
51-    struct wl_signal event_signal;
52+	struct wl_signal event_signal;
53 };
54 
55-bool input_focus_initialize(struct input_focus * input_focus,
56-                            struct input_focus_handler * input_handler);
57+bool input_focus_initialize(struct input_focus *input_focus,
58+                            struct input_focus_handler *input_handler);
59 
60-void input_focus_finalize(struct input_focus * input_focus);
61+void input_focus_finalize(struct input_focus *input_focus);
62 
63-void input_focus_add_resource(struct input_focus * input_focus,
64-                              struct wl_resource * resource);
65+void input_focus_add_resource(struct input_focus *input_focus,
66+                              struct wl_resource *resource);
67 
68-void input_focus_remove_resource(struct input_focus * input_focus,
69-                                 struct wl_resource * resource);
70+void input_focus_remove_resource(struct input_focus *input_focus,
71+                                 struct wl_resource *resource);
72 
73-void input_focus_set(struct input_focus * input_focus,
74-                     struct compositor_view * view);
75+void input_focus_set(struct input_focus *input_focus,
76+                     struct compositor_view *view);
77 
78 /* }}} */
79 
80 /* Key/button handling {{{ */
81 
82-struct press
83-{
84-    uint32_t value;
85-    uint32_t serial;
86-    void * data;
87+struct press {
88+	uint32_t value;
89+	uint32_t serial;
90+	void *data;
91 };
92 
93 /* }}} */
94 
95 #endif
96-
+17, -20
 1@@ -27,29 +27,27 @@
 2 #include <wayland-server.h>
 3 #include <stdbool.h>
 4 
 5-enum
 6-{
 7-    SWC_EVENT_ACTIVATED,
 8-    SWC_EVENT_DEACTIVATED,
 9+enum {
10+	SWC_EVENT_ACTIVATED,
11+	SWC_EVENT_DEACTIVATED,
12 };
13 
14-struct swc
15-{
16-    struct wl_display * display;
17-    struct wl_event_loop * event_loop;
18-    const struct swc_manager * manager;
19-    struct wl_signal event_signal;
20-    bool active;
21-
22-    const struct swc_seat * const seat;
23-    const struct swc_bindings * const bindings;
24-    struct wl_list screens;
25-    struct swc_compositor * const compositor;
26-    struct swc_shm * const shm;
27-    struct swc_drm * const drm;
28+struct swc {
29+	struct wl_display *display;
30+	struct wl_event_loop *event_loop;
31+	const struct swc_manager *manager;
32+	struct wl_signal event_signal;
33+	bool active;
34+
35+	const struct swc_seat *const seat;
36+	const struct swc_bindings *const bindings;
37+	struct wl_list screens;
38+	struct swc_compositor *const compositor;
39+	struct swc_shm *const shm;
40+	struct swc_drm *const drm;
41 
42 #ifdef ENABLE_XWAYLAND
43-    const struct swc_xserver * const xserver;
44+	const struct swc_xserver *const xserver;
45 #endif
46 };
47 
48@@ -59,4 +57,3 @@ void swc_activate(void);
49 void swc_deactivate(void);
50 
51 #endif
52-
+229, -241
  1@@ -38,294 +38,282 @@
  2 
  3 static const int repeat_delay = 500, repeat_rate = 40;
  4 
  5-static void enter(struct input_focus_handler * handler,
  6-                  struct wl_resource * resource, struct compositor_view * view)
  7+static void
  8+enter(struct input_focus_handler *handler,
  9+      struct wl_resource *resource, struct compositor_view *view)
 10 {
 11-    struct keyboard * keyboard
 12-        = wl_container_of(handler, keyboard, focus_handler);
 13-    struct keyboard_modifier_state * state = &keyboard->modifier_state;
 14-    uint32_t serial;
 15-
 16-    serial = wl_display_next_serial(swc.display);
 17-    wl_keyboard_send_modifiers(resource, serial, state->depressed,
 18-                               state->locked, state->latched, state->group);
 19-    wl_keyboard_send_enter(resource, serial, view->surface->resource,
 20-                           &keyboard->client_keys);
 21+	struct keyboard *keyboard = wl_container_of(handler, keyboard, focus_handler);
 22+	struct keyboard_modifier_state *state = &keyboard->modifier_state;
 23+	uint32_t serial;
 24+
 25+	serial = wl_display_next_serial(swc.display);
 26+	wl_keyboard_send_modifiers(resource, serial, state->depressed,
 27+	                           state->locked, state->latched, state->group);
 28+	wl_keyboard_send_enter(resource, serial, view->surface->resource,
 29+	                       &keyboard->client_keys);
 30 }
 31 
 32-static void leave(struct input_focus_handler * handler,
 33-                  struct wl_resource * resource, struct compositor_view * view)
 34+static void
 35+leave(struct input_focus_handler *handler,
 36+      struct wl_resource *resource, struct compositor_view *view)
 37 {
 38-    uint32_t serial;
 39+	uint32_t serial;
 40 
 41-    serial = wl_display_next_serial(swc.display);
 42-    wl_keyboard_send_leave(resource, serial, view->surface->resource);
 43+	serial = wl_display_next_serial(swc.display);
 44+	wl_keyboard_send_leave(resource, serial, view->surface->resource);
 45 }
 46 
 47-static bool client_handle_key(struct keyboard * keyboard, uint32_t time,
 48-                              struct key * key, uint32_t state)
 49+static bool
 50+client_handle_key(struct keyboard *keyboard, uint32_t time,
 51+                  struct key *key, uint32_t state)
 52 {
 53-    uint32_t * value;
 54-
 55-    if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
 56-    {
 57-        if (!(value = wl_array_add(&keyboard->client_keys, sizeof *value)))
 58-            return false;
 59-
 60-        *value = key->press.value;
 61-    }
 62-    else
 63-    {
 64-        wl_array_for_each(value, &keyboard->client_keys)
 65-        {
 66-            if (*value == key->press.value)
 67-            {
 68-                array_remove(&keyboard->client_keys, value, sizeof *value);
 69-                break;
 70-            }
 71-        }
 72-    }
 73-
 74-    if (keyboard->focus.resource)
 75-    {
 76-        wl_keyboard_send_key(keyboard->focus.resource, key->press.serial, time,
 77-                             key->press.value, state);
 78-    }
 79-
 80-    return true;
 81+	uint32_t *value;
 82+
 83+	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
 84+		if (!(value = wl_array_add(&keyboard->client_keys, sizeof *value)))
 85+			return false;
 86+
 87+		*value = key->press.value;
 88+	} else {
 89+		wl_array_for_each (value, &keyboard->client_keys) {
 90+			if (*value == key->press.value) {
 91+				array_remove(&keyboard->client_keys, value, sizeof *value);
 92+				break;
 93+			}
 94+		}
 95+	}
 96+
 97+	if (keyboard->focus.resource) {
 98+		wl_keyboard_send_key(keyboard->focus.resource, key->press.serial, time,
 99+		                     key->press.value, state);
100+	}
101+
102+	return true;
103 }
104 
105-static bool client_handle_modifiers
106-    (struct keyboard * keyboard, const struct keyboard_modifier_state * state)
107+static bool
108+client_handle_modifiers(struct keyboard *keyboard, const struct keyboard_modifier_state *state)
109 {
110-    struct wl_client * client;
111-    struct wl_display * display;
112-    uint32_t serial;
113+	struct wl_client *client;
114+	struct wl_display *display;
115+	uint32_t serial;
116 
117-    if (!keyboard->focus.resource)
118-        return false;
119+	if (!keyboard->focus.resource)
120+		return false;
121 
122-    client = wl_resource_get_client(keyboard->focus.resource);
123-    display = wl_client_get_display(client);
124-    serial = wl_display_next_serial(display);
125-    wl_keyboard_send_modifiers(keyboard->focus.resource, serial,
126-                               state->depressed, state->locked, state->latched,
127-                               state->group);
128+	client = wl_resource_get_client(keyboard->focus.resource);
129+	display = wl_client_get_display(client);
130+	serial = wl_display_next_serial(display);
131+	wl_keyboard_send_modifiers(keyboard->focus.resource, serial,
132+	                           state->depressed, state->locked, state->latched,
133+	                           state->group);
134 
135-    return true;
136+	return true;
137 }
138 
139-bool keyboard_initialize(struct keyboard * keyboard)
140+bool
141+keyboard_initialize(struct keyboard *keyboard)
142 {
143-    if (!xkb_initialize(&keyboard->xkb))
144-    {
145-        ERROR("Could not initialize XKB\n");
146-        goto error0;
147-    }
148-
149-    if (!input_focus_initialize(&keyboard->focus, &keyboard->focus_handler))
150-        goto error1;
151-
152-    keyboard->modifier_state = (struct keyboard_modifier_state) { };
153-    keyboard->modifiers = 0;
154-    keyboard->focus_handler.enter = &enter;
155-    keyboard->focus_handler.leave = &leave;
156-    keyboard->client_handler.key = &client_handle_key;
157-    keyboard->client_handler.modifiers = &client_handle_modifiers;
158-    wl_array_init(&keyboard->client_keys);
159-    wl_array_init(&keyboard->keys);
160-    wl_list_init(&keyboard->handlers);
161-    wl_list_insert(&keyboard->handlers, &keyboard->client_handler.link);
162-
163-    return true;
164-
165-  error1:
166-    xkb_finalize(&keyboard->xkb);
167-  error0:
168-    return false;
169+	if (!xkb_initialize(&keyboard->xkb)) {
170+		ERROR("Could not initialize XKB\n");
171+		goto error0;
172+	}
173+
174+	if (!input_focus_initialize(&keyboard->focus, &keyboard->focus_handler))
175+		goto error1;
176+
177+	keyboard->modifier_state = (struct keyboard_modifier_state){};
178+	keyboard->modifiers = 0;
179+	keyboard->focus_handler.enter = &enter;
180+	keyboard->focus_handler.leave = &leave;
181+	keyboard->client_handler.key = &client_handle_key;
182+	keyboard->client_handler.modifiers = &client_handle_modifiers;
183+	wl_array_init(&keyboard->client_keys);
184+	wl_array_init(&keyboard->keys);
185+	wl_list_init(&keyboard->handlers);
186+	wl_list_insert(&keyboard->handlers, &keyboard->client_handler.link);
187+
188+	return true;
189+
190+error1:
191+	xkb_finalize(&keyboard->xkb);
192+error0:
193+	return false;
194 }
195 
196-void keyboard_finalize(struct keyboard * keyboard)
197+void
198+keyboard_finalize(struct keyboard *keyboard)
199 {
200-    wl_array_release(&keyboard->client_keys);
201-    wl_array_release(&keyboard->keys);
202-    input_focus_finalize(&keyboard->focus);
203-    xkb_finalize(&keyboard->xkb);
204+	wl_array_release(&keyboard->client_keys);
205+	wl_array_release(&keyboard->keys);
206+	input_focus_finalize(&keyboard->focus);
207+	xkb_finalize(&keyboard->xkb);
208 }
209 
210-void keyboard_reset(struct keyboard * keyboard)
211+void
212+keyboard_reset(struct keyboard *keyboard)
213 {
214-    struct key * key;
215-    uint32_t time = get_time();
216-
217-    /* Send simulated key release events for all current key handlers. */
218-    wl_array_for_each(key, &keyboard->keys)
219-    {
220-        if (key->handler)
221-        {
222-            key->press.serial = wl_display_next_serial(swc.display);
223-            key->handler->key(keyboard, time, key,
224-                              WL_KEYBOARD_KEY_STATE_RELEASED);
225-            /* Don't bother updating the XKB state because we will be resetting
226+	struct key *key;
227+	uint32_t time = get_time();
228+
229+	/* Send simulated key release events for all current key handlers. */
230+	wl_array_for_each (key, &keyboard->keys) {
231+		if (key->handler) {
232+			key->press.serial = wl_display_next_serial(swc.display);
233+			key->handler->key(keyboard, time, key,
234+			                  WL_KEYBOARD_KEY_STATE_RELEASED);
235+			/* Don't bother updating the XKB state because we will be resetting
236              * it later on and it is unlikely that a key handler cares about the
237              * keyboard state for release events. */
238-        }
239-    }
240+		}
241+	}
242 
243-    /* We should have removed all the client keys by calling the client key
244+	/* We should have removed all the client keys by calling the client key
245      * handler. */
246-    assert(keyboard->client_keys.size == 0);
247-    keyboard->keys.size = 0;
248-    keyboard->modifier_state = (struct keyboard_modifier_state) { };
249-    keyboard->modifiers = 0;
250-    xkb_reset_state(&keyboard->xkb);
251+	assert(keyboard->client_keys.size == 0);
252+	keyboard->keys.size = 0;
253+	keyboard->modifier_state = (struct keyboard_modifier_state){};
254+	keyboard->modifiers = 0;
255+	xkb_reset_state(&keyboard->xkb);
256 }
257 
258 /**
259  * Sets the focus of the keyboard to the specified surface.
260  */
261-void keyboard_set_focus(struct keyboard * keyboard,
262-                        struct compositor_view * view)
263+void
264+keyboard_set_focus(struct keyboard *keyboard,
265+                   struct compositor_view *view)
266 {
267-    input_focus_set(&keyboard->focus, view);
268+	input_focus_set(&keyboard->focus, view);
269 }
270 
271-static void release(struct wl_client * client, struct wl_resource * resource)
272+static void
273+release(struct wl_client *client, struct wl_resource *resource)
274 {
275-    wl_resource_destroy(resource);
276+	wl_resource_destroy(resource);
277 }
278 
279 static struct wl_keyboard_interface keyboard_implementation = {
280-    .release = &release,
281+	.release = &release,
282 };
283 
284-static void unbind(struct wl_resource * resource)
285+static void
286+unbind(struct wl_resource *resource)
287 {
288-    struct keyboard * keyboard = wl_resource_get_user_data(resource);
289+	struct keyboard *keyboard = wl_resource_get_user_data(resource);
290 
291-    input_focus_remove_resource(&keyboard->focus, resource);
292+	input_focus_remove_resource(&keyboard->focus, resource);
293 }
294 
295-struct wl_resource * keyboard_bind(struct keyboard * keyboard,
296-                                   struct wl_client * client,
297-                                   uint32_t version, uint32_t id)
298+struct wl_resource *
299+keyboard_bind(struct keyboard *keyboard,
300+              struct wl_client *client,
301+              uint32_t version, uint32_t id)
302 {
303-    struct wl_resource * client_resource;
304-
305-    client_resource = wl_resource_create(client, &wl_keyboard_interface,
306-                                         version, id);
307-    wl_resource_set_implementation(client_resource, &keyboard_implementation,
308-                                   keyboard, &unbind);
309-    input_focus_add_resource(&keyboard->focus, client_resource);
310-
311-    /* Subtract one to remove terminating NULL character. */
312-    wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
313-                            keyboard->xkb.keymap.fd,
314-                            keyboard->xkb.keymap.size - 1);
315-
316-    if (version >= 4)
317-    {
318-        wl_keyboard_send_repeat_info(client_resource,
319-                                     repeat_rate, repeat_delay);
320-    }
321-
322-    return client_resource;
323+	struct wl_resource *client_resource;
324+
325+	client_resource = wl_resource_create(client, &wl_keyboard_interface,
326+	                                     version, id);
327+	wl_resource_set_implementation(client_resource, &keyboard_implementation,
328+	                               keyboard, &unbind);
329+	input_focus_add_resource(&keyboard->focus, client_resource);
330+
331+	/* Subtract one to remove terminating NULL character. */
332+	wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
333+	                        keyboard->xkb.keymap.fd,
334+	                        keyboard->xkb.keymap.size - 1);
335+
336+	if (version >= 4) {
337+		wl_keyboard_send_repeat_info(client_resource,
338+		                             repeat_rate, repeat_delay);
339+	}
340+
341+	return client_resource;
342 }
343 
344-void keyboard_handle_key(struct keyboard * keyboard, uint32_t time,
345-                         uint32_t value, uint32_t state)
346+void
347+keyboard_handle_key(struct keyboard *keyboard, uint32_t time,
348+                    uint32_t value, uint32_t state)
349 {
350-    struct key * key;
351-    struct keyboard_modifier_state modifier_state;
352-    enum xkb_key_direction direction;
353-    struct xkb * xkb = &keyboard->xkb;
354-    struct keyboard_handler * handler;
355-    uint32_t serial;
356-
357-    serial = wl_display_next_serial(swc.display);
358-
359-    /* First handle key release events associated with a particular handler. */
360-    wl_array_for_each(key, &keyboard->keys)
361-    {
362-        if (key->press.value == value)
363-        {
364-            /* Ignore repeat events. */
365-            if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
366-                return;
367-
368-            if (key->handler)
369-            {
370-                key->press.serial = serial;
371-                key->handler->key(keyboard, time, key, state);
372-            }
373-
374-            array_remove(&keyboard->keys, key, sizeof *key);
375-            goto update_xkb_state;
376-        }
377-    }
378-
379-    /* If we get a unpaired release event, just ignore it. */
380-    if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
381-        return;
382-
383-    if (!(key = wl_array_add(&keyboard->keys, sizeof *key)))
384-        goto update_xkb_state;
385-
386-    key->press.value = value;
387-    key->press.serial = serial;
388-    key->handler = NULL;
389-
390-    /* Go through handlers to see if any will accept this key event. */
391-    wl_list_for_each(handler, &keyboard->handlers, link)
392-    {
393-        if (handler->key && handler->key(keyboard, time, key, state))
394-        {
395-            key->handler = handler;
396-            break;
397-        }
398-    }
399-
400-    /* Update XKB state. */
401-  update_xkb_state:
402-    direction = state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN
403-                                                       : XKB_KEY_UP;
404-    xkb_state_update_key(xkb->state, XKB_KEY(value), direction);
405-
406-    modifier_state.depressed
407-        = xkb_state_serialize_mods(xkb->state, XKB_STATE_DEPRESSED);
408-    modifier_state.latched
409-        = xkb_state_serialize_mods(xkb->state, XKB_STATE_LATCHED);
410-    modifier_state.locked
411-        = xkb_state_serialize_mods(xkb->state, XKB_STATE_LOCKED);
412-    modifier_state.group
413-        = xkb_state_serialize_layout(xkb->state, XKB_STATE_LAYOUT_EFFECTIVE);
414-
415-    if (modifier_state.depressed != keyboard->modifier_state.depressed
416-        || modifier_state.latched != keyboard->modifier_state.latched
417-        || modifier_state.locked != keyboard->modifier_state.locked
418-        || modifier_state.group != keyboard->modifier_state.group)
419-    {
420-        uint32_t mods_active = modifier_state.depressed
421-                             | modifier_state.latched;
422-
423-        /* Update keyboard modifier state. */
424-        keyboard->modifier_state = modifier_state;
425-        keyboard->modifiers = 0;
426-        if (mods_active & (1 << keyboard->xkb.indices.ctrl))
427-            keyboard->modifiers |= SWC_MOD_CTRL;
428-        if (mods_active & (1 << keyboard->xkb.indices.alt))
429-            keyboard->modifiers |= SWC_MOD_ALT;
430-        if (mods_active & (1 << keyboard->xkb.indices.super))
431-            keyboard->modifiers |= SWC_MOD_LOGO;
432-        if (mods_active & (1 << keyboard->xkb.indices.shift))
433-            keyboard->modifiers |= SWC_MOD_SHIFT;
434-
435-        /* Run any modifier handlers. */
436-        wl_list_for_each(handler, &keyboard->handlers, link)
437-        {
438-            if (handler->modifiers)
439-                handler->modifiers(keyboard, &modifier_state);
440-        }
441-    }
442+	struct key *key;
443+	struct keyboard_modifier_state modifier_state;
444+	enum xkb_key_direction direction;
445+	struct xkb *xkb = &keyboard->xkb;
446+	struct keyboard_handler *handler;
447+	uint32_t serial;
448+
449+	serial = wl_display_next_serial(swc.display);
450+
451+	/* First handle key release events associated with a particular handler. */
452+	wl_array_for_each (key, &keyboard->keys) {
453+		if (key->press.value == value) {
454+			/* Ignore repeat events. */
455+			if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
456+				return;
457+
458+			if (key->handler) {
459+				key->press.serial = serial;
460+				key->handler->key(keyboard, time, key, state);
461+			}
462+
463+			array_remove(&keyboard->keys, key, sizeof *key);
464+			goto update_xkb_state;
465+		}
466+	}
467+
468+	/* If we get a unpaired release event, just ignore it. */
469+	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
470+		return;
471+
472+	if (!(key = wl_array_add(&keyboard->keys, sizeof *key)))
473+		goto update_xkb_state;
474+
475+	key->press.value = value;
476+	key->press.serial = serial;
477+	key->handler = NULL;
478+
479+	/* Go through handlers to see if any will accept this key event. */
480+	wl_list_for_each (handler, &keyboard->handlers, link) {
481+		if (handler->key && handler->key(keyboard, time, key, state)) {
482+			key->handler = handler;
483+			break;
484+		}
485+	}
486+
487+/* Update XKB state. */
488+update_xkb_state:
489+	direction = state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN
490+	                                                   : XKB_KEY_UP;
491+	xkb_state_update_key(xkb->state, XKB_KEY(value), direction);
492+
493+	modifier_state.depressed = xkb_state_serialize_mods(xkb->state, XKB_STATE_DEPRESSED);
494+	modifier_state.latched = xkb_state_serialize_mods(xkb->state, XKB_STATE_LATCHED);
495+	modifier_state.locked = xkb_state_serialize_mods(xkb->state, XKB_STATE_LOCKED);
496+	modifier_state.group = xkb_state_serialize_layout(xkb->state, XKB_STATE_LAYOUT_EFFECTIVE);
497+
498+	if (modifier_state.depressed != keyboard->modifier_state.depressed
499+	    || modifier_state.latched != keyboard->modifier_state.latched
500+	    || modifier_state.locked != keyboard->modifier_state.locked
501+	    || modifier_state.group != keyboard->modifier_state.group) {
502+		uint32_t mods_active = modifier_state.depressed
503+		                       | modifier_state.latched;
504+
505+		/* Update keyboard modifier state. */
506+		keyboard->modifier_state = modifier_state;
507+		keyboard->modifiers = 0;
508+		if (mods_active & (1 << keyboard->xkb.indices.ctrl))
509+			keyboard->modifiers |= SWC_MOD_CTRL;
510+		if (mods_active & (1 << keyboard->xkb.indices.alt))
511+			keyboard->modifiers |= SWC_MOD_ALT;
512+		if (mods_active & (1 << keyboard->xkb.indices.super))
513+			keyboard->modifiers |= SWC_MOD_LOGO;
514+		if (mods_active & (1 << keyboard->xkb.indices.shift))
515+			keyboard->modifiers |= SWC_MOD_SHIFT;
516+
517+		/* Run any modifier handlers. */
518+		wl_list_for_each (handler, &keyboard->handlers, link) {
519+			if (handler->modifiers)
520+				handler->modifiers(keyboard, &modifier_state);
521+		}
522+	}
523 }
524-
+33, -38
 1@@ -32,55 +32,50 @@
 2 struct keyboard;
 3 struct wl_client;
 4 
 5-struct key
 6-{
 7-    struct press press;
 8-    struct keyboard_handler * handler;
 9+struct key {
10+	struct press press;
11+	struct keyboard_handler *handler;
12 };
13 
14-struct keyboard_modifier_state
15-{
16-    uint32_t depressed;
17-    uint32_t latched;
18-    uint32_t locked;
19-    uint32_t group;
20+struct keyboard_modifier_state {
21+	uint32_t depressed;
22+	uint32_t latched;
23+	uint32_t locked;
24+	uint32_t group;
25 };
26 
27-struct keyboard_handler
28-{
29-    bool (* key)(struct keyboard * keyboard, uint32_t time,
30-                 struct key * key, uint32_t state);
31-    bool (* modifiers)(struct keyboard * keyboard,
32-                       const struct keyboard_modifier_state * state);
33+struct keyboard_handler {
34+	bool (*key)(struct keyboard *keyboard, uint32_t time,
35+	            struct key *key, uint32_t state);
36+	bool (*modifiers)(struct keyboard *keyboard,
37+	                  const struct keyboard_modifier_state *state);
38 
39-    struct wl_list link;
40+	struct wl_list link;
41 };
42 
43-struct keyboard
44-{
45-    struct input_focus focus;
46-    struct input_focus_handler focus_handler;
47-    struct xkb xkb;
48+struct keyboard {
49+	struct input_focus focus;
50+	struct input_focus_handler focus_handler;
51+	struct xkb xkb;
52 
53-    struct wl_array keys;
54-    struct wl_list handlers;
55-    struct keyboard_handler client_handler;
56-    struct wl_array client_keys;
57+	struct wl_array keys;
58+	struct wl_list handlers;
59+	struct keyboard_handler client_handler;
60+	struct wl_array client_keys;
61 
62-    struct keyboard_modifier_state modifier_state;
63-    uint32_t modifiers;
64+	struct keyboard_modifier_state modifier_state;
65+	uint32_t modifiers;
66 };
67 
68-bool keyboard_initialize(struct keyboard * keyboard);
69-void keyboard_finalize(struct keyboard * keyboard);
70-void keyboard_reset(struct keyboard * keyboard);
71-void keyboard_set_focus(struct keyboard * keyboard,
72-                        struct compositor_view * view);
73-struct wl_resource * keyboard_bind(struct keyboard * keyboard,
74-                                   struct wl_client * client,
75-                                   uint32_t version, uint32_t id);
76-void keyboard_handle_key(struct keyboard * keyboard, uint32_t time,
77+bool keyboard_initialize(struct keyboard *keyboard);
78+void keyboard_finalize(struct keyboard *keyboard);
79+void keyboard_reset(struct keyboard *keyboard);
80+void keyboard_set_focus(struct keyboard *keyboard,
81+                        struct compositor_view *view);
82+struct wl_resource *keyboard_bind(struct keyboard *keyboard,
83+                                  struct wl_client *client,
84+                                  uint32_t version, uint32_t id);
85+void keyboard_handle_key(struct keyboard *keyboard, uint32_t time,
86                          uint32_t key, uint32_t state);
87 
88 #endif
89-
+78, -75
  1@@ -31,118 +31,121 @@
  2 #include <wayland-server.h>
  3 
  4 static struct
  5-{
  6-    int socket;
  7-    struct wl_event_source * source;
  8-    uint32_t next_serial;
  9+    {
 10+	int socket;
 11+	struct wl_event_source *source;
 12+	uint32_t next_serial;
 13 } launch;
 14 
 15-static bool handle_event(struct swc_launch_event * event)
 16+static bool
 17+handle_event(struct swc_launch_event *event)
 18 {
 19-    switch (event->type)
 20-    {
 21-        case SWC_LAUNCH_EVENT_ACTIVATE:
 22-            swc_activate();
 23-            break;
 24-        case SWC_LAUNCH_EVENT_DEACTIVATE:
 25-            swc_deactivate();
 26-            break;
 27-        default:
 28-            return false;
 29-    }
 30-
 31-    return true;
 32+	switch (event->type) {
 33+	case SWC_LAUNCH_EVENT_ACTIVATE:
 34+		swc_activate();
 35+		break;
 36+	case SWC_LAUNCH_EVENT_DEACTIVATE:
 37+		swc_deactivate();
 38+		break;
 39+	default:
 40+		return false;
 41+	}
 42+
 43+	return true;
 44 }
 45 
 46-static int handle_data(int fd, uint32_t mask, void * data)
 47+static int
 48+handle_data(int fd, uint32_t mask, void *data)
 49 {
 50-    struct swc_launch_event event;
 51+	struct swc_launch_event event;
 52 
 53-    if (receive_fd(fd, NULL, &event, sizeof event) != -1)
 54-        handle_event(&event);
 55+	if (receive_fd(fd, NULL, &event, sizeof event) != -1)
 56+		handle_event(&event);
 57 
 58-    return 1;
 59+	return 1;
 60 }
 61 
 62-bool launch_initialize(void)
 63+bool
 64+launch_initialize(void)
 65 {
 66-    char * socket_string, * end;
 67+	char *socket_string, *end;
 68 
 69-    if (!(socket_string = getenv(SWC_LAUNCH_SOCKET_ENV)))
 70-        return false;
 71+	if (!(socket_string = getenv(SWC_LAUNCH_SOCKET_ENV)))
 72+		return false;
 73 
 74-    launch.socket = strtol(socket_string, &end, 10);
 75+	launch.socket = strtol(socket_string, &end, 10);
 76 
 77-    if (*end != '\0')
 78-        return false;
 79+	if (*end != '\0')
 80+		return false;
 81 
 82-    launch.source = wl_event_loop_add_fd(swc.event_loop, launch.socket,
 83-                                         WL_EVENT_READABLE, &handle_data, NULL);
 84+	launch.source = wl_event_loop_add_fd(swc.event_loop, launch.socket,
 85+	                                     WL_EVENT_READABLE, &handle_data, NULL);
 86 
 87-    if (!launch.source)
 88-        return false;
 89+	if (!launch.source)
 90+		return false;
 91 
 92-    return true;
 93+	return true;
 94 }
 95 
 96-void launch_finalize(void)
 97+void
 98+launch_finalize(void)
 99 {
100-    wl_event_source_remove(launch.source);
101-    close(launch.socket);
102+	wl_event_source_remove(launch.source);
103+	close(launch.socket);
104 }
105 
106-static bool send_request(struct swc_launch_request * request, size_t size,
107-                         struct swc_launch_event * event,
108-                         int out_fd, int * in_fd)
109+static bool
110+send_request(struct swc_launch_request *request, size_t size,
111+             struct swc_launch_event *event,
112+             int out_fd, int *in_fd)
113 {
114-    request->serial = ++launch.next_serial;
115+	request->serial = ++launch.next_serial;
116 
117-    if (send_fd(launch.socket, out_fd, request, size) == -1)
118-        return false;
119+	if (send_fd(launch.socket, out_fd, request, size) == -1)
120+		return false;
121 
122-    while (receive_fd(launch.socket, in_fd, event, sizeof *event) != -1)
123-    {
124-        if (event->type == SWC_LAUNCH_EVENT_RESPONSE
125-            && event->serial == request->serial)
126-        {
127-            return true;
128-        }
129+	while (receive_fd(launch.socket, in_fd, event, sizeof *event) != -1) {
130+		if (event->type == SWC_LAUNCH_EVENT_RESPONSE
131+		    && event->serial == request->serial) {
132+			return true;
133+		}
134 
135-        handle_event(event);
136-    }
137+		handle_event(event);
138+	}
139 
140-    return false;
141+	return false;
142 }
143 
144-int launch_open_device(const char * path, int flags)
145+int
146+launch_open_device(const char *path, int flags)
147 {
148-    size_t path_size = strlen(path);
149-    char buffer[sizeof(struct swc_launch_request) + path_size + 1];
150-    struct swc_launch_request * request = (void *) buffer;
151-    struct swc_launch_event response;
152-    int fd;
153+	size_t path_size = strlen(path);
154+	char buffer[sizeof(struct swc_launch_request) + path_size + 1];
155+	struct swc_launch_request *request = (void *)buffer;
156+	struct swc_launch_event response;
157+	int fd;
158 
159-    request->type = SWC_LAUNCH_REQUEST_OPEN_DEVICE;
160-    request->flags = flags;
161-    strcpy(request->path, path);
162+	request->type = SWC_LAUNCH_REQUEST_OPEN_DEVICE;
163+	request->flags = flags;
164+	strcpy(request->path, path);
165 
166-    if (!send_request(request, sizeof buffer, &response, -1, &fd))
167-        return -1;
168+	if (!send_request(request, sizeof buffer, &response, -1, &fd))
169+		return -1;
170 
171-    return fd;
172+	return fd;
173 }
174 
175-bool launch_activate_vt(unsigned vt)
176+bool
177+launch_activate_vt(unsigned vt)
178 {
179-    struct swc_launch_request request;
180-    struct swc_launch_event response;
181+	struct swc_launch_request request;
182+	struct swc_launch_event response;
183 
184-    request.type = SWC_LAUNCH_REQUEST_ACTIVATE_VT;
185-    request.vt = vt;
186+	request.type = SWC_LAUNCH_REQUEST_ACTIVATE_VT;
187+	request.vt = vt;
188 
189-    if (!send_request(&request, sizeof request, &response, -1, NULL))
190-        return false;
191+	if (!send_request(&request, sizeof request, &response, -1, NULL))
192+		return false;
193 
194-    return response.success;
195+	return response.success;
196 }
197-
+1, -2
 1@@ -30,8 +30,7 @@
 2 bool launch_initialize(void);
 3 void launch_finalize(void);
 4 
 5-int launch_open_device(const char * path, int flags);
 6+int launch_open_device(const char *path, int flags);
 7 bool launch_activate_vt(unsigned vt);
 8 
 9 #endif
10-
+15, -13
 1@@ -23,26 +23,28 @@
 2 
 3 #include "mode.h"
 4 
 5-bool mode_initialize(struct mode * mode, drmModeModeInfo * mode_info)
 6+bool
 7+mode_initialize(struct mode *mode, drmModeModeInfo *mode_info)
 8 {
 9-    mode->width = mode_info->hdisplay;
10-    mode->height = mode_info->vdisplay;
11-    mode->refresh = mode_info->vrefresh * 1000;
12-    mode->preferred = mode_info->type & DRM_MODE_TYPE_PREFERRED;
13+	mode->width = mode_info->hdisplay;
14+	mode->height = mode_info->vdisplay;
15+	mode->refresh = mode_info->vrefresh * 1000;
16+	mode->preferred = mode_info->type & DRM_MODE_TYPE_PREFERRED;
17 
18-    mode->info = *mode_info;
19+	mode->info = *mode_info;
20 
21-    return true;
22+	return true;
23 }
24 
25-void mode_finish(struct mode * mode)
26+void
27+mode_finish(struct mode *mode)
28 {
29 }
30 
31-bool mode_equal(const struct mode * mode1, const struct mode * mode2)
32+bool
33+mode_equal(const struct mode *mode1, const struct mode *mode2)
34 {
35-    return mode1->width == mode2->width
36-        && mode1->height == mode2->height
37-        && mode1->refresh == mode2->refresh;
38+	return mode1->width == mode2->width
39+	       && mode1->height == mode2->height
40+	       && mode1->refresh == mode2->refresh;
41 }
42-
+8, -10
 1@@ -31,20 +31,18 @@
 2 
 3 #include <wayland-util.h>
 4 
 5-struct mode
 6-{
 7-    uint16_t width, height;
 8-    uint32_t refresh;
 9+struct mode {
10+	uint16_t width, height;
11+	uint32_t refresh;
12 
13-    bool preferred;
14+	bool preferred;
15 
16-    drmModeModeInfo info;
17+	drmModeModeInfo info;
18 };
19 
20-bool mode_initialize(struct mode * mode, drmModeModeInfo * mode_info);
21-void mode_finish(struct mode * mode);
22+bool mode_initialize(struct mode *mode, drmModeModeInfo *mode_info);
23+void mode_finish(struct mode *mode);
24 
25-bool mode_equal(const struct mode * mode1, const struct mode * mode2);
26+bool mode_equal(const struct mode *mode1, const struct mode *mode2);
27 
28 #endif
29-
+84, -88
  1@@ -11,113 +11,109 @@
  2 #include <libdrm/drm.h>
  3 #include <xf86drm.h>
  4 
  5-static void bind_output(struct wl_client * client, void * data,
  6-                        uint32_t version, uint32_t id)
  7+static void
  8+bind_output(struct wl_client *client, void *data,
  9+            uint32_t version, uint32_t id)
 10 {
 11-    struct output * output = data;
 12-    struct screen * screen = output->screen;
 13-    struct mode * mode;
 14-    struct wl_resource * resource;
 15-    uint32_t flags;
 16-
 17-    if (version > 2)
 18-        version = 2;
 19-
 20-    resource = wl_resource_create(client, &wl_output_interface, version, id);
 21-
 22-    if (!resource)
 23-    {
 24-        wl_client_post_no_memory(client);
 25-        return;
 26-    }
 27-
 28-    wl_resource_set_implementation(resource, NULL, output, &remove_resource);
 29-    wl_list_insert(&output->resources, wl_resource_get_link(resource));
 30-
 31-    wl_output_send_geometry
 32-        (resource, screen->base.geometry.x, screen->base.geometry.y,
 33-         output->physical_width, output->physical_height, 0, "unknown",
 34-         "unknown", WL_OUTPUT_TRANSFORM_NORMAL);
 35-
 36-    wl_array_for_each(mode, &output->modes)
 37-    {
 38-        flags = 0;
 39-        if (mode->preferred)
 40-            flags |= WL_OUTPUT_MODE_PREFERRED;
 41-        if (mode_equal(&screen->planes.framebuffer.mode, mode))
 42-            flags |= WL_OUTPUT_MODE_CURRENT;
 43-
 44-        wl_output_send_mode(resource, flags,
 45-                            mode->width, mode->height, mode->refresh);
 46-    }
 47-
 48-    if (version >= 2)
 49-        wl_output_send_done(resource);
 50+	struct output *output = data;
 51+	struct screen *screen = output->screen;
 52+	struct mode *mode;
 53+	struct wl_resource *resource;
 54+	uint32_t flags;
 55+
 56+	if (version > 2)
 57+		version = 2;
 58+
 59+	resource = wl_resource_create(client, &wl_output_interface, version, id);
 60+
 61+	if (!resource) {
 62+		wl_client_post_no_memory(client);
 63+		return;
 64+	}
 65+
 66+	wl_resource_set_implementation(resource, NULL, output, &remove_resource);
 67+	wl_list_insert(&output->resources, wl_resource_get_link(resource));
 68+
 69+	wl_output_send_geometry(resource, screen->base.geometry.x, screen->base.geometry.y,
 70+	                        output->physical_width, output->physical_height, 0, "unknown",
 71+	                        "unknown", WL_OUTPUT_TRANSFORM_NORMAL);
 72+
 73+	wl_array_for_each (mode, &output->modes) {
 74+		flags = 0;
 75+		if (mode->preferred)
 76+			flags |= WL_OUTPUT_MODE_PREFERRED;
 77+		if (mode_equal(&screen->planes.framebuffer.mode, mode))
 78+			flags |= WL_OUTPUT_MODE_CURRENT;
 79+
 80+		wl_output_send_mode(resource, flags,
 81+		                    mode->width, mode->height, mode->refresh);
 82+	}
 83+
 84+	if (version >= 2)
 85+		wl_output_send_done(resource);
 86 }
 87 
 88-struct output * output_new(drmModeConnectorPtr connector)
 89+struct output *
 90+output_new(drmModeConnectorPtr connector)
 91 {
 92-    struct output * output;
 93-    struct mode * modes;
 94-    uint32_t index;
 95+	struct output *output;
 96+	struct mode *modes;
 97+	uint32_t index;
 98 
 99-    if (!(output = malloc(sizeof *output)))
100-    {
101-        ERROR("Failed to allocated output\n");
102-        goto error0;
103-    }
104+	if (!(output = malloc(sizeof *output))) {
105+		ERROR("Failed to allocated output\n");
106+		goto error0;
107+	}
108 
109-    output->global = wl_global_create(swc.display, &wl_output_interface, 2,
110-                                      output, &bind_output);
111+	output->global = wl_global_create(swc.display, &wl_output_interface, 2,
112+	                                  output, &bind_output);
113 
114-    if (!output->global)
115-    {
116-        ERROR("Failed to create output global\n");
117-        goto error1;
118-    }
119+	if (!output->global) {
120+		ERROR("Failed to create output global\n");
121+		goto error1;
122+	}
123 
124-    output->physical_width = connector->mmWidth;
125-    output->physical_height = connector->mmHeight;
126+	output->physical_width = connector->mmWidth;
127+	output->physical_height = connector->mmHeight;
128 
129-    wl_list_init(&output->resources);
130-    wl_array_init(&output->modes);
131-    pixman_region32_init(&output->current_damage);
132-    pixman_region32_init(&output->previous_damage);
133+	wl_list_init(&output->resources);
134+	wl_array_init(&output->modes);
135+	pixman_region32_init(&output->current_damage);
136+	pixman_region32_init(&output->previous_damage);
137 
138-    output->connector = connector->connector_id;
139+	output->connector = connector->connector_id;
140 
141-    modes = wl_array_add(&output->modes, connector->count_modes * sizeof *modes);
142+	modes = wl_array_add(&output->modes, connector->count_modes * sizeof *modes);
143 
144-    if (!modes)
145-        goto error2;
146+	if (!modes)
147+		goto error2;
148 
149-    for (index = 0; index < connector->count_modes; ++index)
150-    {
151-        mode_initialize(&modes[index], &connector->modes[index]);
152+	for (index = 0; index < connector->count_modes; ++index) {
153+		mode_initialize(&modes[index], &connector->modes[index]);
154 
155-        if (modes[index].preferred)
156-            output->preferred_mode = &modes[index];
157-    }
158+		if (modes[index].preferred)
159+			output->preferred_mode = &modes[index];
160+	}
161 
162-    return output;
163+	return output;
164 
165-  error2:
166-    wl_global_destroy(output->global);
167-  error1:
168-    free(output);
169-  error0:
170-    return NULL;
171+error2:
172+	wl_global_destroy(output->global);
173+error1:
174+	free(output);
175+error0:
176+	return NULL;
177 }
178 
179-void output_destroy(struct output * output)
180+void
181+output_destroy(struct output *output)
182 {
183-    struct mode * mode;
184+	struct mode *mode;
185 
186-    wl_array_for_each(mode, &output->modes)
187-        mode_finish(mode);
188-    wl_array_release(&output->modes);
189+	wl_array_for_each (mode, &output->modes)
190+		mode_finish(mode);
191+	wl_array_release(&output->modes);
192 
193-    wl_global_destroy(output->global);
194-    free(output);
195+	wl_global_destroy(output->global);
196+	free(output);
197 }
198-
+14, -16
 1@@ -8,28 +8,26 @@
 2 
 3 struct wl_display;
 4 
 5-struct output
 6-{
 7-    struct screen * screen;
 8+struct output {
 9+	struct screen *screen;
10 
11-    /* The physical dimensions (in mm) of this output */
12-    uint32_t physical_width, physical_height;
13+	/* The physical dimensions (in mm) of this output */
14+	uint32_t physical_width, physical_height;
15 
16-    struct wl_array modes;
17-    struct mode * preferred_mode;
18+	struct wl_array modes;
19+	struct mode *preferred_mode;
20 
21-    pixman_region32_t current_damage, previous_damage;
22+	pixman_region32_t current_damage, previous_damage;
23 
24-    /* The DRM connector corresponding to this output */
25-    uint32_t connector;
26+	/* The DRM connector corresponding to this output */
27+	uint32_t connector;
28 
29-    struct wl_global * global;
30-    struct wl_list resources;
31-    struct wl_list link;
32+	struct wl_global *global;
33+	struct wl_list resources;
34+	struct wl_list link;
35 };
36 
37-struct output * output_new(drmModeConnector * connector);
38-void output_destroy(struct output * output);
39+struct output *output_new(drmModeConnector *connector);
40+void output_destroy(struct output *output);
41 
42 #endif
43-
+183, -182
  1@@ -36,237 +36,238 @@
  2 #include <assert.h>
  3 #include <stdlib.h>
  4 
  5-struct panel
  6-{
  7-    struct wl_resource * resource;
  8-
  9-    struct wl_listener surface_destroy_listener;
 10-    struct compositor_view * view;
 11-    struct view_handler view_handler;
 12-    struct screen * screen;
 13-    struct screen_modifier modifier;
 14-    uint32_t edge;
 15-    uint32_t offset, strut_size;
 16-    bool docked;
 17+struct panel {
 18+	struct wl_resource *resource;
 19+
 20+	struct wl_listener surface_destroy_listener;
 21+	struct compositor_view *view;
 22+	struct view_handler view_handler;
 23+	struct screen *screen;
 24+	struct screen_modifier modifier;
 25+	uint32_t edge;
 26+	uint32_t offset, strut_size;
 27+	bool docked;
 28 };
 29 
 30-static void update_position(struct panel * panel)
 31+static void
 32+update_position(struct panel *panel)
 33 {
 34-    int32_t x, y;
 35-    struct swc_rectangle * screen = &panel->screen->base.geometry,
 36-                         * view = &panel->view->base.geometry;
 37-
 38-    switch (panel->edge)
 39-    {
 40-        case SWC_PANEL_EDGE_TOP:
 41-            x = screen->x + panel->offset;
 42-            y = screen->y;
 43-            break;
 44-        case SWC_PANEL_EDGE_BOTTOM:
 45-            x = screen->x + panel->offset;
 46-            y = screen->y + screen->height - view->height;
 47-            break;
 48-        case SWC_PANEL_EDGE_LEFT:
 49-            x = screen->x;
 50-            y = screen->y + screen->height - view->height - panel->offset;
 51-            break;
 52-        case SWC_PANEL_EDGE_RIGHT:
 53-            x = screen->x + screen->width - view->width;
 54-            y = screen->y + panel->offset;
 55-            break;
 56-        default: return;
 57-    }
 58-
 59-    view_move(&panel->view->base, x, y);
 60+	int32_t x, y;
 61+	struct swc_rectangle *screen = &panel->screen->base.geometry,
 62+	                     *view = &panel->view->base.geometry;
 63+
 64+	switch (panel->edge) {
 65+	case SWC_PANEL_EDGE_TOP:
 66+		x = screen->x + panel->offset;
 67+		y = screen->y;
 68+		break;
 69+	case SWC_PANEL_EDGE_BOTTOM:
 70+		x = screen->x + panel->offset;
 71+		y = screen->y + screen->height - view->height;
 72+		break;
 73+	case SWC_PANEL_EDGE_LEFT:
 74+		x = screen->x;
 75+		y = screen->y + screen->height - view->height - panel->offset;
 76+		break;
 77+	case SWC_PANEL_EDGE_RIGHT:
 78+		x = screen->x + screen->width - view->width;
 79+		y = screen->y + panel->offset;
 80+		break;
 81+	default:
 82+		return;
 83+	}
 84+
 85+	view_move(&panel->view->base, x, y);
 86 }
 87 
 88-static void dock(struct wl_client * client, struct wl_resource * resource,
 89-                 uint32_t edge, struct wl_resource * screen_resource,
 90-                 uint32_t focus)
 91+static void
 92+dock(struct wl_client *client, struct wl_resource *resource,
 93+     uint32_t edge, struct wl_resource *screen_resource,
 94+     uint32_t focus)
 95 {
 96-    struct panel * panel = wl_resource_get_user_data(resource);
 97-    struct screen * screen = screen_resource
 98-        ? wl_resource_get_user_data(screen_resource)
 99-        : wl_container_of(swc.screens.next, screen, link);
100-    bool screen_changed = screen != panel->screen;
101-    uint32_t length;
102-
103-    switch (edge)
104-    {
105-        case SWC_PANEL_EDGE_TOP:
106-        case SWC_PANEL_EDGE_BOTTOM:
107-            length = screen->base.geometry.width;
108-            break;
109-        case SWC_PANEL_EDGE_LEFT:
110-        case SWC_PANEL_EDGE_RIGHT:
111-            length = screen->base.geometry.height;
112-            break;
113-        default: return;
114-    }
115-
116-    if (panel->screen && screen_changed)
117-    {
118-        wl_list_remove(&panel->modifier.link);
119-        screen_update_usable_geometry(panel->screen);
120-    }
121-
122-    panel->screen = screen;
123-    panel->edge = edge;
124-    panel->docked = true;
125-
126-    update_position(panel);
127-    compositor_view_show(panel->view);
128-    wl_list_insert(&screen->modifiers, &panel->modifier.link);
129-
130-    if (focus)
131-        keyboard_set_focus(swc.seat->keyboard, panel->view);
132-
133-    swc_panel_send_docked(resource, length);
134+	struct panel *panel = wl_resource_get_user_data(resource);
135+	struct screen *screen = screen_resource
136+	                            ? wl_resource_get_user_data(screen_resource)
137+	                            : wl_container_of(swc.screens.next, screen, link);
138+	bool screen_changed = screen != panel->screen;
139+	uint32_t length;
140+
141+	switch (edge) {
142+	case SWC_PANEL_EDGE_TOP:
143+	case SWC_PANEL_EDGE_BOTTOM:
144+		length = screen->base.geometry.width;
145+		break;
146+	case SWC_PANEL_EDGE_LEFT:
147+	case SWC_PANEL_EDGE_RIGHT:
148+		length = screen->base.geometry.height;
149+		break;
150+	default:
151+		return;
152+	}
153+
154+	if (panel->screen && screen_changed) {
155+		wl_list_remove(&panel->modifier.link);
156+		screen_update_usable_geometry(panel->screen);
157+	}
158+
159+	panel->screen = screen;
160+	panel->edge = edge;
161+	panel->docked = true;
162+
163+	update_position(panel);
164+	compositor_view_show(panel->view);
165+	wl_list_insert(&screen->modifiers, &panel->modifier.link);
166+
167+	if (focus)
168+		keyboard_set_focus(swc.seat->keyboard, panel->view);
169+
170+	swc_panel_send_docked(resource, length);
171 }
172 
173-static void set_offset(struct wl_client * client, struct wl_resource * resource,
174-                       uint32_t offset)
175+static void
176+set_offset(struct wl_client *client, struct wl_resource *resource,
177+           uint32_t offset)
178 {
179-    struct panel * panel = wl_resource_get_user_data(resource);
180+	struct panel *panel = wl_resource_get_user_data(resource);
181 
182-    panel->offset = offset;
183+	panel->offset = offset;
184 
185-    if (panel->docked)
186-        update_position(panel);
187+	if (panel->docked)
188+		update_position(panel);
189 }
190 
191-static void set_strut(struct wl_client * client, struct wl_resource * resource,
192-                      uint32_t size, uint32_t begin, uint32_t end)
193+static void
194+set_strut(struct wl_client *client, struct wl_resource *resource,
195+          uint32_t size, uint32_t begin, uint32_t end)
196 {
197-    struct panel * panel = wl_resource_get_user_data(resource);
198+	struct panel *panel = wl_resource_get_user_data(resource);
199 
200-    panel->strut_size = size;
201+	panel->strut_size = size;
202 
203-    if (panel->docked)
204-        screen_update_usable_geometry(panel->screen);
205+	if (panel->docked)
206+		screen_update_usable_geometry(panel->screen);
207 }
208 
209 static const struct swc_panel_interface panel_implementation = {
210-    .dock = &dock,
211-    .set_offset = &set_offset,
212-    .set_strut = &set_strut
213+	.dock = &dock,
214+	.set_offset = &set_offset,
215+	.set_strut = &set_strut
216 };
217 
218-static void handle_resize(struct view_handler * handler,
219-                          uint32_t old_width, uint32_t old_height)
220+static void
221+handle_resize(struct view_handler *handler,
222+              uint32_t old_width, uint32_t old_height)
223 {
224-    struct panel * panel = wl_container_of(handler, panel, view_handler);
225+	struct panel *panel = wl_container_of(handler, panel, view_handler);
226 
227-    update_position(panel);
228+	update_position(panel);
229 }
230 
231 static const struct view_handler_impl view_handler_impl = {
232-    .resize = &handle_resize,
233+	.resize = &handle_resize,
234 };
235 
236-static void modify(struct screen_modifier * modifier,
237-                   const struct swc_rectangle * geometry,
238-                   pixman_region32_t * usable)
239+static void
240+modify(struct screen_modifier *modifier,
241+       const struct swc_rectangle *geometry,
242+       pixman_region32_t *usable)
243 {
244-    struct panel * panel = wl_container_of(modifier, panel, modifier);
245-    pixman_box32_t box = {
246-        .x1 = geometry->x, .y1 = geometry->y,
247-        .x2 = geometry->x + geometry->width,
248-        .y2 = geometry->y + geometry->height
249-    };
250-
251-    assert(panel->docked);
252-
253-    DEBUG("Original geometry { x1: %d, y1: %d, x2: %d, y2: %d }\n",
254-          box.x1, box.y1, box.x2, box.y2);
255-
256-    switch (panel->edge)
257-    {
258-        case SWC_PANEL_EDGE_TOP:
259-            box.y1 = MAX(box.y1, geometry->y + panel->strut_size);
260-            break;
261-        case SWC_PANEL_EDGE_BOTTOM:
262-            box.y2 = MIN(box.y2, geometry->y + geometry->height
263-                         - panel->strut_size);
264-            break;
265-        case SWC_PANEL_EDGE_LEFT:
266-            box.x1 = MAX(box.x1, geometry->x + panel->strut_size);
267-            break;
268-        case SWC_PANEL_EDGE_RIGHT:
269-            box.x2 = MIN(box.x2, geometry->x + geometry->width
270-                         - panel->strut_size);
271-            break;
272-    }
273-
274-    DEBUG("Usable region { x1: %d, y1: %d, x2: %d, y2: %d }\n",
275-          box.x1, box.y1, box.x2, box.y2);
276-
277-    pixman_region32_reset(usable, &box);
278+	struct panel *panel = wl_container_of(modifier, panel, modifier);
279+	pixman_box32_t box = {
280+		.x1 = geometry->x, .y1 = geometry->y, .x2 = geometry->x + geometry->width, .y2 = geometry->y + geometry->height
281+	};
282+
283+	assert(panel->docked);
284+
285+	DEBUG("Original geometry { x1: %d, y1: %d, x2: %d, y2: %d }\n",
286+	      box.x1, box.y1, box.x2, box.y2);
287+
288+	switch (panel->edge) {
289+	case SWC_PANEL_EDGE_TOP:
290+		box.y1 = MAX(box.y1, geometry->y + panel->strut_size);
291+		break;
292+	case SWC_PANEL_EDGE_BOTTOM:
293+		box.y2 = MIN(box.y2, geometry->y + geometry->height
294+		                         - panel->strut_size);
295+		break;
296+	case SWC_PANEL_EDGE_LEFT:
297+		box.x1 = MAX(box.x1, geometry->x + panel->strut_size);
298+		break;
299+	case SWC_PANEL_EDGE_RIGHT:
300+		box.x2 = MIN(box.x2, geometry->x + geometry->width
301+		                         - panel->strut_size);
302+		break;
303+	}
304+
305+	DEBUG("Usable region { x1: %d, y1: %d, x2: %d, y2: %d }\n",
306+	      box.x1, box.y1, box.x2, box.y2);
307+
308+	pixman_region32_reset(usable, &box);
309 }
310 
311-static void destroy_panel(struct wl_resource * resource)
312+static void
313+destroy_panel(struct wl_resource *resource)
314 {
315-    struct panel * panel = wl_resource_get_user_data(resource);
316+	struct panel *panel = wl_resource_get_user_data(resource);
317 
318-    if (panel->docked)
319-    {
320-        wl_list_remove(&panel->modifier.link);
321-        screen_update_usable_geometry(panel->screen);
322-    }
323+	if (panel->docked) {
324+		wl_list_remove(&panel->modifier.link);
325+		screen_update_usable_geometry(panel->screen);
326+	}
327 
328-    compositor_view_destroy(panel->view);
329-    free(panel);
330+	compositor_view_destroy(panel->view);
331+	free(panel);
332 }
333 
334-static void handle_surface_destroy(struct wl_listener * listener, void * data)
335+static void
336+handle_surface_destroy(struct wl_listener *listener, void *data)
337 {
338-    struct panel * panel
339-        = wl_container_of(listener, panel, surface_destroy_listener);
340+	struct panel *panel = wl_container_of(listener, panel, surface_destroy_listener);
341 
342-    wl_resource_destroy(panel->resource);
343+	wl_resource_destroy(panel->resource);
344 }
345 
346-struct panel * panel_new(struct wl_client * client, uint32_t version,
347-                         uint32_t id, struct surface * surface)
348+struct panel *
349+panel_new(struct wl_client *client, uint32_t version,
350+          uint32_t id, struct surface *surface)
351 {
352-    struct panel * panel;
353+	struct panel *panel;
354 
355-    panel = malloc(sizeof *panel);
356+	panel = malloc(sizeof *panel);
357 
358-    if (!panel)
359-        goto error0;
360+	if (!panel)
361+		goto error0;
362 
363-    panel->resource = wl_resource_create(client, &swc_panel_interface,
364-                                         version, id);
365+	panel->resource = wl_resource_create(client, &swc_panel_interface,
366+	                                     version, id);
367 
368-    if (!panel->resource)
369-        goto error1;
370+	if (!panel->resource)
371+		goto error1;
372 
373-    if (!(panel->view = compositor_create_view(surface)))
374-        goto error2;
375+	if (!(panel->view = compositor_create_view(surface)))
376+		goto error2;
377 
378-    wl_resource_set_implementation(panel->resource, &panel_implementation,
379-                                   panel, &destroy_panel);
380+	wl_resource_set_implementation(panel->resource, &panel_implementation,
381+	                               panel, &destroy_panel);
382 
383-    panel->surface_destroy_listener.notify = &handle_surface_destroy;
384-    panel->view_handler.impl = &view_handler_impl;
385-    panel->modifier.modify = &modify;
386-    panel->screen = NULL;
387-    panel->offset = 0;
388-    panel->strut_size = 0;
389-    panel->docked = false;
390+	panel->surface_destroy_listener.notify = &handle_surface_destroy;
391+	panel->view_handler.impl = &view_handler_impl;
392+	panel->modifier.modify = &modify;
393+	panel->screen = NULL;
394+	panel->offset = 0;
395+	panel->strut_size = 0;
396+	panel->docked = false;
397 
398-    wl_list_insert(&panel->view->base.handlers, &panel->view_handler.link);
399-    wl_resource_add_destroy_listener(surface->resource,
400-                                     &panel->surface_destroy_listener);
401+	wl_list_insert(&panel->view->base.handlers, &panel->view_handler.link);
402+	wl_resource_add_destroy_listener(surface->resource,
403+	                                 &panel->surface_destroy_listener);
404 
405-    return panel;
406+	return panel;
407 
408-  error2:
409-    wl_resource_destroy(panel->resource);
410-  error1:
411-    free(panel);
412-  error0:
413-    return NULL;
414+error2:
415+	wl_resource_destroy(panel->resource);
416+error1:
417+	free(panel);
418+error0:
419+	return NULL;
420 }
421-
+2, -3
 1@@ -29,8 +29,7 @@
 2 #include <stdbool.h>
 3 #include <wayland-server.h>
 4 
 5-struct panel * panel_new(struct wl_client * client, uint32_t version,
 6-                         uint32_t id, struct surface * surface);
 7+struct panel *panel_new(struct wl_client *client, uint32_t version,
 8+                        uint32_t id, struct surface *surface);
 9 
10 #endif
11-
+31, -28
 1@@ -29,54 +29,57 @@
 2 #include "protocol/swc-server-protocol.h"
 3 
 4 static struct
 5-{
 6-    struct wl_global * global;
 7+    {
 8+	struct wl_global *global;
 9 } panel_manager;
10 
11-static void create_panel(struct wl_client * client,
12-                         struct wl_resource * resource, uint32_t id,
13-                         struct wl_resource * surface_resource)
14+static void
15+create_panel(struct wl_client *client,
16+             struct wl_resource *resource, uint32_t id,
17+             struct wl_resource *surface_resource)
18 {
19-    struct surface * surface = wl_resource_get_user_data(surface_resource);
20+	struct surface *surface = wl_resource_get_user_data(surface_resource);
21 
22-    if (!panel_new(client, wl_resource_get_version(resource), id, surface))
23-        wl_client_post_no_memory(client);
24+	if (!panel_new(client, wl_resource_get_version(resource), id, surface))
25+		wl_client_post_no_memory(client);
26 }
27 
28 static const struct swc_panel_manager_interface panel_manager_implementation = {
29-    .create_panel = &create_panel
30+	.create_panel = &create_panel
31 };
32 
33-static void bind_panel_manager(struct wl_client * client, void * data,
34-                               uint32_t version, uint32_t id)
35+static void
36+bind_panel_manager(struct wl_client *client, void *data,
37+                   uint32_t version, uint32_t id)
38 {
39-    struct wl_resource * resource;
40+	struct wl_resource *resource;
41 
42-    if (version > 1)
43-        version = 1;
44+	if (version > 1)
45+		version = 1;
46 
47-    resource = wl_resource_create(client, &swc_panel_manager_interface,
48-                                  version, id);
49-    wl_resource_set_implementation(resource, &panel_manager_implementation,
50-                                   NULL, NULL);
51+	resource = wl_resource_create(client, &swc_panel_manager_interface,
52+	                              version, id);
53+	wl_resource_set_implementation(resource, &panel_manager_implementation,
54+	                               NULL, NULL);
55 }
56 
57-bool panel_manager_initialize(void)
58+bool
59+panel_manager_initialize(void)
60 {
61-    panel_manager.global = wl_global_create(swc.display,
62-                                            &swc_panel_manager_interface, 1,
63-                                            NULL, &bind_panel_manager);
64+	panel_manager.global = wl_global_create(swc.display,
65+	                                        &swc_panel_manager_interface, 1,
66+	                                        NULL, &bind_panel_manager);
67 
68-    if (!panel_manager.global)
69-        return false;
70+	if (!panel_manager.global)
71+		return false;
72 
73-    return true;
74+	return true;
75 }
76 
77-void panel_manager_finalize(void)
78+void
79+panel_manager_finalize(void)
80 {
81-    wl_global_destroy(panel_manager.global);
82+	wl_global_destroy(panel_manager.global);
83 }
84 
85 // vim: fdm=syntax fo=croql et sw=4 sts=4 ts=8
86-
+0, -1
1@@ -30,4 +30,3 @@ bool panel_manager_initialize(void);
2 void panel_manager_finalize(void);
3 
4 #endif
5-
+292, -298
  1@@ -34,410 +34,404 @@
  2 #include <assert.h>
  3 #include <wld/wld.h>
  4 
  5-static void enter(struct input_focus_handler * handler,
  6-                  struct wl_resource * resource, struct compositor_view * view)
  7+static void
  8+enter(struct input_focus_handler *handler,
  9+      struct wl_resource *resource, struct compositor_view *view)
 10 {
 11-    struct pointer * pointer = wl_container_of(handler, pointer, focus_handler);
 12-    uint32_t serial;
 13-    wl_fixed_t surface_x, surface_y;
 14-
 15-    serial = wl_display_next_serial(swc.display);
 16-    surface_x = pointer->x - wl_fixed_from_int(view->base.geometry.x);
 17-    surface_y = pointer->y - wl_fixed_from_int(view->base.geometry.y);
 18-    wl_pointer_send_enter(resource, serial, view->surface->resource,
 19-                          surface_x, surface_y);
 20+	struct pointer *pointer = wl_container_of(handler, pointer, focus_handler);
 21+	uint32_t serial;
 22+	wl_fixed_t surface_x, surface_y;
 23+
 24+	serial = wl_display_next_serial(swc.display);
 25+	surface_x = pointer->x - wl_fixed_from_int(view->base.geometry.x);
 26+	surface_y = pointer->y - wl_fixed_from_int(view->base.geometry.y);
 27+	wl_pointer_send_enter(resource, serial, view->surface->resource,
 28+	                      surface_x, surface_y);
 29 }
 30 
 31-static void leave(struct input_focus_handler * handler,
 32-                  struct wl_resource * resource, struct compositor_view * view)
 33+static void
 34+leave(struct input_focus_handler *handler,
 35+      struct wl_resource *resource, struct compositor_view *view)
 36 {
 37-    uint32_t serial;
 38+	uint32_t serial;
 39 
 40-    serial = wl_display_next_serial(swc.display);
 41+	serial = wl_display_next_serial(swc.display);
 42 
 43-    wl_pointer_send_leave(resource, serial, view->surface->resource);
 44+	wl_pointer_send_leave(resource, serial, view->surface->resource);
 45 }
 46 
 47-static void handle_cursor_surface_destroy(struct wl_listener * listener,
 48-                                          void * data)
 49+static void
 50+handle_cursor_surface_destroy(struct wl_listener *listener,
 51+                              void *data)
 52 {
 53-    struct pointer * pointer
 54-        = wl_container_of(listener, pointer, cursor.destroy_listener);
 55+	struct pointer *pointer = wl_container_of(listener, pointer, cursor.destroy_listener);
 56 
 57-    view_attach(&pointer->cursor.view, NULL);
 58-    pointer->cursor.surface = NULL;
 59+	view_attach(&pointer->cursor.view, NULL);
 60+	pointer->cursor.surface = NULL;
 61 }
 62 
 63-static bool update(struct view * view)
 64+static bool
 65+update(struct view *view)
 66 {
 67-    return true;
 68+	return true;
 69 }
 70 
 71-static int attach(struct view * view, struct wld_buffer * buffer)
 72+static int
 73+attach(struct view *view, struct wld_buffer *buffer)
 74 {
 75-    struct pointer * pointer = wl_container_of(view, pointer, cursor.view);
 76-    struct surface * surface = pointer->cursor.surface;
 77+	struct pointer *pointer = wl_container_of(view, pointer, cursor.view);
 78+	struct surface *surface = pointer->cursor.surface;
 79 
 80-    if (surface && !pixman_region32_not_empty(&surface->state.damage))
 81-        return 0;
 82+	if (surface && !pixman_region32_not_empty(&surface->state.damage))
 83+		return 0;
 84 
 85-    wld_set_target_buffer(swc.shm->renderer, pointer->cursor.buffer);
 86-    wld_fill_rectangle(swc.shm->renderer, 0x00000000, 0, 0, 64, 64);
 87+	wld_set_target_buffer(swc.shm->renderer, pointer->cursor.buffer);
 88+	wld_fill_rectangle(swc.shm->renderer, 0x00000000, 0, 0, 64, 64);
 89 
 90-    if (buffer)
 91-    {
 92-        wld_copy_rectangle(swc.shm->renderer, buffer, 0, 0, 0, 0,
 93-                           buffer->width, buffer->height);
 94-    }
 95+	if (buffer) {
 96+		wld_copy_rectangle(swc.shm->renderer, buffer, 0, 0, 0, 0,
 97+		                   buffer->width, buffer->height);
 98+	}
 99 
100-    wld_flush(swc.shm->renderer);
101+	wld_flush(swc.shm->renderer);
102 
103-    if (surface)
104-        pixman_region32_clear(&surface->state.damage);
105+	if (surface)
106+		pixman_region32_clear(&surface->state.damage);
107 
108-    /* TODO: Send an early release to the buffer */
109+	/* TODO: Send an early release to the buffer */
110 
111-    if (view_set_size_from_buffer(view, buffer))
112-        view_update_screens(view);
113+	if (view_set_size_from_buffer(view, buffer))
114+		view_update_screens(view);
115 
116-    return 0;
117+	return 0;
118 }
119 
120-static bool move(struct view * view, int32_t x, int32_t y)
121+static bool
122+move(struct view *view, int32_t x, int32_t y)
123 {
124-    struct screen * screen;
125+	struct screen *screen;
126 
127-    if (view_set_position(view, x, y))
128-        view_update_screens(view);
129+	if (view_set_position(view, x, y))
130+		view_update_screens(view);
131 
132-    wl_list_for_each(screen, &swc.screens, link)
133-    {
134-        view_move(&screen->planes.cursor.view,
135-                  view->geometry.x, view->geometry.y);
136-    }
137+	wl_list_for_each (screen, &swc.screens, link) {
138+		view_move(&screen->planes.cursor.view,
139+		          view->geometry.x, view->geometry.y);
140+	}
141 
142-    return true;
143+	return true;
144 }
145 
146 static const struct view_impl view_impl = {
147-    .update = &update,
148-    .attach = &attach,
149-    .move = &move,
150+	.update = &update,
151+	.attach = &attach,
152+	.move = &move,
153 };
154 
155-static inline void update_cursor(struct pointer * pointer)
156+static inline void
157+update_cursor(struct pointer *pointer)
158 {
159-    view_move(&pointer->cursor.view,
160-              wl_fixed_to_int(pointer->x) - pointer->cursor.hotspot.x,
161-              wl_fixed_to_int(pointer->y) - pointer->cursor.hotspot.y);
162+	view_move(&pointer->cursor.view,
163+	          wl_fixed_to_int(pointer->x) - pointer->cursor.hotspot.x,
164+	          wl_fixed_to_int(pointer->y) - pointer->cursor.hotspot.y);
165 }
166 
167-void pointer_set_cursor(struct pointer * pointer, uint32_t id)
168+void
169+pointer_set_cursor(struct pointer *pointer, uint32_t id)
170 {
171-    struct cursor * cursor = &cursor_metadata[id];
172-    union wld_object object = { .ptr = &cursor_data[cursor->offset] };
173-
174-    if (pointer->cursor.internal_buffer)
175-        wld_buffer_unreference(pointer->cursor.internal_buffer);
176-
177-    pointer->cursor.internal_buffer = wld_import_buffer
178-        (swc.shm->context, WLD_OBJECT_DATA, object,
179-         cursor->width, cursor->height, WLD_FORMAT_ARGB8888, cursor->width * 4);
180-
181-    if (!pointer->cursor.internal_buffer)
182-    {
183-        ERROR("Failed to create cursor buffer\n");
184-        return;
185-    }
186-
187-    pointer->cursor.hotspot.x = cursor->hotspot_x;
188-    pointer->cursor.hotspot.y = cursor->hotspot_y;
189-    update_cursor(pointer);
190-    view_attach(&pointer->cursor.view, pointer->cursor.internal_buffer);
191+	struct cursor *cursor = &cursor_metadata[id];
192+	union wld_object object = {.ptr = &cursor_data[cursor->offset] };
193+
194+	if (pointer->cursor.internal_buffer)
195+		wld_buffer_unreference(pointer->cursor.internal_buffer);
196+
197+	pointer->cursor.internal_buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
198+	                                                    cursor->width, cursor->height, WLD_FORMAT_ARGB8888, cursor->width * 4);
199+
200+	if (!pointer->cursor.internal_buffer) {
201+		ERROR("Failed to create cursor buffer\n");
202+		return;
203+	}
204+
205+	pointer->cursor.hotspot.x = cursor->hotspot_x;
206+	pointer->cursor.hotspot.y = cursor->hotspot_y;
207+	update_cursor(pointer);
208+	view_attach(&pointer->cursor.view, pointer->cursor.internal_buffer);
209 }
210 
211-static bool client_handle_button
212-    (struct pointer_handler * handler, uint32_t time,
213-     struct button * button, uint32_t state)
214+static bool
215+client_handle_button(struct pointer_handler *handler, uint32_t time,
216+                     struct button *button, uint32_t state)
217 {
218-    struct pointer * pointer
219-        = wl_container_of(handler, pointer, client_handler);
220+	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
221 
222-    if (!pointer->focus.resource)
223-        return false;
224+	if (!pointer->focus.resource)
225+		return false;
226 
227-    wl_pointer_send_button(pointer->focus.resource, button->press.serial, time,
228-                           button->press.value, state);
229+	wl_pointer_send_button(pointer->focus.resource, button->press.serial, time,
230+	                       button->press.value, state);
231 
232-    return true;
233+	return true;
234 }
235 
236-static bool client_handle_axis(struct pointer_handler * handler,
237-                               uint32_t time, uint32_t axis, wl_fixed_t amount)
238+static bool
239+client_handle_axis(struct pointer_handler *handler,
240+                   uint32_t time, uint32_t axis, wl_fixed_t amount)
241 {
242-    struct pointer * pointer
243-        = wl_container_of(handler, pointer, client_handler);
244+	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
245 
246-    if (!pointer->focus.resource)
247-        return false;
248+	if (!pointer->focus.resource)
249+		return false;
250 
251-    wl_pointer_send_axis(pointer->focus.resource, time, axis, amount);
252+	wl_pointer_send_axis(pointer->focus.resource, time, axis, amount);
253 
254-    return true;
255+	return true;
256 }
257 
258-static bool client_handle_motion(struct pointer_handler * handler,
259-                                 uint32_t time, wl_fixed_t x, wl_fixed_t y)
260+static bool
261+client_handle_motion(struct pointer_handler *handler,
262+                     uint32_t time, wl_fixed_t x, wl_fixed_t y)
263 {
264-    struct pointer * pointer
265-        = wl_container_of(handler, pointer, client_handler);
266+	struct pointer *pointer = wl_container_of(handler, pointer, client_handler);
267 
268-    if (!pointer->focus.resource)
269-        return false;
270+	if (!pointer->focus.resource)
271+		return false;
272 
273-    wl_pointer_send_motion
274-        (pointer->focus.resource, time,
275-         x - wl_fixed_from_int(pointer->focus.view->base.geometry.x),
276-         y - wl_fixed_from_int(pointer->focus.view->base.geometry.y));
277+	wl_pointer_send_motion(pointer->focus.resource, time,
278+	                       x - wl_fixed_from_int(pointer->focus.view->base.geometry.x),
279+	                       y - wl_fixed_from_int(pointer->focus.view->base.geometry.y));
280 
281-    return true;
282+	return true;
283 }
284 
285-bool pointer_initialize(struct pointer * pointer)
286+bool
287+pointer_initialize(struct pointer *pointer)
288 {
289-    struct screen * screen;
290-
291-    /* Center cursor in the geometry of the first screen. */
292-    screen = wl_container_of(swc.screens.next, screen, link);
293-    pointer->x = wl_fixed_from_int
294-        (screen->base.geometry.x + screen->base.geometry.width / 2);
295-    pointer->y = wl_fixed_from_int
296-        (screen->base.geometry.y + screen->base.geometry.height / 2);
297-
298-    pointer->focus_handler.enter = &enter;
299-    pointer->focus_handler.leave = &leave;
300-    pointer->client_handler.button = &client_handle_button;
301-    pointer->client_handler.axis = &client_handle_axis;
302-    pointer->client_handler.motion = &client_handle_motion;
303-    wl_list_init(&pointer->handlers);
304-    wl_list_insert(&pointer->handlers, &pointer->client_handler.link);
305-    wl_array_init(&pointer->buttons);
306-
307-    view_initialize(&pointer->cursor.view, &view_impl);
308-    pointer->cursor.surface = NULL;
309-    pointer->cursor.destroy_listener.notify = &handle_cursor_surface_destroy;
310-    pointer->cursor.buffer = wld_create_buffer
311-        (swc.drm->context, 64, 64, WLD_FORMAT_ARGB8888, WLD_FLAG_MAP);
312-    pointer->cursor.internal_buffer = NULL;
313-
314-    if (!pointer->cursor.buffer)
315-        return false;
316-
317-    pointer_set_cursor(pointer, cursor_left_ptr);
318-
319-    wl_list_for_each(screen, &swc.screens, link)
320-        view_attach(&screen->planes.cursor.view, pointer->cursor.buffer);
321-
322-    input_focus_initialize(&pointer->focus, &pointer->focus_handler);
323-    pixman_region32_init(&pointer->region);
324-
325-    return true;
326+	struct screen *screen;
327+
328+	/* Center cursor in the geometry of the first screen. */
329+	screen = wl_container_of(swc.screens.next, screen, link);
330+	pointer->x = wl_fixed_from_int(screen->base.geometry.x + screen->base.geometry.width / 2);
331+	pointer->y = wl_fixed_from_int(screen->base.geometry.y + screen->base.geometry.height / 2);
332+
333+	pointer->focus_handler.enter = &enter;
334+	pointer->focus_handler.leave = &leave;
335+	pointer->client_handler.button = &client_handle_button;
336+	pointer->client_handler.axis = &client_handle_axis;
337+	pointer->client_handler.motion = &client_handle_motion;
338+	wl_list_init(&pointer->handlers);
339+	wl_list_insert(&pointer->handlers, &pointer->client_handler.link);
340+	wl_array_init(&pointer->buttons);
341+
342+	view_initialize(&pointer->cursor.view, &view_impl);
343+	pointer->cursor.surface = NULL;
344+	pointer->cursor.destroy_listener.notify = &handle_cursor_surface_destroy;
345+	pointer->cursor.buffer = wld_create_buffer(swc.drm->context, 64, 64, WLD_FORMAT_ARGB8888, WLD_FLAG_MAP);
346+	pointer->cursor.internal_buffer = NULL;
347+
348+	if (!pointer->cursor.buffer)
349+		return false;
350+
351+	pointer_set_cursor(pointer, cursor_left_ptr);
352+
353+	wl_list_for_each (screen, &swc.screens, link)
354+		view_attach(&screen->planes.cursor.view, pointer->cursor.buffer);
355+
356+	input_focus_initialize(&pointer->focus, &pointer->focus_handler);
357+	pixman_region32_init(&pointer->region);
358+
359+	return true;
360 }
361 
362-void pointer_finalize(struct pointer * pointer)
363+void
364+pointer_finalize(struct pointer *pointer)
365 {
366-    input_focus_finalize(&pointer->focus);
367-    pixman_region32_fini(&pointer->region);
368+	input_focus_finalize(&pointer->focus);
369+	pixman_region32_fini(&pointer->region);
370 }
371 
372-void pointer_set_focus(struct pointer * pointer, struct compositor_view * view)
373+void
374+pointer_set_focus(struct pointer *pointer, struct compositor_view *view)
375 {
376-    input_focus_set(&pointer->focus, view);
377+	input_focus_set(&pointer->focus, view);
378 }
379 
380-static void clip_position(struct pointer * pointer,
381-                          wl_fixed_t fx, wl_fixed_t fy)
382+static void
383+clip_position(struct pointer *pointer,
384+              wl_fixed_t fx, wl_fixed_t fy)
385 {
386-    int32_t x, y, last_x, last_y;
387-    pixman_box32_t box;
388-
389-    x = wl_fixed_to_int(fx);
390-    y = wl_fixed_to_int(fy);
391-    last_x = wl_fixed_to_int(pointer->x);
392-    last_y = wl_fixed_to_int(pointer->y);
393-
394-    if (!pixman_region32_contains_point(&pointer->region, x, y, NULL))
395-    {
396-        assert(pixman_region32_contains_point(&pointer->region,
397-                                              last_x, last_y, &box));
398-
399-        /* Do some clipping. */
400-        x = MAX(MIN(x, box.x2 - 1), box.x1);
401-        y = MAX(MIN(y, box.y2 - 1), box.y1);
402-    }
403-
404-    pointer->x = wl_fixed_from_int(x);
405-    pointer->y = wl_fixed_from_int(y);
406+	int32_t x, y, last_x, last_y;
407+	pixman_box32_t box;
408+
409+	x = wl_fixed_to_int(fx);
410+	y = wl_fixed_to_int(fy);
411+	last_x = wl_fixed_to_int(pointer->x);
412+	last_y = wl_fixed_to_int(pointer->y);
413+
414+	if (!pixman_region32_contains_point(&pointer->region, x, y, NULL)) {
415+		assert(pixman_region32_contains_point(&pointer->region,
416+		                                      last_x, last_y, &box));
417+
418+		/* Do some clipping. */
419+		x = MAX(MIN(x, box.x2 - 1), box.x1);
420+		y = MAX(MIN(y, box.y2 - 1), box.y1);
421+	}
422+
423+	pointer->x = wl_fixed_from_int(x);
424+	pointer->y = wl_fixed_from_int(y);
425 }
426 
427-void pointer_set_region(struct pointer * pointer, pixman_region32_t * region)
428+void
429+pointer_set_region(struct pointer *pointer, pixman_region32_t *region)
430 {
431-    pixman_region32_copy(&pointer->region, region);
432-    clip_position(pointer, pointer->x, pointer->y);
433+	pixman_region32_copy(&pointer->region, region);
434+	clip_position(pointer, pointer->x, pointer->y);
435 }
436 
437-static void set_cursor(struct wl_client * client,
438-                       struct wl_resource * resource, uint32_t serial,
439-                       struct wl_resource * surface_resource,
440-                       int32_t hotspot_x, int32_t hotspot_y)
441+static void
442+set_cursor(struct wl_client *client,
443+           struct wl_resource *resource, uint32_t serial,
444+           struct wl_resource *surface_resource,
445+           int32_t hotspot_x, int32_t hotspot_y)
446 {
447-    struct pointer * pointer = wl_resource_get_user_data(resource);
448-    struct surface * surface;
449-
450-    if (!pointer->focus.resource || client != wl_resource_get_client(pointer->focus.resource))
451-        return;
452-
453-    if (pointer->cursor.surface)
454-        wl_list_remove(&pointer->cursor.destroy_listener.link);
455-
456-    surface = surface_resource ? wl_resource_get_user_data(surface_resource)
457-                               : NULL;
458-    pointer->cursor.surface = surface;
459-    pointer->cursor.hotspot.x = hotspot_x;
460-    pointer->cursor.hotspot.y = hotspot_y;
461-
462-    if (surface)
463-    {
464-        surface_set_view(surface, &pointer->cursor.view);
465-        wl_resource_add_destroy_listener(surface->resource,
466-                                         &pointer->cursor.destroy_listener);
467-        update_cursor(pointer);
468-    }
469+	struct pointer *pointer = wl_resource_get_user_data(resource);
470+	struct surface *surface;
471+
472+	if (!pointer->focus.resource || client != wl_resource_get_client(pointer->focus.resource))
473+		return;
474+
475+	if (pointer->cursor.surface)
476+		wl_list_remove(&pointer->cursor.destroy_listener.link);
477+
478+	surface = surface_resource ? wl_resource_get_user_data(surface_resource)
479+	                           : NULL;
480+	pointer->cursor.surface = surface;
481+	pointer->cursor.hotspot.x = hotspot_x;
482+	pointer->cursor.hotspot.y = hotspot_y;
483+
484+	if (surface) {
485+		surface_set_view(surface, &pointer->cursor.view);
486+		wl_resource_add_destroy_listener(surface->resource,
487+		                                 &pointer->cursor.destroy_listener);
488+		update_cursor(pointer);
489+	}
490 }
491 
492-static void release(struct wl_client * client, struct wl_resource * resource)
493+static void
494+release(struct wl_client *client, struct wl_resource *resource)
495 {
496-    wl_resource_destroy(resource);
497+	wl_resource_destroy(resource);
498 }
499 
500 static struct wl_pointer_interface pointer_implementation = {
501-    .set_cursor = &set_cursor,
502-    .release = &release,
503+	.set_cursor = &set_cursor,
504+	.release = &release,
505 };
506 
507-static void unbind(struct wl_resource * resource)
508+static void
509+unbind(struct wl_resource *resource)
510 {
511-    struct pointer * pointer = wl_resource_get_user_data(resource);
512+	struct pointer *pointer = wl_resource_get_user_data(resource);
513 
514-    input_focus_remove_resource(&pointer->focus, resource);
515+	input_focus_remove_resource(&pointer->focus, resource);
516 }
517 
518-struct wl_resource * pointer_bind(struct pointer * pointer,
519-                                  struct wl_client * client,
520-                                  uint32_t version, uint32_t id)
521+struct wl_resource *
522+pointer_bind(struct pointer *pointer,
523+             struct wl_client *client,
524+             uint32_t version, uint32_t id)
525 {
526-    struct wl_resource * client_resource;
527+	struct wl_resource *client_resource;
528 
529-    client_resource = wl_resource_create(client, &wl_pointer_interface,
530-                                         version, id);
531-    wl_resource_set_implementation(client_resource, &pointer_implementation,
532-                                   pointer, &unbind);
533-    input_focus_add_resource(&pointer->focus, client_resource);
534+	client_resource = wl_resource_create(client, &wl_pointer_interface,
535+	                                     version, id);
536+	wl_resource_set_implementation(client_resource, &pointer_implementation,
537+	                               pointer, &unbind);
538+	input_focus_add_resource(&pointer->focus, client_resource);
539 
540-    return client_resource;
541+	return client_resource;
542 }
543 
544-struct button * pointer_get_button(struct pointer * pointer, uint32_t serial)
545+struct button *
546+pointer_get_button(struct pointer *pointer, uint32_t serial)
547 {
548-    struct button * button;
549+	struct button *button;
550 
551-    wl_array_for_each(button, &pointer->buttons)
552-    {
553-        if (button->press.serial == serial)
554-            return button;
555-    }
556+	wl_array_for_each (button, &pointer->buttons) {
557+		if (button->press.serial == serial)
558+			return button;
559+	}
560 
561-    return NULL;
562+	return NULL;
563 }
564 
565-void pointer_handle_button(struct pointer * pointer, uint32_t time,
566-                           uint32_t value, uint32_t state)
567+void
568+pointer_handle_button(struct pointer *pointer, uint32_t time,
569+                      uint32_t value, uint32_t state)
570 {
571-    struct pointer_handler * handler;
572-    struct button * button;
573-    uint32_t serial;
574-
575-    serial = wl_display_next_serial(swc.display);
576-
577-    if (state == WL_POINTER_BUTTON_STATE_RELEASED)
578-    {
579-        wl_array_for_each(button, &pointer->buttons)
580-        {
581-            if (button->press.value == value)
582-            {
583-                if (button->handler)
584-                {
585-                    button->press.serial = serial;
586-                    button->handler->button(button->handler, time,
587-                                            button, state);
588-                }
589-
590-                array_remove(&pointer->buttons, button, sizeof *button);
591-                break;
592-            }
593-        }
594-    }
595-    else
596-    {
597-        button = wl_array_add(&pointer->buttons, sizeof *button);
598-
599-        if (!button)
600-            return;
601-
602-        button->press.value = value;
603-        button->press.serial = serial;
604-        button->handler = NULL;
605-
606-        wl_list_for_each(handler, &pointer->handlers, link)
607-        {
608-            if (handler->button && handler->button(handler, time,
609-                                                   button, state))
610-            {
611-                button->handler = handler;
612-                break;
613-            }
614-        }
615-    }
616+	struct pointer_handler *handler;
617+	struct button *button;
618+	uint32_t serial;
619+
620+	serial = wl_display_next_serial(swc.display);
621+
622+	if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
623+		wl_array_for_each (button, &pointer->buttons) {
624+			if (button->press.value == value) {
625+				if (button->handler) {
626+					button->press.serial = serial;
627+					button->handler->button(button->handler, time,
628+					                        button, state);
629+				}
630+
631+				array_remove(&pointer->buttons, button, sizeof *button);
632+				break;
633+			}
634+		}
635+	} else {
636+		button = wl_array_add(&pointer->buttons, sizeof *button);
637+
638+		if (!button)
639+			return;
640+
641+		button->press.value = value;
642+		button->press.serial = serial;
643+		button->handler = NULL;
644+
645+		wl_list_for_each (handler, &pointer->handlers, link) {
646+			if (handler->button && handler->button(handler, time, button, state)) {
647+				button->handler = handler;
648+				break;
649+			}
650+		}
651+	}
652 }
653 
654-void pointer_handle_axis(struct pointer * pointer, uint32_t time,
655-                         uint32_t axis, wl_fixed_t amount)
656+void
657+pointer_handle_axis(struct pointer *pointer, uint32_t time,
658+                    uint32_t axis, wl_fixed_t amount)
659 {
660-    struct pointer_handler * handler;
661+	struct pointer_handler *handler;
662 
663-    wl_list_for_each(handler, &pointer->handlers, link)
664-    {
665-        if (handler->axis && handler->axis(handler, time, axis, amount))
666-            break;
667-    }
668+	wl_list_for_each (handler, &pointer->handlers, link) {
669+		if (handler->axis && handler->axis(handler, time, axis, amount))
670+			break;
671+	}
672 }
673 
674-void pointer_handle_relative_motion(struct pointer * pointer, uint32_t time,
675-                                    wl_fixed_t dx, wl_fixed_t dy)
676+void
677+pointer_handle_relative_motion(struct pointer *pointer, uint32_t time,
678+                               wl_fixed_t dx, wl_fixed_t dy)
679 {
680-    struct pointer_handler * handler;
681+	struct pointer_handler *handler;
682 
683-    clip_position(pointer, pointer->x + dx, pointer->y + dy);
684+	clip_position(pointer, pointer->x + dx, pointer->y + dy);
685 
686-    wl_list_for_each(handler, &pointer->handlers, link)
687-    {
688-        if (handler->motion && handler->motion(handler, time,
689-                                               pointer->x, pointer->y))
690-        {
691-            break;
692-        }
693-    }
694+	wl_list_for_each (handler, &pointer->handlers, link) {
695+		if (handler->motion && handler->motion(handler, time, pointer->x, pointer->y)) {
696+			break;
697+		}
698+	}
699 
700-    update_cursor(pointer);
701+	update_cursor(pointer);
702 }
703-
+49, -53
  1@@ -31,70 +31,66 @@
  2 #include <wayland-server.h>
  3 #include <pixman.h>
  4 
  5-struct button
  6-{
  7-    struct press press;
  8-    struct pointer_handler * handler;
  9+struct button {
 10+	struct press press;
 11+	struct pointer_handler *handler;
 12 };
 13 
 14-struct pointer_handler
 15-{
 16-    bool (* motion)(struct pointer_handler * handler, uint32_t time,
 17-                    wl_fixed_t x, wl_fixed_t y);
 18-    bool (* button)(struct pointer_handler * handler, uint32_t time,
 19-                    struct button * button, uint32_t state);
 20-    bool (* axis)(struct pointer_handler * handler, uint32_t time,
 21-                  enum wl_pointer_axis axis, wl_fixed_t amount);
 22+struct pointer_handler {
 23+	bool (*motion)(struct pointer_handler *handler, uint32_t time,
 24+	               wl_fixed_t x, wl_fixed_t y);
 25+	bool (*button)(struct pointer_handler *handler, uint32_t time,
 26+	               struct button *button, uint32_t state);
 27+	bool (*axis)(struct pointer_handler *handler, uint32_t time,
 28+	             enum wl_pointer_axis axis, wl_fixed_t amount);
 29 
 30-    struct wl_list link;
 31+	struct wl_list link;
 32 };
 33 
 34-struct pointer
 35-{
 36-    struct input_focus focus;
 37-    struct input_focus_handler focus_handler;
 38-
 39-    struct
 40-    {
 41-        struct view view;
 42-        struct surface * surface;
 43-        struct wl_listener destroy_listener;
 44-        struct wld_buffer * buffer;
 45-
 46-        /* Used for cursors set with pointer_set_cursor */
 47-        struct wld_buffer * internal_buffer;
 48-
 49-        struct
 50-        {
 51-            int32_t x, y;
 52-        } hotspot;
 53-    } cursor;
 54-
 55-    struct wl_array buttons;
 56-    struct wl_list handlers;
 57-    struct pointer_handler client_handler;
 58-
 59-    wl_fixed_t x, y;
 60-    pixman_region32_t region;
 61+struct pointer {
 62+	struct input_focus focus;
 63+	struct input_focus_handler focus_handler;
 64+
 65+	struct
 66+	    {
 67+		struct view view;
 68+		struct surface *surface;
 69+		struct wl_listener destroy_listener;
 70+		struct wld_buffer *buffer;
 71+
 72+		/* Used for cursors set with pointer_set_cursor */
 73+		struct wld_buffer *internal_buffer;
 74+
 75+		struct
 76+		    {
 77+			int32_t x, y;
 78+		} hotspot;
 79+	} cursor;
 80+
 81+	struct wl_array buttons;
 82+	struct wl_list handlers;
 83+	struct pointer_handler client_handler;
 84+
 85+	wl_fixed_t x, y;
 86+	pixman_region32_t region;
 87 };
 88 
 89-bool pointer_initialize(struct pointer * pointer);
 90-void pointer_finalize(struct pointer * pointer);
 91-void pointer_set_focus(struct pointer * pointer, struct compositor_view * view);
 92-void pointer_set_region(struct pointer * pointer, pixman_region32_t * region);
 93-void pointer_set_cursor(struct pointer * pointer, uint32_t id);
 94+bool pointer_initialize(struct pointer *pointer);
 95+void pointer_finalize(struct pointer *pointer);
 96+void pointer_set_focus(struct pointer *pointer, struct compositor_view *view);
 97+void pointer_set_region(struct pointer *pointer, pixman_region32_t *region);
 98+void pointer_set_cursor(struct pointer *pointer, uint32_t id);
 99 
100-struct button * pointer_get_button(struct pointer * pointer, uint32_t serial);
101+struct button *pointer_get_button(struct pointer *pointer, uint32_t serial);
102 
103-struct wl_resource * pointer_bind(struct pointer * pointer,
104-                                  struct wl_client * client,
105-                                  uint32_t version, uint32_t id);
106-void pointer_handle_button(struct pointer * pointer, uint32_t time,
107+struct wl_resource *pointer_bind(struct pointer *pointer,
108+                                 struct wl_client *client,
109+                                 uint32_t version, uint32_t id);
110+void pointer_handle_button(struct pointer *pointer, uint32_t time,
111                            uint32_t button, uint32_t state);
112-void pointer_handle_axis(struct pointer * pointer, uint32_t time,
113+void pointer_handle_axis(struct pointer *pointer, uint32_t time,
114                          uint32_t axis, wl_fixed_t amount);
115-void pointer_handle_relative_motion(struct pointer * pointer, uint32_t time,
116+void pointer_handle_relative_motion(struct pointer *pointer, uint32_t time,
117                                     wl_fixed_t dx, wl_fixed_t dy);
118 
119 #endif
120-
+40, -36
  1@@ -3,65 +3,69 @@
  2 #include <stdlib.h>
  3 #include <wayland-server.h>
  4 
  5-static void destroy(struct wl_client * client, struct wl_resource * resource)
  6+static void
  7+destroy(struct wl_client *client, struct wl_resource *resource)
  8 {
  9-    wl_resource_destroy(resource);
 10+	wl_resource_destroy(resource);
 11 }
 12 
 13-static void add(struct wl_client * client, struct wl_resource * resource,
 14-                int32_t x, int32_t y, int32_t width, int32_t height)
 15+static void
 16+add(struct wl_client *client, struct wl_resource *resource,
 17+    int32_t x, int32_t y, int32_t width, int32_t height)
 18 {
 19-    struct region * region = wl_resource_get_user_data(resource);
 20+	struct region *region = wl_resource_get_user_data(resource);
 21 
 22-    pixman_region32_union_rect(&region->region, &region->region,
 23-                               x, y, width, height);
 24+	pixman_region32_union_rect(&region->region, &region->region,
 25+	                           x, y, width, height);
 26 }
 27 
 28-static void subtract(struct wl_client * client, struct wl_resource * resource,
 29-                     int32_t x, int32_t y, int32_t width, int32_t height)
 30+static void
 31+subtract(struct wl_client *client, struct wl_resource *resource,
 32+         int32_t x, int32_t y, int32_t width, int32_t height)
 33 {
 34-    struct region * region = wl_resource_get_user_data(resource);
 35-    pixman_region32_t operand;
 36+	struct region *region = wl_resource_get_user_data(resource);
 37+	pixman_region32_t operand;
 38 
 39-    pixman_region32_init_rect(&operand, x, y, width, height);
 40-    pixman_region32_subtract(&region->region, &region->region, &operand);
 41+	pixman_region32_init_rect(&operand, x, y, width, height);
 42+	pixman_region32_subtract(&region->region, &region->region, &operand);
 43 }
 44 
 45 static const struct wl_region_interface region_implementation = {
 46-    .destroy = &destroy,
 47-    .add = &add,
 48-    .subtract = &subtract
 49+	.destroy = &destroy,
 50+	.add = &add,
 51+	.subtract = &subtract
 52 };
 53 
 54-static void region_destroy(struct wl_resource * resource)
 55+static void
 56+region_destroy(struct wl_resource *resource)
 57 {
 58-    struct region * region = wl_resource_get_user_data(resource);
 59+	struct region *region = wl_resource_get_user_data(resource);
 60 
 61-    /* Finish the region. */
 62-    pixman_region32_fini(&region->region);
 63+	/* Finish the region. */
 64+	pixman_region32_fini(&region->region);
 65 
 66-    free(region);
 67+	free(region);
 68 }
 69 
 70-struct region * region_new(struct wl_client * client,
 71-                           uint32_t version, uint32_t id)
 72+struct region *
 73+region_new(struct wl_client *client,
 74+           uint32_t version, uint32_t id)
 75 {
 76-    struct region * region;
 77+	struct region *region;
 78 
 79-    region = malloc(sizeof *region);
 80+	region = malloc(sizeof *region);
 81 
 82-    if (!region)
 83-        return NULL;
 84+	if (!region)
 85+		return NULL;
 86 
 87-    /* Initialize the region. */
 88-    pixman_region32_init(&region->region);
 89+	/* Initialize the region. */
 90+	pixman_region32_init(&region->region);
 91 
 92-    /* Add the region to the client. */
 93-    region->resource = wl_resource_create(client, &wl_region_interface,
 94-                                          version, id);
 95-    wl_resource_set_implementation(region->resource, &region_implementation,
 96-                                   region, &region_destroy);
 97+	/* Add the region to the client. */
 98+	region->resource = wl_resource_create(client, &wl_region_interface,
 99+	                                      version, id);
100+	wl_resource_set_implementation(region->resource, &region_implementation,
101+	                               region, &region_destroy);
102 
103-    return region;
104+	return region;
105 }
106-
+5, -7
 1@@ -6,14 +6,12 @@
 2 
 3 struct wl_client;
 4 
 5-struct region
 6-{
 7-    struct wl_resource * resource;
 8-    pixman_region32_t region;
 9+struct region {
10+	struct wl_resource *resource;
11+	pixman_region32_t region;
12 };
13 
14-struct region * region_new(struct wl_client * client,
15-                           uint32_t version, uint32_t id);
16+struct region *region_new(struct wl_client *client,
17+                          uint32_t version, uint32_t id);
18 
19 #endif
20-
+160, -162
  1@@ -34,206 +34,204 @@
  2 #include <stdlib.h>
  3 #include <sys/param.h>
  4 
  5-#define INTERNAL(s) ((struct screen *) (s))
  6+#define INTERNAL(s) ((struct screen *)(s))
  7 
  8-static struct screen * active_screen;
  9+static struct screen *active_screen;
 10 static const struct swc_screen_handler null_handler;
 11 
 12-static bool handle_motion(struct pointer_handler * handler, uint32_t time,
 13+static bool handle_motion(struct pointer_handler *handler, uint32_t time,
 14                           wl_fixed_t x, wl_fixed_t y);
 15 
 16 struct pointer_handler screens_pointer_handler = {
 17-    .motion = &handle_motion
 18+	.motion = &handle_motion
 19 };
 20 
 21 EXPORT
 22-void swc_screen_set_handler(struct swc_screen * base,
 23-                            const struct swc_screen_handler * handler,
 24-                            void * data)
 25+void
 26+swc_screen_set_handler(struct swc_screen *base,
 27+                       const struct swc_screen_handler *handler,
 28+                       void *data)
 29 {
 30-    struct screen * screen = INTERNAL(base);
 31+	struct screen *screen = INTERNAL(base);
 32 
 33-    screen->handler = handler;
 34-    screen->handler_data = data;
 35+	screen->handler = handler;
 36+	screen->handler_data = data;
 37 }
 38 
 39-bool screens_initialize(void)
 40+bool
 41+screens_initialize(void)
 42 {
 43-    wl_list_init(&swc.screens);
 44+	wl_list_init(&swc.screens);
 45 
 46-    if (!drm_create_screens(&swc.screens))
 47-        return false;
 48+	if (!drm_create_screens(&swc.screens))
 49+		return false;
 50 
 51-    if (wl_list_empty(&swc.screens))
 52-        return false;
 53+	if (wl_list_empty(&swc.screens))
 54+		return false;
 55 
 56-    return true;
 57+	return true;
 58 }
 59 
 60-void screens_finalize(void)
 61+void
 62+screens_finalize(void)
 63 {
 64-    struct screen * screen, * tmp;
 65+	struct screen *screen, *tmp;
 66 
 67-    wl_list_for_each_safe(screen, tmp, &swc.screens, link)
 68-        screen_destroy(screen);
 69+	wl_list_for_each_safe (screen, tmp, &swc.screens, link)
 70+		screen_destroy(screen);
 71 }
 72 
 73-static void bind_screen(struct wl_client * client, void * data,
 74-                        uint32_t version, uint32_t id)
 75+static void
 76+bind_screen(struct wl_client *client, void *data,
 77+            uint32_t version, uint32_t id)
 78 {
 79-    struct screen * screen = data;
 80-    struct wl_resource * resource;
 81+	struct screen *screen = data;
 82+	struct wl_resource *resource;
 83 
 84-    if (version > 1)
 85-        version = 1;
 86+	if (version > 1)
 87+		version = 1;
 88 
 89-    resource = wl_resource_create(client, &swc_screen_interface, version, id);
 90+	resource = wl_resource_create(client, &swc_screen_interface, version, id);
 91 
 92-    if (!resource)
 93-    {
 94-        wl_client_post_no_memory(client);
 95-        return;
 96-    }
 97+	if (!resource) {
 98+		wl_client_post_no_memory(client);
 99+		return;
100+	}
101 
102-    wl_resource_set_implementation(resource, NULL, screen, &remove_resource);
103-    wl_list_insert(&screen->resources, wl_resource_get_link(resource));
104+	wl_resource_set_implementation(resource, NULL, screen, &remove_resource);
105+	wl_list_insert(&screen->resources, wl_resource_get_link(resource));
106 }
107 
108-struct screen * screen_new(uint32_t crtc, struct output * output)
109+struct screen *
110+screen_new(uint32_t crtc, struct output *output)
111 {
112-    struct screen * screen;
113-    int32_t x = 0;
114-
115-    /* Simple heuristic for initial screen positioning. */
116-    wl_list_for_each(screen, &swc.screens, link)
117-        x = MAX(x, screen->base.geometry.x + screen->base.geometry.width);
118-
119-    if (!(screen = malloc(sizeof *screen)))
120-        goto error0;
121-
122-    screen->global = wl_global_create(swc.display, &swc_screen_interface, 1,
123-                                      screen, &bind_screen);
124-
125-    if (!screen->global)
126-    {
127-        ERROR("Failed to create screen global\n");
128-        goto error1;
129-    }
130-
131-    if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc,
132-                                      output->preferred_mode,
133-                                      &output->connector, 1))
134-    {
135-        ERROR("Failed to initialize framebuffer plane\n");
136-        goto error2;
137-    }
138-
139-    if (!cursor_plane_initialize(&screen->planes.cursor, crtc,
140-                                 &screen->base.geometry))
141-    {
142-        ERROR("Failed to initialize cursor plane\n");
143-        goto error3;
144-    }
145-
146-    screen->handler = &null_handler;
147-    wl_signal_init(&screen->destroy_signal);
148-    wl_list_init(&screen->resources);
149-    wl_list_init(&screen->outputs);
150-    wl_list_insert(&screen->outputs, &output->link);
151-    wl_list_init(&screen->modifiers);
152-
153-    view_move(&screen->planes.framebuffer.view, x, 0);
154-    screen->base.geometry = screen->planes.framebuffer.view.geometry;
155-    screen->base.usable_geometry = screen->base.geometry;
156-
157-    swc.manager->new_screen(&screen->base);
158-
159-    return screen;
160-
161-  error3:
162-    framebuffer_plane_finalize(&screen->planes.framebuffer);
163-  error2:
164-    wl_global_destroy(screen->global);
165-  error1:
166-    free(screen);
167-  error0:
168-    return NULL;
169+	struct screen *screen;
170+	int32_t x = 0;
171+
172+	/* Simple heuristic for initial screen positioning. */
173+	wl_list_for_each (screen, &swc.screens, link)
174+		x = MAX(x, screen->base.geometry.x + screen->base.geometry.width);
175+
176+	if (!(screen = malloc(sizeof *screen)))
177+		goto error0;
178+
179+	screen->global = wl_global_create(swc.display, &swc_screen_interface, 1,
180+	                                  screen, &bind_screen);
181+
182+	if (!screen->global) {
183+		ERROR("Failed to create screen global\n");
184+		goto error1;
185+	}
186+
187+	if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc,
188+	                                  output->preferred_mode,
189+	                                  &output->connector, 1)) {
190+		ERROR("Failed to initialize framebuffer plane\n");
191+		goto error2;
192+	}
193+
194+	if (!cursor_plane_initialize(&screen->planes.cursor, crtc,
195+	                             &screen->base.geometry)) {
196+		ERROR("Failed to initialize cursor plane\n");
197+		goto error3;
198+	}
199+
200+	screen->handler = &null_handler;
201+	wl_signal_init(&screen->destroy_signal);
202+	wl_list_init(&screen->resources);
203+	wl_list_init(&screen->outputs);
204+	wl_list_insert(&screen->outputs, &output->link);
205+	wl_list_init(&screen->modifiers);
206+
207+	view_move(&screen->planes.framebuffer.view, x, 0);
208+	screen->base.geometry = screen->planes.framebuffer.view.geometry;
209+	screen->base.usable_geometry = screen->base.geometry;
210+
211+	swc.manager->new_screen(&screen->base);
212+
213+	return screen;
214+
215+error3:
216+	framebuffer_plane_finalize(&screen->planes.framebuffer);
217+error2:
218+	wl_global_destroy(screen->global);
219+error1:
220+	free(screen);
221+error0:
222+	return NULL;
223 }
224 
225-void screen_destroy(struct screen * screen)
226+void
227+screen_destroy(struct screen *screen)
228 {
229-    struct output * output, * next;
230-
231-    if (active_screen == screen)
232-        active_screen = NULL;
233-    if (screen->handler->destroy)
234-        screen->handler->destroy(screen->handler_data);
235-    wl_signal_emit(&screen->destroy_signal, NULL);
236-    wl_list_for_each_safe(output, next, &screen->outputs, link)
237-        output_destroy(output);
238-    framebuffer_plane_finalize(&screen->planes.framebuffer);
239-    cursor_plane_finalize(&screen->planes.cursor);
240-    free(screen);
241+	struct output *output, *next;
242+
243+	if (active_screen == screen)
244+		active_screen = NULL;
245+	if (screen->handler->destroy)
246+		screen->handler->destroy(screen->handler_data);
247+	wl_signal_emit(&screen->destroy_signal, NULL);
248+	wl_list_for_each_safe (output, next, &screen->outputs, link)
249+		output_destroy(output);
250+	framebuffer_plane_finalize(&screen->planes.framebuffer);
251+	cursor_plane_finalize(&screen->planes.cursor);
252+	free(screen);
253 }
254 
255-void screen_update_usable_geometry(struct screen * screen)
256+void
257+screen_update_usable_geometry(struct screen *screen)
258 {
259-    pixman_region32_t total_usable, usable;
260-    pixman_box32_t * extents;
261-    struct screen_modifier * modifier;
262-
263-    DEBUG("Updating usable geometry\n");
264-
265-    pixman_region32_init_rect(&total_usable,
266-                              screen->base.geometry.x, screen->base.geometry.y,
267-                              screen->base.geometry.width,
268-                              screen->base.geometry.height);
269-    pixman_region32_init(&usable);
270-
271-    wl_list_for_each(modifier, &screen->modifiers, link)
272-    {
273-        modifier->modify(modifier, &screen->base.geometry, &usable);
274-        pixman_region32_intersect(&total_usable, &total_usable, &usable);
275-    }
276-
277-    extents = pixman_region32_extents(&total_usable);
278-
279-    if (extents->x1 != screen->base.usable_geometry.x
280-        || extents->y1 != screen->base.usable_geometry.y
281-        || (extents->x2 - extents->x1) != screen->base.usable_geometry.width
282-        || (extents->y2 - extents->y1) != screen->base.usable_geometry.height)
283-    {
284-        screen->base.usable_geometry.x = extents->x1;
285-        screen->base.usable_geometry.y = extents->y1;
286-        screen->base.usable_geometry.width = extents->x2 - extents->x1;
287-        screen->base.usable_geometry.height = extents->y2 - extents->y1;
288-
289-        if (screen->handler->usable_geometry_changed)
290-            screen->handler->usable_geometry_changed(screen->handler_data);
291-    }
292+	pixman_region32_t total_usable, usable;
293+	pixman_box32_t *extents;
294+	struct screen_modifier *modifier;
295+
296+	DEBUG("Updating usable geometry\n");
297+
298+	pixman_region32_init_rect(&total_usable,
299+	                          screen->base.geometry.x, screen->base.geometry.y,
300+	                          screen->base.geometry.width,
301+	                          screen->base.geometry.height);
302+	pixman_region32_init(&usable);
303+
304+	wl_list_for_each (modifier, &screen->modifiers, link) {
305+		modifier->modify(modifier, &screen->base.geometry, &usable);
306+		pixman_region32_intersect(&total_usable, &total_usable, &usable);
307+	}
308+
309+	extents = pixman_region32_extents(&total_usable);
310+
311+	if (extents->x1 != screen->base.usable_geometry.x
312+	    || extents->y1 != screen->base.usable_geometry.y
313+	    || (extents->x2 - extents->x1) != screen->base.usable_geometry.width
314+	    || (extents->y2 - extents->y1) != screen->base.usable_geometry.height) {
315+		screen->base.usable_geometry.x = extents->x1;
316+		screen->base.usable_geometry.y = extents->y1;
317+		screen->base.usable_geometry.width = extents->x2 - extents->x1;
318+		screen->base.usable_geometry.height = extents->y2 - extents->y1;
319+
320+		if (screen->handler->usable_geometry_changed)
321+			screen->handler->usable_geometry_changed(screen->handler_data);
322+	}
323 }
324 
325-bool handle_motion(struct pointer_handler * handler, uint32_t time,
326-                   wl_fixed_t fx, wl_fixed_t fy)
327+bool
328+handle_motion(struct pointer_handler *handler, uint32_t time,
329+              wl_fixed_t fx, wl_fixed_t fy)
330 {
331-    struct screen * screen;
332-    int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
333-
334-    wl_list_for_each(screen, &swc.screens, link)
335-    {
336-        if (rectangle_contains_point(&screen->base.geometry, x, y))
337-        {
338-            if (screen != active_screen)
339-            {
340-                active_screen = screen;
341-
342-                if (screen->handler->entered)
343-                    screen->handler->entered(screen->handler_data);
344-            }
345-            break;
346-        }
347-    }
348-
349-    return false;
350+	struct screen *screen;
351+	int32_t x = wl_fixed_to_int(fx), y = wl_fixed_to_int(fy);
352+
353+	wl_list_for_each (screen, &swc.screens, link) {
354+		if (rectangle_contains_point(&screen->base.geometry, x, y)) {
355+			if (screen != active_screen) {
356+				active_screen = screen;
357+
358+				if (screen->handler->entered)
359+					screen->handler->entered(screen->handler_data);
360+			}
361+			break;
362+		}
363+	}
364+
365+	return false;
366 }
367-
+28, -30
 1@@ -33,54 +33,52 @@
 2 struct output;
 3 struct pixman_region32;
 4 
 5-struct screen_modifier
 6-{
 7-    /**
 8+struct screen_modifier {
 9+	/**
10      * Takes the screen geometry and sets 'usable' to the usable region of the
11      * screen. 'usable' is an already initialized pixman region.
12      */
13-    void (* modify)(struct screen_modifier * modifier,
14-                    const struct swc_rectangle * geometry,
15-                    struct pixman_region32 * usable);
16+	void (*modify)(struct screen_modifier *modifier,
17+	               const struct swc_rectangle *geometry,
18+	               struct pixman_region32 *usable);
19 
20-    struct wl_list link;
21+	struct wl_list link;
22 };
23 
24-struct screen
25-{
26-    struct swc_screen base;
27-    const struct swc_screen_handler * handler;
28-    void * handler_data;
29+struct screen {
30+	struct swc_screen base;
31+	const struct swc_screen_handler *handler;
32+	void *handler_data;
33 
34-    struct wl_signal destroy_signal;
35-    uint8_t id;
36+	struct wl_signal destroy_signal;
37+	uint8_t id;
38 
39-    struct
40-    {
41-        struct framebuffer_plane framebuffer;
42-        struct cursor_plane cursor;
43-    } planes;
44+	struct
45+	    {
46+		struct framebuffer_plane framebuffer;
47+		struct cursor_plane cursor;
48+	} planes;
49 
50-    struct wl_global * global;
51-    struct wl_list resources;
52+	struct wl_global *global;
53+	struct wl_list resources;
54 
55-    struct wl_list outputs;
56-    struct wl_list modifiers;
57-    struct wl_list link;
58+	struct wl_list outputs;
59+	struct wl_list modifiers;
60+	struct wl_list link;
61 };
62 
63 bool screens_initialize(void);
64 void screens_finalize(void);
65 
66-struct screen * screen_new(uint32_t crtc, struct output * output);
67-void screen_destroy(struct screen * screen);
68+struct screen *screen_new(uint32_t crtc, struct output *output);
69+void screen_destroy(struct screen *screen);
70 
71-static inline uint32_t screen_mask(struct screen * screen)
72+static inline uint32_t
73+screen_mask(struct screen *screen)
74 {
75-    return 1 << screen->id;
76+	return 1 << screen->id;
77 }
78 
79-void screen_update_usable_geometry(struct screen * screen);
80+void screen_update_usable_geometry(struct screen *screen);
81 
82 #endif
83-
+347, -357
  1@@ -39,509 +39,499 @@
  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-    char * name;
 14-    uint32_t capabilities;
 15+    {
 16+	char *name;
 17+	uint32_t capabilities;
 18 
 19 #ifdef ENABLE_LIBINPUT
 20-    struct udev * udev;
 21-    struct libinput * libinput;
 22-    struct wl_event_source * libinput_source;
 23+	struct udev *udev;
 24+	struct libinput *libinput;
 25+	struct wl_event_source *libinput_source;
 26 #else
 27-    struct wl_list devices;
 28+	struct wl_list devices;
 29 #endif
 30 
 31-    struct wl_listener swc_listener;
 32+	struct wl_listener swc_listener;
 33 
 34-    struct keyboard keyboard;
 35-    struct pointer pointer;
 36-    struct data_device data_device;
 37+	struct keyboard keyboard;
 38+	struct pointer pointer;
 39+	struct data_device data_device;
 40 
 41-    struct wl_global * global;
 42-    struct wl_list resources;
 43+	struct wl_global *global;
 44+	struct wl_list resources;
 45 } seat;
 46 
 47 const struct swc_seat swc_seat = {
 48-    .pointer = &seat.pointer,
 49-    .keyboard = &seat.keyboard,
 50-    .data_device = &seat.data_device
 51+	.pointer = &seat.pointer,
 52+	.keyboard = &seat.keyboard,
 53+	.data_device = &seat.data_device
 54 };
 55 
 56-static void handle_key(uint32_t time, uint32_t key, uint32_t state)
 57+static void
 58+handle_key(uint32_t time, uint32_t key, uint32_t state)
 59 {
 60-    keyboard_handle_key(&seat.keyboard, time, key, state);
 61+	keyboard_handle_key(&seat.keyboard, time, key, state);
 62 }
 63 
 64-static void handle_button(uint32_t time, uint32_t button, uint32_t state)
 65+static void
 66+handle_button(uint32_t time, uint32_t button, uint32_t state)
 67 {
 68-    pointer_handle_button(&seat.pointer, time, button, state);
 69+	pointer_handle_button(&seat.pointer, time, button, state);
 70 }
 71 
 72-static void handle_axis(uint32_t time, uint32_t axis, wl_fixed_t amount)
 73+static void
 74+handle_axis(uint32_t time, uint32_t axis, wl_fixed_t amount)
 75 {
 76-    pointer_handle_axis(&seat.pointer, time, axis, amount);
 77+	pointer_handle_axis(&seat.pointer, time, axis, amount);
 78 }
 79 
 80-static void handle_relative_motion(uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
 81+static void
 82+handle_relative_motion(uint32_t time, wl_fixed_t dx, wl_fixed_t dy)
 83 {
 84-    pointer_handle_relative_motion(&seat.pointer, time, dx, dy);
 85+	pointer_handle_relative_motion(&seat.pointer, time, dx, dy);
 86 }
 87 
 88-static void handle_keyboard_focus_event(struct wl_listener * listener,
 89-                                        void * data)
 90+static void
 91+handle_keyboard_focus_event(struct wl_listener *listener,
 92+                            void *data)
 93 {
 94-    struct event * event = data;
 95-    struct input_focus_event_data * event_data = event->data;
 96-
 97-    switch (event->type)
 98-    {
 99-        case INPUT_FOCUS_EVENT_CHANGED:
100-            if (event_data->new)
101-            {
102-                struct wl_client * client = wl_resource_get_client
103-                    (event_data->new->surface->resource);
104-
105-                /* Offer the selection to the new focus. */
106-                data_device_offer_selection(&seat.data_device, client);
107-            }
108-            break;
109-    }
110+	struct event *event = data;
111+	struct input_focus_event_data *event_data = event->data;
112+
113+	switch (event->type) {
114+	case INPUT_FOCUS_EVENT_CHANGED:
115+		if (event_data->new) {
116+			struct wl_client *client = wl_resource_get_client(event_data->new->surface->resource);
117+
118+			/* Offer the selection to the new focus. */
119+			data_device_offer_selection(&seat.data_device, client);
120+		}
121+		break;
122+	}
123 }
124 
125 static struct wl_listener keyboard_focus_listener = {
126-    .notify = &handle_keyboard_focus_event
127+	.notify = &handle_keyboard_focus_event
128 };
129 
130-static void handle_data_device_event(struct wl_listener * listener, void * data)
131+static void
132+handle_data_device_event(struct wl_listener *listener, void *data)
133 {
134-    struct event * event = data;
135-
136-    switch (event->type)
137-    {
138-        case DATA_DEVICE_EVENT_SELECTION_CHANGED:
139-            if (seat.keyboard.focus.resource)
140-            {
141-                struct wl_client * client
142-                    = wl_resource_get_client(seat.keyboard.focus.resource);
143-                data_device_offer_selection(&seat.data_device, client);
144-            }
145-            break;
146-    }
147+	struct event *event = data;
148+
149+	switch (event->type) {
150+	case DATA_DEVICE_EVENT_SELECTION_CHANGED:
151+		if (seat.keyboard.focus.resource) {
152+			struct wl_client *client = wl_resource_get_client(seat.keyboard.focus.resource);
153+			data_device_offer_selection(&seat.data_device, client);
154+		}
155+		break;
156+	}
157 }
158 
159 static struct wl_listener data_device_listener = {
160-    .notify = &handle_data_device_event
161+	.notify = &handle_data_device_event
162 };
163 
164-static void handle_swc_event(struct wl_listener * listener, void * data)
165+static void
166+handle_swc_event(struct wl_listener *listener, void *data)
167 {
168-    struct event * event = data;
169+	struct event *event = data;
170 
171-    switch (event->type)
172-    {
173-        case SWC_EVENT_DEACTIVATED:
174+	switch (event->type) {
175+	case SWC_EVENT_DEACTIVATED:
176 #ifdef ENABLE_LIBINPUT
177-            libinput_suspend(seat.libinput);
178+		libinput_suspend(seat.libinput);
179 #endif
180-            keyboard_reset(&seat.keyboard);
181-            break;
182-        case SWC_EVENT_ACTIVATED:
183-        {
184+		keyboard_reset(&seat.keyboard);
185+		break;
186+	case SWC_EVENT_ACTIVATED: {
187 #ifdef ENABLE_LIBINPUT
188-            if (libinput_resume(seat.libinput) != 0)
189-                WARNING("Failed to resume libinput context\n");
190+		if (libinput_resume(seat.libinput) != 0)
191+			WARNING("Failed to resume libinput context\n");
192 #else
193-            struct evdev_device * device, * next;
194-
195-            /* Re-open all input devices */
196-            wl_list_for_each_safe(device, next, &seat.devices, link)
197-            {
198-                if (!evdev_device_reopen(device))
199-                {
200-                    wl_list_remove(&device->link);
201-                    evdev_device_destroy(device);
202-                }
203-            }
204+		struct evdev_device *device, *next;
205+
206+		/* Re-open all input devices */
207+		wl_list_for_each_safe (device, next, &seat.devices, link) {
208+			if (!evdev_device_reopen(device)) {
209+				wl_list_remove(&device->link);
210+				evdev_device_destroy(device);
211+			}
212+		}
213 #endif
214-            break;
215-        }
216-    }
217+		break;
218+	}
219+	}
220 }
221 
222 /* Wayland Seat Interface */
223-static void get_pointer(struct wl_client * client,
224-                        struct wl_resource * resource, uint32_t id)
225+static void
226+get_pointer(struct wl_client *client,
227+            struct wl_resource *resource, uint32_t id)
228 {
229-    pointer_bind(&seat.pointer, client, wl_resource_get_version(resource), id);
230+	pointer_bind(&seat.pointer, client, wl_resource_get_version(resource), id);
231 }
232 
233-static void get_keyboard(struct wl_client * client,
234-                         struct wl_resource * resource, uint32_t id)
235+static void
236+get_keyboard(struct wl_client *client,
237+             struct wl_resource *resource, uint32_t id)
238 {
239-    keyboard_bind(&seat.keyboard, client,
240-                  wl_resource_get_version(resource), id);
241+	keyboard_bind(&seat.keyboard, client,
242+	              wl_resource_get_version(resource), id);
243 }
244 
245-static void get_touch(struct wl_client * client, struct wl_resource * resource,
246-               uint32_t id)
247+static void
248+get_touch(struct wl_client *client, struct wl_resource *resource,
249+          uint32_t id)
250 {
251-    /* XXX: Implement */
252+	/* XXX: Implement */
253 }
254 
255 static struct wl_seat_interface seat_implementation = {
256-    .get_pointer = &get_pointer,
257-    .get_keyboard = &get_keyboard,
258-    .get_touch = &get_touch
259+	.get_pointer = &get_pointer,
260+	.get_keyboard = &get_keyboard,
261+	.get_touch = &get_touch
262 };
263 
264-static void bind_seat(struct wl_client * client, void * data, uint32_t version,
265-                      uint32_t id)
266+static void
267+bind_seat(struct wl_client *client, void *data, uint32_t version,
268+          uint32_t id)
269 {
270-    struct wl_resource * resource;
271+	struct wl_resource *resource;
272 
273-    if (version > 4)
274-        version = 4;
275+	if (version > 4)
276+		version = 4;
277 
278-    resource = wl_resource_create(client, &wl_seat_interface, version, id);
279-    wl_resource_set_implementation(resource, &seat_implementation, NULL,
280-                                   &remove_resource);
281-    wl_list_insert(&seat.resources, wl_resource_get_link(resource));
282+	resource = wl_resource_create(client, &wl_seat_interface, version, id);
283+	wl_resource_set_implementation(resource, &seat_implementation, NULL,
284+	                               &remove_resource);
285+	wl_list_insert(&seat.resources, wl_resource_get_link(resource));
286 
287-    if (version >= 2)
288-        wl_seat_send_name(resource, seat.name);
289+	if (version >= 2)
290+		wl_seat_send_name(resource, seat.name);
291 
292-    wl_seat_send_capabilities(resource, seat.capabilities);
293+	wl_seat_send_capabilities(resource, seat.capabilities);
294 }
295 
296-static void update_capabilities(uint32_t capabilities)
297+static void
298+update_capabilities(uint32_t capabilities)
299 {
300-    if (~seat.capabilities & capabilities)
301-    {
302-        struct wl_resource * resource;
303+	if (~seat.capabilities & capabilities) {
304+		struct wl_resource *resource;
305 
306-        seat.capabilities |= capabilities;
307-        wl_list_for_each(resource, &seat.resources, link)
308-            wl_seat_send_capabilities(resource, seat.capabilities);
309-    }
310+		seat.capabilities |= capabilities;
311+		wl_list_for_each (resource, &seat.resources, link)
312+			wl_seat_send_capabilities(resource, seat.capabilities);
313+	}
314 }
315 
316 #ifdef ENABLE_LIBINPUT
317-static int open_restricted(const char * path, int flags, void * user_data)
318+static int
319+open_restricted(const char *path, int flags, void *user_data)
320 {
321-    return launch_open_device(path, flags);
322+	return launch_open_device(path, flags);
323 }
324 
325-static void close_restricted(int fd, void * user_data)
326+static void
327+close_restricted(int fd, void *user_data)
328 {
329-    close(fd);
330+	close(fd);
331 }
332 
333 const struct libinput_interface libinput_interface = {
334-    .open_restricted = &open_restricted,
335-    .close_restricted = &close_restricted,
336+	.open_restricted = &open_restricted,
337+	.close_restricted = &close_restricted,
338 };
339 
340-static uint32_t device_capabilities(struct libinput_device * device)
341+static uint32_t
342+device_capabilities(struct libinput_device *device)
343 {
344-    uint32_t capabilities = 0;
345+	uint32_t capabilities = 0;
346 
347-    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
348-        capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
349-    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
350-        capabilities |= WL_SEAT_CAPABILITY_POINTER;
351-    /* TODO: Add touch device support
352+	if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
353+		capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
354+	if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
355+		capabilities |= WL_SEAT_CAPABILITY_POINTER;
356+	/* TODO: Add touch device support
357     if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
358         capabilities |= WL_SEAT_CAPABILITY_TOUCH;
359     */
360 
361-    return capabilities;
362+	return capabilities;
363 }
364 
365-static void handle_libinput_axis_event(struct libinput_event_pointer * event,
366-                                       enum libinput_pointer_axis axis)
367+static void
368+handle_libinput_axis_event(struct libinput_event_pointer *event,
369+                           enum libinput_pointer_axis axis)
370 {
371-    if (!libinput_event_pointer_has_axis(event, axis))
372-        return;
373+	if (!libinput_event_pointer_has_axis(event, axis))
374+		return;
375 
376-    double amount;
377+	double amount;
378 
379-    amount = libinput_event_pointer_get_axis_value(event, axis);
380-    handle_axis(libinput_event_pointer_get_time(event), axis,
381-                wl_fixed_from_double(amount));
382+	amount = libinput_event_pointer_get_axis_value(event, axis);
383+	handle_axis(libinput_event_pointer_get_time(event), axis,
384+	            wl_fixed_from_double(amount));
385 }
386 
387-static int handle_libinput_data(int fd, uint32_t mask, void * data)
388+static int
389+handle_libinput_data(int fd, uint32_t mask, void *data)
390 {
391-    struct libinput_event * generic_event;
392-
393-    if (libinput_dispatch(seat.libinput) != 0)
394-    {
395-        WARNING("libinput_dispatch failed: %s\n", strerror(errno));
396-        return 0;
397-    }
398-
399-    while ((generic_event = libinput_get_event(seat.libinput)))
400-    {
401-        switch (libinput_event_get_type(generic_event))
402-        {
403-            case LIBINPUT_EVENT_DEVICE_ADDED:
404-            {
405-                struct libinput_device * device;
406-
407-                device = libinput_event_get_device(generic_event);
408-                update_capabilities(device_capabilities(device));
409-                break;
410-            }
411-            case LIBINPUT_EVENT_KEYBOARD_KEY:
412-            {
413-                struct libinput_event_keyboard * event;
414-
415-                event = libinput_event_get_keyboard_event(generic_event);
416-                handle_key(libinput_event_keyboard_get_time(event),
417-                           libinput_event_keyboard_get_key(event),
418-                           libinput_event_keyboard_get_key_state(event));
419-                break;
420-            }
421-            case LIBINPUT_EVENT_POINTER_MOTION:
422-            {
423-                struct libinput_event_pointer * event;
424-                wl_fixed_t dx, dy;
425-
426-                event = libinput_event_get_pointer_event(generic_event);
427-                dx = wl_fixed_from_double(libinput_event_pointer_get_dx(event));
428-                dy = wl_fixed_from_double(libinput_event_pointer_get_dy(event));
429-                handle_relative_motion(libinput_event_pointer_get_time(event),
430-                                       dx, dy);
431-                break;
432-            }
433-            case LIBINPUT_EVENT_POINTER_BUTTON:
434-            {
435-                struct libinput_event_pointer * event;
436-
437-                event = libinput_event_get_pointer_event(generic_event);
438-                handle_button(libinput_event_pointer_get_time(event),
439-                              libinput_event_pointer_get_button(event),
440-                              libinput_event_pointer_get_button_state(event));
441-                break;
442-            }
443-            case LIBINPUT_EVENT_POINTER_AXIS:
444-            {
445-                struct libinput_event_pointer * event;
446-
447-                event = libinput_event_get_pointer_event(generic_event);
448-                handle_libinput_axis_event
449-                    (event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
450-                handle_libinput_axis_event
451-                    (event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
452-
453-                break;
454-            }
455-            default:
456-                break;
457-        }
458-
459-        libinput_event_destroy(generic_event);
460-    }
461-
462-    return 0;
463+	struct libinput_event *generic_event;
464+
465+	if (libinput_dispatch(seat.libinput) != 0) {
466+		WARNING("libinput_dispatch failed: %s\n", strerror(errno));
467+		return 0;
468+	}
469+
470+	while ((generic_event = libinput_get_event(seat.libinput))) {
471+		switch (libinput_event_get_type(generic_event)) {
472+		case LIBINPUT_EVENT_DEVICE_ADDED: {
473+			struct libinput_device *device;
474+
475+			device = libinput_event_get_device(generic_event);
476+			update_capabilities(device_capabilities(device));
477+			break;
478+		}
479+		case LIBINPUT_EVENT_KEYBOARD_KEY: {
480+			struct libinput_event_keyboard *event;
481+
482+			event = libinput_event_get_keyboard_event(generic_event);
483+			handle_key(libinput_event_keyboard_get_time(event),
484+			           libinput_event_keyboard_get_key(event),
485+			           libinput_event_keyboard_get_key_state(event));
486+			break;
487+		}
488+		case LIBINPUT_EVENT_POINTER_MOTION: {
489+			struct libinput_event_pointer *event;
490+			wl_fixed_t dx, dy;
491+
492+			event = libinput_event_get_pointer_event(generic_event);
493+			dx = wl_fixed_from_double(libinput_event_pointer_get_dx(event));
494+			dy = wl_fixed_from_double(libinput_event_pointer_get_dy(event));
495+			handle_relative_motion(libinput_event_pointer_get_time(event),
496+			                       dx, dy);
497+			break;
498+		}
499+		case LIBINPUT_EVENT_POINTER_BUTTON: {
500+			struct libinput_event_pointer *event;
501+
502+			event = libinput_event_get_pointer_event(generic_event);
503+			handle_button(libinput_event_pointer_get_time(event),
504+			              libinput_event_pointer_get_button(event),
505+			              libinput_event_pointer_get_button_state(event));
506+			break;
507+		}
508+		case LIBINPUT_EVENT_POINTER_AXIS: {
509+			struct libinput_event_pointer *event;
510+
511+			event = libinput_event_get_pointer_event(generic_event);
512+			handle_libinput_axis_event(event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
513+			handle_libinput_axis_event(event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
514+
515+			break;
516+		}
517+		default:
518+			break;
519+		}
520+
521+		libinput_event_destroy(generic_event);
522+	}
523+
524+	return 0;
525 }
526 
527-bool initialize_libinput(const char * seat_name)
528+bool
529+initialize_libinput(const char *seat_name)
530 {
531-    if (!(seat.udev = udev_new()))
532-    {
533-        ERROR("Could not create udev context\n");
534-        goto error0;
535-    }
536-
537-    seat.libinput = libinput_udev_create_context(&libinput_interface, NULL,
538-                                                 seat.udev);
539-
540-    if (!seat.libinput)
541-    {
542-        ERROR("Could not create libinput context\n");
543-        goto error1;
544-    }
545-
546-    if (libinput_udev_assign_seat(seat.libinput, seat_name) != 0)
547-    {
548-        ERROR("Failed to assign seat to libinput context\n");
549-        goto error2;
550-    }
551-
552-    seat.libinput_source = wl_event_loop_add_fd
553-        (swc.event_loop, libinput_get_fd(seat.libinput), WL_EVENT_READABLE,
554-         &handle_libinput_data, NULL);
555-
556-    if (!seat.libinput_source)
557-    {
558-        ERROR("Could not create event source for libinput\n");
559-        goto error2;
560-    }
561-
562-    if (!swc.active)
563-        libinput_suspend(seat.libinput);
564-
565-    return true;
566-
567-  error2:
568-    libinput_unref(seat.libinput);
569-  error1:
570-    udev_unref(seat.udev);
571-  error0:
572-    return false;
573+	if (!(seat.udev = udev_new())) {
574+		ERROR("Could not create udev context\n");
575+		goto error0;
576+	}
577+
578+	seat.libinput = libinput_udev_create_context(&libinput_interface, NULL,
579+	                                             seat.udev);
580+
581+	if (!seat.libinput) {
582+		ERROR("Could not create libinput context\n");
583+		goto error1;
584+	}
585+
586+	if (libinput_udev_assign_seat(seat.libinput, seat_name) != 0) {
587+		ERROR("Failed to assign seat to libinput context\n");
588+		goto error2;
589+	}
590+
591+	seat.libinput_source = wl_event_loop_add_fd(swc.event_loop, libinput_get_fd(seat.libinput), WL_EVENT_READABLE,
592+	                                            &handle_libinput_data, NULL);
593+
594+	if (!seat.libinput_source) {
595+		ERROR("Could not create event source for libinput\n");
596+		goto error2;
597+	}
598+
599+	if (!swc.active)
600+		libinput_suspend(seat.libinput);
601+
602+	return true;
603+
604+error2:
605+	libinput_unref(seat.libinput);
606+error1:
607+	udev_unref(seat.udev);
608+error0:
609+	return false;
610 }
611 
612-void finalize_libinput(void)
613+void
614+finalize_libinput(void)
615 {
616-    wl_event_source_remove(seat.libinput_source);
617-    libinput_unref(seat.libinput);
618-    udev_unref(seat.udev);
619+	wl_event_source_remove(seat.libinput_source);
620+	libinput_unref(seat.libinput);
621+	udev_unref(seat.udev);
622 }
623 #else
624 const static struct evdev_device_handler evdev_handler = {
625-    .key = &handle_key,
626-    .button = &handle_button,
627-    .axis = &handle_axis,
628-    .relative_motion = &handle_relative_motion,
629+	.key = &handle_key,
630+	.button = &handle_button,
631+	.axis = &handle_axis,
632+	.relative_motion = &handle_relative_motion,
633 };
634 
635-static void add_device(const char * path)
636+static void
637+add_device(const char *path)
638 {
639-    struct evdev_device * device;
640+	struct evdev_device *device;
641 
642-    if (!(device = evdev_device_new(path, &evdev_handler)))
643-    {
644-        ERROR("Could not create evdev device\n");
645-        return;
646-    }
647+	if (!(device = evdev_device_new(path, &evdev_handler))) {
648+		ERROR("Could not create evdev device\n");
649+		return;
650+	}
651 
652-    update_capabilities(device->capabilities);
653-    wl_list_insert(&seat.devices, &device->link);
654+	update_capabilities(device->capabilities);
655+	wl_list_insert(&seat.devices, &device->link);
656 }
657 
658-static int select_device(const struct dirent * entry)
659+static int
660+select_device(const struct dirent *entry)
661 {
662-    unsigned num;
663+	unsigned num;
664 
665-    return sscanf(entry->d_name, "event%u", &num) == 1;
666+	return sscanf(entry->d_name, "event%u", &num) == 1;
667 }
668 
669-static bool add_devices(void)
670+static bool
671+add_devices(void)
672 {
673-    struct dirent ** devices;
674-    int num_devices;
675-    char path[64];
676-    unsigned index;
677+	struct dirent **devices;
678+	int num_devices;
679+	char path[64];
680+	unsigned index;
681 
682-    num_devices = scandir("/dev/input", &devices, &select_device, &alphasort);
683+	num_devices = scandir("/dev/input", &devices, &select_device, &alphasort);
684 
685-    if (num_devices == -1)
686-    {
687-        ERROR("Failed to scan /dev/input for event devices\n");
688-        return false;
689-    }
690+	if (num_devices == -1) {
691+		ERROR("Failed to scan /dev/input for event devices\n");
692+		return false;
693+	}
694 
695-    for (index = 0; index < num_devices; ++index)
696-    {
697-        snprintf(path, sizeof path, "/dev/input/%s", devices[index]->d_name);
698-        free(devices[index]);
699-        add_device(path);
700-    }
701+	for (index = 0; index < num_devices; ++index) {
702+		snprintf(path, sizeof path, "/dev/input/%s", devices[index]->d_name);
703+		free(devices[index]);
704+		add_device(path);
705+	}
706 
707-    free(devices);
708+	free(devices);
709 
710-    return true;
711+	return true;
712 }
713 #endif
714 
715-bool seat_initialize(const char * seat_name)
716+bool
717+seat_initialize(const char *seat_name)
718 {
719-    if (!(seat.name = strdup(seat_name)))
720-    {
721-        ERROR("Could not allocate seat name string\n");
722-        goto error0;
723-    }
724+	if (!(seat.name = strdup(seat_name))) {
725+		ERROR("Could not allocate seat name string\n");
726+		goto error0;
727+	}
728 
729-    seat.global = wl_global_create(swc.display, &wl_seat_interface, 4,
730-                                   NULL, &bind_seat);
731+	seat.global = wl_global_create(swc.display, &wl_seat_interface, 4,
732+	                               NULL, &bind_seat);
733 
734-    if (!seat.global)
735-        goto error1;
736+	if (!seat.global)
737+		goto error1;
738 
739-    seat.capabilities = 0;
740-    wl_list_init(&seat.resources);
741-    seat.swc_listener.notify = &handle_swc_event;
742-    wl_signal_add(&swc.event_signal, &seat.swc_listener);
743+	seat.capabilities = 0;
744+	wl_list_init(&seat.resources);
745+	seat.swc_listener.notify = &handle_swc_event;
746+	wl_signal_add(&swc.event_signal, &seat.swc_listener);
747 
748-    if (!data_device_initialize(&seat.data_device))
749-    {
750-        ERROR("Could not initialize data device\n");
751-        goto error2;
752-    }
753+	if (!data_device_initialize(&seat.data_device)) {
754+		ERROR("Could not initialize data device\n");
755+		goto error2;
756+	}
757 
758-    wl_signal_add(&seat.data_device.event_signal, &data_device_listener);
759+	wl_signal_add(&seat.data_device.event_signal, &data_device_listener);
760 
761-    if (!keyboard_initialize(&seat.keyboard))
762-    {
763-        ERROR("Could not initialize keyboard\n");
764-        goto error3;
765-    }
766+	if (!keyboard_initialize(&seat.keyboard)) {
767+		ERROR("Could not initialize keyboard\n");
768+		goto error3;
769+	}
770 
771-    wl_signal_add(&seat.keyboard.focus.event_signal, &keyboard_focus_listener);
772+	wl_signal_add(&seat.keyboard.focus.event_signal, &keyboard_focus_listener);
773 
774-    if (!pointer_initialize(&seat.pointer))
775-    {
776-        ERROR("Could not initialize pointer\n");
777-        goto error4;
778-    }
779+	if (!pointer_initialize(&seat.pointer)) {
780+		ERROR("Could not initialize pointer\n");
781+		goto error4;
782+	}
783 
784 #ifdef ENABLE_LIBINPUT
785-    if (!initialize_libinput(seat.name))
786-        goto error5;
787+	if (!initialize_libinput(seat.name))
788+		goto error5;
789 #else
790-    wl_list_init(&seat.devices);
791+	wl_list_init(&seat.devices);
792 
793-    if (!add_devices())
794-        goto error5;
795+	if (!add_devices())
796+		goto error5;
797 #endif
798 
799-    return true;
800-
801-  error5:
802-    pointer_finalize(&seat.pointer);
803-  error4:
804-    keyboard_finalize(&seat.keyboard);
805-  error3:
806-    data_device_finalize(&seat.data_device);
807-  error2:
808-    wl_global_destroy(seat.global);
809-  error1:
810-    free(seat.name);
811-  error0:
812-    return false;
813+	return true;
814+
815+error5:
816+	pointer_finalize(&seat.pointer);
817+error4:
818+	keyboard_finalize(&seat.keyboard);
819+error3:
820+	data_device_finalize(&seat.data_device);
821+error2:
822+	wl_global_destroy(seat.global);
823+error1:
824+	free(seat.name);
825+error0:
826+	return false;
827 }
828 
829-void seat_finalize(void)
830+void
831+seat_finalize(void)
832 {
833 #ifdef ENABLE_LIBINPUT
834-    finalize_libinput();
835+	finalize_libinput();
836 #else
837-    struct evdev_device * device, * tmp;
838-    wl_list_for_each_safe(device, tmp, &seat.devices, link)
839-        evdev_device_destroy(device);
840+	struct evdev_device *device, *tmp;
841+	wl_list_for_each_safe (device, tmp, &seat.devices, link)
842+		evdev_device_destroy(device);
843 #endif
844 
845-    pointer_finalize(&seat.pointer);
846-    keyboard_finalize(&seat.keyboard);
847-    data_device_finalize(&seat.data_device);
848+	pointer_finalize(&seat.pointer);
849+	keyboard_finalize(&seat.keyboard);
850+	data_device_finalize(&seat.data_device);
851 
852-    wl_global_destroy(seat.global);
853-    free(seat.name);
854+	wl_global_destroy(seat.global);
855+	free(seat.name);
856 }
857-
+5, -7
 1@@ -26,16 +26,14 @@
 2 
 3 #include <stdbool.h>
 4 
 5-struct swc_seat
 6-{
 7-    struct pointer * pointer;
 8-    struct keyboard * keyboard;
 9-    struct data_device * data_device;
10+struct swc_seat {
11+	struct pointer *pointer;
12+	struct keyboard *keyboard;
13+	struct data_device *data_device;
14 };
15 
16-bool seat_initialize(const char * seat_name);
17+bool seat_initialize(const char *seat_name);
18 void seat_finalize(void);
19 void seat_reopen_devices(void);
20 
21 #endif
22-
+29, -26
 1@@ -28,50 +28,53 @@
 2 #include <wayland-server.h>
 3 
 4 static struct
 5-{
 6-    struct wl_global * global;
 7+    {
 8+	struct wl_global *global;
 9 } shell;
10 
11-static void get_shell_surface(struct wl_client * client,
12-                              struct wl_resource * resource, uint32_t id,
13-                              struct wl_resource * surface_resource)
14+static void
15+get_shell_surface(struct wl_client *client,
16+                  struct wl_resource *resource, uint32_t id,
17+                  struct wl_resource *surface_resource)
18 {
19-    struct surface * surface = wl_resource_get_user_data(surface_resource);
20-    struct shell_surface * shell_surface;
21+	struct surface *surface = wl_resource_get_user_data(surface_resource);
22+	struct shell_surface *shell_surface;
23 
24-    shell_surface = shell_surface_new(client, wl_resource_get_version(resource),
25-                                      id, surface);
26+	shell_surface = shell_surface_new(client, wl_resource_get_version(resource),
27+	                                  id, surface);
28 
29-    if (!shell_surface)
30-        wl_resource_post_no_memory(resource);
31+	if (!shell_surface)
32+		wl_resource_post_no_memory(resource);
33 }
34 
35 static const struct wl_shell_interface shell_implementation = {
36-    &get_shell_surface
37+	&get_shell_surface
38 };
39 
40-static void bind_shell(struct wl_client * client, void * data,
41-                       uint32_t version, uint32_t id)
42+static void
43+bind_shell(struct wl_client *client, void *data,
44+           uint32_t version, uint32_t id)
45 {
46-    struct wl_resource * resource;
47+	struct wl_resource *resource;
48 
49-    if (version > 1)
50-        version = 1;
51+	if (version > 1)
52+		version = 1;
53 
54-    resource = wl_resource_create(client, &wl_shell_interface, version, id);
55-    wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
56+	resource = wl_resource_create(client, &wl_shell_interface, version, id);
57+	wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
58 }
59 
60-bool shell_initialize(void)
61+bool
62+shell_initialize(void)
63 {
64-    shell.global = wl_global_create(swc.display, &wl_shell_interface, 1,
65-                                    NULL, &bind_shell);
66+	shell.global = wl_global_create(swc.display, &wl_shell_interface, 1,
67+	                                NULL, &bind_shell);
68 
69-    return shell.global;
70+	return shell.global;
71 }
72 
73-void shell_finalize(void)
74+void
75+shell_finalize(void)
76 {
77-    wl_global_destroy(shell.global);
78+	wl_global_destroy(shell.global);
79 }
80-
+0, -1
1@@ -30,4 +30,3 @@ bool shell_initialize(void);
2 void shell_finalize(void);
3 
4 #endif
5-
+154, -148
  1@@ -36,228 +36,234 @@
  2 #include <stdlib.h>
  3 #include <signal.h>
  4 
  5-struct shell_surface
  6-{
  7-    struct window window;
  8+struct shell_surface {
  9+	struct window window;
 10 
 11-    struct wl_resource * resource;
 12-    struct wl_listener surface_destroy_listener;
 13+	struct wl_resource *resource;
 14+	struct wl_listener surface_destroy_listener;
 15 };
 16 
 17-static void configure(struct window * window, uint32_t width, uint32_t height)
 18+static void
 19+configure(struct window *window, uint32_t width, uint32_t height)
 20 {
 21-    struct shell_surface * shell_surface
 22-        = wl_container_of(window, shell_surface, window);
 23-
 24-    wl_shell_surface_send_configure(shell_surface->resource,
 25-                                    WL_SHELL_SURFACE_RESIZE_NONE,
 26-                                    width, height);
 27-    /* wl_shell does not support acknowledging configures. */
 28-    window->configure.acknowledged = true;
 29+	struct shell_surface *shell_surface = wl_container_of(window, shell_surface, window);
 30+
 31+	wl_shell_surface_send_configure(shell_surface->resource,
 32+	                                WL_SHELL_SURFACE_RESIZE_NONE,
 33+	                                width, height);
 34+	/* wl_shell does not support acknowledging configures. */
 35+	window->configure.acknowledged = true;
 36 }
 37 
 38-static void close(struct window * window)
 39+static void
 40+close(struct window *window)
 41 {
 42-    struct shell_surface * shell_surface
 43-        = wl_container_of(window, shell_surface, window);
 44-    struct wl_client * client;
 45-    pid_t pid;
 46-
 47-    client = wl_resource_get_client(shell_surface->resource);
 48-    wl_client_get_credentials(client, &pid, NULL, NULL);
 49-    kill(pid, SIGTERM);
 50+	struct shell_surface *shell_surface = wl_container_of(window, shell_surface, window);
 51+	struct wl_client *client;
 52+	pid_t pid;
 53+
 54+	client = wl_resource_get_client(shell_surface->resource);
 55+	wl_client_get_credentials(client, &pid, NULL, NULL);
 56+	kill(pid, SIGTERM);
 57 }
 58 
 59 static const struct window_impl window_impl = {
 60-    .configure = &configure,
 61-    .close = &close,
 62+	.configure = &configure,
 63+	.close = &close,
 64 };
 65 
 66-static void pong(struct wl_client * client, struct wl_resource * resource,
 67-                 uint32_t serial)
 68+static void
 69+pong(struct wl_client *client, struct wl_resource *resource,
 70+     uint32_t serial)
 71 {
 72 }
 73 
 74-static void move(struct wl_client * client, struct wl_resource * resource,
 75-                 struct wl_resource * seat_resource, uint32_t serial)
 76+static void
 77+move(struct wl_client *client, struct wl_resource *resource,
 78+     struct wl_resource *seat_resource, uint32_t serial)
 79 {
 80-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
 81-    struct button * button;
 82+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
 83+	struct button *button;
 84 
 85-    if (!(button = pointer_get_button(swc.seat->pointer, serial)))
 86-        return;
 87+	if (!(button = pointer_get_button(swc.seat->pointer, serial)))
 88+		return;
 89 
 90-    window_begin_move(&shell_surface->window, button);
 91+	window_begin_move(&shell_surface->window, button);
 92 }
 93 
 94-static void resize(struct wl_client * client, struct wl_resource * resource,
 95-                   struct wl_resource * seat_resource, uint32_t serial,
 96-                   uint32_t edges)
 97+static void
 98+resize(struct wl_client *client, struct wl_resource *resource,
 99+       struct wl_resource *seat_resource, uint32_t serial,
100+       uint32_t edges)
101 {
102-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
103-    struct button * button;
104+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
105+	struct button *button;
106 
107-    if (!(button = pointer_get_button(swc.seat->pointer, serial)))
108-        return;
109+	if (!(button = pointer_get_button(swc.seat->pointer, serial)))
110+		return;
111 
112-    window_begin_resize(&shell_surface->window, edges, button);
113+	window_begin_resize(&shell_surface->window, edges, button);
114 }
115 
116-static void set_toplevel(struct wl_client * client,
117-                         struct wl_resource * resource)
118+static void
119+set_toplevel(struct wl_client *client,
120+             struct wl_resource *resource)
121 {
122-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
123+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
124 
125-    window_manage(&shell_surface->window);
126-    window_set_parent(&shell_surface->window, NULL);
127+	window_manage(&shell_surface->window);
128+	window_set_parent(&shell_surface->window, NULL);
129 }
130 
131-static void set_transient(struct wl_client * client,
132-                          struct wl_resource * resource,
133-                          struct wl_resource * parent_resource,
134-                          int32_t x, int32_t y, uint32_t flags)
135+static void
136+set_transient(struct wl_client *client,
137+              struct wl_resource *resource,
138+              struct wl_resource *parent_resource,
139+              int32_t x, int32_t y, uint32_t flags)
140 {
141-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
142-    struct surface * parent_surface
143-        = wl_resource_get_user_data(parent_resource);
144-    struct compositor_view * parent_view
145-        = compositor_view(parent_surface->view);
146+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
147+	struct surface *parent_surface = wl_resource_get_user_data(parent_resource);
148+	struct compositor_view *parent_view = compositor_view(parent_surface->view);
149 
150-    if (!parent_view || !parent_view->window)
151-        return;
152+	if (!parent_view || !parent_view->window)
153+		return;
154 
155-    window_manage(&shell_surface->window);
156-    window_set_parent(&shell_surface->window, parent_view->window);
157+	window_manage(&shell_surface->window);
158+	window_set_parent(&shell_surface->window, parent_view->window);
159 }
160 
161-static void set_fullscreen(struct wl_client * client,
162-                           struct wl_resource * resource,
163-                           uint32_t method, uint32_t framerate,
164-                           struct wl_resource * output_resource)
165+static void
166+set_fullscreen(struct wl_client *client,
167+               struct wl_resource *resource,
168+               uint32_t method, uint32_t framerate,
169+               struct wl_resource *output_resource)
170 {
171-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
172-    struct output * output = output_resource
173-        ? wl_resource_get_user_data(output_resource) : NULL;
174-    struct screen * screen;
175+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
176+	struct output *output = output_resource
177+	                            ? wl_resource_get_user_data(output_resource)
178+	                            : NULL;
179+	struct screen *screen;
180 
181-    screen = output ? output->screen
182-                    : wl_container_of(swc.screens.next, screen, link);
183+	screen = output ? output->screen
184+	                : wl_container_of(swc.screens.next, screen, link);
185 
186-    /* TODO: Handle fullscreen windows. */
187+	/* TODO: Handle fullscreen windows. */
188 
189-    window_manage(&shell_surface->window);
190-    window_set_parent(&shell_surface->window, NULL);
191+	window_manage(&shell_surface->window);
192+	window_set_parent(&shell_surface->window, NULL);
193 }
194 
195-static void set_popup(struct wl_client * client, struct wl_resource * resource,
196-                      struct wl_resource * seat_resource, uint32_t serial,
197-                      struct wl_resource * parent_resource,
198-                      int32_t x, int32_t y, uint32_t flags)
199+static void
200+set_popup(struct wl_client *client, struct wl_resource *resource,
201+          struct wl_resource *seat_resource, uint32_t serial,
202+          struct wl_resource *parent_resource,
203+          int32_t x, int32_t y, uint32_t flags)
204 {
205-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
206-    struct surface * parent_surface
207-        = wl_resource_get_user_data(parent_resource);
208-    struct compositor_view * parent_view
209-        = compositor_view(parent_surface->view);
210-
211-    if (!parent_view || !parent_view->window)
212-        return;
213-
214-    window_unmanage(&shell_surface->window);
215-    window_set_parent(&shell_surface->window, parent_view->window);
216-    view_move(&shell_surface->window.view->base,
217-              parent_view->base.geometry.x + x,
218-              parent_view->base.geometry.y + y);
219+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
220+	struct surface *parent_surface = wl_resource_get_user_data(parent_resource);
221+	struct compositor_view *parent_view = compositor_view(parent_surface->view);
222+
223+	if (!parent_view || !parent_view->window)
224+		return;
225+
226+	window_unmanage(&shell_surface->window);
227+	window_set_parent(&shell_surface->window, parent_view->window);
228+	view_move(&shell_surface->window.view->base,
229+	          parent_view->base.geometry.x + x,
230+	          parent_view->base.geometry.y + y);
231 }
232 
233-static void set_maximized(struct wl_client * client,
234-                          struct wl_resource * resource,
235-                          struct wl_resource * output_resource)
236+static void
237+set_maximized(struct wl_client *client,
238+              struct wl_resource *resource,
239+              struct wl_resource *output_resource)
240 {
241-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
242+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
243 
244-    /* TODO: Handle maximized windows. */
245+	/* TODO: Handle maximized windows. */
246 
247-    window_manage(&shell_surface->window);
248-    window_set_parent(&shell_surface->window, NULL);
249+	window_manage(&shell_surface->window);
250+	window_set_parent(&shell_surface->window, NULL);
251 }
252 
253-static void set_title(struct wl_client * client, struct wl_resource * resource,
254-                      const char * title)
255+static void
256+set_title(struct wl_client *client, struct wl_resource *resource,
257+          const char *title)
258 {
259-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
260+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
261 
262-    window_set_title(&shell_surface->window, title, -1);
263+	window_set_title(&shell_surface->window, title, -1);
264 }
265 
266-static void set_class(struct wl_client * client, struct wl_resource * resource,
267-                      const char * class)
268+static void
269+set_class(struct wl_client *client, struct wl_resource *resource,
270+          const char *class)
271 {
272-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
273+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
274 
275-    window_set_app_id(&shell_surface->window, class);
276+	window_set_app_id(&shell_surface->window, class);
277 }
278 
279 static const struct wl_shell_surface_interface shell_surface_implementation = {
280-    .pong = &pong,
281-    .move = &move,
282-    .resize = &resize,
283-    .set_toplevel = &set_toplevel,
284-    .set_transient = &set_transient,
285-    .set_fullscreen = &set_fullscreen,
286-    .set_popup = &set_popup,
287-    .set_maximized = &set_maximized,
288-    .set_title = &set_title,
289-    .set_class = &set_class
290+	.pong = &pong,
291+	.move = &move,
292+	.resize = &resize,
293+	.set_toplevel = &set_toplevel,
294+	.set_transient = &set_transient,
295+	.set_fullscreen = &set_fullscreen,
296+	.set_popup = &set_popup,
297+	.set_maximized = &set_maximized,
298+	.set_title = &set_title,
299+	.set_class = &set_class
300 };
301 
302-static void handle_surface_destroy(struct wl_listener * listener, void * data)
303+static void
304+handle_surface_destroy(struct wl_listener *listener, void *data)
305 {
306-    struct shell_surface * shell_surface
307-        = wl_container_of(listener, shell_surface, surface_destroy_listener);
308+	struct shell_surface *shell_surface = wl_container_of(listener, shell_surface, surface_destroy_listener);
309 
310-    wl_resource_destroy(shell_surface->resource);
311+	wl_resource_destroy(shell_surface->resource);
312 }
313 
314-static void destroy_shell_surface(struct wl_resource * resource)
315+static void
316+destroy_shell_surface(struct wl_resource *resource)
317 {
318-    struct shell_surface * shell_surface = wl_resource_get_user_data(resource);
319+	struct shell_surface *shell_surface = wl_resource_get_user_data(resource);
320 
321-    window_finalize(&shell_surface->window);
322-    free(shell_surface);
323+	window_finalize(&shell_surface->window);
324+	free(shell_surface);
325 }
326 
327-struct shell_surface * shell_surface_new(struct wl_client * client,
328-                                         uint32_t version, uint32_t id,
329-                                         struct surface * surface)
330+struct shell_surface *
331+shell_surface_new(struct wl_client *client,
332+                  uint32_t version, uint32_t id,
333+                  struct surface *surface)
334 {
335-    struct shell_surface * shell_surface;
336+	struct shell_surface *shell_surface;
337 
338-    shell_surface = malloc(sizeof *shell_surface);
339+	shell_surface = malloc(sizeof *shell_surface);
340 
341-    if (!shell_surface)
342-        goto error0;
343+	if (!shell_surface)
344+		goto error0;
345 
346-    shell_surface->resource = wl_resource_create
347-        (client, &wl_shell_surface_interface, version, id);
348+	shell_surface->resource = wl_resource_create(client, &wl_shell_surface_interface, version, id);
349 
350-    if (!shell_surface->resource)
351-        goto error1;
352+	if (!shell_surface->resource)
353+		goto error1;
354 
355-    wl_resource_set_implementation(shell_surface->resource,
356-                                   &shell_surface_implementation,
357-                                   shell_surface, &destroy_shell_surface);
358+	wl_resource_set_implementation(shell_surface->resource,
359+	                               &shell_surface_implementation,
360+	                               shell_surface, &destroy_shell_surface);
361 
362-    window_initialize(&shell_surface->window, &window_impl, surface);
363-    shell_surface->surface_destroy_listener.notify = &handle_surface_destroy;
364-    wl_resource_add_destroy_listener(surface->resource,
365-                                     &shell_surface->surface_destroy_listener);
366+	window_initialize(&shell_surface->window, &window_impl, surface);
367+	shell_surface->surface_destroy_listener.notify = &handle_surface_destroy;
368+	wl_resource_add_destroy_listener(surface->resource,
369+	                                 &shell_surface->surface_destroy_listener);
370 
371-    return shell_surface;
372+	return shell_surface;
373 
374-  error1:
375-    free(shell_surface);
376-  error0:
377-    return NULL;
378+error1:
379+	free(shell_surface);
380+error0:
381+	return NULL;
382 }
383-
+3, -4
 1@@ -29,9 +29,8 @@
 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,
 9+                                        uint32_t version, uint32_t id,
10+                                        struct surface *surface);
11 
12 #endif
13-
+162, -162
  1@@ -40,231 +40,231 @@
  2 struct swc_shm swc_shm;
  3 
  4 static struct
  5-{
  6-    struct wl_global * global;
  7+    {
  8+	struct wl_global *global;
  9 } shm;
 10 
 11-struct pool
 12-{
 13-    struct wl_resource * resource;
 14-    void * data;
 15-    uint32_t size;
 16-    unsigned references;
 17+struct pool {
 18+	struct wl_resource *resource;
 19+	void *data;
 20+	uint32_t size;
 21+	unsigned references;
 22 };
 23 
 24-struct pool_reference
 25-{
 26-    struct wld_destructor destructor;
 27-    struct pool * pool;
 28+struct pool_reference {
 29+	struct wld_destructor destructor;
 30+	struct pool *pool;
 31 };
 32 
 33-static void unref_pool(struct pool * pool)
 34+static void
 35+unref_pool(struct pool *pool)
 36 {
 37-    if (--pool->references > 0)
 38-        return;
 39+	if (--pool->references > 0)
 40+		return;
 41 
 42-    munmap(pool->data, pool->size);
 43-    free(pool);
 44+	munmap(pool->data, pool->size);
 45+	free(pool);
 46 }
 47 
 48-static void destroy_pool_resource(struct wl_resource * resource)
 49+static void
 50+destroy_pool_resource(struct wl_resource *resource)
 51 {
 52-    struct pool * pool = wl_resource_get_user_data(resource);
 53+	struct pool *pool = wl_resource_get_user_data(resource);
 54 
 55-    unref_pool(pool);
 56+	unref_pool(pool);
 57 }
 58 
 59-static void handle_buffer_destroy(struct wld_destructor * destructor)
 60+static void
 61+handle_buffer_destroy(struct wld_destructor *destructor)
 62 {
 63-    struct pool_reference * reference
 64-        = wl_container_of(destructor, reference, destructor);
 65+	struct pool_reference *reference = wl_container_of(destructor, reference, destructor);
 66 
 67-    unref_pool(reference->pool);
 68+	unref_pool(reference->pool);
 69 }
 70 
 71-static inline uint32_t format_shm_to_wld(uint32_t format)
 72+static inline uint32_t
 73+format_shm_to_wld(uint32_t format)
 74 {
 75-    switch (format)
 76-    {
 77-        case WL_SHM_FORMAT_ARGB8888:
 78-            return WLD_FORMAT_ARGB8888;
 79-        case WL_SHM_FORMAT_XRGB8888:
 80-            return WLD_FORMAT_XRGB8888;
 81-        default:
 82-            return format;
 83-    }
 84+	switch (format) {
 85+	case WL_SHM_FORMAT_ARGB8888:
 86+		return WLD_FORMAT_ARGB8888;
 87+	case WL_SHM_FORMAT_XRGB8888:
 88+		return WLD_FORMAT_XRGB8888;
 89+	default:
 90+		return format;
 91+	}
 92 }
 93 
 94-static void create_buffer(struct wl_client * client,
 95-                          struct wl_resource * resource, uint32_t id,
 96-                          int32_t offset, int32_t width, int32_t height,
 97-                          int32_t stride, uint32_t format)
 98+static void
 99+create_buffer(struct wl_client *client,
100+              struct wl_resource *resource, uint32_t id,
101+              int32_t offset, int32_t width, int32_t height,
102+              int32_t stride, uint32_t format)
103 {
104-    struct pool * pool = wl_resource_get_user_data(resource);
105-    struct pool_reference * reference;
106-    struct wld_buffer * buffer;
107-    struct wl_resource * buffer_resource;
108-    union wld_object object;
109-
110-    if (offset > pool->size || offset < 0)
111-    {
112-        wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE,
113-                               "offset is too big or negative");
114-        return;
115-    }
116-
117-    object.ptr = (void *)((uintptr_t) pool->data + offset);
118-    buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
119-                               width, height, format_shm_to_wld(format),
120-                               stride);
121-
122-    if (!buffer)
123-        goto error0;
124-
125-    buffer_resource = wayland_buffer_create_resource
126-        (client, wl_resource_get_version(resource), id, buffer);
127-
128-    if (!buffer_resource)
129-        goto error1;
130-
131-    if (!(reference = malloc(sizeof *reference)))
132-        goto error2;
133-
134-    reference->pool = pool;
135-    reference->destructor.destroy = &handle_buffer_destroy;
136-    wld_buffer_add_destructor(buffer, &reference->destructor);
137-    ++pool->references;
138-
139-    return;
140-
141-  error2:
142-    wl_resource_destroy(buffer_resource);
143-  error1:
144-    wld_buffer_unreference(buffer);
145-  error0:
146-    wl_resource_post_no_memory(resource);
147+	struct pool *pool = wl_resource_get_user_data(resource);
148+	struct pool_reference *reference;
149+	struct wld_buffer *buffer;
150+	struct wl_resource *buffer_resource;
151+	union wld_object object;
152+
153+	if (offset > pool->size || offset < 0) {
154+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_STRIDE,
155+		                       "offset is too big or negative");
156+		return;
157+	}
158+
159+	object.ptr = (void *)((uintptr_t)pool->data + offset);
160+	buffer = wld_import_buffer(swc.shm->context, WLD_OBJECT_DATA, object,
161+	                           width, height, format_shm_to_wld(format),
162+	                           stride);
163+
164+	if (!buffer)
165+		goto error0;
166+
167+	buffer_resource = wayland_buffer_create_resource(client, wl_resource_get_version(resource), id, buffer);
168+
169+	if (!buffer_resource)
170+		goto error1;
171+
172+	if (!(reference = malloc(sizeof *reference)))
173+		goto error2;
174+
175+	reference->pool = pool;
176+	reference->destructor.destroy = &handle_buffer_destroy;
177+	wld_buffer_add_destructor(buffer, &reference->destructor);
178+	++pool->references;
179+
180+	return;
181+
182+error2:
183+	wl_resource_destroy(buffer_resource);
184+error1:
185+	wld_buffer_unreference(buffer);
186+error0:
187+	wl_resource_post_no_memory(resource);
188 }
189 
190-static void destroy(struct wl_client * client, struct wl_resource * resource)
191+static void
192+destroy(struct wl_client *client, struct wl_resource *resource)
193 {
194-    wl_resource_destroy(resource);
195+	wl_resource_destroy(resource);
196 }
197 
198-static void resize(struct wl_client * client, struct wl_resource * resource,
199-                   int32_t size)
200+static void
201+resize(struct wl_client *client, struct wl_resource *resource,
202+       int32_t size)
203 {
204-    struct pool * pool = wl_resource_get_user_data(resource);
205-    void * data;
206+	struct pool *pool = wl_resource_get_user_data(resource);
207+	void *data;
208 
209-    data = mremap(pool->data, pool->size, size, MREMAP_MAYMOVE);
210+	data = mremap(pool->data, pool->size, size, MREMAP_MAYMOVE);
211 
212-    if (data == MAP_FAILED)
213-    {
214-        wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
215-                               "mremap failed: %s", strerror(errno));
216-        return;
217-    }
218+	if (data == MAP_FAILED) {
219+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
220+		                       "mremap failed: %s", strerror(errno));
221+		return;
222+	}
223 
224-    pool->data = data;
225-    pool->size = size;
226+	pool->data = data;
227+	pool->size = size;
228 }
229 
230 static struct wl_shm_pool_interface shm_pool_implementation = {
231-    .create_buffer = &create_buffer,
232-    .destroy = &destroy,
233-    .resize = &resize
234+	.create_buffer = &create_buffer,
235+	.destroy = &destroy,
236+	.resize = &resize
237 };
238 
239-static void create_pool(struct wl_client * client,
240-                        struct wl_resource * resource, uint32_t id,
241-                        int32_t fd, int32_t size)
242+static void
243+create_pool(struct wl_client *client,
244+            struct wl_resource *resource, uint32_t id,
245+            int32_t fd, int32_t size)
246 {
247-    struct pool * pool;
248+	struct pool *pool;
249 
250-    if (!(pool = malloc(sizeof *pool)))
251-    {
252-        wl_resource_post_no_memory(resource);
253-        return;
254-    }
255+	if (!(pool = malloc(sizeof *pool))) {
256+		wl_resource_post_no_memory(resource);
257+		return;
258+	}
259 
260-    pool->resource = wl_resource_create(client, &wl_shm_pool_interface,
261-                                        wl_resource_get_version(resource), id);
262+	pool->resource = wl_resource_create(client, &wl_shm_pool_interface,
263+	                                    wl_resource_get_version(resource), id);
264 
265-    if (!pool->resource)
266-    {
267-        wl_resource_post_no_memory(resource);
268-        goto error0;
269-    }
270+	if (!pool->resource) {
271+		wl_resource_post_no_memory(resource);
272+		goto error0;
273+	}
274 
275-    wl_resource_set_implementation(pool->resource, &shm_pool_implementation,
276-                                   pool, &destroy_pool_resource);
277-    pool->data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
278+	wl_resource_set_implementation(pool->resource, &shm_pool_implementation,
279+	                               pool, &destroy_pool_resource);
280+	pool->data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
281 
282-    if (pool->data == MAP_FAILED)
283-    {
284-        wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
285-                               "mmap failed: %s", strerror(errno));
286-        goto error1;
287-    }
288+	if (pool->data == MAP_FAILED) {
289+		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,
290+		                       "mmap failed: %s", strerror(errno));
291+		goto error1;
292+	}
293 
294-    pool->size = size;
295-    pool->references = 1;
296+	pool->size = size;
297+	pool->references = 1;
298 
299-    return;
300+	return;
301 
302-  error1:
303-    wl_resource_destroy(pool->resource);
304-  error0:
305-    free(pool);
306+error1:
307+	wl_resource_destroy(pool->resource);
308+error0:
309+	free(pool);
310 }
311 
312 static struct wl_shm_interface shm_implementation = {
313-    .create_pool = &create_pool
314+	.create_pool = &create_pool
315 };
316 
317-static void bind_shm(struct wl_client * client, void * data, uint32_t version,
318-                     uint32_t id)
319+static void
320+bind_shm(struct wl_client *client, void *data, uint32_t version,
321+         uint32_t id)
322 {
323-    struct wl_resource * resource;
324+	struct wl_resource *resource;
325 
326-    if (version > 1)
327-        version = 1;
328+	if (version > 1)
329+		version = 1;
330 
331-    resource = wl_resource_create(client, &wl_shm_interface, version, id);
332-    wl_resource_set_implementation(resource, &shm_implementation, NULL, NULL);
333+	resource = wl_resource_create(client, &wl_shm_interface, version, id);
334+	wl_resource_set_implementation(resource, &shm_implementation, NULL, NULL);
335 
336-    wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
337-    wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
338+	wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888);
339+	wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888);
340 }
341 
342-bool shm_initialize(void)
343+bool
344+shm_initialize(void)
345 {
346-    if (!(swc.shm->context = wld_pixman_create_context()))
347-        goto error0;
348+	if (!(swc.shm->context = wld_pixman_create_context()))
349+		goto error0;
350 
351-    if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
352-        goto error1;
353+	if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
354+		goto error1;
355 
356-    shm.global = wl_global_create(swc.display, &wl_shm_interface, 1,
357-                                  NULL, &bind_shm);
358+	shm.global = wl_global_create(swc.display, &wl_shm_interface, 1,
359+	                              NULL, &bind_shm);
360 
361-    if (!shm.global)
362-        goto error2;
363+	if (!shm.global)
364+		goto error2;
365 
366-    return true;
367+	return true;
368 
369-  error2:
370-    wld_destroy_renderer(swc.shm->renderer);
371-  error1:
372-    wld_destroy_context(swc.shm->context);
373-  error0:
374-    return false;
375+error2:
376+	wld_destroy_renderer(swc.shm->renderer);
377+error1:
378+	wld_destroy_context(swc.shm->context);
379+error0:
380+	return false;
381 }
382 
383-void shm_finalize(void)
384+void
385+shm_finalize(void)
386 {
387-    wl_global_destroy(shm.global);
388-    wld_destroy_renderer(swc.shm->renderer);
389-    wld_destroy_context(swc.shm->context);
390+	wl_global_destroy(shm.global);
391+	wld_destroy_renderer(swc.shm->renderer);
392+	wld_destroy_context(swc.shm->context);
393 }
394-
+3, -5
 1@@ -26,10 +26,9 @@
 2 
 3 #include <stdbool.h>
 4 
 5-struct swc_shm
 6-{
 7-    struct wld_context * context;
 8-    struct wld_renderer * renderer;
 9+struct swc_shm {
10+	struct wld_context *context;
11+	struct wld_renderer *renderer;
12 };
13 
14 bool shm_initialize(void);
15@@ -37,4 +36,3 @@ bool shm_initialize(void);
16 void shm_finalize(void);
17 
18 #endif
19-
+34, -32
 1@@ -26,56 +26,58 @@
 2 #include "subcompositor.h"
 3 #include "subsurface.h"
 4 
 5-static struct wl_global * global;
 6+static struct wl_global *global;
 7 
 8-static void get_subsurface(struct wl_client * client,
 9-                           struct wl_resource * resource,
10-                           uint32_t id,
11-                           struct wl_resource * surface_resource,
12-                           struct wl_resource * parent_resource)
13+static void
14+get_subsurface(struct wl_client *client,
15+               struct wl_resource *resource,
16+               uint32_t id,
17+               struct wl_resource *surface_resource,
18+               struct wl_resource *parent_resource)
19 {
20-    struct subsurface * subsurface;
21+	struct subsurface *subsurface;
22 
23-    subsurface = subsurface_new(client, wl_resource_get_version(resource), id);
24+	subsurface = subsurface_new(client, wl_resource_get_version(resource), id);
25 
26-    if (!subsurface)
27-    {
28-        wl_resource_post_no_memory(resource);
29-        return;
30-    }
31+	if (!subsurface) {
32+		wl_resource_post_no_memory(resource);
33+		return;
34+	}
35 }
36 
37 static struct wl_subcompositor_interface subcompositor_implementation = {
38-    .get_subsurface = &get_subsurface,
39+	.get_subsurface = &get_subsurface,
40 };
41 
42-static void bind_subcompositor(struct wl_client * client, void * data,
43-                               uint32_t version, uint32_t id)
44+static void
45+bind_subcompositor(struct wl_client *client, void *data,
46+                   uint32_t version, uint32_t id)
47 {
48-    struct wl_resource * resource;
49+	struct wl_resource *resource;
50 
51-    if (version > 1)
52-        version = 1;
53+	if (version > 1)
54+		version = 1;
55 
56-    resource = wl_resource_create(client, &wl_subcompositor_interface,
57-                                  version, id);
58-    wl_resource_set_implementation(resource, &subcompositor_implementation,
59-                                   NULL, NULL);
60+	resource = wl_resource_create(client, &wl_subcompositor_interface,
61+	                              version, id);
62+	wl_resource_set_implementation(resource, &subcompositor_implementation,
63+	                               NULL, NULL);
64 }
65 
66-bool subcompositor_initialize()
67+bool
68+subcompositor_initialize()
69 {
70-    global = wl_global_create(swc.display, &wl_subcompositor_interface, 1,
71-                              NULL, &bind_subcompositor);
72+	global = wl_global_create(swc.display, &wl_subcompositor_interface, 1,
73+	                          NULL, &bind_subcompositor);
74 
75-    if (!global)
76-        return false;
77+	if (!global)
78+		return false;
79 
80-    return true;
81+	return true;
82 }
83 
84-void subcompositor_finalize()
85+void
86+subcompositor_finalize()
87 {
88-    wl_global_destroy(global);
89+	wl_global_destroy(global);
90 }
91-
+0, -1
1@@ -29,4 +29,3 @@ bool subcompositor_initialize();
2 void subcompositor_finalize();
3 
4 #endif
5-
+52, -45
  1@@ -26,81 +26,88 @@
  2 #include <stdlib.h>
  3 #include <wayland-server.h>
  4 
  5-static void destroy(struct wl_client * client, struct wl_resource * resource)
  6+static void
  7+destroy(struct wl_client *client, struct wl_resource *resource)
  8 {
  9-    wl_resource_destroy(resource);
 10+	wl_resource_destroy(resource);
 11 }
 12 
 13-static void set_position(struct wl_client * client,
 14-                         struct wl_resource * resource,
 15-                         int32_t x, int32_t y)
 16+static void
 17+set_position(struct wl_client *client,
 18+             struct wl_resource *resource,
 19+             int32_t x, int32_t y)
 20 {
 21-    /* TODO: Implement. */
 22+	/* TODO: Implement. */
 23 }
 24 
 25-static void place_above(struct wl_client * client,
 26-                        struct wl_resource * resource,
 27-                        struct wl_resource * sibling_resource)
 28+static void
 29+place_above(struct wl_client *client,
 30+            struct wl_resource *resource,
 31+            struct wl_resource *sibling_resource)
 32 {
 33-    /* TODO: Implement. */
 34+	/* TODO: Implement. */
 35 }
 36 
 37-static void place_below(struct wl_client * client,
 38-                        struct wl_resource * resource,
 39-                        struct wl_resource * sibling_resource)
 40+static void
 41+place_below(struct wl_client *client,
 42+            struct wl_resource *resource,
 43+            struct wl_resource *sibling_resource)
 44 {
 45-    /* TODO: Implement. */
 46+	/* TODO: Implement. */
 47 }
 48 
 49-static void set_sync(struct wl_client * client, struct wl_resource * resource)
 50+static void
 51+set_sync(struct wl_client *client, struct wl_resource *resource)
 52 {
 53-    /* TODO: Implement. */
 54+	/* TODO: Implement. */
 55 }
 56 
 57-static void set_desync(struct wl_client * client, struct wl_resource * resource)
 58+static void
 59+set_desync(struct wl_client *client, struct wl_resource *resource)
 60 {
 61-    /* TODO: Implement. */
 62+	/* TODO: Implement. */
 63 }
 64 
 65 static struct wl_subsurface_interface subsurface_implementation = {
 66-    .destroy = &destroy,
 67-    .set_position = &set_position,
 68-    .place_above = &place_above,
 69-    .place_below = &place_below,
 70-    .set_sync = &set_sync,
 71-    .set_desync = &set_desync,
 72+	.destroy = &destroy,
 73+	.set_position = &set_position,
 74+	.place_above = &place_above,
 75+	.place_below = &place_below,
 76+	.set_sync = &set_sync,
 77+	.set_desync = &set_desync,
 78 };
 79 
 80-static void subsurface_destroy(struct wl_resource * resource)
 81+static void
 82+subsurface_destroy(struct wl_resource *resource)
 83 {
 84-    struct subsurface * subsurface = wl_resource_get_user_data(resource);
 85+	struct subsurface *subsurface = wl_resource_get_user_data(resource);
 86 
 87-    free(subsurface);
 88+	free(subsurface);
 89 }
 90 
 91-struct subsurface * subsurface_new(struct wl_client * client,
 92-                                   uint32_t version, uint32_t id)
 93+struct subsurface *
 94+subsurface_new(struct wl_client *client,
 95+               uint32_t version, uint32_t id)
 96 {
 97-    struct subsurface * subsurface;
 98+	struct subsurface *subsurface;
 99 
100-    if (!(subsurface = malloc(sizeof *subsurface)))
101-        goto error0;
102+	if (!(subsurface = malloc(sizeof *subsurface)))
103+		goto error0;
104 
105-    subsurface->resource = wl_resource_create(client, &wl_subsurface_interface,
106-                                              version, id);
107+	subsurface->resource = wl_resource_create(client, &wl_subsurface_interface,
108+	                                          version, id);
109 
110-    if (!subsurface->resource)
111-        goto error1;
112+	if (!subsurface->resource)
113+		goto error1;
114 
115-    wl_resource_set_implementation(subsurface->resource,
116-                                   &subsurface_implementation,
117-                                   subsurface, &subsurface_destroy);
118+	wl_resource_set_implementation(subsurface->resource,
119+	                               &subsurface_implementation,
120+	                               subsurface, &subsurface_destroy);
121 
122-    return subsurface;
123+	return subsurface;
124 
125-  error1:
126-    free(subsurface);
127-  error0:
128-    return NULL;
129+error1:
130+	free(subsurface);
131+error0:
132+	return NULL;
133 }
134-
+4, -6
 1@@ -28,13 +28,11 @@
 2 
 3 struct wl_client;
 4 
 5-struct subsurface
 6-{
 7-    struct wl_resource * resource;
 8+struct subsurface {
 9+	struct wl_resource *resource;
10 };
11 
12-struct subsurface * subsurface_new(struct wl_client * client,
13-                                   uint32_t version, uint32_t id);
14+struct subsurface *subsurface_new(struct wl_client *client,
15+                                  uint32_t version, uint32_t id);
16 
17 #endif
18-
+250, -254
  1@@ -38,313 +38,309 @@
  2 /**
  3  * Removes a buffer from a surface state.
  4  */
  5-static void handle_buffer_destroy(struct wl_listener * listener, void * data)
  6+static void
  7+handle_buffer_destroy(struct wl_listener *listener, void *data)
  8 {
  9-    struct surface_state * state;
 10+	struct surface_state *state;
 11 
 12-    state = wl_container_of(listener, state, buffer_destroy_listener);
 13-    state->buffer = NULL;
 14+	state = wl_container_of(listener, state, buffer_destroy_listener);
 15+	state->buffer = NULL;
 16 }
 17 
 18-static void state_initialize(struct surface_state * state)
 19+static void
 20+state_initialize(struct surface_state *state)
 21 {
 22-    state->buffer = NULL;
 23-    state->buffer_destroy_listener.notify = &handle_buffer_destroy;
 24+	state->buffer = NULL;
 25+	state->buffer_destroy_listener.notify = &handle_buffer_destroy;
 26 
 27-    pixman_region32_init(&state->damage);
 28-    pixman_region32_init(&state->opaque);
 29-    pixman_region32_init_with_extents(&state->input, &infinite_extents);
 30+	pixman_region32_init(&state->damage);
 31+	pixman_region32_init(&state->opaque);
 32+	pixman_region32_init_with_extents(&state->input, &infinite_extents);
 33 
 34-    wl_list_init(&state->frame_callbacks);
 35+	wl_list_init(&state->frame_callbacks);
 36 }
 37 
 38-static void state_finalize(struct surface_state * state)
 39+static void
 40+state_finalize(struct surface_state *state)
 41 {
 42-    struct wl_resource * resource, * tmp;
 43+	struct wl_resource *resource, *tmp;
 44 
 45-    if (state->buffer)
 46-    {
 47-        /* Remove any buffer listeners */
 48-        wl_list_remove(&state->buffer_destroy_listener.link);
 49-    }
 50+	if (state->buffer) {
 51+		/* Remove any buffer listeners */
 52+		wl_list_remove(&state->buffer_destroy_listener.link);
 53+	}
 54 
 55-    pixman_region32_fini(&state->damage);
 56-    pixman_region32_fini(&state->opaque);
 57-    pixman_region32_fini(&state->input);
 58+	pixman_region32_fini(&state->damage);
 59+	pixman_region32_fini(&state->opaque);
 60+	pixman_region32_fini(&state->input);
 61 
 62-    /* Remove all leftover callbacks. */
 63-    wl_list_for_each_safe(resource, tmp, &state->frame_callbacks, link)
 64-        wl_resource_destroy(resource);
 65+	/* Remove all leftover callbacks. */
 66+	wl_list_for_each_safe (resource, tmp, &state->frame_callbacks, link)
 67+		wl_resource_destroy(resource);
 68 }
 69 
 70 /**
 71  * In order to set the buffer of a surface state (current or pending), we need
 72  * to manage the destroy listeners we have for the new and old buffer.
 73  */
 74-static void state_set_buffer(struct surface_state * state,
 75-                             struct wl_resource * resource)
 76+static void
 77+state_set_buffer(struct surface_state *state,
 78+                 struct wl_resource *resource)
 79 {
 80-    struct wld_buffer * buffer = resource ? wayland_buffer_get(resource) : NULL;
 81+	struct wld_buffer *buffer = resource ? wayland_buffer_get(resource) : NULL;
 82 
 83-    if (state->buffer)
 84-    {
 85-        /* No longer need to worry about the old buffer being destroyed. */
 86-        wl_list_remove(&state->buffer_destroy_listener.link);
 87-    }
 88+	if (state->buffer) {
 89+		/* No longer need to worry about the old buffer being destroyed. */
 90+		wl_list_remove(&state->buffer_destroy_listener.link);
 91+	}
 92 
 93-    if (buffer)
 94-    {
 95-        /* Need to watch the new buffer for destruction so we can remove it
 96+	if (buffer) {
 97+		/* Need to watch the new buffer for destruction so we can remove it
 98          * from state. */
 99-        wl_resource_add_destroy_listener(resource,
100-                                         &state->buffer_destroy_listener);
101-    }
102+		wl_resource_add_destroy_listener(resource,
103+		                                 &state->buffer_destroy_listener);
104+	}
105 
106-    state->buffer = buffer;
107-    state->buffer_resource = resource;
108+	state->buffer = buffer;
109+	state->buffer_resource = resource;
110 }
111 
112-static void handle_frame(struct view_handler * handler, uint32_t time)
113+static void
114+handle_frame(struct view_handler *handler, uint32_t time)
115 {
116-    struct surface * surface
117-        = wl_container_of(handler, surface, view_handler);
118-    struct wl_resource * resource, * tmp;
119-
120-    wl_list_for_each_safe(resource, tmp,
121-                          &surface->state.frame_callbacks, link)
122-    {
123-        wl_callback_send_done(resource, time);
124-        wl_resource_destroy(resource);
125-    }
126-
127-    wl_list_init(&surface->state.frame_callbacks);
128+	struct surface *surface = wl_container_of(handler, surface, view_handler);
129+	struct wl_resource *resource, *tmp;
130+
131+	wl_list_for_each_safe (resource, tmp,
132+	                       &surface->state.frame_callbacks, link) {
133+		wl_callback_send_done(resource, time);
134+		wl_resource_destroy(resource);
135+	}
136+
137+	wl_list_init(&surface->state.frame_callbacks);
138 }
139 
140-static void handle_screens(struct view_handler * handler,
141-                           uint32_t entered, uint32_t left)
142+static void
143+handle_screens(struct view_handler *handler,
144+               uint32_t entered, uint32_t left)
145 {
146-    struct surface * surface
147-        = wl_container_of(handler, surface, view_handler);
148-    struct screen * screen;
149-    struct output * output;
150-    struct wl_client * client;
151-    struct wl_resource * resource;
152-
153-    client = wl_resource_get_client(surface->resource);
154-
155-    wl_list_for_each(screen, &swc.screens, link)
156-    {
157-        if (!((entered | left) & screen_mask(screen)))
158-            continue;
159-
160-        wl_list_for_each(output, &screen->outputs, link)
161-        {
162-            resource = wl_resource_find_for_client
163-                (&output->resources, client);
164-
165-            if (resource)
166-            {
167-                if (entered & screen_mask(screen))
168-                    wl_surface_send_enter(surface->resource, resource);
169-                else if (left & screen_mask(screen))
170-                    wl_surface_send_leave(surface->resource, resource);
171-            }
172-        }
173-    }
174+	struct surface *surface = wl_container_of(handler, surface, view_handler);
175+	struct screen *screen;
176+	struct output *output;
177+	struct wl_client *client;
178+	struct wl_resource *resource;
179+
180+	client = wl_resource_get_client(surface->resource);
181+
182+	wl_list_for_each (screen, &swc.screens, link) {
183+		if (!((entered | left) & screen_mask(screen)))
184+			continue;
185+
186+		wl_list_for_each (output, &screen->outputs, link) {
187+			resource = wl_resource_find_for_client(&output->resources, client);
188+
189+			if (resource) {
190+				if (entered & screen_mask(screen))
191+					wl_surface_send_enter(surface->resource, resource);
192+				else if (left & screen_mask(screen))
193+					wl_surface_send_leave(surface->resource, resource);
194+			}
195+		}
196+	}
197 }
198 
199 static const struct view_handler_impl view_handler_impl = {
200-    .frame = &handle_frame,
201-    .screens = &handle_screens,
202+	.frame = &handle_frame,
203+	.screens = &handle_screens,
204 };
205 
206-static void destroy(struct wl_client * client, struct wl_resource * resource)
207+static void
208+destroy(struct wl_client *client, struct wl_resource *resource)
209 {
210-    wl_resource_destroy(resource);
211+	wl_resource_destroy(resource);
212 }
213 
214-static void attach(struct wl_client * client, struct wl_resource * resource,
215-                   struct wl_resource * buffer_resource, int32_t x, int32_t y)
216+static void
217+attach(struct wl_client *client, struct wl_resource *resource,
218+       struct wl_resource *buffer_resource, int32_t x, int32_t y)
219 {
220-    struct surface * surface = wl_resource_get_user_data(resource);
221+	struct surface *surface = wl_resource_get_user_data(resource);
222 
223-    surface->pending.commit |= SURFACE_COMMIT_ATTACH;
224+	surface->pending.commit |= SURFACE_COMMIT_ATTACH;
225 
226-    state_set_buffer(&surface->pending.state, buffer_resource);
227-    surface->pending.x = x;
228-    surface->pending.y = y;
229+	state_set_buffer(&surface->pending.state, buffer_resource);
230+	surface->pending.x = x;
231+	surface->pending.y = y;
232 }
233 
234-static void damage(struct wl_client * client, struct wl_resource * resource,
235-                   int32_t x, int32_t y, int32_t width, int32_t height)
236+static void
237+damage(struct wl_client *client, struct wl_resource *resource,
238+       int32_t x, int32_t y, int32_t width, int32_t height)
239 {
240-    struct surface * surface = wl_resource_get_user_data(resource);
241+	struct surface *surface = wl_resource_get_user_data(resource);
242 
243-    surface->pending.commit |= SURFACE_COMMIT_DAMAGE;
244+	surface->pending.commit |= SURFACE_COMMIT_DAMAGE;
245 
246-    pixman_region32_union_rect(&surface->pending.state.damage,
247-                               &surface->pending.state.damage,
248-                               x, y, width, height);
249+	pixman_region32_union_rect(&surface->pending.state.damage,
250+	                           &surface->pending.state.damage,
251+	                           x, y, width, height);
252 }
253 
254-static void frame(struct wl_client * client, struct wl_resource * resource,
255-                  uint32_t id)
256+static void
257+frame(struct wl_client *client, struct wl_resource *resource,
258+      uint32_t id)
259 {
260-    struct surface * surface = wl_resource_get_user_data(resource);
261-    struct wl_resource * callback_resource;
262+	struct surface *surface = wl_resource_get_user_data(resource);
263+	struct wl_resource *callback_resource;
264 
265-    surface->pending.commit |= SURFACE_COMMIT_FRAME;
266+	surface->pending.commit |= SURFACE_COMMIT_FRAME;
267 
268-    callback_resource = wl_resource_create(client, &wl_callback_interface,
269-                                           1, id);
270-    wl_resource_set_implementation(callback_resource, NULL, NULL,
271-                                   &remove_resource);
272-    wl_list_insert(surface->pending.state.frame_callbacks.prev,
273-                   wl_resource_get_link(callback_resource));
274+	callback_resource = wl_resource_create(client, &wl_callback_interface,
275+	                                       1, id);
276+	wl_resource_set_implementation(callback_resource, NULL, NULL,
277+	                               &remove_resource);
278+	wl_list_insert(surface->pending.state.frame_callbacks.prev,
279+	               wl_resource_get_link(callback_resource));
280 }
281 
282-static void set_opaque_region(struct wl_client * client,
283-                              struct wl_resource * resource,
284-                              struct wl_resource * region_resource)
285+static void
286+set_opaque_region(struct wl_client *client,
287+                  struct wl_resource *resource,
288+                  struct wl_resource *region_resource)
289 {
290-    struct surface * surface = wl_resource_get_user_data(resource);
291+	struct surface *surface = wl_resource_get_user_data(resource);
292 
293-    surface->pending.commit |= SURFACE_COMMIT_OPAQUE;
294+	surface->pending.commit |= SURFACE_COMMIT_OPAQUE;
295 
296-    if (region_resource)
297-    {
298-        struct region * region = wl_resource_get_user_data(region_resource);
299+	if (region_resource) {
300+		struct region *region = wl_resource_get_user_data(region_resource);
301 
302-        pixman_region32_copy(&surface->pending.state.opaque, &region->region);
303-    }
304-    else
305-        pixman_region32_clear(&surface->pending.state.opaque);
306+		pixman_region32_copy(&surface->pending.state.opaque, &region->region);
307+	} else
308+		pixman_region32_clear(&surface->pending.state.opaque);
309 }
310 
311-static void set_input_region(struct wl_client * client,
312-                             struct wl_resource * resource,
313-                             struct wl_resource * region_resource)
314+static void
315+set_input_region(struct wl_client *client,
316+                 struct wl_resource *resource,
317+                 struct wl_resource *region_resource)
318 {
319-    struct surface * surface = wl_resource_get_user_data(resource);
320+	struct surface *surface = wl_resource_get_user_data(resource);
321 
322-    surface->pending.commit |= SURFACE_COMMIT_INPUT;
323+	surface->pending.commit |= SURFACE_COMMIT_INPUT;
324 
325-    if (region_resource)
326-    {
327-        struct region * region = wl_resource_get_user_data(region_resource);
328+	if (region_resource) {
329+		struct region *region = wl_resource_get_user_data(region_resource);
330 
331-        pixman_region32_copy(&surface->pending.state.input, &region->region);
332-    }
333-    else
334-        pixman_region32_reset(&surface->pending.state.input, &infinite_extents);
335+		pixman_region32_copy(&surface->pending.state.input, &region->region);
336+	} else
337+		pixman_region32_reset(&surface->pending.state.input, &infinite_extents);
338 }
339 
340-static inline void trim_region(pixman_region32_t * region,
341-                               struct wld_buffer * buffer)
342+static inline void
343+trim_region(pixman_region32_t *region,
344+            struct wld_buffer *buffer)
345 {
346-    pixman_region32_intersect_rect(region, region, 0, 0,
347-                                   buffer ? buffer->width : 0,
348-                                   buffer ? buffer->height : 0);
349+	pixman_region32_intersect_rect(region, region, 0, 0,
350+	                               buffer ? buffer->width : 0,
351+	                               buffer ? buffer->height : 0);
352 }
353 
354-static void commit(struct wl_client * client, struct wl_resource * resource)
355+static void
356+commit(struct wl_client *client, struct wl_resource *resource)
357 {
358-    struct surface * surface = wl_resource_get_user_data(resource);
359-    struct wld_buffer * buffer;
360-
361-    /* Attach */
362-    if (surface->pending.commit & SURFACE_COMMIT_ATTACH)
363-    {
364-        if (surface->state.buffer
365-            && surface->state.buffer != surface->pending.state.buffer)
366-        {
367-            wl_buffer_send_release(surface->state.buffer_resource);
368-        }
369-
370-        state_set_buffer(&surface->state,
371-                         surface->pending.state.buffer_resource);
372-    }
373-
374-    buffer = surface->state.buffer;
375-
376-    /* Damage */
377-    if (surface->pending.commit & SURFACE_COMMIT_DAMAGE)
378-    {
379-        pixman_region32_union(&surface->state.damage, &surface->state.damage,
380-                              &surface->pending.state.damage);
381-        pixman_region32_clear(&surface->pending.state.damage);
382-    }
383-
384-    /* Opaque */
385-    if (surface->pending.commit & SURFACE_COMMIT_OPAQUE)
386-    {
387-        pixman_region32_copy(&surface->state.opaque,
388-                             &surface->pending.state.opaque);
389-    }
390-
391-    /* Input */
392-    if (surface->pending.commit & SURFACE_COMMIT_INPUT)
393-    {
394-        pixman_region32_copy(&surface->state.input,
395-                             &surface->pending.state.input);
396-    }
397-
398-    /* Frame */
399-    if (surface->pending.commit & SURFACE_COMMIT_FRAME)
400-    {
401-        wl_list_insert_list(&surface->state.frame_callbacks,
402-                            &surface->pending.state.frame_callbacks);
403-        wl_list_init(&surface->pending.state.frame_callbacks);
404-    }
405-
406-    trim_region(&surface->state.damage, buffer);
407-    trim_region(&surface->state.opaque, buffer);
408-
409-    if (surface->view)
410-    {
411-        if (surface->pending.commit & SURFACE_COMMIT_ATTACH)
412-            view_attach(surface->view, buffer);
413-        view_update(surface->view);
414-    }
415-
416-    surface->pending.commit = 0;
417+	struct surface *surface = wl_resource_get_user_data(resource);
418+	struct wld_buffer *buffer;
419+
420+	/* Attach */
421+	if (surface->pending.commit & SURFACE_COMMIT_ATTACH) {
422+		if (surface->state.buffer
423+		    && surface->state.buffer != surface->pending.state.buffer) {
424+			wl_buffer_send_release(surface->state.buffer_resource);
425+		}
426+
427+		state_set_buffer(&surface->state,
428+		                 surface->pending.state.buffer_resource);
429+	}
430+
431+	buffer = surface->state.buffer;
432+
433+	/* Damage */
434+	if (surface->pending.commit & SURFACE_COMMIT_DAMAGE) {
435+		pixman_region32_union(&surface->state.damage, &surface->state.damage,
436+		                      &surface->pending.state.damage);
437+		pixman_region32_clear(&surface->pending.state.damage);
438+	}
439+
440+	/* Opaque */
441+	if (surface->pending.commit & SURFACE_COMMIT_OPAQUE) {
442+		pixman_region32_copy(&surface->state.opaque,
443+		                     &surface->pending.state.opaque);
444+	}
445+
446+	/* Input */
447+	if (surface->pending.commit & SURFACE_COMMIT_INPUT) {
448+		pixman_region32_copy(&surface->state.input,
449+		                     &surface->pending.state.input);
450+	}
451+
452+	/* Frame */
453+	if (surface->pending.commit & SURFACE_COMMIT_FRAME) {
454+		wl_list_insert_list(&surface->state.frame_callbacks,
455+		                    &surface->pending.state.frame_callbacks);
456+		wl_list_init(&surface->pending.state.frame_callbacks);
457+	}
458+
459+	trim_region(&surface->state.damage, buffer);
460+	trim_region(&surface->state.opaque, buffer);
461+
462+	if (surface->view) {
463+		if (surface->pending.commit & SURFACE_COMMIT_ATTACH)
464+			view_attach(surface->view, buffer);
465+		view_update(surface->view);
466+	}
467+
468+	surface->pending.commit = 0;
469 }
470 
471-void set_buffer_transform(struct wl_client * client,
472-                          struct wl_resource * surface, int32_t transform)
473+void
474+set_buffer_transform(struct wl_client *client,
475+                     struct wl_resource *surface, int32_t transform)
476 {
477-    /* TODO: Implement */
478+	/* TODO: Implement */
479 }
480 
481-void set_buffer_scale(struct wl_client * client, struct wl_resource * surface,
482-                      int32_t scale)
483+void
484+set_buffer_scale(struct wl_client *client, struct wl_resource *surface,
485+                 int32_t scale)
486 {
487-    /* TODO: Implement */
488+	/* TODO: Implement */
489 }
490 
491 static struct wl_surface_interface surface_implementation = {
492-    .destroy = &destroy,
493-    .attach = &attach,
494-    .damage = &damage,
495-    .frame = &frame,
496-    .set_opaque_region = &set_opaque_region,
497-    .set_input_region = &set_input_region,
498-    .commit = &commit,
499-    .set_buffer_transform = &set_buffer_transform,
500-    .set_buffer_scale = &set_buffer_scale
501+	.destroy = &destroy,
502+	.attach = &attach,
503+	.damage = &damage,
504+	.frame = &frame,
505+	.set_opaque_region = &set_opaque_region,
506+	.set_input_region = &set_input_region,
507+	.commit = &commit,
508+	.set_buffer_transform = &set_buffer_transform,
509+	.set_buffer_scale = &set_buffer_scale
510 };
511 
512-static void surface_destroy(struct wl_resource * resource)
513+static void
514+surface_destroy(struct wl_resource *resource)
515 {
516-    struct surface * surface = wl_resource_get_user_data(resource);
517+	struct surface *surface = wl_resource_get_user_data(resource);
518 
519-    state_finalize(&surface->state);
520-    state_finalize(&surface->pending.state);
521+	state_finalize(&surface->state);
522+	state_finalize(&surface->pending.state);
523 
524-    if (surface->view)
525-        wl_list_remove(&surface->view_handler.link);
526+	if (surface->view)
527+		wl_list_remove(&surface->view_handler.link);
528 
529-    free(surface);
530+	free(surface);
531 }
532 
533 /**
534@@ -354,48 +350,48 @@ static void surface_destroy(struct wl_resource * resource)
535  *
536  * @return The newly allocated surface.
537  */
538-struct surface * surface_new(struct wl_client * client,
539-                             uint32_t version, uint32_t id)
540+struct surface *
541+surface_new(struct wl_client *client,
542+            uint32_t version, uint32_t id)
543 {
544-    struct surface * surface;
545+	struct surface *surface;
546 
547-    surface = malloc(sizeof *surface);
548+	surface = malloc(sizeof *surface);
549 
550-    if (!surface)
551-        return NULL;
552+	if (!surface)
553+		return NULL;
554 
555-    /* Initialize the surface. */
556-    surface->pending.commit = 0;
557-    surface->view = NULL;
558-    surface->view_handler.impl = &view_handler_impl;
559+	/* Initialize the surface. */
560+	surface->pending.commit = 0;
561+	surface->view = NULL;
562+	surface->view_handler.impl = &view_handler_impl;
563 
564-    state_initialize(&surface->state);
565-    state_initialize(&surface->pending.state);
566+	state_initialize(&surface->state);
567+	state_initialize(&surface->pending.state);
568 
569-    /* Add the surface to the client. */
570-    surface->resource = wl_resource_create(client, &wl_surface_interface,
571-                                           version, id);
572-    wl_resource_set_implementation(surface->resource, &surface_implementation,
573-                                   surface, &surface_destroy);
574+	/* Add the surface to the client. */
575+	surface->resource = wl_resource_create(client, &wl_surface_interface,
576+	                                       version, id);
577+	wl_resource_set_implementation(surface->resource, &surface_implementation,
578+	                               surface, &surface_destroy);
579 
580-    return surface;
581+	return surface;
582 }
583 
584-void surface_set_view(struct surface * surface, struct view * view)
585+void
586+surface_set_view(struct surface *surface, struct view *view)
587 {
588-    if (surface->view == view)
589-        return;
590+	if (surface->view == view)
591+		return;
592 
593-    if (surface->view)
594-        wl_list_remove(&surface->view_handler.link);
595+	if (surface->view)
596+		wl_list_remove(&surface->view_handler.link);
597 
598-    surface->view = view;
599+	surface->view = view;
600 
601-    if (view)
602-    {
603-        wl_list_insert(&view->handlers, &surface->view_handler.link);
604-        view_attach(view, surface->state.buffer);
605-        view_update(view);
606-    }
607+	if (view) {
608+		wl_list_insert(&view->handlers, &surface->view_handler.link);
609+		view_attach(view, surface->state.buffer);
610+		view_update(view);
611+	}
612 }
613-
+31, -35
 1@@ -30,54 +30,50 @@
 2 #include <wayland-server.h>
 3 #include <pixman.h>
 4 
 5-enum
 6-{
 7-    SURFACE_COMMIT_ATTACH = (1 << 0),
 8-    SURFACE_COMMIT_DAMAGE = (1 << 1),
 9-    SURFACE_COMMIT_OPAQUE = (1 << 2),
10-    SURFACE_COMMIT_INPUT = (1 << 3),
11-    SURFACE_COMMIT_FRAME = (1 << 4)
12+enum {
13+	SURFACE_COMMIT_ATTACH = (1 << 0),
14+	SURFACE_COMMIT_DAMAGE = (1 << 1),
15+	SURFACE_COMMIT_OPAQUE = (1 << 2),
16+	SURFACE_COMMIT_INPUT = (1 << 3),
17+	SURFACE_COMMIT_FRAME = (1 << 4)
18 };
19 
20-struct surface_state
21-{
22-    struct wld_buffer * buffer;
23-    struct wl_resource * buffer_resource;
24-    struct wl_listener buffer_destroy_listener;
25+struct surface_state {
26+	struct wld_buffer *buffer;
27+	struct wl_resource *buffer_resource;
28+	struct wl_listener buffer_destroy_listener;
29 
30-    /* The region that needs to be repainted. */
31-    pixman_region32_t damage;
32+	/* The region that needs to be repainted. */
33+	pixman_region32_t damage;
34 
35-    /* The region that is opaque. */
36-    pixman_region32_t opaque;
37+	/* The region that is opaque. */
38+	pixman_region32_t opaque;
39 
40-    /* The region that accepts input. */
41-    pixman_region32_t input;
42+	/* The region that accepts input. */
43+	pixman_region32_t input;
44 
45-    struct wl_list frame_callbacks;
46+	struct wl_list frame_callbacks;
47 };
48 
49-struct surface
50-{
51-    struct wl_resource * resource;
52+struct surface {
53+	struct wl_resource *resource;
54 
55-    struct surface_state state;
56+	struct surface_state state;
57 
58-    struct
59-    {
60-        struct surface_state state;
61-        uint32_t commit;
62-        int32_t x, y;
63-    } pending;
64+	struct
65+	    {
66+		struct surface_state state;
67+		uint32_t commit;
68+		int32_t x, y;
69+	} pending;
70 
71-    struct view * view;
72-    struct view_handler view_handler;
73+	struct view *view;
74+	struct view_handler view_handler;
75 };
76 
77-struct surface * surface_new(struct wl_client * client,
78-                             uint32_t version, uint32_t id);
79+struct surface *surface_new(struct wl_client *client,
80+                            uint32_t version, uint32_t id);
81 
82-void surface_set_view(struct surface * surface, struct view * view);
83+void surface_set_view(struct surface *surface, struct view *view);
84 
85 #endif
86-
+158, -168
  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@@ -57,200 +57,190 @@ extern struct swc_xserver swc_xserver;
 11 extern struct pointer_handler screens_pointer_handler;
 12 
 13 struct swc swc = {
 14-    .seat = &swc_seat,
 15-    .bindings = &swc_bindings,
 16-    .compositor = &swc_compositor,
 17-    .drm = &swc_drm,
 18-    .shm = &swc_shm,
 19+	.seat = &swc_seat,
 20+	.bindings = &swc_bindings,
 21+	.compositor = &swc_compositor,
 22+	.drm = &swc_drm,
 23+	.shm = &swc_shm,
 24 #ifdef ENABLE_XWAYLAND
 25-    .xserver = &swc_xserver,
 26+	.xserver = &swc_xserver,
 27 #endif
 28 };
 29 
 30-static void setup_compositor(void)
 31+static void
 32+setup_compositor(void)
 33 {
 34-    pixman_region32_t pointer_region;
 35-    struct screen * screen;
 36-    struct swc_rectangle * geometry;
 37-
 38-    wl_list_insert(&swc.seat->keyboard->handlers,
 39-                   &swc.bindings->keyboard_handler->link);
 40-    wl_list_insert(&swc.seat->pointer->handlers,
 41-                   &swc.bindings->pointer_handler->link);
 42-    wl_list_insert(&swc.seat->pointer->handlers,
 43-                   &swc.compositor->pointer_handler->link);
 44-    wl_list_insert(&swc.seat->pointer->handlers,
 45-                   &screens_pointer_handler.link);
 46-    wl_signal_add(&swc.seat->pointer->focus.event_signal,
 47-                  &window_enter_listener);
 48-
 49-    /* Calculate pointer region */
 50-    pixman_region32_init(&pointer_region);
 51-
 52-    wl_list_for_each(screen, &swc.screens, link)
 53-    {
 54-        geometry = &screen->base.geometry;
 55-        pixman_region32_union_rect(&pointer_region, &pointer_region,
 56-                                   geometry->x, geometry->y,
 57-                                   geometry->width, geometry->height);
 58-    }
 59-
 60-    pointer_set_region(swc.seat->pointer, &pointer_region);
 61-    pixman_region32_fini(&pointer_region);
 62+	pixman_region32_t pointer_region;
 63+	struct screen *screen;
 64+	struct swc_rectangle *geometry;
 65+
 66+	wl_list_insert(&swc.seat->keyboard->handlers,
 67+	               &swc.bindings->keyboard_handler->link);
 68+	wl_list_insert(&swc.seat->pointer->handlers,
 69+	               &swc.bindings->pointer_handler->link);
 70+	wl_list_insert(&swc.seat->pointer->handlers,
 71+	               &swc.compositor->pointer_handler->link);
 72+	wl_list_insert(&swc.seat->pointer->handlers,
 73+	               &screens_pointer_handler.link);
 74+	wl_signal_add(&swc.seat->pointer->focus.event_signal,
 75+	              &window_enter_listener);
 76+
 77+	/* Calculate pointer region */
 78+	pixman_region32_init(&pointer_region);
 79+
 80+	wl_list_for_each (screen, &swc.screens, link) {
 81+		geometry = &screen->base.geometry;
 82+		pixman_region32_union_rect(&pointer_region, &pointer_region,
 83+		                           geometry->x, geometry->y,
 84+		                           geometry->width, geometry->height);
 85+	}
 86+
 87+	pointer_set_region(swc.seat->pointer, &pointer_region);
 88+	pixman_region32_fini(&pointer_region);
 89 }
 90 
 91-void swc_activate(void)
 92+void
 93+swc_activate(void)
 94 {
 95-    swc.active = true;
 96-    send_event(&swc.event_signal, SWC_EVENT_ACTIVATED, NULL);
 97+	swc.active = true;
 98+	send_event(&swc.event_signal, SWC_EVENT_ACTIVATED, NULL);
 99 }
100 
101-void swc_deactivate(void)
102+void
103+swc_deactivate(void)
104 {
105-    swc.active = false;
106-    send_event(&swc.event_signal, SWC_EVENT_DEACTIVATED, NULL);
107+	swc.active = false;
108+	send_event(&swc.event_signal, SWC_EVENT_DEACTIVATED, NULL);
109 }
110 
111 EXPORT
112-bool swc_initialize(struct wl_display * display,
113-                    struct wl_event_loop * event_loop,
114-                    const struct swc_manager * manager)
115+bool
116+swc_initialize(struct wl_display *display,
117+               struct wl_event_loop *event_loop,
118+               const struct swc_manager *manager)
119 {
120-    swc.display = display;
121-    swc.event_loop = event_loop ?: wl_display_get_event_loop(display);
122-    swc.manager = manager;
123-    const char * default_seat = "seat0";
124-    wl_signal_init(&swc.event_signal);
125-
126-    if (!launch_initialize())
127-    {
128-        ERROR("Could not connect to swc-launch\n");
129-        goto error0;
130-    }
131-
132-    if (!drm_initialize())
133-    {
134-        ERROR("Could not initialize DRM\n");
135-        goto error1;
136-    }
137-
138-    if (!shm_initialize())
139-    {
140-        ERROR("Could not initialize SHM\n");
141-        goto error2;
142-    }
143-
144-    if (!bindings_initialize())
145-    {
146-        ERROR("Could not initialize bindings\n");
147-        goto error3;
148-    }
149-
150-    if (!subcompositor_initialize())
151-    {
152-        ERROR("Could not initialize subcompositor\n");
153-        goto error4;
154-    }
155-
156-    if (!screens_initialize())
157-    {
158-        ERROR("Could not initialize screens\n");
159-        goto error5;
160-    }
161-
162-    if (!compositor_initialize())
163-    {
164-        ERROR("Could not initialize compositor\n");
165-        goto error6;
166-    }
167-
168-    if (!data_device_manager_initialize())
169-    {
170-        ERROR("Could not initialize data device manager\n");
171-        goto error7;
172-    }
173-
174-    if (!seat_initialize(default_seat))
175-    {
176-        ERROR("Could not initialize seat\n");
177-        goto error8;
178-    }
179-
180-    if (!shell_initialize())
181-    {
182-        ERROR("Could not initialize shell\n");
183-        goto error9;
184-    }
185-
186-    if (!xdg_shell_initialize())
187-    {
188-        ERROR("Could not initialize XDG shell\n");
189-        goto error10;
190-    }
191-
192-    if (!panel_manager_initialize())
193-    {
194-        ERROR("Could not initialize panel manager\n");
195-        goto error11;
196-    }
197+	swc.display = display;
198+	swc.event_loop = event_loop ?: wl_display_get_event_loop(display);
199+	swc.manager = manager;
200+	const char *default_seat = "seat0";
201+	wl_signal_init(&swc.event_signal);
202+
203+	if (!launch_initialize()) {
204+		ERROR("Could not connect to swc-launch\n");
205+		goto error0;
206+	}
207+
208+	if (!drm_initialize()) {
209+		ERROR("Could not initialize DRM\n");
210+		goto error1;
211+	}
212+
213+	if (!shm_initialize()) {
214+		ERROR("Could not initialize SHM\n");
215+		goto error2;
216+	}
217+
218+	if (!bindings_initialize()) {
219+		ERROR("Could not initialize bindings\n");
220+		goto error3;
221+	}
222+
223+	if (!subcompositor_initialize()) {
224+		ERROR("Could not initialize subcompositor\n");
225+		goto error4;
226+	}
227+
228+	if (!screens_initialize()) {
229+		ERROR("Could not initialize screens\n");
230+		goto error5;
231+	}
232+
233+	if (!compositor_initialize()) {
234+		ERROR("Could not initialize compositor\n");
235+		goto error6;
236+	}
237+
238+	if (!data_device_manager_initialize()) {
239+		ERROR("Could not initialize data device manager\n");
240+		goto error7;
241+	}
242+
243+	if (!seat_initialize(default_seat)) {
244+		ERROR("Could not initialize seat\n");
245+		goto error8;
246+	}
247+
248+	if (!shell_initialize()) {
249+		ERROR("Could not initialize shell\n");
250+		goto error9;
251+	}
252+
253+	if (!xdg_shell_initialize()) {
254+		ERROR("Could not initialize XDG shell\n");
255+		goto error10;
256+	}
257+
258+	if (!panel_manager_initialize()) {
259+		ERROR("Could not initialize panel manager\n");
260+		goto error11;
261+	}
262 
263 #ifdef ENABLE_XWAYLAND
264-    if (!xserver_initialize())
265-    {
266-        ERROR("Could not initialize xwayland\n");
267-        goto error12;
268-    }
269+	if (!xserver_initialize()) {
270+		ERROR("Could not initialize xwayland\n");
271+		goto error12;
272+	}
273 #endif
274 
275-    setup_compositor();
276+	setup_compositor();
277 
278-    return true;
279+	return true;
280 
281 #ifdef ENABLE_XWAYLAND
282-  error12:
283-    panel_manager_finalize();
284+error12:
285+	panel_manager_finalize();
286 #endif
287-  error11:
288-    xdg_shell_finalize();
289-  error10:
290-    shell_finalize();
291-  error9:
292-    seat_finalize();
293-  error8:
294-    data_device_manager_finalize();
295-  error7:
296-    subcompositor_finalize();
297-  error6:
298-    compositor_finalize();
299-  error5:
300-    screens_finalize();
301-  error4:
302-    bindings_finalize();
303-  error3:
304-    shm_finalize();
305-  error2:
306-    drm_finalize();
307-  error1:
308-    launch_finalize();
309-  error0:
310-    return false;
311+error11:
312+	xdg_shell_finalize();
313+error10:
314+	shell_finalize();
315+error9:
316+	seat_finalize();
317+error8:
318+	data_device_manager_finalize();
319+error7:
320+	subcompositor_finalize();
321+error6:
322+	compositor_finalize();
323+error5:
324+	screens_finalize();
325+error4:
326+	bindings_finalize();
327+error3:
328+	shm_finalize();
329+error2:
330+	drm_finalize();
331+error1:
332+	launch_finalize();
333+error0:
334+	return false;
335 }
336 
337 EXPORT
338-void swc_finalize(void)
339+void
340+swc_finalize(void)
341 {
342 #ifdef ENABLE_XWAYLAND
343-    xserver_finalize();
344+	xserver_finalize();
345 #endif
346-    panel_manager_finalize();
347-    shell_finalize();
348-    seat_finalize();
349-    data_device_manager_finalize();
350-    compositor_finalize();
351-    screens_finalize();
352-    bindings_finalize();
353-    shm_finalize();
354-    drm_finalize();
355-    launch_finalize();
356+	panel_manager_finalize();
357+	shell_finalize();
358+	seat_finalize();
359+	data_device_manager_finalize();
360+	compositor_finalize();
361+	screens_finalize();
362+	bindings_finalize();
363+	shm_finalize();
364+	drm_finalize();
365+	launch_finalize();
366 }
367-
+86, -96
  1@@ -30,156 +30,151 @@
  2 
  3 /* Rectangles {{{ */
  4 
  5-struct swc_rectangle
  6-{
  7-    int32_t x, y;
  8-    uint32_t width, height;
  9+struct swc_rectangle {
 10+	int32_t x, y;
 11+	uint32_t width, height;
 12 };
 13 
 14 /* }}} */
 15 
 16 /* Screens {{{ */
 17 
 18-struct swc_screen_handler
 19-{
 20-    /**
 21+struct swc_screen_handler {
 22+	/**
 23      * Called when the screen is about to be destroyed.
 24      *
 25      * After this is called, the screen is no longer valid.
 26      */
 27-    void (* destroy)(void * data);
 28+	void (*destroy)(void *data);
 29 
 30-    /**
 31+	/**
 32      * Called when the total area of the screen has changed.
 33      */
 34-    void (* geometry_changed)(void * data);
 35+	void (*geometry_changed)(void *data);
 36 
 37-    /**
 38+	/**
 39      * Called when the geometry of the screen available for laying out windows
 40      * has changed.
 41      *
 42      * A window manager should respond by making sure all visible windows are
 43      * within this area.
 44      */
 45-    void (* usable_geometry_changed)(void * data);
 46+	void (*usable_geometry_changed)(void *data);
 47 
 48-    /**
 49+	/**
 50      * Called when the pointer enters the screen.
 51      */
 52-    void (* entered)(void * data);
 53+	void (*entered)(void *data);
 54 };
 55 
 56-struct swc_screen
 57-{
 58-    /**
 59+struct swc_screen {
 60+	/**
 61      * The total area of the screen.
 62      */
 63-    struct swc_rectangle geometry;
 64+	struct swc_rectangle geometry;
 65 
 66-    /**
 67+	/**
 68      * The area of the screen available for placing windows.
 69      */
 70-    struct swc_rectangle usable_geometry;
 71+	struct swc_rectangle usable_geometry;
 72 };
 73 
 74 /**
 75  * Set the handler associated with this screen.
 76  */
 77-void swc_screen_set_handler(struct swc_screen * screen,
 78-                            const struct swc_screen_handler * handler,
 79-                            void * data);
 80+void swc_screen_set_handler(struct swc_screen *screen,
 81+                            const struct swc_screen_handler *handler,
 82+                            void *data);
 83 
 84 /* }}} */
 85 
 86 /* Windows {{{ */
 87 
 88-struct swc_window_handler
 89-{
 90-    /**
 91+struct swc_window_handler {
 92+	/**
 93      * Called when the window is about to be destroyed.
 94      *
 95      * After this is called, the window is no longer valid.
 96      */
 97-    void (* destroy)(void * data);
 98+	void (*destroy)(void *data);
 99 
100-    /**
101+	/**
102      * Called when the window's title changes.
103      */
104-    void (* title_changed)(void * data);
105+	void (*title_changed)(void *data);
106 
107-    /**
108+	/**
109      * Called when the window's application identifier changes.
110      */
111-    void (* app_id_changed)(void * data);
112+	void (*app_id_changed)(void *data);
113 
114-    /**
115+	/**
116      * Called when the window's parent changes.
117      *
118      * This can occur when the window becomes a transient for another window, or
119      * becomes a toplevel window.
120      */
121-    void (* parent_changed)(void * data);
122+	void (*parent_changed)(void *data);
123 
124-    /**
125+	/**
126      * Called when the pointer enters the window.
127      */
128-    void (* entered)(void * data);
129+	void (*entered)(void *data);
130 
131-    /**
132+	/**
133      * Called when the window wants to initiate an interactive move, but the
134      * window is not in stacked mode.
135      *
136      * The window manager may respond by changing the window's mode, after which
137      * the interactive move will be honored.
138      */
139-    void (* move)(void * data);
140+	void (*move)(void *data);
141 
142-    /**
143+	/**
144      * Called when the window wants to initiate an interactive resize, but the
145      * window is not in stacked mode.
146      *
147      * The window manager may respond by changing the window's mode, after which
148      * the interactive resize will be honored.
149      */
150-    void (* resize)(void * data);
151+	void (*resize)(void *data);
152 };
153 
154-struct swc_window
155-{
156-    char * title;
157-    char * app_id;
158+struct swc_window {
159+	char *title;
160+	char *app_id;
161 
162-    struct swc_window * parent;
163+	struct swc_window *parent;
164 };
165 
166 /**
167  * Set the handler associated with this window.
168  */
169-void swc_window_set_handler(struct swc_window * window,
170-                            const struct swc_window_handler * handler,
171-                            void * data);
172+void swc_window_set_handler(struct swc_window *window,
173+                            const struct swc_window_handler *handler,
174+                            void *data);
175 
176 /**
177  * Request that the specified window close.
178  */
179-void swc_window_close(struct swc_window * window);
180+void swc_window_close(struct swc_window *window);
181 
182 /**
183  * Make the specified window visible.
184  */
185-void swc_window_show(struct swc_window * window);
186+void swc_window_show(struct swc_window *window);
187 
188 /**
189  * Make the specified window hidden.
190  */
191-void swc_window_hide(struct swc_window * window);
192+void swc_window_hide(struct swc_window *window);
193 
194 /**
195  * Set the keyboard focus to the specified window.
196  *
197  * If window is NULL, the keyboard will have no focus.
198  */
199-void swc_window_focus(struct swc_window * window);
200+void swc_window_focus(struct swc_window *window);
201 
202 /**
203  * Sets the window to stacked mode.
204@@ -190,7 +185,7 @@ void swc_window_focus(struct swc_window * window);
205  *
206  * Use of this mode is required to allow interactive moving and resizing.
207  */
208-void swc_window_set_stacked(struct swc_window * window);
209+void swc_window_set_stacked(struct swc_window *window);
210 
211 /**
212  * Sets the window to tiled mode.
213@@ -201,13 +196,13 @@ void swc_window_set_stacked(struct swc_window * window);
214  *
215  * It is invalid to interactively move or resize a window in tiled mode.
216  */
217-void swc_window_set_tiled(struct swc_window * window);
218+void swc_window_set_tiled(struct swc_window *window);
219 
220 /**
221  * Sets the window to fullscreen mode.
222  */
223-void swc_window_set_fullscreen(struct swc_window * window,
224-                               struct swc_screen * screen);
225+void swc_window_set_fullscreen(struct swc_window *window,
226+                               struct swc_screen *screen);
227 
228 /**
229  * Set the window's position.
230@@ -215,7 +210,7 @@ void swc_window_set_fullscreen(struct swc_window * window,
231  * The x and y coordinates refer to the top-left corner of the actual contents
232  * of the window and should be adjusted for the border size.
233  */
234-void swc_window_set_position(struct swc_window * window, int32_t x, int32_t y);
235+void swc_window_set_position(struct swc_window *window, int32_t x, int32_t y);
236 
237 /**
238  * Set the window's size.
239@@ -223,7 +218,7 @@ void swc_window_set_position(struct swc_window * window, int32_t x, int32_t y);
240  * The width and height refer to the dimension of the actual contents of the
241  * window and should be adjusted for the border size.
242  */
243-void swc_window_set_size(struct swc_window * window,
244+void swc_window_set_size(struct swc_window *window,
245                          uint32_t width, uint32_t height);
246 
247 /**
248@@ -232,8 +227,8 @@ void swc_window_set_size(struct swc_window * window,
249  * This is a convenience function that is equivalent to calling
250  * swc_window_set_size and then swc_window_set_position.
251  */
252-void swc_window_set_geometry(struct swc_window * window,
253-                             const struct swc_rectangle * geometry);
254+void swc_window_set_geometry(struct swc_window *window,
255+                             const struct swc_rectangle *geometry);
256 
257 /**
258  * Set the window's border color and width.
259@@ -241,59 +236,56 @@ void swc_window_set_geometry(struct swc_window * window,
260  * NOTE: The window's geometry remains unchanged, and should be updated if a
261  *       fixed top-left corner of the border is desired.
262  */
263-void swc_window_set_border(struct swc_window * window,
264+void swc_window_set_border(struct swc_window *window,
265                            uint32_t color, uint32_t width);
266 
267 /**
268  * Begin an interactive move of the specified window.
269  */
270-void swc_window_begin_move(struct swc_window * window);
271+void swc_window_begin_move(struct swc_window *window);
272 
273 /**
274  * End an interactive move of the specified window.
275  */
276-void swc_window_end_move(struct swc_window * window);
277-
278-enum
279-{
280-    SWC_WINDOW_EDGE_AUTO    = 0,
281-    SWC_WINDOW_EDGE_TOP     = (1 << 0),
282-    SWC_WINDOW_EDGE_BOTTOM  = (1 << 1),
283-    SWC_WINDOW_EDGE_LEFT    = (1 << 2),
284-    SWC_WINDOW_EDGE_RIGHT   = (1 << 3)
285+void swc_window_end_move(struct swc_window *window);
286+
287+enum {
288+	SWC_WINDOW_EDGE_AUTO = 0,
289+	SWC_WINDOW_EDGE_TOP = (1 << 0),
290+	SWC_WINDOW_EDGE_BOTTOM = (1 << 1),
291+	SWC_WINDOW_EDGE_LEFT = (1 << 2),
292+	SWC_WINDOW_EDGE_RIGHT = (1 << 3)
293 };
294 
295 /**
296  * Begin an interactive resize of the specified window.
297  */
298-void swc_window_begin_resize(struct swc_window * window, uint32_t edges);
299+void swc_window_begin_resize(struct swc_window *window, uint32_t edges);
300 
301 /**
302  * End an interactive resize of the specified window.
303  */
304-void swc_window_end_resize(struct swc_window * window);
305+void swc_window_end_resize(struct swc_window *window);
306 
307 /* }}} */
308 
309 /* Bindings {{{ */
310 
311-enum
312-{
313-    SWC_MOD_CTRL    = 1 << 0,
314-    SWC_MOD_ALT     = 1 << 1,
315-    SWC_MOD_LOGO    = 1 << 2,
316-    SWC_MOD_SHIFT   = 1 << 3,
317-    SWC_MOD_ANY     = ~0
318+enum {
319+	SWC_MOD_CTRL = 1 << 0,
320+	SWC_MOD_ALT = 1 << 1,
321+	SWC_MOD_LOGO = 1 << 2,
322+	SWC_MOD_SHIFT = 1 << 3,
323+	SWC_MOD_ANY = ~0
324 };
325 
326-enum swc_binding_type
327-{
328-    SWC_BINDING_KEY,
329-    SWC_BINDING_BUTTON,
330+enum swc_binding_type {
331+	SWC_BINDING_KEY,
332+	SWC_BINDING_BUTTON,
333 };
334 
335-typedef void (* swc_binding_handler)(void * data, uint32_t time,
336-                                     uint32_t value, uint32_t state);
337+typedef void (*swc_binding_handler)(void *data, uint32_t time,
338+                                    uint32_t value, uint32_t state);
339 
340 /**
341  * Register a new input binding.
342@@ -302,7 +294,7 @@ typedef void (* swc_binding_handler)(void * data, uint32_t time,
343  */
344 int swc_add_binding(enum swc_binding_type type,
345                     uint32_t modifiers, uint32_t value,
346-                    swc_binding_handler handler, void * data);
347+                    swc_binding_handler handler, void *data);
348 
349 /* }}} */
350 
351@@ -310,26 +302,25 @@ int swc_add_binding(enum swc_binding_type type,
352  * This is a user-provided structure that swc will use to notify the display
353  * server of new windows and screens.
354  */
355-struct swc_manager
356-{
357-    /**
358+struct swc_manager {
359+	/**
360      * Called when a new screen is created.
361      */
362-    void (* new_screen)(struct swc_screen * screen);
363+	void (*new_screen)(struct swc_screen *screen);
364 
365-    /**
366+	/**
367      * Called when a new window is created.
368      */
369-    void (* new_window)(struct swc_window * window);
370+	void (*new_window)(struct swc_window *window);
371 };
372 
373 /**
374  * Initializes the compositor using the specified display, event_loop, and
375  * manager.
376  */
377-bool swc_initialize(struct wl_display * display,
378-                    struct wl_event_loop * event_loop,
379-                    const struct swc_manager * manager);
380+bool swc_initialize(struct wl_display *display,
381+                    struct wl_event_loop *event_loop,
382+                    const struct swc_manager *manager);
383 
384 /**
385  * Stops the compositor, releasing any used resources.
386@@ -339,4 +330,3 @@ void swc_finalize(void);
387 #endif
388 
389 /* vim: set fdm=marker : */
390-
+4, -5
 1@@ -26,12 +26,11 @@
 2 #include <wayland-server.h>
 3 
 4 pixman_box32_t infinite_extents = {
 5-    .x1 = INT32_MIN, .y1 = INT32_MIN,
 6-    .x2 = INT32_MAX, .y2 = INT32_MAX
 7+	.x1 = INT32_MIN, .y1 = INT32_MIN, .x2 = INT32_MAX, .y2 = INT32_MAX
 8 };
 9 
10-void remove_resource(struct wl_resource * resource)
11+void
12+remove_resource(struct wl_resource *resource)
13 {
14-    wl_list_remove(wl_resource_get_link(resource));
15+	wl_list_remove(wl_resource_get_link(resource));
16 }
17-
+37, -34
  1@@ -38,66 +38,69 @@
  2 #define EXPORT __attribute__((visibility("default")))
  3 
  4 #if ENABLE_DEBUG
  5-# define MESSAGE_SOURCE \
  6-    fprintf(stderr, "[swc:%s:%d] ", __FILE__, __LINE__);
  7+#define MESSAGE_SOURCE \
  8+	fprintf(stderr, "[swc:%s:%d] ", __FILE__, __LINE__);
  9 #else
 10-# define MESSAGE_SOURCE
 11+#define MESSAGE_SOURCE
 12 #endif
 13 
 14-#define MESSAGE(type, format, ...) \
 15-    do { MESSAGE_SOURCE                                         \
 16-         fprintf(stderr, type ": " format, ## __VA_ARGS__); }   \
 17-    while (false)
 18+#define MESSAGE(type, format, ...)                                \
 19+	do {                                                      \
 20+		MESSAGE_SOURCE                                    \
 21+		fprintf(stderr, type ": " format, ##__VA_ARGS__); \
 22+	} while (false)
 23 
 24-#define WARNING(format, ...)    MESSAGE("WARNING", format, ## __VA_ARGS__)
 25-#define ERROR(format, ...)      MESSAGE("ERROR", format, ## __VA_ARGS__)
 26+#define WARNING(format, ...) MESSAGE("WARNING", format, ##__VA_ARGS__)
 27+#define ERROR(format, ...) MESSAGE("ERROR", format, ##__VA_ARGS__)
 28 
 29 #if ENABLE_DEBUG
 30-# define DEBUG(format, ...)     MESSAGE("DEBUG", format, ## __VA_ARGS__)
 31+#define DEBUG(format, ...) MESSAGE("DEBUG", format, ##__VA_ARGS__)
 32 #else
 33-# define DEBUG(format, ...)
 34+#define DEBUG(format, ...)
 35 #endif
 36 
 37-#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
 38+#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array)[0])
 39 
 40 struct wl_resource;
 41 
 42-void remove_resource(struct wl_resource * resource);
 43+void remove_resource(struct wl_resource *resource);
 44 
 45-static inline uint32_t get_time(void)
 46+static inline uint32_t
 47+get_time(void)
 48 {
 49-    struct timeval timeval;
 50+	struct timeval timeval;
 51 
 52-    gettimeofday(&timeval, NULL);
 53-    return timeval.tv_sec * 1000 + timeval.tv_usec / 1000;
 54+	gettimeofday(&timeval, NULL);
 55+	return timeval.tv_sec * 1000 + timeval.tv_usec / 1000;
 56 }
 57 
 58 extern pixman_box32_t infinite_extents;
 59 
 60-static inline bool rectangle_contains_point
 61-    (const struct swc_rectangle * rectangle, int32_t x, int32_t y)
 62+static inline bool
 63+rectangle_contains_point(const struct swc_rectangle *rectangle, int32_t x, int32_t y)
 64 {
 65-    return x > rectangle->x && x < rectangle->x + rectangle->width
 66-        && y > rectangle->y && y < rectangle->y + rectangle->height;
 67+	return x > rectangle->x && x < rectangle->x + rectangle->width
 68+	       && y > rectangle->y && y < rectangle->y + rectangle->height;
 69 }
 70 
 71-static inline bool rectangle_overlap(const struct swc_rectangle * r1,
 72-                                     const struct swc_rectangle * r2)
 73+static inline bool
 74+rectangle_overlap(const struct swc_rectangle *r1,
 75+                  const struct swc_rectangle *r2)
 76 {
 77-    return (MAX(r1->x + r1->width, r2->x + r2->width) - MIN(r1->x, r2->x)
 78-            < r1->width + r2->width)
 79-        && (MAX(r1->y + r1->height, r2->y + r2->height) - MIN(r1->y, r2->y)
 80-            < r1->height + r2->height);
 81+	return (MAX(r1->x + r1->width, r2->x + r2->width) - MIN(r1->x, r2->x)
 82+	        < r1->width + r2->width)
 83+	       && (MAX(r1->y + r1->height, r2->y + r2->height) - MIN(r1->y, r2->y)
 84+	           < r1->height + r2->height);
 85 }
 86 
 87-static inline void array_remove(struct wl_array * array,
 88-                                void * item, size_t size)
 89+static inline void
 90+array_remove(struct wl_array *array,
 91+             void *item, size_t size)
 92 {
 93-    size_t bytes = array->size - ((intptr_t) item + size - (intptr_t) array->data);
 94-    if (bytes > 0)
 95-        memmove(item, (void *)((intptr_t) item + size), bytes);
 96-    array->size -= size;
 97+	size_t bytes = array->size - ((intptr_t)item + size - (intptr_t)array->data);
 98+	if (bytes > 0)
 99+		memmove(item, (void *)((intptr_t)item + size), bytes);
100+	array->size -= size;
101 }
102 
103 #endif
104-
+87, -80
  1@@ -29,132 +29,139 @@
  2 
  3 #include <wld/wld.h>
  4 
  5-#define HANDLE(view, handler, method, ...)                                  \
  6-    do                                                                      \
  7-    {                                                                       \
  8-        wl_list_for_each(handler, &view->handlers, link)                    \
  9-        {                                                                   \
 10-            if (handler->impl->method)                                      \
 11-                handler->impl->method(handler, ## __VA_ARGS__);             \
 12-        }                                                                   \
 13-    } while (0)
 14-
 15-void view_initialize(struct view * view, const struct view_impl * impl)
 16+#define HANDLE(view, handler, method, ...)                                     \
 17+	do {                                                                   \
 18+		wl_list_for_each (handler, &view->handlers, link) {            \
 19+			if (handler->impl->method)                             \
 20+				handler->impl->method(handler, ##__VA_ARGS__); \
 21+		}                                                              \
 22+	} while (0)
 23+
 24+void
 25+view_initialize(struct view *view, const struct view_impl *impl)
 26 {
 27-    view->impl = impl;
 28-    view->geometry.x = 0;
 29-    view->geometry.y = 0;
 30-    view->geometry.width = 0;
 31-    view->geometry.height = 0;
 32-    view->buffer = NULL;
 33-    view->screens = 0;
 34-    wl_list_init(&view->handlers);
 35+	view->impl = impl;
 36+	view->geometry.x = 0;
 37+	view->geometry.y = 0;
 38+	view->geometry.width = 0;
 39+	view->geometry.height = 0;
 40+	view->buffer = NULL;
 41+	view->screens = 0;
 42+	wl_list_init(&view->handlers);
 43 }
 44 
 45-void view_finalize(struct view * view)
 46+void
 47+view_finalize(struct view *view)
 48 {
 49-    if (view->buffer)
 50-        wld_buffer_unreference(view->buffer);
 51+	if (view->buffer)
 52+		wld_buffer_unreference(view->buffer);
 53 }
 54 
 55-int view_attach(struct view * view, struct wld_buffer * buffer)
 56+int
 57+view_attach(struct view *view, struct wld_buffer *buffer)
 58 {
 59-    int ret;
 60-    struct view_handler * handler;
 61+	int ret;
 62+	struct view_handler *handler;
 63 
 64-    if ((ret = view->impl->attach(view, buffer)) < 0)
 65-        return ret;
 66+	if ((ret = view->impl->attach(view, buffer)) < 0)
 67+		return ret;
 68 
 69-    if (view->buffer)
 70-        wld_buffer_unreference(view->buffer);
 71+	if (view->buffer)
 72+		wld_buffer_unreference(view->buffer);
 73 
 74-    if (buffer)
 75-        wld_buffer_reference(buffer);
 76+	if (buffer)
 77+		wld_buffer_reference(buffer);
 78 
 79-    view->buffer = buffer;
 80-    HANDLE(view, handler, attach);
 81+	view->buffer = buffer;
 82+	HANDLE(view, handler, attach);
 83 
 84-    return 0;
 85+	return 0;
 86 }
 87 
 88-bool view_update(struct view * view)
 89+bool
 90+view_update(struct view *view)
 91 {
 92-    return view->impl->update(view);
 93+	return view->impl->update(view);
 94 }
 95 
 96-bool view_move(struct view * view, int32_t x, int32_t y)
 97+bool
 98+view_move(struct view *view, int32_t x, int32_t y)
 99 {
100-    return view->impl->move(view, x, y);
101+	return view->impl->move(view, x, y);
102 }
103 
104-bool view_set_position(struct view * view, int32_t x, int32_t y)
105+bool
106+view_set_position(struct view *view, int32_t x, int32_t y)
107 {
108-    struct view_handler * handler;
109+	struct view_handler *handler;
110 
111-    if (x == view->geometry.x && y == view->geometry.y)
112-        return false;
113+	if (x == view->geometry.x && y == view->geometry.y)
114+		return false;
115 
116-    view->geometry.x = x;
117-    view->geometry.y = y;
118-    HANDLE(view, handler, move);
119+	view->geometry.x = x;
120+	view->geometry.y = y;
121+	HANDLE(view, handler, move);
122 
123-    return true;
124+	return true;
125 }
126 
127-bool view_set_size(struct view * view, uint32_t width, uint32_t height)
128+bool
129+view_set_size(struct view *view, uint32_t width, uint32_t height)
130 {
131-    struct view_handler * handler;
132+	struct view_handler *handler;
133 
134-    if (view->geometry.width == width && view->geometry.height == height)
135-        return false;
136+	if (view->geometry.width == width && view->geometry.height == height)
137+		return false;
138 
139-    uint32_t old_width = view->geometry.width,
140-             old_height = view->geometry.height;
141+	uint32_t old_width = view->geometry.width,
142+	         old_height = view->geometry.height;
143 
144-    view->geometry.width = width;
145-    view->geometry.height = height;
146-    HANDLE(view, handler, resize, old_width, old_height);
147+	view->geometry.width = width;
148+	view->geometry.height = height;
149+	HANDLE(view, handler, resize, old_width, old_height);
150 
151-    return true;
152+	return true;
153 }
154 
155-bool view_set_size_from_buffer(struct view * view, struct wld_buffer * buffer)
156+bool
157+view_set_size_from_buffer(struct view *view, struct wld_buffer *buffer)
158 {
159-    return view_set_size(view, buffer ? buffer->width : 0,
160-                               buffer ? buffer->height : 0);
161+	return view_set_size(view, buffer ? buffer->width : 0,
162+	                     buffer ? buffer->height : 0);
163 }
164 
165-void view_set_screens(struct view * view, uint32_t screens)
166+void
167+view_set_screens(struct view *view, uint32_t screens)
168 {
169-    if (view->screens == screens)
170-        return;
171+	if (view->screens == screens)
172+		return;
173 
174-    uint32_t entered = screens & ~view->screens,
175-             left = view->screens & ~screens;
176-    struct view_handler * handler;
177+	uint32_t entered = screens & ~view->screens,
178+	         left = view->screens & ~screens;
179+	struct view_handler *handler;
180 
181-    view->screens = screens;
182-    HANDLE(view, handler, screens, entered, left);
183+	view->screens = screens;
184+	HANDLE(view, handler, screens, entered, left);
185 }
186 
187-void view_update_screens(struct view * view)
188+void
189+view_update_screens(struct view *view)
190 {
191-    uint32_t screens = 0;
192-    struct screen * screen;
193+	uint32_t screens = 0;
194+	struct screen *screen;
195 
196-    wl_list_for_each(screen, &swc.screens, link)
197-    {
198-        if (rectangle_overlap(&screen->base.geometry, &view->geometry))
199-            screens |= screen_mask(screen);
200-    }
201+	wl_list_for_each (screen, &swc.screens, link) {
202+		if (rectangle_overlap(&screen->base.geometry, &view->geometry))
203+			screens |= screen_mask(screen);
204+	}
205 
206-    view_set_screens(view, screens);
207+	view_set_screens(view, screens);
208 }
209 
210-void view_frame(struct view * view, uint32_t time)
211+void
212+view_frame(struct view *view, uint32_t time)
213 {
214-    struct view_handler * handler;
215+	struct view_handler *handler;
216 
217-    HANDLE(view, handler, frame, time);
218+	HANDLE(view, handler, frame, time);
219 }
220-
+37, -42
  1@@ -38,21 +38,19 @@
  2  * way, allowing operations like setting the output view of a surface directly
  3  * to an output's framebuffer plane, bypassing the compositor.
  4  */
  5-struct view
  6-{
  7-    const struct view_impl * impl;
  8-    struct wl_list handlers;
  9+struct view {
 10+	const struct view_impl *impl;
 11+	struct wl_list handlers;
 12 
 13-    struct swc_rectangle geometry;
 14-    uint32_t screens;
 15+	struct swc_rectangle geometry;
 16+	uint32_t screens;
 17 
 18-    struct wld_buffer * buffer;
 19+	struct wld_buffer *buffer;
 20 };
 21 
 22-struct view_handler
 23-{
 24-    const struct view_handler_impl * impl;
 25-    struct wl_list link;
 26+struct view_handler {
 27+	const struct view_handler_impl *impl;
 28+	struct wl_list link;
 29 };
 30 
 31 /**
 32@@ -60,27 +58,25 @@ struct view_handler
 33  *
 34  * For descriptions, see the corresponding view_* function.
 35  */
 36-struct view_impl
 37-{
 38-    bool (* update)(struct view * view);
 39-    int (* attach)(struct view * view, struct wld_buffer * buffer);
 40-    bool (* move)(struct view * view, int32_t x, int32_t y);
 41+struct view_impl {
 42+	bool (*update)(struct view *view);
 43+	int (*attach)(struct view *view, struct wld_buffer *buffer);
 44+	bool (*move)(struct view *view, int32_t x, int32_t y);
 45 };
 46 
 47-struct view_handler_impl
 48-{
 49-    /* Called when the view has displayed the next frame. */
 50-    void (* frame)(struct view_handler * handler, uint32_t time);
 51-    /* Called when a new buffer is attached to the view. */
 52-    void (* attach)(struct view_handler * handler);
 53-    /* Called after the view's position changes. */
 54-    void (* move)(struct view_handler * handler);
 55-    /* Called after the view's size changes. */
 56-    void (* resize)(struct view_handler * handler,
 57-                    uint32_t old_width, uint32_t old_height);
 58-    /* Called when the set of screens the view is visible on changes. */
 59-    void (* screens)(struct view_handler * handler,
 60-                     uint32_t left, uint32_t entered);
 61+struct view_handler_impl {
 62+	/* Called when the view has displayed the next frame. */
 63+	void (*frame)(struct view_handler *handler, uint32_t time);
 64+	/* Called when a new buffer is attached to the view. */
 65+	void (*attach)(struct view_handler *handler);
 66+	/* Called after the view's position changes. */
 67+	void (*move)(struct view_handler *handler);
 68+	/* Called after the view's size changes. */
 69+	void (*resize)(struct view_handler *handler,
 70+	               uint32_t old_width, uint32_t old_height);
 71+	/* Called when the set of screens the view is visible on changes. */
 72+	void (*screens)(struct view_handler *handler,
 73+	                uint32_t left, uint32_t entered);
 74 };
 75 
 76 /**
 77@@ -90,39 +86,39 @@ struct view_handler_impl
 78  *
 79  * @return 0 on success, negative error code otherwise.
 80  */
 81-int view_attach(struct view * view, struct wld_buffer * buffer);
 82+int view_attach(struct view *view, struct wld_buffer *buffer);
 83 
 84 /**
 85  * Display a new frame consisting of the currently attached buffer.
 86  *
 87  * @return Whether or not the update succeeds.
 88  */
 89-bool view_update(struct view * view);
 90+bool view_update(struct view *view);
 91 
 92 /**
 93  * Move the view to the specified coordinates, if supported.
 94  *
 95  * @return Whether or not the move succeeds.
 96  */
 97-bool view_move(struct view * view, int32_t x, int32_t y);
 98+bool view_move(struct view *view, int32_t x, int32_t y);
 99 
100 /**** For internal view use only ****/
101 
102 /**
103  * Initialize a new view with the specified implementation.
104  */
105-void view_initialize(struct view * view, const struct view_impl * impl);
106+void view_initialize(struct view *view, const struct view_impl *impl);
107 
108 /**
109  * Release any resources associated with this view.
110  */
111-void view_finalize(struct view * view);
112+void view_finalize(struct view *view);
113 
114-bool view_set_position(struct view * view, int32_t x, int32_t y);
115-bool view_set_size(struct view * view, uint32_t width, uint32_t height);
116-bool view_set_size_from_buffer(struct view * view, struct wld_buffer * bufer);
117-void view_set_screens(struct view * view, uint32_t screens);
118-void view_update_screens(struct view * view);
119+bool view_set_position(struct view *view, int32_t x, int32_t y);
120+bool view_set_size(struct view *view, uint32_t width, uint32_t height);
121+bool view_set_size_from_buffer(struct view *view, struct wld_buffer *bufer);
122+void view_set_screens(struct view *view, uint32_t screens);
123+void view_update_screens(struct view *view);
124 
125 /**
126  * Send a new frame event through the view's event signal.
127@@ -131,7 +127,6 @@ void view_update_screens(struct view * view);
128  * the user. If time information is not available, swc_time() can be passed
129  * instead.
130  */
131-void view_frame(struct view * view, uint32_t time);
132+void view_frame(struct view *view, uint32_t time);
133 
134 #endif
135-
+27, -27
 1@@ -29,50 +29,50 @@
 2 #include <wld/wld.h>
 3 #include <wld/pixman.h>
 4 
 5-static void destroy(struct wl_client * client, struct wl_resource * resource)
 6+static void
 7+destroy(struct wl_client *client, struct wl_resource *resource)
 8 {
 9-    wl_resource_destroy(resource);
10+	wl_resource_destroy(resource);
11 }
12 
13 static const struct wl_buffer_interface buffer_implementation = {
14-    .destroy = &destroy
15+	.destroy = &destroy
16 };
17 
18-struct wld_buffer * wayland_buffer_get(struct wl_resource * resource)
19+struct wld_buffer *
20+wayland_buffer_get(struct wl_resource *resource)
21 {
22-    if (wl_resource_instance_of(resource, &wl_buffer_interface,
23-                                &buffer_implementation))
24-    {
25-        return wl_resource_get_user_data(resource);
26-    }
27+	if (wl_resource_instance_of(resource, &wl_buffer_interface,
28+	                            &buffer_implementation)) {
29+		return wl_resource_get_user_data(resource);
30+	}
31 
32-    return NULL;
33+	return NULL;
34 }
35 
36-static void destroy_buffer(struct wl_resource * resource)
37+static void
38+destroy_buffer(struct wl_resource *resource)
39 {
40-    struct wld_buffer * buffer = wl_resource_get_user_data(resource);
41+	struct wld_buffer *buffer = wl_resource_get_user_data(resource);
42 
43-    wld_buffer_unreference(buffer);
44+	wld_buffer_unreference(buffer);
45 }
46 
47-struct wl_resource * wayland_buffer_create_resource
48-    (struct wl_client * client, uint32_t version, uint32_t id,
49-     struct wld_buffer * buffer)
50+struct wl_resource *
51+wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id,
52+                               struct wld_buffer *buffer)
53 {
54-    struct wl_resource * resource;
55+	struct wl_resource *resource;
56 
57-    resource = wl_resource_create(client, &wl_buffer_interface, version, id);
58+	resource = wl_resource_create(client, &wl_buffer_interface, version, id);
59 
60-    if (!resource)
61-    {
62-        wl_client_post_no_memory(client);
63-        return NULL;
64-    }
65+	if (!resource) {
66+		wl_client_post_no_memory(client);
67+		return NULL;
68+	}
69 
70-    wl_resource_set_implementation(resource, &buffer_implementation,
71-                                   buffer, &destroy_buffer);
72+	wl_resource_set_implementation(resource, &buffer_implementation,
73+	                               buffer, &destroy_buffer);
74 
75-    return resource;
76+	return resource;
77 }
78-
+3, -5
 1@@ -29,11 +29,9 @@
 2 struct wl_client;
 3 struct wl_resource;
 4 
 5-struct wld_buffer * wayland_buffer_get(struct wl_resource * resource);
 6+struct wld_buffer *wayland_buffer_get(struct wl_resource *resource);
 7 
 8-struct wl_resource * wayland_buffer_create_resource
 9-    (struct wl_client * client, uint32_t version, uint32_t id,
10-     struct wld_buffer * buffer);
11+struct wl_resource *wayland_buffer_create_resource(struct wl_client *client, uint32_t version, uint32_t id,
12+                                                   struct wld_buffer *buffer);
13 
14 #endif
15-
+330, -311
  1@@ -34,500 +34,519 @@
  2 #include <stdlib.h>
  3 #include <string.h>
  4 
  5-#define INTERNAL(w) ((struct window *) (w))
  6+#define INTERNAL(w) ((struct window *)(w))
  7 
  8 static const struct swc_window_handler null_handler;
  9 
 10-static void handle_window_enter(struct wl_listener * listener, void * data)
 11+static void
 12+handle_window_enter(struct wl_listener *listener, void *data)
 13 {
 14-    struct event * event = data;
 15-    struct input_focus_event_data * event_data = event->data;
 16-    struct window * window;
 17+	struct event *event = data;
 18+	struct input_focus_event_data *event_data = event->data;
 19+	struct window *window;
 20 
 21-    if (event->type != INPUT_FOCUS_EVENT_CHANGED)
 22-        return;
 23+	if (event->type != INPUT_FOCUS_EVENT_CHANGED)
 24+		return;
 25 
 26-    if (!event_data->new || !(window = event_data->new->window))
 27-        return;
 28+	if (!event_data->new || !(window = event_data->new->window))
 29+		return;
 30 
 31-    if (window->handler->entered)
 32-        window->handler->entered(window->handler_data);
 33+	if (window->handler->entered)
 34+		window->handler->entered(window->handler_data);
 35 }
 36 
 37 struct wl_listener window_enter_listener = {
 38-    .notify = &handle_window_enter
 39+	.notify = &handle_window_enter
 40 };
 41 
 42-static void begin_interaction(struct window_pointer_interaction * interaction,
 43-                              struct button * button)
 44+static void
 45+begin_interaction(struct window_pointer_interaction *interaction,
 46+                  struct button *button)
 47 {
 48-    if (button)
 49-    {
 50-        /* Store the serial of the button press so we are able to cancel the
 51+	if (button) {
 52+		/* Store the serial of the button press so we are able to cancel the
 53          * interaction if the window changes from stacked mode. */
 54-        interaction->serial = button->press.serial;
 55-        interaction->original_handler = button->handler;
 56-        button->handler = &interaction->handler;
 57-    }
 58-    else
 59-        interaction->original_handler = NULL;
 60+		interaction->serial = button->press.serial;
 61+		interaction->original_handler = button->handler;
 62+		button->handler = &interaction->handler;
 63+	} else
 64+		interaction->original_handler = NULL;
 65 
 66-    interaction->active = true;
 67-    wl_list_insert(&swc.seat->pointer->handlers, &interaction->handler.link);
 68+	interaction->active = true;
 69+	wl_list_insert(&swc.seat->pointer->handlers, &interaction->handler.link);
 70 }
 71 
 72-static void end_interaction(struct window_pointer_interaction * interaction,
 73-                            struct button * button)
 74+static void
 75+end_interaction(struct window_pointer_interaction *interaction,
 76+                struct button *button)
 77 {
 78-    if (!interaction->active)
 79-        return;
 80+	if (!interaction->active)
 81+		return;
 82 
 83-    if (interaction->original_handler)
 84-    {
 85-        if (!button)
 86-        {
 87-            button = pointer_get_button(swc.seat->pointer, interaction->serial);
 88+	if (interaction->original_handler) {
 89+		if (!button) {
 90+			button = pointer_get_button(swc.seat->pointer, interaction->serial);
 91 
 92-            if (!button)
 93-            {
 94-                WARNING("No button with serial %u\n", interaction->serial);
 95-                goto remove;
 96-            }
 97-        }
 98+			if (!button) {
 99+				WARNING("No button with serial %u\n", interaction->serial);
100+				goto remove;
101+			}
102+		}
103 
104-        interaction->original_handler->button(interaction->original_handler,
105-                                              get_time(), button,
106-                                              WL_POINTER_BUTTON_STATE_RELEASED);
107-    }
108+		interaction->original_handler->button(interaction->original_handler,
109+		                                      get_time(), button,
110+		                                      WL_POINTER_BUTTON_STATE_RELEASED);
111+	}
112 
113-  remove:
114-    interaction->active = false;
115-    wl_list_remove(&interaction->handler.link);
116+remove:
117+	interaction->active = false;
118+	wl_list_remove(&interaction->handler.link);
119 }
120 
121-static void flush(struct window * window)
122+static void
123+flush(struct window *window)
124 {
125-    if (window->move.pending)
126-    {
127-        if (window->impl->move)
128-            window->impl->move(window, window->move.x, window->move.y);
129+	if (window->move.pending) {
130+		if (window->impl->move)
131+			window->impl->move(window, window->move.x, window->move.y);
132 
133-        view_move(&window->view->base, window->move.x, window->move.y);
134-        window->move.pending = false;
135-    }
136+		view_move(&window->view->base, window->move.x, window->move.y);
137+		window->move.pending = false;
138+	}
139 }
140 
141 EXPORT
142-void swc_window_set_handler(struct swc_window * base,
143-                            const struct swc_window_handler * handler,
144-                            void * data)
145+void
146+swc_window_set_handler(struct swc_window *base,
147+                       const struct swc_window_handler *handler,
148+                       void *data)
149 {
150-    struct window * window = INTERNAL(base);
151+	struct window *window = INTERNAL(base);
152 
153-    window->handler = handler;
154-    window->handler_data = data;
155+	window->handler = handler;
156+	window->handler_data = data;
157 }
158 
159 EXPORT
160-void swc_window_close(struct swc_window * base)
161+void
162+swc_window_close(struct swc_window *base)
163 {
164-    struct window * window = INTERNAL(base);
165+	struct window *window = INTERNAL(base);
166 
167-    if (window->impl->close)
168-        window->impl->close(window);
169+	if (window->impl->close)
170+		window->impl->close(window);
171 }
172 
173 EXPORT
174-void swc_window_show(struct swc_window * window)
175+void
176+swc_window_show(struct swc_window *window)
177 {
178-    compositor_view_show(INTERNAL(window)->view);
179+	compositor_view_show(INTERNAL(window)->view);
180 }
181 
182 EXPORT
183-void swc_window_hide(struct swc_window * window)
184+void
185+swc_window_hide(struct swc_window *window)
186 {
187-    compositor_view_hide(INTERNAL(window)->view);
188+	compositor_view_hide(INTERNAL(window)->view);
189 }
190 
191 EXPORT
192-void swc_window_focus(struct swc_window * base)
193+void
194+swc_window_focus(struct swc_window *base)
195 {
196-    struct window * window = INTERNAL(base);
197-    struct compositor_view * new_focus = window ? window->view : NULL,
198-                           * old_focus = swc.seat->keyboard->focus.view;
199+	struct window *window = INTERNAL(base);
200+	struct compositor_view *new_focus = window ? window->view : NULL,
201+	                       *old_focus = swc.seat->keyboard->focus.view;
202 
203-    if (new_focus == old_focus)
204-        return;
205+	if (new_focus == old_focus)
206+		return;
207 
208-    /* Focus the new window before unfocusing the old one in case both are X11
209+	/* Focus the new window before unfocusing the old one in case both are X11
210      * windows so the xwl_window implementation can handle this transition
211      * correctly. */
212-    if (window && window->impl->focus)
213-        window->impl->focus(window);
214-    if (old_focus && old_focus->window && old_focus->window->impl->unfocus)
215-        old_focus->window->impl->unfocus(old_focus->window);
216+	if (window && window->impl->focus)
217+		window->impl->focus(window);
218+	if (old_focus && old_focus->window && old_focus->window->impl->unfocus)
219+		old_focus->window->impl->unfocus(old_focus->window);
220 
221-    keyboard_set_focus(swc.seat->keyboard, new_focus);
222+	keyboard_set_focus(swc.seat->keyboard, new_focus);
223 }
224 
225 EXPORT
226-void swc_window_set_stacked(struct swc_window * base)
227+void
228+swc_window_set_stacked(struct swc_window *base)
229 {
230-    struct window * window = INTERNAL(base);
231+	struct window *window = INTERNAL(base);
232 
233-    flush(window);
234-    window->configure.pending = false;
235-    window->configure.width = 0;
236-    window->configure.height = 0;
237-    if (window->impl->set_mode)
238-        window->impl->set_mode(window, WINDOW_MODE_STACKED);
239-    window->mode = WINDOW_MODE_STACKED;
240+	flush(window);
241+	window->configure.pending = false;
242+	window->configure.width = 0;
243+	window->configure.height = 0;
244+	if (window->impl->set_mode)
245+		window->impl->set_mode(window, WINDOW_MODE_STACKED);
246+	window->mode = WINDOW_MODE_STACKED;
247 }
248 
249 EXPORT
250-void swc_window_set_tiled(struct swc_window * base)
251+void
252+swc_window_set_tiled(struct swc_window *base)
253 {
254-    struct window * window = INTERNAL(base);
255+	struct window *window = INTERNAL(base);
256 
257-    end_interaction(&window->move.interaction, NULL);
258-    end_interaction(&window->resize.interaction, NULL);
259-    if (window->impl->set_mode)
260-        window->impl->set_mode(window, WINDOW_MODE_TILED);
261-    window->mode = WINDOW_MODE_TILED;
262+	end_interaction(&window->move.interaction, NULL);
263+	end_interaction(&window->resize.interaction, NULL);
264+	if (window->impl->set_mode)
265+		window->impl->set_mode(window, WINDOW_MODE_TILED);
266+	window->mode = WINDOW_MODE_TILED;
267 }
268 
269 EXPORT
270-void swc_window_set_fullscreen(struct swc_window * base,
271-                               struct swc_screen * screen)
272+void
273+swc_window_set_fullscreen(struct swc_window *base,
274+                          struct swc_screen *screen)
275 {
276-    struct window * window = INTERNAL(base);
277+	struct window *window = INTERNAL(base);
278 
279-    /* TODO: Implement fullscreen windows. */
280+	/* TODO: Implement fullscreen windows. */
281 
282-    if (window->impl->set_mode)
283-        window->impl->set_mode(window, WINDOW_MODE_FULLSCREEN);
284-    window->mode = WINDOW_MODE_FULLSCREEN;
285+	if (window->impl->set_mode)
286+		window->impl->set_mode(window, WINDOW_MODE_FULLSCREEN);
287+	window->mode = WINDOW_MODE_FULLSCREEN;
288 }
289 
290 EXPORT
291-void swc_window_set_position(struct swc_window * base, int32_t x, int32_t y)
292+void
293+swc_window_set_position(struct swc_window *base, int32_t x, int32_t y)
294 {
295-    struct window * window = INTERNAL(base);
296-    struct swc_rectangle * geometry = &window->view->base.geometry;
297+	struct window *window = INTERNAL(base);
298+	struct swc_rectangle *geometry = &window->view->base.geometry;
299 
300-    if (x == geometry->x && y == geometry->y)
301-    {
302-        window->move.pending = false;
303-        return;
304-    }
305+	if (x == geometry->x && y == geometry->y) {
306+		window->move.pending = false;
307+		return;
308+	}
309 
310-    window->move.x = x;
311-    window->move.y = y;
312-    window->move.pending = true;
313+	window->move.x = x;
314+	window->move.y = y;
315+	window->move.pending = true;
316 
317-    /* If we don't have a configure pending, perform the move now. */
318-    if (!window->configure.pending)
319-        flush(window);
320+	/* If we don't have a configure pending, perform the move now. */
321+	if (!window->configure.pending)
322+		flush(window);
323 }
324 
325 EXPORT
326-void swc_window_set_size(struct swc_window * base,
327-                         uint32_t width, uint32_t height)
328+void
329+swc_window_set_size(struct swc_window *base,
330+                    uint32_t width, uint32_t height)
331 {
332-    struct window * window = INTERNAL(base);
333-    struct swc_rectangle * geometry = &window->view->base.geometry;
334+	struct window *window = INTERNAL(base);
335+	struct swc_rectangle *geometry = &window->view->base.geometry;
336 
337-    if ((window->configure.pending
338-         && width == window->configure.width
339-         && height == window->configure.height)
340-        || (!window->configure.pending
341-            && width == geometry->width && height == geometry->height))
342-    {
343-        return;
344-    }
345+	if ((window->configure.pending
346+	     && width == window->configure.width
347+	     && height == window->configure.height)
348+	    || (!window->configure.pending
349+	        && width == geometry->width && height == geometry->height)) {
350+		return;
351+	}
352 
353-    window->impl->configure(window, width, height);
354+	window->impl->configure(window, width, height);
355 
356-    if (window->mode == WINDOW_MODE_TILED)
357-    {
358-        window->configure.width = width;
359-        window->configure.height = height;
360-        window->configure.pending = true;
361-    }
362+	if (window->mode == WINDOW_MODE_TILED) {
363+		window->configure.width = width;
364+		window->configure.height = height;
365+		window->configure.pending = true;
366+	}
367 }
368 
369 EXPORT
370-void swc_window_set_geometry(struct swc_window * window,
371-                             const struct swc_rectangle * geometry)
372+void
373+swc_window_set_geometry(struct swc_window *window,
374+                        const struct swc_rectangle *geometry)
375 {
376-    swc_window_set_size(window, geometry->width, geometry->height);
377-    swc_window_set_position(window, geometry->x, geometry->y);
378+	swc_window_set_size(window, geometry->width, geometry->height);
379+	swc_window_set_position(window, geometry->x, geometry->y);
380 }
381 
382 EXPORT
383-void swc_window_set_border(struct swc_window * window,
384-                           uint32_t border_color, uint32_t border_width)
385+void
386+swc_window_set_border(struct swc_window *window,
387+                      uint32_t border_color, uint32_t border_width)
388 {
389-    struct compositor_view * view = INTERNAL(window)->view;
390+	struct compositor_view *view = INTERNAL(window)->view;
391 
392-    compositor_view_set_border_color(view, border_color);
393-    compositor_view_set_border_width(view, border_width);
394+	compositor_view_set_border_color(view, border_color);
395+	compositor_view_set_border_width(view, border_width);
396 }
397 
398 EXPORT
399-void swc_window_begin_move(struct swc_window * window)
400+void
401+swc_window_begin_move(struct swc_window *window)
402 {
403-    window_begin_move(INTERNAL(window), NULL);
404+	window_begin_move(INTERNAL(window), NULL);
405 }
406 
407 EXPORT
408-void swc_window_end_move(struct swc_window * window)
409+void
410+swc_window_end_move(struct swc_window *window)
411 {
412-    end_interaction(&INTERNAL(window)->move.interaction, NULL);
413+	end_interaction(&INTERNAL(window)->move.interaction, NULL);
414 }
415 
416 EXPORT
417-void swc_window_begin_resize(struct swc_window * window, uint32_t edges)
418+void
419+swc_window_begin_resize(struct swc_window *window, uint32_t edges)
420 {
421-    window_begin_resize(INTERNAL(window), edges, NULL);
422+	window_begin_resize(INTERNAL(window), edges, NULL);
423 }
424 
425 EXPORT
426-void swc_window_end_resize(struct swc_window * window)
427+void
428+swc_window_end_resize(struct swc_window *window)
429 {
430-    end_interaction(&INTERNAL(window)->resize.interaction, NULL);
431+	end_interaction(&INTERNAL(window)->resize.interaction, NULL);
432 }
433 
434-static bool move_motion(struct pointer_handler * handler, uint32_t time,
435-                        wl_fixed_t fx, wl_fixed_t fy)
436+static bool
437+move_motion(struct pointer_handler *handler, uint32_t time,
438+            wl_fixed_t fx, wl_fixed_t fy)
439 {
440-    struct window * window
441-        = wl_container_of(handler, window, move.interaction.handler);
442+	struct window *window = wl_container_of(handler, window, move.interaction.handler);
443 
444-    view_move(&window->view->base, wl_fixed_to_int(fx) + window->move.offset.x,
445-                                   wl_fixed_to_int(fy) + window->move.offset.y);
446+	view_move(&window->view->base, wl_fixed_to_int(fx) + window->move.offset.x,
447+	          wl_fixed_to_int(fy) + window->move.offset.y);
448 
449-    return true;
450+	return true;
451 }
452 
453-static bool resize_motion(struct pointer_handler * handler, uint32_t time,
454-                          wl_fixed_t fx, wl_fixed_t fy)
455+static bool
456+resize_motion(struct pointer_handler *handler, uint32_t time,
457+              wl_fixed_t fx, wl_fixed_t fy)
458 {
459-    struct window * window
460-        = wl_container_of(handler, window, resize.interaction.handler);
461-    const struct swc_rectangle * geometry = &window->view->base.geometry;
462-    uint32_t width = geometry->width, height = geometry->height;
463+	struct window *window = wl_container_of(handler, window, resize.interaction.handler);
464+	const struct swc_rectangle *geometry = &window->view->base.geometry;
465+	uint32_t width = geometry->width, height = geometry->height;
466 
467-    if (window->resize.edges & SWC_WINDOW_EDGE_LEFT)
468-        width -= wl_fixed_to_int(fx) + window->resize.offset.x - geometry->x;
469-    else if (window->resize.edges & SWC_WINDOW_EDGE_RIGHT)
470-        width = wl_fixed_to_int(fx) + window->resize.offset.x - geometry->x;
471+	if (window->resize.edges & SWC_WINDOW_EDGE_LEFT)
472+		width -= wl_fixed_to_int(fx) + window->resize.offset.x - geometry->x;
473+	else if (window->resize.edges & SWC_WINDOW_EDGE_RIGHT)
474+		width = wl_fixed_to_int(fx) + window->resize.offset.x - geometry->x;
475 
476-    if (window->resize.edges & SWC_WINDOW_EDGE_TOP)
477-        height -= wl_fixed_to_int(fy) + window->resize.offset.y - geometry->y;
478-    else if (window->resize.edges & SWC_WINDOW_EDGE_BOTTOM)
479-        height = wl_fixed_to_int(fy) + window->resize.offset.y - geometry->y;
480+	if (window->resize.edges & SWC_WINDOW_EDGE_TOP)
481+		height -= wl_fixed_to_int(fy) + window->resize.offset.y - geometry->y;
482+	else if (window->resize.edges & SWC_WINDOW_EDGE_BOTTOM)
483+		height = wl_fixed_to_int(fy) + window->resize.offset.y - geometry->y;
484 
485-    window->impl->configure(window, width, height);
486+	window->impl->configure(window, width, height);
487 
488-    return true;
489+	return true;
490 }
491 
492-static bool handle_button(struct pointer_handler * handler, uint32_t time,
493-                          struct button * button, uint32_t state)
494+static bool
495+handle_button(struct pointer_handler *handler, uint32_t time,
496+              struct button *button, uint32_t state)
497 {
498-    struct window_pointer_interaction * interaction
499-        = wl_container_of(handler, interaction, handler);
500+	struct window_pointer_interaction *interaction = wl_container_of(handler, interaction, handler);
501 
502-    if (state != WL_POINTER_BUTTON_STATE_RELEASED
503-        || !interaction->original_handler)
504-    {
505-        return false;
506-    }
507+	if (state != WL_POINTER_BUTTON_STATE_RELEASED
508+	    || !interaction->original_handler) {
509+		return false;
510+	}
511 
512-    end_interaction(interaction, button);
513-    return true;
514+	end_interaction(interaction, button);
515+	return true;
516 }
517 
518-static void handle_attach(struct view_handler * handler)
519+static void
520+handle_attach(struct view_handler *handler)
521 {
522-    struct window * window = wl_container_of(handler, window, view_handler);
523+	struct window *window = wl_container_of(handler, window, view_handler);
524 
525-    if (window->configure.acknowledged)
526-        flush(window);
527-    window->configure.pending = false;
528+	if (window->configure.acknowledged)
529+		flush(window);
530+	window->configure.pending = false;
531 }
532 
533-static void handle_resize(struct view_handler * handler,
534-                          uint32_t old_width, uint32_t old_height)
535+static void
536+handle_resize(struct view_handler *handler,
537+              uint32_t old_width, uint32_t old_height)
538 {
539-    struct window * window = wl_container_of(handler, window, view_handler);
540+	struct window *window = wl_container_of(handler, window, view_handler);
541 
542-    if (window->resize.interaction.active
543-        && window->resize.edges & (SWC_WINDOW_EDGE_TOP | SWC_WINDOW_EDGE_LEFT))
544-    {
545-        const struct swc_rectangle * geometry = &window->view->base.geometry;
546-        int32_t x = geometry->x, y = geometry->y;
547+	if (window->resize.interaction.active
548+	    && window->resize.edges & (SWC_WINDOW_EDGE_TOP | SWC_WINDOW_EDGE_LEFT)) {
549+		const struct swc_rectangle *geometry = &window->view->base.geometry;
550+		int32_t x = geometry->x, y = geometry->y;
551 
552-        if (window->resize.edges & SWC_WINDOW_EDGE_LEFT)
553-            x += old_width - geometry->width;
554-        if (window->resize.edges & SWC_WINDOW_EDGE_TOP)
555-            y += old_height - geometry->height;
556+		if (window->resize.edges & SWC_WINDOW_EDGE_LEFT)
557+			x += old_width - geometry->width;
558+		if (window->resize.edges & SWC_WINDOW_EDGE_TOP)
559+			y += old_height - geometry->height;
560 
561-        view_move(&window->view->base, x, y);
562-    }
563+		view_move(&window->view->base, x, y);
564+	}
565 }
566 
567 static const struct view_handler_impl view_handler_impl = {
568-    .attach = &handle_attach,
569-    .resize = &handle_resize,
570+	.attach = &handle_attach,
571+	.resize = &handle_resize,
572 };
573 
574-bool window_initialize(struct window * window, const struct window_impl * impl,
575-                       struct surface * surface)
576+bool
577+window_initialize(struct window *window, const struct window_impl *impl,
578+                  struct surface *surface)
579 {
580-    DEBUG("Initializing window, %p\n", window);
581+	DEBUG("Initializing window, %p\n", window);
582 
583-    window->base.title = NULL;
584-    window->base.app_id = NULL;
585-    window->base.parent = NULL;
586+	window->base.title = NULL;
587+	window->base.app_id = NULL;
588+	window->base.parent = NULL;
589 
590-    if (!(window->view = compositor_create_view(surface)))
591-        return false;
592+	if (!(window->view = compositor_create_view(surface)))
593+		return false;
594 
595-    window->impl = impl;
596-    window->handler = &null_handler;
597-    window->view_handler.impl = &view_handler_impl;
598-    window->view->window = window;
599-    window->managed = false;
600-    window->mode = WINDOW_MODE_STACKED;
601-    window->move.pending = false;
602-    window->move.interaction.active = false;
603-    window->move.interaction.handler = (struct pointer_handler) {
604-        .motion = &move_motion,
605-        .button = &handle_button
606-    };
607-    window->configure.pending = false;
608-    window->configure.width = 0;
609-    window->configure.height = 0;
610-    window->resize.interaction.active = false;
611-    window->resize.interaction.handler = (struct pointer_handler) {
612-        .motion = &resize_motion,
613-        .button = &handle_button
614-    };
615+	window->impl = impl;
616+	window->handler = &null_handler;
617+	window->view_handler.impl = &view_handler_impl;
618+	window->view->window = window;
619+	window->managed = false;
620+	window->mode = WINDOW_MODE_STACKED;
621+	window->move.pending = false;
622+	window->move.interaction.active = false;
623+	window->move.interaction.handler = (struct pointer_handler){
624+		.motion = &move_motion,
625+		.button = &handle_button
626+	};
627+	window->configure.pending = false;
628+	window->configure.width = 0;
629+	window->configure.height = 0;
630+	window->resize.interaction.active = false;
631+	window->resize.interaction.handler = (struct pointer_handler){
632+		.motion = &resize_motion,
633+		.button = &handle_button
634+	};
635 
636-    wl_list_insert(&window->view->base.handlers, &window->view_handler.link);
637+	wl_list_insert(&window->view->base.handlers, &window->view_handler.link);
638 
639-    return true;
640+	return true;
641 }
642 
643-void window_finalize(struct window * window)
644+void
645+window_finalize(struct window *window)
646 {
647-    DEBUG("Finalizing window, %p\n", window);
648+	DEBUG("Finalizing window, %p\n", window);
649 
650-    window_unmanage(window);
651-    compositor_view_destroy(window->view);
652-    free(window->base.title);
653-    free(window->base.app_id);
654+	window_unmanage(window);
655+	compositor_view_destroy(window->view);
656+	free(window->base.title);
657+	free(window->base.app_id);
658 }
659 
660-void window_manage(struct window * window)
661+void
662+window_manage(struct window *window)
663 {
664-    if (window->managed)
665-        return;
666+	if (window->managed)
667+		return;
668 
669-    swc.manager->new_window(&window->base);
670-    window->managed = true;
671+	swc.manager->new_window(&window->base);
672+	window->managed = true;
673 }
674 
675-void window_unmanage(struct window * window)
676+void
677+window_unmanage(struct window *window)
678 {
679-    if (!window->managed)
680-        return;
681+	if (!window->managed)
682+		return;
683 
684-    if (window->handler->destroy)
685-        window->handler->destroy(window->handler_data);
686-    window->handler = &null_handler;
687-    window->managed = false;
688+	if (window->handler->destroy)
689+		window->handler->destroy(window->handler_data);
690+	window->handler = &null_handler;
691+	window->managed = false;
692 }
693 
694-void window_set_title(struct window * window, const char * title, size_t length)
695+void
696+window_set_title(struct window *window, const char *title, size_t length)
697 {
698-    free(window->base.title);
699-    window->base.title = strndup(title, length);
700+	free(window->base.title);
701+	window->base.title = strndup(title, length);
702 
703-    if (window->handler->title_changed)
704-        window->handler->title_changed(window->handler_data);
705+	if (window->handler->title_changed)
706+		window->handler->title_changed(window->handler_data);
707 }
708 
709-void window_set_app_id(struct window * window, const char * app_id)
710+void
711+window_set_app_id(struct window *window, const char *app_id)
712 {
713-    free(window->base.app_id);
714-    window->base.app_id = strdup(app_id);
715+	free(window->base.app_id);
716+	window->base.app_id = strdup(app_id);
717 
718-    if (window->handler->app_id_changed)
719-        window->handler->app_id_changed(window->handler_data);
720+	if (window->handler->app_id_changed)
721+		window->handler->app_id_changed(window->handler_data);
722 }
723 
724-void window_set_parent(struct window * window, struct window * parent)
725+void
726+window_set_parent(struct window *window, struct window *parent)
727 {
728-    if (window->base.parent == &parent->base)
729-        return;
730+	if (window->base.parent == &parent->base)
731+		return;
732 
733-    compositor_view_set_parent(window->view, parent->view);
734-    window->base.parent = &parent->base;
735+	compositor_view_set_parent(window->view, parent->view);
736+	window->base.parent = &parent->base;
737 
738-    if (window->handler->parent_changed)
739-        window->handler->parent_changed(window->handler_data);
740+	if (window->handler->parent_changed)
741+		window->handler->parent_changed(window->handler_data);
742 }
743 
744-void window_begin_move(struct window * window, struct button * button)
745+void
746+window_begin_move(struct window *window, struct button *button)
747 {
748-    if (window->mode != WINDOW_MODE_STACKED && window->handler->move)
749-        window->handler->move(window->handler_data);
750+	if (window->mode != WINDOW_MODE_STACKED && window->handler->move)
751+		window->handler->move(window->handler_data);
752 
753-    if (window->mode != WINDOW_MODE_STACKED || window->move.interaction.active)
754-        return;
755+	if (window->mode != WINDOW_MODE_STACKED || window->move.interaction.active)
756+		return;
757 
758-    struct swc_rectangle * geometry = &window->view->base.geometry;
759-    int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
760-            py = wl_fixed_to_int(swc.seat->pointer->y);
761+	struct swc_rectangle *geometry = &window->view->base.geometry;
762+	int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
763+	        py = wl_fixed_to_int(swc.seat->pointer->y);
764 
765-    begin_interaction(&window->move.interaction, button);
766-    window->move.offset.x = geometry->x - px;
767-    window->move.offset.y = geometry->y - py;
768+	begin_interaction(&window->move.interaction, button);
769+	window->move.offset.x = geometry->x - px;
770+	window->move.offset.y = geometry->y - py;
771 }
772 
773-void window_begin_resize(struct window * window, uint32_t edges,
774-                         struct button * button)
775+void
776+window_begin_resize(struct window *window, uint32_t edges,
777+                    struct button *button)
778 {
779-    if (window->mode != WINDOW_MODE_STACKED && window->handler->resize)
780-        window->handler->resize(window->handler_data);
781+	if (window->mode != WINDOW_MODE_STACKED && window->handler->resize)
782+		window->handler->resize(window->handler_data);
783 
784-    if (window->mode != WINDOW_MODE_STACKED
785-        || window->resize.interaction.active)
786-    {
787-        return;
788-    }
789+	if (window->mode != WINDOW_MODE_STACKED
790+	    || window->resize.interaction.active) {
791+		return;
792+	}
793 
794-    struct swc_rectangle * geometry = &window->view->base.geometry;
795-    int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
796-            py = wl_fixed_to_int(swc.seat->pointer->y);
797+	struct swc_rectangle *geometry = &window->view->base.geometry;
798+	int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
799+	        py = wl_fixed_to_int(swc.seat->pointer->y);
800 
801-    begin_interaction(&window->resize.interaction, button);
802+	begin_interaction(&window->resize.interaction, button);
803 
804-    if (!edges)
805-    {
806-        edges |= (px < geometry->x + geometry->width / 2)
807-            ? SWC_WINDOW_EDGE_LEFT : SWC_WINDOW_EDGE_RIGHT;
808-        edges |= (py < geometry->y + geometry->height / 2)
809-            ? SWC_WINDOW_EDGE_TOP : SWC_WINDOW_EDGE_BOTTOM;
810-    }
811+	if (!edges) {
812+		edges |= (px < geometry->x + geometry->width / 2)
813+		             ? SWC_WINDOW_EDGE_LEFT
814+		             : SWC_WINDOW_EDGE_RIGHT;
815+		edges |= (py < geometry->y + geometry->height / 2)
816+		             ? SWC_WINDOW_EDGE_TOP
817+		             : SWC_WINDOW_EDGE_BOTTOM;
818+	}
819 
820-    window->resize.offset.x = geometry->x - px
821-        + ((edges & SWC_WINDOW_EDGE_RIGHT) ? geometry->width : 0);
822-    window->resize.offset.y = geometry->y - py
823-        + ((edges & SWC_WINDOW_EDGE_BOTTOM) ? geometry->height : 0);
824-    window->resize.edges = edges;
825+	window->resize.offset.x = geometry->x - px
826+	                          + ((edges & SWC_WINDOW_EDGE_RIGHT) ? geometry->width : 0);
827+	window->resize.offset.y = geometry->y - py
828+	                          + ((edges & SWC_WINDOW_EDGE_BOTTOM) ? geometry->height : 0);
829+	window->resize.edges = edges;
830 }
831-
+63, -64
  1@@ -30,87 +30,86 @@
  2 #include <stdint.h>
  3 #include <wayland-server.h>
  4 
  5-struct window_pointer_interaction
  6-{
  7-    bool active;
  8-    uint32_t serial;
  9-    struct pointer_handler handler, * original_handler;
 10+struct window_pointer_interaction {
 11+	bool active;
 12+	uint32_t serial;
 13+	struct pointer_handler handler, *original_handler;
 14 };
 15 
 16-enum window_mode
 17-{
 18-    WINDOW_MODE_STACKED,
 19-    WINDOW_MODE_TILED,
 20-    WINDOW_MODE_FULLSCREEN,
 21+enum window_mode {
 22+	WINDOW_MODE_STACKED,
 23+	WINDOW_MODE_TILED,
 24+	WINDOW_MODE_FULLSCREEN,
 25 };
 26 
 27-struct window
 28-{
 29-    struct swc_window base;
 30-    const struct window_impl * impl;
 31-    const struct swc_window_handler * handler;
 32-    void * handler_data;
 33-
 34-    struct compositor_view * view;
 35-    struct view_handler view_handler;
 36-    bool managed;
 37-    unsigned mode;
 38-
 39-    struct
 40-    {
 41-        struct window_pointer_interaction interaction;
 42-        struct { int32_t x, y; } offset;
 43-
 44-        bool pending;
 45-        int32_t x, y;
 46-    } move;
 47-
 48-    struct
 49-    {
 50-        struct window_pointer_interaction interaction;
 51-        struct { int32_t x, y; } offset;
 52-        uint32_t edges;
 53-    } resize;
 54-
 55-    struct
 56-    {
 57-        bool pending, acknowledged;
 58-        uint32_t width, height;
 59-    } configure;
 60+struct window {
 61+	struct swc_window base;
 62+	const struct window_impl *impl;
 63+	const struct swc_window_handler *handler;
 64+	void *handler_data;
 65+
 66+	struct compositor_view *view;
 67+	struct view_handler view_handler;
 68+	bool managed;
 69+	unsigned mode;
 70+
 71+	struct
 72+	    {
 73+		struct window_pointer_interaction interaction;
 74+		struct {
 75+			int32_t x, y;
 76+		} offset;
 77+
 78+		bool pending;
 79+		int32_t x, y;
 80+	} move;
 81+
 82+	struct
 83+	    {
 84+		struct window_pointer_interaction interaction;
 85+		struct {
 86+			int32_t x, y;
 87+		} offset;
 88+		uint32_t edges;
 89+	} resize;
 90+
 91+	struct
 92+	    {
 93+		bool pending, acknowledged;
 94+		uint32_t width, height;
 95+	} configure;
 96 };
 97 
 98-struct window_impl
 99-{
100-    void (* move)(struct window * window, int32_t x, int32_t y);
101-    void (* configure)(struct window * window, uint32_t width, uint32_t height);
102-    void (* focus)(struct window * window);
103-    void (* unfocus)(struct window * window);
104-    void (* close)(struct window * window);
105-    void (* set_mode)(struct window * window, enum window_mode mode);
106+struct window_impl {
107+	void (*move)(struct window *window, int32_t x, int32_t y);
108+	void (*configure)(struct window *window, uint32_t width, uint32_t height);
109+	void (*focus)(struct window *window);
110+	void (*unfocus)(struct window *window);
111+	void (*close)(struct window *window);
112+	void (*set_mode)(struct window *window, enum window_mode mode);
113 };
114 
115 extern struct wl_listener window_enter_listener;
116 
117-bool window_initialize(struct window * window, const struct window_impl * impl,
118-                       struct surface * surface);
119+bool window_initialize(struct window *window, const struct window_impl *impl,
120+                       struct surface *surface);
121 
122-void window_finalize(struct window * window);
123+void window_finalize(struct window *window);
124 
125-void window_manage(struct window * window);
126+void window_manage(struct window *window);
127 
128-void window_unmanage(struct window * window);
129+void window_unmanage(struct window *window);
130 
131-void window_set_title(struct window * window,
132-                      const char * title, size_t length);
133+void window_set_title(struct window *window,
134+                      const char *title, size_t length);
135 
136-void window_set_app_id(struct window * window, const char * app_id);
137+void window_set_app_id(struct window *window, const char *app_id);
138 
139-void window_set_parent(struct window * window, struct window * parent);
140+void window_set_parent(struct window *window, struct window *parent);
141 
142-void window_begin_move(struct window * window, struct button * button);
143+void window_begin_move(struct window *window, struct button *button);
144 
145-void window_begin_resize(struct window * window, uint32_t edges,
146-                         struct button * button);
147+void window_begin_resize(struct window *window, uint32_t edges,
148+                         struct button *button);
149 
150 #endif
151-
+52, -51
  1@@ -30,82 +30,83 @@
  2 
  3 #include <stdlib.h>
  4 
  5-struct xdg_popup
  6-{
  7-    struct wl_resource * resource;
  8-    struct compositor_view * view;
  9-    struct wl_listener surface_destroy_listener;
 10+struct xdg_popup {
 11+	struct wl_resource *resource;
 12+	struct compositor_view *view;
 13+	struct wl_listener surface_destroy_listener;
 14 };
 15 
 16-static void destroy(struct wl_client * client, struct wl_resource * resource)
 17+static void
 18+destroy(struct wl_client *client, struct wl_resource *resource)
 19 {
 20-    wl_resource_destroy(resource);
 21+	wl_resource_destroy(resource);
 22 }
 23 
 24 static const struct xdg_popup_interface xdg_popup_implementation = {
 25-    .destroy = &destroy
 26+	.destroy = &destroy
 27 };
 28 
 29-static void handle_surface_destroy(struct wl_listener * listener, void * data)
 30+static void
 31+handle_surface_destroy(struct wl_listener *listener, void *data)
 32 {
 33-    struct xdg_popup * popup
 34-        = wl_container_of(listener, popup, surface_destroy_listener);
 35+	struct xdg_popup *popup = wl_container_of(listener, popup, surface_destroy_listener);
 36 
 37-    wl_resource_destroy(popup->resource);
 38+	wl_resource_destroy(popup->resource);
 39 }
 40 
 41-static void destroy_popup(struct wl_resource * resource)
 42+static void
 43+destroy_popup(struct wl_resource *resource)
 44 {
 45-    struct xdg_popup * popup = wl_resource_get_user_data(resource);
 46+	struct xdg_popup *popup = wl_resource_get_user_data(resource);
 47 
 48-    wl_list_remove(&popup->surface_destroy_listener.link);
 49-    compositor_view_destroy(popup->view);
 50-    free(popup);
 51+	wl_list_remove(&popup->surface_destroy_listener.link);
 52+	compositor_view_destroy(popup->view);
 53+	free(popup);
 54 }
 55 
 56-struct xdg_popup * xdg_popup_new(struct wl_client * client,
 57-                                 uint32_t version, uint32_t id,
 58-                                 struct surface * surface,
 59-                                 struct surface * parent_surface,
 60-                                 int32_t x, int32_t y)
 61+struct xdg_popup *
 62+xdg_popup_new(struct wl_client *client,
 63+              uint32_t version, uint32_t id,
 64+              struct surface *surface,
 65+              struct surface *parent_surface,
 66+              int32_t x, int32_t y)
 67 {
 68-    struct xdg_popup * popup;
 69-    struct compositor_view * parent = compositor_view(parent_surface->view);
 70+	struct xdg_popup *popup;
 71+	struct compositor_view *parent = compositor_view(parent_surface->view);
 72 
 73-    if (!parent)
 74-        goto error0;
 75+	if (!parent)
 76+		goto error0;
 77 
 78-    popup = malloc(sizeof *popup);
 79+	popup = malloc(sizeof *popup);
 80 
 81-    if (!popup)
 82-        goto error0;
 83+	if (!popup)
 84+		goto error0;
 85 
 86-    popup->resource = wl_resource_create(client, &xdg_popup_interface,
 87-                                         version, id);
 88+	popup->resource = wl_resource_create(client, &xdg_popup_interface,
 89+	                                     version, id);
 90 
 91-    if (!popup->resource)
 92-        goto error1;
 93+	if (!popup->resource)
 94+		goto error1;
 95 
 96-    popup->surface_destroy_listener.notify = &handle_surface_destroy;
 97-    wl_resource_add_destroy_listener(surface->resource,
 98-                                     &popup->surface_destroy_listener);
 99-    wl_resource_set_implementation(popup->resource, &xdg_popup_implementation,
100-                                   popup, &destroy_popup);
101+	popup->surface_destroy_listener.notify = &handle_surface_destroy;
102+	wl_resource_add_destroy_listener(surface->resource,
103+	                                 &popup->surface_destroy_listener);
104+	wl_resource_set_implementation(popup->resource, &xdg_popup_implementation,
105+	                               popup, &destroy_popup);
106 
107-    if (!(popup->view = compositor_create_view(surface)))
108-        goto error2;
109+	if (!(popup->view = compositor_create_view(surface)))
110+		goto error2;
111 
112-    view_move(&popup->view->base,
113-              parent->base.geometry.x + x, parent->base.geometry.y + y);
114-    compositor_view_set_parent(popup->view, parent);
115+	view_move(&popup->view->base,
116+	          parent->base.geometry.x + x, parent->base.geometry.y + y);
117+	compositor_view_set_parent(popup->view, parent);
118 
119-    return popup;
120+	return popup;
121 
122-  error2:
123-    wl_resource_destroy(popup->resource);
124-  error1:
125-    free(popup);
126-  error0:
127-    return NULL;
128+error2:
129+	wl_resource_destroy(popup->resource);
130+error1:
131+	free(popup);
132+error0:
133+	return NULL;
134 }
135-
+5, -6
 1@@ -29,11 +29,10 @@
 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,
11+                                uint32_t version, uint32_t id,
12+                                struct surface *surface,
13+                                struct surface *parent,
14+                                int32_t x, int32_t y);
15 
16 #endif
17-
+80, -74
  1@@ -36,115 +36,121 @@ static_assert(XDG_SHELL_VERSION == XDG_SHELL_VERSION_CURRENT,
  2               "xdg_shell implementation does not match protocol version");
  3 
  4 static struct
  5-{
  6-    struct wl_global * global;
  7+    {
  8+	struct wl_global *global;
  9 } shell;
 10 
 11-static void destroy(struct wl_client * client, struct wl_resource * resource)
 12+static void
 13+destroy(struct wl_client *client, struct wl_resource *resource)
 14 {
 15-    wl_resource_destroy(resource);
 16+	wl_resource_destroy(resource);
 17 }
 18 
 19-static void use_unstable_version(struct wl_client * client,
 20-                                 struct wl_resource * resource, int32_t version)
 21+static void
 22+use_unstable_version(struct wl_client *client,
 23+                     struct wl_resource *resource, int32_t version)
 24 {
 25 }
 26 
 27-static void get_xdg_surface(struct wl_client * client,
 28-                            struct wl_resource * resource, uint32_t id,
 29-                            struct wl_resource * surface_resource)
 30+static void
 31+get_xdg_surface(struct wl_client *client,
 32+                struct wl_resource *resource, uint32_t id,
 33+                struct wl_resource *surface_resource)
 34 {
 35-    struct surface * surface = wl_resource_get_user_data(surface_resource);
 36-    struct xdg_surface * xdg_surface;
 37+	struct surface *surface = wl_resource_get_user_data(surface_resource);
 38+	struct xdg_surface *xdg_surface;
 39 
 40-    xdg_surface = xdg_surface_new(client, wl_resource_get_version(resource), id,
 41-                                  surface);
 42+	xdg_surface = xdg_surface_new(client, wl_resource_get_version(resource), id,
 43+	                              surface);
 44 
 45-    if (!xdg_surface)
 46-        wl_resource_post_no_memory(resource);
 47+	if (!xdg_surface)
 48+		wl_resource_post_no_memory(resource);
 49 }
 50 
 51-static void get_xdg_popup(struct wl_client * client,
 52-                          struct wl_resource * resource, uint32_t id,
 53-                          struct wl_resource * surface_resource,
 54-                          struct wl_resource * parent_resource,
 55-                          struct wl_resource * seat_resource,
 56-                          uint32_t serial, int32_t x, int32_t y)
 57+static void
 58+get_xdg_popup(struct wl_client *client,
 59+              struct wl_resource *resource, uint32_t id,
 60+              struct wl_resource *surface_resource,
 61+              struct wl_resource *parent_resource,
 62+              struct wl_resource *seat_resource,
 63+              uint32_t serial, int32_t x, int32_t y)
 64 {
 65-    struct surface * surface = wl_resource_get_user_data(surface_resource);
 66-    struct surface * parent = wl_resource_get_user_data(parent_resource);
 67-    struct xdg_popup * popup;
 68+	struct surface *surface = wl_resource_get_user_data(surface_resource);
 69+	struct surface *parent = wl_resource_get_user_data(parent_resource);
 70+	struct xdg_popup *popup;
 71 
 72-    popup = xdg_popup_new(client, wl_resource_get_version(resource), id,
 73-                          surface, parent, x, y);
 74+	popup = xdg_popup_new(client, wl_resource_get_version(resource), id,
 75+	                      surface, parent, x, y);
 76 
 77-    if (!popup)
 78-        wl_resource_post_no_memory(resource);
 79+	if (!popup)
 80+		wl_resource_post_no_memory(resource);
 81 }
 82 
 83-static void pong(struct wl_client * client, struct wl_resource * resource,
 84-                 uint32_t serial)
 85+static void
 86+pong(struct wl_client *client, struct wl_resource *resource,
 87+     uint32_t serial)
 88 {
 89 }
 90 
 91 static const struct xdg_shell_interface shell_implementation = {
 92-    .destroy = &destroy,
 93-    .use_unstable_version = &use_unstable_version,
 94-    .get_xdg_surface = &get_xdg_surface,
 95-    .get_xdg_popup = &get_xdg_popup,
 96-    .pong = &pong
 97+	.destroy = &destroy,
 98+	.use_unstable_version = &use_unstable_version,
 99+	.get_xdg_surface = &get_xdg_surface,
100+	.get_xdg_popup = &get_xdg_popup,
101+	.pong = &pong
102 };
103 
104-static int unversioned_dispatch(const void * implementation, void * target,
105-                                uint32_t opcode,
106-                                const struct wl_message * message,
107-                                union wl_argument * arguments)
108+static int
109+unversioned_dispatch(const void *implementation, void *target,
110+                     uint32_t opcode,
111+                     const struct wl_message *message,
112+                     union wl_argument *arguments)
113 {
114-    struct wl_resource * resource = target;
115-
116-    if (opcode != 1)
117-    {
118-        wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
119-                               "use_unstable_version must be called first");
120-        return 0;
121-    }
122-
123-    if (arguments[0].i != XDG_SHELL_VERSION)
124-    {
125-        wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
126-                               "incompatible xdg_shell versions, "
127-                               "server: %d, client: %d",
128-                               XDG_SHELL_VERSION, arguments[0].i);
129-        return 0;
130-    }
131-
132-    wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
133-    return 1;
134+	struct wl_resource *resource = target;
135+
136+	if (opcode != 1) {
137+		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
138+		                       "use_unstable_version must be called first");
139+		return 0;
140+	}
141+
142+	if (arguments[0].i != XDG_SHELL_VERSION) {
143+		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
144+		                       "incompatible xdg_shell versions, "
145+		                       "server: %d, client: %d",
146+		                       XDG_SHELL_VERSION, arguments[0].i);
147+		return 0;
148+	}
149+
150+	wl_resource_set_implementation(resource, &shell_implementation, NULL, NULL);
151+	return 1;
152 }
153 
154-static void bind_shell(struct wl_client * client, void * data,
155-                       uint32_t version, uint32_t id)
156+static void
157+bind_shell(struct wl_client *client, void *data,
158+           uint32_t version, uint32_t id)
159 {
160-    struct wl_resource * resource;
161+	struct wl_resource *resource;
162 
163-    if (version > 1)
164-        version = 1;
165+	if (version > 1)
166+		version = 1;
167 
168-    resource = wl_resource_create(client, &xdg_shell_interface, version, id);
169-    wl_resource_set_dispatcher(resource, &unversioned_dispatch,
170-                               NULL, NULL, NULL);
171+	resource = wl_resource_create(client, &xdg_shell_interface, version, id);
172+	wl_resource_set_dispatcher(resource, &unversioned_dispatch,
173+	                           NULL, NULL, NULL);
174 }
175 
176-bool xdg_shell_initialize(void)
177+bool
178+xdg_shell_initialize(void)
179 {
180-    shell.global = wl_global_create(swc.display, &xdg_shell_interface, 1,
181-                                    NULL, &bind_shell);
182+	shell.global = wl_global_create(swc.display, &xdg_shell_interface, 1,
183+	                                NULL, &bind_shell);
184 
185-    return shell.global;
186+	return shell.global;
187 }
188 
189-void xdg_shell_finalize(void)
190+void
191+xdg_shell_finalize(void)
192 {
193-    wl_global_destroy(shell.global);
194+	wl_global_destroy(shell.global);
195 }
196-
+0, -1
1@@ -30,4 +30,3 @@ bool xdg_shell_initialize(void);
2 void xdg_shell_finalize(void);
3 
4 #endif
5-
+212, -203
  1@@ -33,306 +33,315 @@
  2 
  3 #include <stdlib.h>
  4 
  5-struct xdg_surface
  6-{
  7-    struct window window;
  8-    struct wl_resource * resource;
  9-    struct wl_listener surface_destroy_listener;
 10-    struct wl_array states;
 11-    uint32_t configure_serial;
 12+struct xdg_surface {
 13+	struct window window;
 14+	struct wl_resource *resource;
 15+	struct wl_listener surface_destroy_listener;
 16+	struct wl_array states;
 17+	uint32_t configure_serial;
 18 };
 19 
 20-static bool add_state(struct xdg_surface * xdg_surface, uint32_t state)
 21+static bool
 22+add_state(struct xdg_surface *xdg_surface, uint32_t state)
 23 {
 24-    uint32_t * current_state;
 25-
 26-    wl_array_for_each(current_state, &xdg_surface->states)
 27-    {
 28-        if (*current_state == state)
 29-            return false;
 30-    }
 31-
 32-    if (!(current_state = wl_array_add(&xdg_surface->states, sizeof state)))
 33-    {
 34-        WARNING("xdg_surface: Failed to allocate new state\n");
 35-        return false;
 36-    }
 37-
 38-    *current_state = state;
 39-    return true;
 40+	uint32_t *current_state;
 41+
 42+	wl_array_for_each (current_state, &xdg_surface->states) {
 43+		if (*current_state == state)
 44+			return false;
 45+	}
 46+
 47+	if (!(current_state = wl_array_add(&xdg_surface->states, sizeof state))) {
 48+		WARNING("xdg_surface: Failed to allocate new state\n");
 49+		return false;
 50+	}
 51+
 52+	*current_state = state;
 53+	return true;
 54 }
 55 
 56-static bool remove_state(struct xdg_surface * xdg_surface, uint32_t state)
 57+static bool
 58+remove_state(struct xdg_surface *xdg_surface, uint32_t state)
 59 {
 60-    uint32_t * current_state;
 61-
 62-    wl_array_for_each(current_state, &xdg_surface->states)
 63-    {
 64-        if (*current_state == state)
 65-        {
 66-            array_remove(&xdg_surface->states, current_state, sizeof state);
 67-            return true;
 68-        }
 69-    }
 70-
 71-    return false;
 72+	uint32_t *current_state;
 73+
 74+	wl_array_for_each (current_state, &xdg_surface->states) {
 75+		if (*current_state == state) {
 76+			array_remove(&xdg_surface->states, current_state, sizeof state);
 77+			return true;
 78+		}
 79+	}
 80+
 81+	return false;
 82 }
 83 
 84-static void configure(struct window * window, uint32_t width, uint32_t height)
 85+static void
 86+configure(struct window *window, uint32_t width, uint32_t height)
 87 {
 88-    struct xdg_surface * xdg_surface
 89-        = wl_container_of(window, xdg_surface, window);
 90-
 91-    window->configure.acknowledged = false;
 92-    xdg_surface->configure_serial = wl_display_next_serial(swc.display);
 93-    xdg_surface_send_configure(xdg_surface->resource, width, height,
 94-                               &xdg_surface->states,
 95-                               xdg_surface->configure_serial);
 96+	struct xdg_surface *xdg_surface = wl_container_of(window, xdg_surface, window);
 97+
 98+	window->configure.acknowledged = false;
 99+	xdg_surface->configure_serial = wl_display_next_serial(swc.display);
100+	xdg_surface_send_configure(xdg_surface->resource, width, height,
101+	                           &xdg_surface->states,
102+	                           xdg_surface->configure_serial);
103 }
104 
105-static void focus(struct window * window)
106+static void
107+focus(struct window *window)
108 {
109-    struct xdg_surface * xdg_surface
110-        = wl_container_of(window, xdg_surface, window);
111+	struct xdg_surface *xdg_surface = wl_container_of(window, xdg_surface, window);
112 
113-    add_state(xdg_surface, XDG_SURFACE_STATE_ACTIVATED);
114-    configure(window, window->configure.width, window->configure.height);
115+	add_state(xdg_surface, XDG_SURFACE_STATE_ACTIVATED);
116+	configure(window, window->configure.width, window->configure.height);
117 }
118 
119-static void unfocus(struct window * window)
120+static void
121+unfocus(struct window *window)
122 {
123-    struct xdg_surface * xdg_surface
124-        = wl_container_of(window, xdg_surface, window);
125+	struct xdg_surface *xdg_surface = wl_container_of(window, xdg_surface, window);
126 
127-    remove_state(xdg_surface, XDG_SURFACE_STATE_ACTIVATED);
128-    configure(window, window->configure.width, window->configure.height);
129+	remove_state(xdg_surface, XDG_SURFACE_STATE_ACTIVATED);
130+	configure(window, window->configure.width, window->configure.height);
131 }
132 
133-static void close(struct window * window)
134+static void
135+close(struct window *window)
136 {
137-    struct xdg_surface * xdg_surface
138-        = wl_container_of(window, xdg_surface, window);
139+	struct xdg_surface *xdg_surface = wl_container_of(window, xdg_surface, window);
140 
141-    xdg_surface_send_close(xdg_surface->resource);
142+	xdg_surface_send_close(xdg_surface->resource);
143 }
144 
145-static void set_mode(struct window * window, unsigned mode)
146+static void
147+set_mode(struct window *window, unsigned mode)
148 {
149-    struct xdg_surface * xdg_surface
150-        = wl_container_of(window, xdg_surface, window);
151-
152-    switch (window->mode)
153-    {
154-        case WINDOW_MODE_TILED:
155-            remove_state(xdg_surface, XDG_SURFACE_STATE_MAXIMIZED);
156-            break;
157-        case WINDOW_MODE_FULLSCREEN:
158-            remove_state(xdg_surface, XDG_SURFACE_STATE_FULLSCREEN);
159-            break;
160-    }
161-
162-    switch (mode)
163-    {
164-        case WINDOW_MODE_TILED:
165-            add_state(xdg_surface, XDG_SURFACE_STATE_MAXIMIZED);
166-            break;
167-        case WINDOW_MODE_FULLSCREEN:
168-            add_state(xdg_surface, XDG_SURFACE_STATE_FULLSCREEN);
169-            break;
170-    }
171+	struct xdg_surface *xdg_surface = wl_container_of(window, xdg_surface, window);
172+
173+	switch (window->mode) {
174+	case WINDOW_MODE_TILED:
175+		remove_state(xdg_surface, XDG_SURFACE_STATE_MAXIMIZED);
176+		break;
177+	case WINDOW_MODE_FULLSCREEN:
178+		remove_state(xdg_surface, XDG_SURFACE_STATE_FULLSCREEN);
179+		break;
180+	}
181+
182+	switch (mode) {
183+	case WINDOW_MODE_TILED:
184+		add_state(xdg_surface, XDG_SURFACE_STATE_MAXIMIZED);
185+		break;
186+	case WINDOW_MODE_FULLSCREEN:
187+		add_state(xdg_surface, XDG_SURFACE_STATE_FULLSCREEN);
188+		break;
189+	}
190 }
191 
192 static const struct window_impl xdg_surface_window_impl = {
193-    .configure = &configure,
194-    .focus = &focus,
195-    .unfocus = &unfocus,
196-    .close = &close,
197-    .set_mode = &set_mode,
198+	.configure = &configure,
199+	.focus = &focus,
200+	.unfocus = &unfocus,
201+	.close = &close,
202+	.set_mode = &set_mode,
203 };
204 
205-static void destroy(struct wl_client * client, struct wl_resource * resource)
206+static void
207+destroy(struct wl_client *client, struct wl_resource *resource)
208 {
209-    wl_resource_destroy(resource);
210+	wl_resource_destroy(resource);
211 }
212 
213-static void set_parent(struct wl_client * client, struct wl_resource * resource,
214-                       struct wl_resource * parent_resource)
215+static void
216+set_parent(struct wl_client *client, struct wl_resource *resource,
217+           struct wl_resource *parent_resource)
218 {
219-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource),
220-                       * parent_surface;
221-    struct window * parent_window = NULL;
222+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource),
223+	                   *parent_surface;
224+	struct window *parent_window = NULL;
225 
226-    if (parent_resource)
227-    {
228-        parent_surface = wl_resource_get_user_data(parent_resource);
229-        parent_window = &parent_surface->window;
230-    }
231+	if (parent_resource) {
232+		parent_surface = wl_resource_get_user_data(parent_resource);
233+		parent_window = &parent_surface->window;
234+	}
235 
236-    window_set_parent(&xdg_surface->window, parent_window);
237+	window_set_parent(&xdg_surface->window, parent_window);
238 }
239 
240-static void set_title(struct wl_client * client, struct wl_resource * resource,
241-                      const char * title)
242+static void
243+set_title(struct wl_client *client, struct wl_resource *resource,
244+          const char *title)
245 {
246-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource);
247+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
248 
249-    window_set_title(&xdg_surface->window, title, -1);
250+	window_set_title(&xdg_surface->window, title, -1);
251 }
252 
253-static void set_app_id(struct wl_client * client, struct wl_resource * resource,
254-                       const char * app_id)
255+static void
256+set_app_id(struct wl_client *client, struct wl_resource *resource,
257+           const char *app_id)
258 {
259-    struct xdg_surface * surface = wl_resource_get_user_data(resource);
260+	struct xdg_surface *surface = wl_resource_get_user_data(resource);
261 
262-    window_set_app_id(&surface->window, app_id);
263+	window_set_app_id(&surface->window, app_id);
264 }
265 
266-static void show_window_menu(struct wl_client * client,
267-                             struct wl_resource * resource,
268-                             struct wl_resource * seat_resource,
269-                             uint32_t serial, int32_t x, int32_t y)
270+static void
271+show_window_menu(struct wl_client *client,
272+                 struct wl_resource *resource,
273+                 struct wl_resource *seat_resource,
274+                 uint32_t serial, int32_t x, int32_t y)
275 {
276 }
277 
278-static void move(struct wl_client * client, struct wl_resource * resource,
279-                 struct wl_resource * seat_resource, uint32_t serial)
280+static void
281+move(struct wl_client *client, struct wl_resource *resource,
282+     struct wl_resource *seat_resource, uint32_t serial)
283 {
284-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource);
285-    struct button * button;
286+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
287+	struct button *button;
288 
289-    if (!(button = pointer_get_button(swc.seat->pointer, serial)))
290-        return;
291+	if (!(button = pointer_get_button(swc.seat->pointer, serial)))
292+		return;
293 
294-    window_begin_move(&xdg_surface->window, button);
295+	window_begin_move(&xdg_surface->window, button);
296 }
297 
298-static void resize(struct wl_client * client, struct wl_resource * resource,
299-                   struct wl_resource * seat_resource, uint32_t serial,
300-                   uint32_t edges)
301+static void
302+resize(struct wl_client *client, struct wl_resource *resource,
303+       struct wl_resource *seat_resource, uint32_t serial,
304+       uint32_t edges)
305 {
306-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource);
307-    struct button * button;
308+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
309+	struct button *button;
310 
311-    if (!(button = pointer_get_button(swc.seat->pointer, serial)))
312-        return;
313+	if (!(button = pointer_get_button(swc.seat->pointer, serial)))
314+		return;
315 
316-    window_begin_resize(&xdg_surface->window, edges, button);
317+	window_begin_resize(&xdg_surface->window, edges, button);
318 }
319 
320-static void ack_configure(struct wl_client * client,
321-                          struct wl_resource * resource, uint32_t serial)
322+static void
323+ack_configure(struct wl_client *client,
324+              struct wl_resource *resource, uint32_t serial)
325 {
326-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource);
327+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
328 
329-    if (serial == xdg_surface->configure_serial)
330-        xdg_surface->window.configure.acknowledged = true;
331+	if (serial == xdg_surface->configure_serial)
332+		xdg_surface->window.configure.acknowledged = true;
333 }
334 
335-static void set_window_geometry(struct wl_client * client,
336-                                struct wl_resource * resource,
337-                                int32_t x, int32_t y,
338-                                int32_t width, int32_t height)
339+static void
340+set_window_geometry(struct wl_client *client,
341+                    struct wl_resource *resource,
342+                    int32_t x, int32_t y,
343+                    int32_t width, int32_t height)
344 {
345-    /* TODO: Implement set_window_geometry. */
346+	/* TODO: Implement set_window_geometry. */
347 }
348 
349-static void set_maximized(struct wl_client * client,
350-                          struct wl_resource * resource)
351+static void
352+set_maximized(struct wl_client *client,
353+              struct wl_resource *resource)
354 {
355-    /* TODO: Implement set_maximized. */
356+	/* TODO: Implement set_maximized. */
357 }
358 
359-static void unset_maximized(struct wl_client * client,
360-                            struct wl_resource * resource)
361+static void
362+unset_maximized(struct wl_client *client,
363+                struct wl_resource *resource)
364 {
365-    /* TODO: Implement unset_maximized. */
366+	/* TODO: Implement unset_maximized. */
367 }
368 
369-static void set_fullscreen(struct wl_client * client,
370-                           struct wl_resource * resource,
371-                           struct wl_resource * output_resource)
372+static void
373+set_fullscreen(struct wl_client *client,
374+               struct wl_resource *resource,
375+               struct wl_resource *output_resource)
376 {
377-    /* TODO: Implement set_fullscreen. */
378+	/* TODO: Implement set_fullscreen. */
379 }
380 
381-static void unset_fullscreen(struct wl_client * client,
382-                             struct wl_resource * resource)
383+static void
384+unset_fullscreen(struct wl_client *client,
385+                 struct wl_resource *resource)
386 {
387-    /* TODO: Implement unset_fullscreen. */
388+	/* TODO: Implement unset_fullscreen. */
389 }
390 
391-static void set_minimized(struct wl_client * client,
392-                          struct wl_resource * resource)
393+static void
394+set_minimized(struct wl_client *client,
395+              struct wl_resource *resource)
396 {
397-    /* TODO: Implement set_minimized. */
398+	/* TODO: Implement set_minimized. */
399 }
400 
401 static const struct xdg_surface_interface xdg_surface_implementation = {
402-    .destroy = &destroy,
403-    .set_parent = &set_parent,
404-    .set_title = &set_title,
405-    .set_app_id = &set_app_id,
406-    .show_window_menu = &show_window_menu,
407-    .move = &move,
408-    .resize = &resize,
409-    .ack_configure = &ack_configure,
410-    .set_window_geometry = &set_window_geometry,
411-    .set_maximized = &set_maximized,
412-    .unset_maximized = &unset_maximized,
413-    .set_fullscreen = &set_fullscreen,
414-    .unset_fullscreen = &unset_fullscreen,
415-    .set_minimized = &set_minimized,
416+	.destroy = &destroy,
417+	.set_parent = &set_parent,
418+	.set_title = &set_title,
419+	.set_app_id = &set_app_id,
420+	.show_window_menu = &show_window_menu,
421+	.move = &move,
422+	.resize = &resize,
423+	.ack_configure = &ack_configure,
424+	.set_window_geometry = &set_window_geometry,
425+	.set_maximized = &set_maximized,
426+	.unset_maximized = &unset_maximized,
427+	.set_fullscreen = &set_fullscreen,
428+	.unset_fullscreen = &unset_fullscreen,
429+	.set_minimized = &set_minimized,
430 };
431 
432-static void handle_surface_destroy(struct wl_listener * listener, void * data)
433+static void
434+handle_surface_destroy(struct wl_listener *listener, void *data)
435 {
436-    struct xdg_surface * xdg_surface
437-        = wl_container_of (listener, xdg_surface, surface_destroy_listener);
438+	struct xdg_surface *xdg_surface = wl_container_of(listener, xdg_surface, surface_destroy_listener);
439 
440-    wl_resource_destroy(xdg_surface->resource);
441+	wl_resource_destroy(xdg_surface->resource);
442 }
443 
444-static void destroy_xdg_surface(struct wl_resource * resource)
445+static void
446+destroy_xdg_surface(struct wl_resource *resource)
447 {
448-    struct xdg_surface * xdg_surface = wl_resource_get_user_data(resource);
449+	struct xdg_surface *xdg_surface = wl_resource_get_user_data(resource);
450 
451-    wl_list_remove(&xdg_surface->surface_destroy_listener.link);
452-    window_finalize(&xdg_surface->window);
453-    free(xdg_surface);
454+	wl_list_remove(&xdg_surface->surface_destroy_listener.link);
455+	window_finalize(&xdg_surface->window);
456+	free(xdg_surface);
457 }
458 
459-struct xdg_surface * xdg_surface_new(struct wl_client * client,
460-                                     uint32_t version, uint32_t id,
461-                                     struct surface * surface)
462+struct xdg_surface *
463+xdg_surface_new(struct wl_client *client,
464+                uint32_t version, uint32_t id,
465+                struct surface *surface)
466 {
467-    struct xdg_surface * xdg_surface;
468+	struct xdg_surface *xdg_surface;
469 
470-    xdg_surface = malloc(sizeof *xdg_surface);
471+	xdg_surface = malloc(sizeof *xdg_surface);
472 
473-    if (!xdg_surface)
474-        goto error0;
475+	if (!xdg_surface)
476+		goto error0;
477 
478-    xdg_surface->resource = wl_resource_create(client, &xdg_surface_interface,
479-                                               version, id);
480+	xdg_surface->resource = wl_resource_create(client, &xdg_surface_interface,
481+	                                           version, id);
482 
483-    if (!xdg_surface->resource)
484-        goto error1;
485+	if (!xdg_surface->resource)
486+		goto error1;
487 
488-    window_initialize(&xdg_surface->window, &xdg_surface_window_impl, surface);
489-    xdg_surface->surface_destroy_listener.notify = &handle_surface_destroy;
490-    wl_array_init(&xdg_surface->states);
491-    wl_resource_add_destroy_listener(surface->resource,
492-                                     &xdg_surface->surface_destroy_listener);
493-    wl_resource_set_implementation(xdg_surface->resource,
494-                                   &xdg_surface_implementation,
495-                                   xdg_surface, &destroy_xdg_surface);
496-    window_manage(&xdg_surface->window);
497+	window_initialize(&xdg_surface->window, &xdg_surface_window_impl, surface);
498+	xdg_surface->surface_destroy_listener.notify = &handle_surface_destroy;
499+	wl_array_init(&xdg_surface->states);
500+	wl_resource_add_destroy_listener(surface->resource,
501+	                                 &xdg_surface->surface_destroy_listener);
502+	wl_resource_set_implementation(xdg_surface->resource,
503+	                               &xdg_surface_implementation,
504+	                               xdg_surface, &destroy_xdg_surface);
505+	window_manage(&xdg_surface->window);
506 
507-    return xdg_surface;
508+	return xdg_surface;
509 
510-  error1:
511-    free(xdg_surface);
512-  error0:
513-    return NULL;
514+error1:
515+	free(xdg_surface);
516+error0:
517+	return NULL;
518 }
519-
+3, -4
 1@@ -29,9 +29,8 @@
 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,
 9+                                    uint32_t version, uint32_t id,
10+                                    struct surface *surface);
11 
12 #endif
13-
+101, -111
  1@@ -32,140 +32,130 @@
  2 
  3 static const char keymap_file_template[] = "swc-xkb-keymap-XXXXXX";
  4 
  5-bool xkb_initialize(struct xkb * xkb)
  6+bool
  7+xkb_initialize(struct xkb *xkb)
  8 {
  9-    xkb->context = xkb_context_new(0);
 10-
 11-    if (!xkb->context)
 12-    {
 13-        ERROR("Could not create XKB context\n");
 14-        goto error0;
 15-    }
 16-
 17-    xkb->keymap.map = xkb_keymap_new_from_names(xkb->context, NULL, 0);
 18-
 19-    if (!xkb->keymap.map)
 20-    {
 21-        ERROR("Could not create XKB keymap\n");
 22-        goto error1;
 23-    }
 24-
 25-    xkb->state = xkb_state_new(xkb->keymap.map);
 26-
 27-    if (!xkb->state)
 28-    {
 29-        ERROR("Could not create XKB state\n");
 30-        goto error2;
 31-    }
 32-
 33-    if (!xkb_update_keymap(xkb))
 34-    {
 35-        ERROR("Could not update XKB keymap\n");
 36-        goto error3;
 37-    }
 38-
 39-    return true;
 40-
 41-  error3:
 42-    xkb_state_unref(xkb->state);
 43-  error2:
 44-    xkb_keymap_unref(xkb->keymap.map);
 45-  error1:
 46-    xkb_context_unref(xkb->context);
 47-  error0:
 48-    return false;
 49+	xkb->context = xkb_context_new(0);
 50+
 51+	if (!xkb->context) {
 52+		ERROR("Could not create XKB context\n");
 53+		goto error0;
 54+	}
 55+
 56+	xkb->keymap.map = xkb_keymap_new_from_names(xkb->context, NULL, 0);
 57+
 58+	if (!xkb->keymap.map) {
 59+		ERROR("Could not create XKB keymap\n");
 60+		goto error1;
 61+	}
 62+
 63+	xkb->state = xkb_state_new(xkb->keymap.map);
 64+
 65+	if (!xkb->state) {
 66+		ERROR("Could not create XKB state\n");
 67+		goto error2;
 68+	}
 69+
 70+	if (!xkb_update_keymap(xkb)) {
 71+		ERROR("Could not update XKB keymap\n");
 72+		goto error3;
 73+	}
 74+
 75+	return true;
 76+
 77+error3:
 78+	xkb_state_unref(xkb->state);
 79+error2:
 80+	xkb_keymap_unref(xkb->keymap.map);
 81+error1:
 82+	xkb_context_unref(xkb->context);
 83+error0:
 84+	return false;
 85 }
 86 
 87-void xkb_finalize(struct xkb * xkb)
 88+void
 89+xkb_finalize(struct xkb *xkb)
 90 {
 91-    munmap(xkb->keymap.area, xkb->keymap.size);
 92-    close(xkb->keymap.fd);
 93-    xkb_state_unref(xkb->state);
 94-    xkb_keymap_unref(xkb->keymap.map);
 95-    xkb_context_unref(xkb->context);
 96+	munmap(xkb->keymap.area, xkb->keymap.size);
 97+	close(xkb->keymap.fd);
 98+	xkb_state_unref(xkb->state);
 99+	xkb_keymap_unref(xkb->keymap.map);
100+	xkb_context_unref(xkb->context);
101 }
102 
103-bool xkb_reset_state(struct xkb * xkb)
104+bool
105+xkb_reset_state(struct xkb *xkb)
106 {
107-    struct xkb_state * state;
108+	struct xkb_state *state;
109 
110-    if (!(state = xkb_state_new(xkb->keymap.map)))
111-    {
112-        ERROR("Failed to allocate new XKB state\n");
113-        return false;
114-    }
115+	if (!(state = xkb_state_new(xkb->keymap.map))) {
116+		ERROR("Failed to allocate new XKB state\n");
117+		return false;
118+	}
119 
120-    xkb_state_unref(xkb->state);
121-    xkb->state = state;
122-    return true;
123+	xkb_state_unref(xkb->state);
124+	xkb->state = state;
125+	return true;
126 }
127 
128-bool xkb_update_keymap(struct xkb * xkb)
129+bool
130+xkb_update_keymap(struct xkb *xkb)
131 {
132-    const char * keymap_directory = getenv("XDG_RUNTIME_DIR") ?: "/tmp";
133-    char * keymap_string;
134-    char keymap_path[strlen(keymap_directory) + 1
135-                     + sizeof keymap_file_template];
136-
137-    xkb->indices.ctrl
138-        = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_CTRL);
139-    xkb->indices.alt
140-        = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_ALT);
141-    xkb->indices.super
142-        = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_LOGO);
143-    xkb->indices.shift
144-        = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_SHIFT);
145-
146-    /* In order to send the keymap to clients, we must first convert it to a
147+	const char *keymap_directory = getenv("XDG_RUNTIME_DIR") ?: "/tmp";
148+	char *keymap_string;
149+	char keymap_path[strlen(keymap_directory) + 1
150+	                 + sizeof keymap_file_template];
151+
152+	xkb->indices.ctrl = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_CTRL);
153+	xkb->indices.alt = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_ALT);
154+	xkb->indices.super = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_LOGO);
155+	xkb->indices.shift = xkb_keymap_mod_get_index(xkb->keymap.map, XKB_MOD_NAME_SHIFT);
156+
157+	/* In order to send the keymap to clients, we must first convert it to a
158      * string and then mmap it to a file. */
159-    keymap_string = xkb_keymap_get_as_string(xkb->keymap.map,
160-                                             XKB_KEYMAP_FORMAT_TEXT_V1);
161+	keymap_string = xkb_keymap_get_as_string(xkb->keymap.map,
162+	                                         XKB_KEYMAP_FORMAT_TEXT_V1);
163 
164-    if (!keymap_string)
165-    {
166-        WARNING("Could not get XKB keymap as a string\n");
167-        goto error0;
168-    }
169+	if (!keymap_string) {
170+		WARNING("Could not get XKB keymap as a string\n");
171+		goto error0;
172+	}
173 
174-    sprintf(keymap_path, "%s/%s", keymap_directory, keymap_file_template);
175+	sprintf(keymap_path, "%s/%s", keymap_directory, keymap_file_template);
176 
177-    xkb->keymap.size = strlen(keymap_string) + 1;
178-    xkb->keymap.fd = mkostemp(keymap_path, O_CLOEXEC);
179+	xkb->keymap.size = strlen(keymap_string) + 1;
180+	xkb->keymap.fd = mkostemp(keymap_path, O_CLOEXEC);
181 
182-    if (xkb->keymap.fd == -1)
183-    {
184-        WARNING("Could not create XKB keymap file\n");
185-        goto error1;
186-    }
187+	if (xkb->keymap.fd == -1) {
188+		WARNING("Could not create XKB keymap file\n");
189+		goto error1;
190+	}
191 
192-    unlink(keymap_path);
193+	unlink(keymap_path);
194 
195-    if (posix_fallocate(xkb->keymap.fd, 0, xkb->keymap.size) != 0)
196-    {
197-        WARNING("Could not resize XKB keymap file\n");
198-        goto error2;
199-    }
200+	if (posix_fallocate(xkb->keymap.fd, 0, xkb->keymap.size) != 0) {
201+		WARNING("Could not resize XKB keymap file\n");
202+		goto error2;
203+	}
204 
205-    xkb->keymap.area = mmap(NULL, xkb->keymap.size, PROT_READ | PROT_WRITE,
206-                            MAP_SHARED, xkb->keymap.fd, 0);
207+	xkb->keymap.area = mmap(NULL, xkb->keymap.size, PROT_READ | PROT_WRITE,
208+	                        MAP_SHARED, xkb->keymap.fd, 0);
209 
210-    if (xkb->keymap.area == MAP_FAILED)
211-    {
212-        WARNING("Could not mmap XKB keymap string\n");
213-        goto error2;
214-    }
215+	if (xkb->keymap.area == MAP_FAILED) {
216+		WARNING("Could not mmap XKB keymap string\n");
217+		goto error2;
218+	}
219 
220-    strcpy(xkb->keymap.area, keymap_string);
221+	strcpy(xkb->keymap.area, keymap_string);
222 
223-    free(keymap_string);
224+	free(keymap_string);
225 
226-    return true;
227+	return true;
228 
229-  error2:
230-    close(xkb->keymap.fd);
231-  error1:
232-    free(keymap_string);
233-  error0:
234-    return false;
235+error2:
236+	close(xkb->keymap.fd);
237+error1:
238+	free(keymap_string);
239+error0:
240+	return false;
241 }
242-
+20, -22
 1@@ -30,30 +30,28 @@
 2 /* Keycodes are offset by 8 in XKB. */
 3 #define XKB_KEY(key) ((key) + 8)
 4 
 5-struct xkb
 6-{
 7-    struct xkb_context * context;
 8-    struct xkb_state * state;
 9-
10-    struct
11-    {
12-        struct xkb_keymap * map;
13-        int fd;
14-        uint32_t size;
15-        char * area;
16-    } keymap;
17-
18-    struct
19-    {
20-        uint32_t ctrl, alt, super, shift;
21-    } indices;
22+struct xkb {
23+	struct xkb_context *context;
24+	struct xkb_state *state;
25+
26+	struct
27+	    {
28+		struct xkb_keymap *map;
29+		int fd;
30+		uint32_t size;
31+		char *area;
32+	} keymap;
33+
34+	struct
35+	    {
36+		uint32_t ctrl, alt, super, shift;
37+	} indices;
38 };
39 
40-bool xkb_initialize(struct xkb * xkb);
41-void xkb_finalize(struct xkb * xkb);
42-bool xkb_reset_state(struct xkb * xkb);
43+bool xkb_initialize(struct xkb *xkb);
44+void xkb_finalize(struct xkb *xkb);
45+bool xkb_reset_state(struct xkb *xkb);
46 
47-bool xkb_update_keymap(struct xkb * xkb);
48+bool xkb_update_keymap(struct xkb *xkb);
49 
50 #endif
51-
+234, -243
  1@@ -40,284 +40,275 @@
  2 #include <sys/un.h>
  3 #include <wayland-server.h>
  4 
  5-#define LOCK_FMT    "/tmp/.X%d-lock"
  6-#define SOCKET_DIR  "/tmp/.X11-unix"
  7-#define SOCKET_FMT  SOCKET_DIR "/X%d"
  8+#define LOCK_FMT "/tmp/.X%d-lock"
  9+#define SOCKET_DIR "/tmp/.X11-unix"
 10+#define SOCKET_FMT SOCKET_DIR "/X%d"
 11 
 12 static struct
 13-{
 14-    struct wl_resource * resource;
 15-    struct wl_event_source * usr1_source;
 16-    int display;
 17-    char display_name[16];
 18-    int abstract_fd, unix_fd, wm_fd;
 19+    {
 20+	struct wl_resource *resource;
 21+	struct wl_event_source *usr1_source;
 22+	int display;
 23+	char display_name[16];
 24+	int abstract_fd, unix_fd, wm_fd;
 25 } xserver;
 26 
 27 struct swc_xserver swc_xserver;
 28 
 29-static int open_socket(struct sockaddr_un * addr, size_t path_size)
 30+static int
 31+open_socket(struct sockaddr_un *addr, size_t path_size)
 32 {
 33-    int fd;
 34-    socklen_t size = offsetof(typeof(*addr), sun_path) + path_size + 1;
 35+	int fd;
 36+	socklen_t size = offsetof(typeof(*addr), sun_path) + path_size + 1;
 37 
 38-    if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0)
 39-        goto error0;
 40+	if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0)
 41+		goto error0;
 42 
 43-    /* Unlink the socket location in case it was being used by a process which
 44+	/* Unlink the socket location in case it was being used by a process which
 45      * left around a stale lockfile. */
 46-    unlink(addr->sun_path);
 47+	unlink(addr->sun_path);
 48 
 49-    if (bind(fd, (struct sockaddr *) addr, size) < 0)
 50-        goto error1;
 51+	if (bind(fd, (struct sockaddr *)addr, size) < 0)
 52+		goto error1;
 53 
 54-    if (listen(fd, 1) < 0)
 55-        goto error2;
 56+	if (listen(fd, 1) < 0)
 57+		goto error2;
 58 
 59-    return fd;
 60+	return fd;
 61 
 62-  error2:
 63-    if (addr->sun_path[0])
 64-        unlink(addr->sun_path);
 65-  error1:
 66-    close(fd);
 67-  error0:
 68-    return -1;
 69+error2:
 70+	if (addr->sun_path[0])
 71+		unlink(addr->sun_path);
 72+error1:
 73+	close(fd);
 74+error0:
 75+	return -1;
 76 }
 77 
 78-static bool open_display(void)
 79+static bool
 80+open_display(void)
 81 {
 82-    char lock_name[64], pid[12];
 83-    int lock_fd;
 84-    struct sockaddr_un addr = { .sun_family = AF_LOCAL };
 85-    size_t path_size;
 86-
 87-    xserver.display = 0;
 88-
 89-    /* Create X lockfile and server sockets */
 90-    goto begin;
 91-
 92-  retry2:
 93-    close(xserver.abstract_fd);
 94-  retry1:
 95-    unlink(lock_name);
 96-  retry0:
 97-    if (++xserver.display > 32)
 98-    {
 99-        ERROR("No open display in first 32\n");
100-        return false;
101-    }
102-
103-  begin:
104-    snprintf(lock_name, sizeof lock_name, LOCK_FMT, xserver.display);
105-    lock_fd = open(lock_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0444);
106-
107-    if (lock_fd == -1)
108-    {
109-        char * end;
110-        pid_t owner;
111-
112-        /* Check if the owning process is still alive. */
113-        if ((lock_fd = open(lock_name, O_RDONLY)) == -1)
114-            goto retry0;
115-
116-        if (read(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1)
117-            goto retry0;
118-
119-        owner = strtol(pid, &end, 10);
120-
121-        if (end != pid + 10)
122-            goto retry0;
123-
124-        if (kill(owner, 0) == 0 || errno != ESRCH)
125-            goto retry0;
126-
127-        if (unlink(lock_name) != 0)
128-            goto retry0;
129-
130-        goto begin;
131-    }
132-
133-    snprintf(pid, sizeof pid, "%10d\n", getpid());
134-    if (write(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1)
135-    {
136-        ERROR("Failed to write PID file\n");
137-        unlink(lock_name);
138-        close(lock_fd);
139-        return false;
140-    }
141-
142-    close(lock_fd);
143-
144-    /* Bind to abstract socket */
145-    addr.sun_path[0] = '\0';
146-    path_size = snprintf(addr.sun_path + 1, sizeof addr.sun_path - 1,
147-                         SOCKET_FMT, xserver.display);
148-    if ((xserver.abstract_fd = open_socket(&addr, path_size)) < 0)
149-        goto retry1;
150-
151-    /* Bind to unix socket */
152-    mkdir(SOCKET_DIR, 0777);
153-    path_size = snprintf(addr.sun_path, sizeof addr.sun_path,
154-                         SOCKET_FMT, xserver.display);
155-    if ((xserver.unix_fd = open_socket(&addr, path_size)) < 0)
156-        goto retry2;
157-
158-    snprintf(xserver.display_name, sizeof xserver.display_name,
159-             ":%d", xserver.display);
160-    setenv("DISPLAY", xserver.display_name, true);
161-
162-    return true;
163+	char lock_name[64], pid[12];
164+	int lock_fd;
165+	struct sockaddr_un addr = {.sun_family = AF_LOCAL };
166+	size_t path_size;
167+
168+	xserver.display = 0;
169+
170+	/* Create X lockfile and server sockets */
171+	goto begin;
172+
173+retry2:
174+	close(xserver.abstract_fd);
175+retry1:
176+	unlink(lock_name);
177+retry0:
178+	if (++xserver.display > 32) {
179+		ERROR("No open display in first 32\n");
180+		return false;
181+	}
182+
183+begin:
184+	snprintf(lock_name, sizeof lock_name, LOCK_FMT, xserver.display);
185+	lock_fd = open(lock_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0444);
186+
187+	if (lock_fd == -1) {
188+		char *end;
189+		pid_t owner;
190+
191+		/* Check if the owning process is still alive. */
192+		if ((lock_fd = open(lock_name, O_RDONLY)) == -1)
193+			goto retry0;
194+
195+		if (read(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1)
196+			goto retry0;
197+
198+		owner = strtol(pid, &end, 10);
199+
200+		if (end != pid + 10)
201+			goto retry0;
202+
203+		if (kill(owner, 0) == 0 || errno != ESRCH)
204+			goto retry0;
205+
206+		if (unlink(lock_name) != 0)
207+			goto retry0;
208+
209+		goto begin;
210+	}
211+
212+	snprintf(pid, sizeof pid, "%10d\n", getpid());
213+	if (write(lock_fd, pid, sizeof pid - 1) != sizeof pid - 1) {
214+		ERROR("Failed to write PID file\n");
215+		unlink(lock_name);
216+		close(lock_fd);
217+		return false;
218+	}
219+
220+	close(lock_fd);
221+
222+	/* Bind to abstract socket */
223+	addr.sun_path[0] = '\0';
224+	path_size = snprintf(addr.sun_path + 1, sizeof addr.sun_path - 1,
225+	                     SOCKET_FMT, xserver.display);
226+	if ((xserver.abstract_fd = open_socket(&addr, path_size)) < 0)
227+		goto retry1;
228+
229+	/* Bind to unix socket */
230+	mkdir(SOCKET_DIR, 0777);
231+	path_size = snprintf(addr.sun_path, sizeof addr.sun_path,
232+	                     SOCKET_FMT, xserver.display);
233+	if ((xserver.unix_fd = open_socket(&addr, path_size)) < 0)
234+		goto retry2;
235+
236+	snprintf(xserver.display_name, sizeof xserver.display_name,
237+	         ":%d", xserver.display);
238+	setenv("DISPLAY", xserver.display_name, true);
239+
240+	return true;
241 }
242 
243-static void close_display(void)
244+static void
245+close_display(void)
246 {
247-    char path[64];
248+	char path[64];
249 
250-    close(xserver.abstract_fd);
251-    close(xserver.unix_fd);
252+	close(xserver.abstract_fd);
253+	close(xserver.unix_fd);
254 
255-    snprintf(path, sizeof path, SOCKET_FMT, xserver.display);
256-    unlink(path);
257-    snprintf(path, sizeof path, LOCK_FMT, xserver.display);
258-    unlink(path);
259+	snprintf(path, sizeof path, SOCKET_FMT, xserver.display);
260+	unlink(path);
261+	snprintf(path, sizeof path, LOCK_FMT, xserver.display);
262+	unlink(path);
263 
264-    unsetenv("DISPLAY");
265+	unsetenv("DISPLAY");
266 }
267 
268-static int handle_usr1(int signal_number, void * data)
269+static int
270+handle_usr1(int signal_number, void *data)
271 {
272-    if (!xwm_initialize(xserver.wm_fd))
273-    {
274-        ERROR("Failed to initialize X window manager\n");
275-        /* XXX: How do we handle this case? */
276-    }
277+	if (!xwm_initialize(xserver.wm_fd)) {
278+		ERROR("Failed to initialize X window manager\n");
279+		/* XXX: How do we handle this case? */
280+	}
281 
282-    wl_event_source_remove(xserver.usr1_source);
283+	wl_event_source_remove(xserver.usr1_source);
284 
285-    return 0;
286+	return 0;
287 }
288 
289-bool xserver_initialize(void)
290+bool
291+xserver_initialize(void)
292 {
293-    int wl[2], wm[2];
294-
295-    /* Open an X display */
296-    if (!open_display())
297-    {
298-        ERROR("Failed to get X lockfile and sockets\n");
299-        goto error0;
300-    }
301-
302-    xserver.usr1_source = wl_event_loop_add_signal(swc.event_loop, SIGUSR1,
303-                                                   &handle_usr1, NULL);
304-
305-    if (!xserver.usr1_source)
306-    {
307-        ERROR("Failed to create SIGUSR1 event source\n");
308-        goto error1;
309-    }
310-
311-    /* Open a socket for the Wayland connection from Xwayland. */
312-    if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, wl) != 0)
313-    {
314-        ERROR("Failed to create socketpair: %s\n", strerror(errno));
315-        goto error2;
316-    }
317-
318-    /* Open a socket for the X connection to Xwayland. */
319-    if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, wm) != 0)
320-    {
321-        ERROR("Failed to create socketpair: %s\n", strerror(errno));
322-        goto error3;
323-    }
324-
325-    if (!(swc_xserver.client = wl_client_create(swc.display, wl[0])))
326-        goto error4;
327-
328-    xserver.wm_fd = wm[0];
329-
330-    /* Start the X server */
331-    switch (fork())
332-    {
333-        case 0:
334-        {
335-            int fds[] = { wl[1], wm[1], xserver.abstract_fd, xserver.unix_fd };
336-            char strings[ARRAY_LENGTH(fds)][16];
337-            unsigned index;
338-            struct sigaction action = { .sa_handler = SIG_IGN };
339-
340-            /* Unset the FD_CLOEXEC flag on the FDs that will get passed to
341+	int wl[2], wm[2];
342+
343+	/* Open an X display */
344+	if (!open_display()) {
345+		ERROR("Failed to get X lockfile and sockets\n");
346+		goto error0;
347+	}
348+
349+	xserver.usr1_source = wl_event_loop_add_signal(swc.event_loop, SIGUSR1,
350+	                                               &handle_usr1, NULL);
351+
352+	if (!xserver.usr1_source) {
353+		ERROR("Failed to create SIGUSR1 event source\n");
354+		goto error1;
355+	}
356+
357+	/* Open a socket for the Wayland connection from Xwayland. */
358+	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, wl) != 0) {
359+		ERROR("Failed to create socketpair: %s\n", strerror(errno));
360+		goto error2;
361+	}
362+
363+	/* Open a socket for the X connection to Xwayland. */
364+	if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, wm) != 0) {
365+		ERROR("Failed to create socketpair: %s\n", strerror(errno));
366+		goto error3;
367+	}
368+
369+	if (!(swc_xserver.client = wl_client_create(swc.display, wl[0])))
370+		goto error4;
371+
372+	xserver.wm_fd = wm[0];
373+
374+	/* Start the X server */
375+	switch (fork()) {
376+	case 0: {
377+		int fds[] = { wl[1], wm[1], xserver.abstract_fd, xserver.unix_fd };
378+		char strings[ARRAY_LENGTH(fds)][16];
379+		unsigned index;
380+		struct sigaction action = {.sa_handler = SIG_IGN };
381+
382+		/* Unset the FD_CLOEXEC flag on the FDs that will get passed to
383              * Xwayland. */
384-            for (index = 0; index < ARRAY_LENGTH(fds); ++index)
385-            {
386-                if (fcntl(fds[index], F_SETFD, 0) != 0)
387-                {
388-                    ERROR("fcntl() failed: %s\n", strerror(errno));
389-                    goto fail;
390-                }
391-
392-                if (snprintf(strings[index], sizeof strings[index],
393-                             "%d", fds[index]) >= sizeof strings[index])
394-                {
395-                    ERROR("FD is too large\n");
396-                    goto fail;
397-                }
398-            }
399-
400-            /* Ignore the USR1 signal so that Xwayland will send a USR1 signal
401+		for (index = 0; index < ARRAY_LENGTH(fds); ++index) {
402+			if (fcntl(fds[index], F_SETFD, 0) != 0) {
403+				ERROR("fcntl() failed: %s\n", strerror(errno));
404+				goto fail;
405+			}
406+
407+			if (snprintf(strings[index], sizeof strings[index],
408+			             "%d", fds[index]) >= sizeof strings[index]) {
409+				ERROR("FD is too large\n");
410+				goto fail;
411+			}
412+		}
413+
414+		/* Ignore the USR1 signal so that Xwayland will send a USR1 signal
415              * to the parent process (us) after it finishes initializing. See
416              * Xserver(1) for more details. */
417-            if (sigaction(SIGUSR1, &action, NULL) != 0)
418-            {
419-                ERROR("Failed to set SIGUSR1 handler to SIG_IGN: %s\n",
420-                      strerror(errno));
421-                goto fail;
422-            }
423-
424-            setenv("WAYLAND_SOCKET", strings[0], true);
425-            execlp("Xwayland", "Xwayland",
426-                   xserver.display_name,
427-                   "-rootless",
428-                   "-terminate",
429-                   "-listen", strings[2],
430-                   "-listen", strings[3],
431-                   "-wm", strings[1],
432-                   NULL);
433-
434-          fail:
435-            exit(EXIT_FAILURE);
436-        }
437-        case -1:
438-            ERROR("fork() failed when trying to start X server: %s\n",
439-                  strerror(errno));
440-            goto error5;
441-    }
442-
443-    close(wl[1]);
444-    close(wm[1]);
445-
446-    return true;
447-
448-  error5:
449-    wl_client_destroy(swc_xserver.client);
450-  error4:
451-    close(wm[1]);
452-    close(wm[0]);
453-  error3:
454-    close(wl[1]);
455-    close(wl[0]);
456-  error2:
457-    wl_event_source_remove(xserver.usr1_source);
458-  error1:
459-    close_display();
460-  error0:
461-    return false;
462+		if (sigaction(SIGUSR1, &action, NULL) != 0) {
463+			ERROR("Failed to set SIGUSR1 handler to SIG_IGN: %s\n",
464+			      strerror(errno));
465+			goto fail;
466+		}
467+
468+		setenv("WAYLAND_SOCKET", strings[0], true);
469+		execlp("Xwayland", "Xwayland",
470+		       xserver.display_name,
471+		       "-rootless",
472+		       "-terminate",
473+		       "-listen", strings[2],
474+		       "-listen", strings[3],
475+		       "-wm", strings[1],
476+		       NULL);
477+
478+	fail:
479+		exit(EXIT_FAILURE);
480+	}
481+	case -1:
482+		ERROR("fork() failed when trying to start X server: %s\n",
483+		      strerror(errno));
484+		goto error5;
485+	}
486+
487+	close(wl[1]);
488+	close(wm[1]);
489+
490+	return true;
491+
492+error5:
493+	wl_client_destroy(swc_xserver.client);
494+error4:
495+	close(wm[1]);
496+	close(wm[0]);
497+error3:
498+	close(wl[1]);
499+	close(wl[0]);
500+error2:
501+	wl_event_source_remove(xserver.usr1_source);
502+error1:
503+	close_display();
504+error0:
505+	return false;
506 }
507 
508-void xserver_finalize(void)
509+void
510+xserver_finalize(void)
511 {
512-    xwm_finalize();
513-    close_display();
514-    wl_client_destroy(swc_xserver.client);
515+	xwm_finalize();
516+	close_display();
517+	wl_client_destroy(swc_xserver.client);
518 }
519-
+2, -4
 1@@ -26,13 +26,11 @@
 2 
 3 #include <stdbool.h>
 4 
 5-struct swc_xserver
 6-{
 7-    struct wl_client * client;
 8+struct swc_xserver {
 9+	struct wl_client *client;
10 };
11 
12 bool xserver_initialize(void);
13 void xserver_finalize(void);
14 
15 #endif
16-
+407, -425
  1@@ -36,539 +36,521 @@
  2 #include <xcb/xcb_ewmh.h>
  3 #include <xcb/xcb_icccm.h>
  4 
  5-struct xwl_window
  6-{
  7-    xcb_window_t id;
  8-    uint32_t surface_id;
  9-    bool override_redirect, supports_delete;
 10-    struct wl_list link;
 11-
 12-    /* Only used for paired windows. */
 13-    struct {
 14-        struct window window;
 15-        struct wl_listener surface_destroy_listener;
 16-    };
 17+struct xwl_window {
 18+	xcb_window_t id;
 19+	uint32_t surface_id;
 20+	bool override_redirect, supports_delete;
 21+	struct wl_list link;
 22+
 23+	/* Only used for paired windows. */
 24+	struct {
 25+		struct window window;
 26+		struct wl_listener surface_destroy_listener;
 27+	};
 28 };
 29 
 30-enum atom
 31-{
 32-    ATOM_WL_SURFACE_ID,
 33-    ATOM_WM_DELETE_WINDOW,
 34-    ATOM_WM_PROTOCOLS,
 35-    ATOM_WM_S0,
 36+enum atom {
 37+	ATOM_WL_SURFACE_ID,
 38+	ATOM_WM_DELETE_WINDOW,
 39+	ATOM_WM_PROTOCOLS,
 40+	ATOM_WM_S0,
 41 };
 42 
 43 static struct
 44-{
 45-    xcb_connection_t * connection;
 46-    xcb_ewmh_connection_t ewmh;
 47-    xcb_screen_t * screen;
 48-    xcb_window_t window;
 49-    struct xwl_window * focus;
 50-    struct wl_event_source * source;
 51-    struct wl_list windows, unpaired_windows;
 52-    union
 53     {
 54-        const char * name;
 55-        xcb_intern_atom_cookie_t cookie;
 56-        xcb_atom_t value;
 57-    } atoms[4];
 58+	xcb_connection_t *connection;
 59+	xcb_ewmh_connection_t ewmh;
 60+	xcb_screen_t *screen;
 61+	xcb_window_t window;
 62+	struct xwl_window *focus;
 63+	struct wl_event_source *source;
 64+	struct wl_list windows, unpaired_windows;
 65+	union {
 66+		const char *name;
 67+		xcb_intern_atom_cookie_t cookie;
 68+		xcb_atom_t value;
 69+	} atoms[4];
 70 } xwm = {
 71-    .atoms = {
 72-        [ATOM_WL_SURFACE_ID]    = "WL_SURFACE_ID",
 73-        [ATOM_WM_DELETE_WINDOW] = "WM_DELETE_WINDOW",
 74-        [ATOM_WM_PROTOCOLS]     = "WM_PROTOCOLS",
 75-        [ATOM_WM_S0]            = "WM_S0",
 76-    }
 77+	.atoms = {
 78+	        [ATOM_WL_SURFACE_ID] = "WL_SURFACE_ID",
 79+	        [ATOM_WM_DELETE_WINDOW] = "WM_DELETE_WINDOW",
 80+	        [ATOM_WM_PROTOCOLS] = "WM_PROTOCOLS",
 81+	        [ATOM_WM_S0] = "WM_S0",
 82+	}
 83 };
 84 
 85-static void update_name(struct xwl_window * xwl_window)
 86+static void
 87+update_name(struct xwl_window *xwl_window)
 88 {
 89-    xcb_get_property_cookie_t wm_name_cookie;
 90-    xcb_ewmh_get_utf8_strings_reply_t wm_name_reply;
 91+	xcb_get_property_cookie_t wm_name_cookie;
 92+	xcb_ewmh_get_utf8_strings_reply_t wm_name_reply;
 93 
 94-    wm_name_cookie = xcb_ewmh_get_wm_name(&xwm.ewmh, xwl_window->id);
 95+	wm_name_cookie = xcb_ewmh_get_wm_name(&xwm.ewmh, xwl_window->id);
 96 
 97-    if (xcb_ewmh_get_wm_name_reply(&xwm.ewmh, wm_name_cookie,
 98-                                   &wm_name_reply, NULL))
 99-    {
100-        window_set_title(&xwl_window->window,
101-                         wm_name_reply.strings, wm_name_reply.strings_len);
102+	if (xcb_ewmh_get_wm_name_reply(&xwm.ewmh, wm_name_cookie,
103+	                               &wm_name_reply, NULL)) {
104+		window_set_title(&xwl_window->window,
105+		                 wm_name_reply.strings, wm_name_reply.strings_len);
106 
107-        xcb_ewmh_get_utf8_strings_reply_wipe(&wm_name_reply);
108-    }
109-    else
110-        window_set_title(&xwl_window->window, NULL, 0);
111+		xcb_ewmh_get_utf8_strings_reply_wipe(&wm_name_reply);
112+	} else
113+		window_set_title(&xwl_window->window, NULL, 0);
114 }
115 
116-static void update_protocols(struct xwl_window * xwl_window)
117+static void
118+update_protocols(struct xwl_window *xwl_window)
119 {
120-    xcb_get_property_cookie_t cookie;
121-    xcb_icccm_get_wm_protocols_reply_t reply;
122-    unsigned index;
123+	xcb_get_property_cookie_t cookie;
124+	xcb_icccm_get_wm_protocols_reply_t reply;
125+	unsigned index;
126 
127-    cookie = xcb_icccm_get_wm_protocols(xwm.connection, xwl_window->id,
128-                                        xwm.atoms[ATOM_WM_PROTOCOLS].value);
129+	cookie = xcb_icccm_get_wm_protocols(xwm.connection, xwl_window->id,
130+	                                    xwm.atoms[ATOM_WM_PROTOCOLS].value);
131 
132-    xwl_window->supports_delete = true;
133+	xwl_window->supports_delete = true;
134 
135-    if (!xcb_icccm_get_wm_protocols_reply(xwm.connection, cookie, &reply, NULL))
136-        return;
137+	if (!xcb_icccm_get_wm_protocols_reply(xwm.connection, cookie, &reply, NULL))
138+		return;
139 
140-    for (index = 0; index < reply.atoms_len; ++index)
141-    {
142-        if (reply.atoms[index] == xwm.atoms[ATOM_WM_DELETE_WINDOW].value)
143-            xwl_window->supports_delete = true;
144-    }
145+	for (index = 0; index < reply.atoms_len; ++index) {
146+		if (reply.atoms[index] == xwm.atoms[ATOM_WM_DELETE_WINDOW].value)
147+			xwl_window->supports_delete = true;
148+	}
149 
150-    xcb_icccm_get_wm_protocols_reply_wipe(&reply);
151+	xcb_icccm_get_wm_protocols_reply_wipe(&reply);
152 }
153 
154-static struct xwl_window * find_window(struct wl_list * list, xcb_window_t id)
155+static struct xwl_window *
156+find_window(struct wl_list *list, xcb_window_t id)
157 {
158-    struct xwl_window * window;
159+	struct xwl_window *window;
160 
161-    wl_list_for_each(window, list, link)
162-    {
163-        if (window->id == id)
164-            return window;
165-    }
166+	wl_list_for_each (window, list, link) {
167+		if (window->id == id)
168+			return window;
169+	}
170 
171-    return NULL;
172+	return NULL;
173 }
174 
175-static struct xwl_window * find_window_by_surface_id(struct wl_list * list,
176-                                                     uint32_t id)
177+static struct xwl_window *
178+find_window_by_surface_id(struct wl_list *list,
179+                          uint32_t id)
180 {
181-    struct xwl_window * window;
182+	struct xwl_window *window;
183 
184-    wl_list_for_each(window, list, link)
185-    {
186-        if (window->surface_id == id)
187-            return window;
188-    }
189+	wl_list_for_each (window, list, link) {
190+		if (window->surface_id == id)
191+			return window;
192+	}
193 
194-    return NULL;
195+	return NULL;
196 }
197 
198-static void move(struct window * window, int32_t x, int32_t y)
199+static void
200+move(struct window *window, int32_t x, int32_t y)
201 {
202-    uint32_t mask, values[2];
203-    struct xwl_window * xwl_window
204-        = wl_container_of(window, xwl_window, window);
205+	uint32_t mask, values[2];
206+	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
207 
208-    mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
209-    values[0] = x;
210-    values[1] = y;
211+	mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
212+	values[0] = x;
213+	values[1] = y;
214 
215-    xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
216-    xcb_flush(xwm.connection);
217+	xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
218+	xcb_flush(xwm.connection);
219 }
220 
221-static void configure(struct window * window, uint32_t width, uint32_t height)
222+static void
223+configure(struct window *window, uint32_t width, uint32_t height)
224 {
225-    uint32_t mask, values[2];
226-    struct xwl_window * xwl_window
227-        = wl_container_of(window, xwl_window, window);
228+	uint32_t mask, values[2];
229+	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
230 
231-    mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
232-    values[0] = width;
233-    values[1] = height;
234+	mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
235+	values[0] = width;
236+	values[1] = height;
237 
238-    window->configure.acknowledged = true;
239-    xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
240-    xcb_flush(xwm.connection);
241+	window->configure.acknowledged = true;
242+	xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
243+	xcb_flush(xwm.connection);
244 }
245 
246-static void focus(struct window * window)
247+static void
248+focus(struct window *window)
249 {
250-    struct xwl_window * xwl_window
251-        = wl_container_of(window, xwl_window, window);
252+	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
253 
254-    xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE,
255-                        xwl_window->id, XCB_CURRENT_TIME);
256-    xcb_flush(xwm.connection);
257-    xwm.focus = xwl_window;
258+	xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE,
259+	                    xwl_window->id, XCB_CURRENT_TIME);
260+	xcb_flush(xwm.connection);
261+	xwm.focus = xwl_window;
262 }
263 
264-static void unfocus(struct window * window)
265+static void
266+unfocus(struct window *window)
267 {
268-    struct xwl_window * xwl_window
269-        = wl_container_of(window, xwl_window, window);
270+	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
271 
272-    /* If the window we are unfocusing is the latest xwl_window to be focused,
273+	/* If the window we are unfocusing is the latest xwl_window to be focused,
274      * we know we have transitioned to some other window type, so the X11 focus
275      * can be set to XCB_NONE. Otherwise, we have transitioned to another X11
276      * window, and the X11 focus has already been updated. */
277-    if (xwl_window == xwm.focus)
278-    {
279-        xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, XCB_NONE,
280-                            XCB_CURRENT_TIME);
281-        xcb_flush(xwm.connection);
282-    }
283+	if (xwl_window == xwm.focus) {
284+		xcb_set_input_focus(xwm.connection, XCB_INPUT_FOCUS_NONE, XCB_NONE,
285+		                    XCB_CURRENT_TIME);
286+		xcb_flush(xwm.connection);
287+	}
288 }
289 
290-static void close(struct window * window)
291+static void
292+close(struct window *window)
293 {
294-    struct xwl_window * xwl_window
295-        = wl_container_of(window, xwl_window, window);
296-
297-    if (xwl_window->supports_delete)
298-    {
299-        xcb_client_message_event_t event = {
300-            .response_type = XCB_CLIENT_MESSAGE,
301-            .format = 32,
302-            .window = xwl_window->id,
303-            .type = xwm.atoms[ATOM_WM_PROTOCOLS].value,
304-            .data.data32 = {
305-                xwm.atoms[ATOM_WM_DELETE_WINDOW].value,
306-                XCB_CURRENT_TIME,
307-            },
308-        };
309-
310-        xcb_send_event(xwm.connection, false, xwl_window->id,
311-                       XCB_EVENT_MASK_NO_EVENT, (const char *) &event);
312-    }
313-    else
314-        xcb_kill_client(xwm.connection, xwl_window->id);
315-
316-    xcb_flush(xwm.connection);
317+	struct xwl_window *xwl_window = wl_container_of(window, xwl_window, window);
318+
319+	if (xwl_window->supports_delete) {
320+		xcb_client_message_event_t event = {
321+			.response_type = XCB_CLIENT_MESSAGE,
322+			.format = 32,
323+			.window = xwl_window->id,
324+			.type = xwm.atoms[ATOM_WM_PROTOCOLS].value,
325+			.data.data32 = {
326+			    xwm.atoms[ATOM_WM_DELETE_WINDOW].value,
327+			    XCB_CURRENT_TIME,
328+			},
329+		};
330+
331+		xcb_send_event(xwm.connection, false, xwl_window->id,
332+		               XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
333+	} else
334+		xcb_kill_client(xwm.connection, xwl_window->id);
335+
336+	xcb_flush(xwm.connection);
337 }
338 
339 static const struct window_impl xwl_window_handler = {
340-    .move = &move,
341-    .configure = &configure,
342-    .focus = &focus,
343-    .unfocus = &unfocus,
344-    .close = &close,
345+	.move = &move,
346+	.configure = &configure,
347+	.focus = &focus,
348+	.unfocus = &unfocus,
349+	.close = &close,
350 };
351 
352-static void handle_surface_destroy(struct wl_listener * listener, void * data)
353+static void
354+handle_surface_destroy(struct wl_listener *listener, void *data)
355 {
356-    struct xwl_window * xwl_window
357-        = wl_container_of(listener, xwl_window, surface_destroy_listener);
358+	struct xwl_window *xwl_window = wl_container_of(listener, xwl_window, surface_destroy_listener);
359 
360-    if (xwm.focus == xwl_window)
361-        xwm.focus = NULL;
362+	if (xwm.focus == xwl_window)
363+		xwm.focus = NULL;
364 
365-    window_finalize(&xwl_window->window);
366-    wl_list_remove(&xwl_window->link);
367-    wl_list_insert(&xwm.unpaired_windows, &xwl_window->link);
368-    xwl_window->surface_id = 0;
369+	window_finalize(&xwl_window->window);
370+	wl_list_remove(&xwl_window->link);
371+	wl_list_insert(&xwm.unpaired_windows, &xwl_window->link);
372+	xwl_window->surface_id = 0;
373 }
374 
375-static bool manage_window(struct xwl_window * xwl_window)
376+static bool
377+manage_window(struct xwl_window *xwl_window)
378 {
379-    struct wl_resource * resource;
380-    struct surface * surface;
381-    xcb_get_geometry_cookie_t geometry_cookie;
382-    xcb_get_geometry_reply_t * geometry_reply;
383-
384-    resource = wl_client_get_object(swc.xserver->client,
385-                                    xwl_window->surface_id);
386-
387-    if (!resource)
388-        return false;
389-
390-    surface = wl_resource_get_user_data(resource);
391-    geometry_cookie = xcb_get_geometry(xwm.connection, xwl_window->id);
392-
393-    window_initialize(&xwl_window->window, &xwl_window_handler, surface);
394-    xwl_window->surface_destroy_listener.notify = &handle_surface_destroy;
395-    wl_resource_add_destroy_listener(surface->resource,
396-                                     &xwl_window->surface_destroy_listener);
397-
398-    if ((geometry_reply = xcb_get_geometry_reply(xwm.connection,
399-                                                 geometry_cookie, NULL)))
400-    {
401-        view_move(surface->view, geometry_reply->x, geometry_reply->y);
402-        free(geometry_reply);
403-    }
404-
405-    if (xwl_window->override_redirect)
406-        compositor_view_show(xwl_window->window.view);
407-    else
408-    {
409-        uint32_t mask, values[1];
410-
411-        mask = XCB_CW_EVENT_MASK;
412-        values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
413-        xcb_change_window_attributes(xwm.connection, xwl_window->id,
414-                                     mask, values);
415-        mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
416-        values[0] = 0;
417-        xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
418-        update_name(xwl_window);
419-        update_protocols(xwl_window);
420-        window_manage(&xwl_window->window);
421-    }
422-
423-    wl_list_remove(&xwl_window->link);
424-    wl_list_insert(&xwm.windows, &xwl_window->link);
425-
426-    return true;
427+	struct wl_resource *resource;
428+	struct surface *surface;
429+	xcb_get_geometry_cookie_t geometry_cookie;
430+	xcb_get_geometry_reply_t *geometry_reply;
431+
432+	resource = wl_client_get_object(swc.xserver->client,
433+	                                xwl_window->surface_id);
434+
435+	if (!resource)
436+		return false;
437+
438+	surface = wl_resource_get_user_data(resource);
439+	geometry_cookie = xcb_get_geometry(xwm.connection, xwl_window->id);
440+
441+	window_initialize(&xwl_window->window, &xwl_window_handler, surface);
442+	xwl_window->surface_destroy_listener.notify = &handle_surface_destroy;
443+	wl_resource_add_destroy_listener(surface->resource,
444+	                                 &xwl_window->surface_destroy_listener);
445+
446+	if ((geometry_reply = xcb_get_geometry_reply(xwm.connection,
447+	                                             geometry_cookie, NULL))) {
448+		view_move(surface->view, geometry_reply->x, geometry_reply->y);
449+		free(geometry_reply);
450+	}
451+
452+	if (xwl_window->override_redirect)
453+		compositor_view_show(xwl_window->window.view);
454+	else {
455+		uint32_t mask, values[1];
456+
457+		mask = XCB_CW_EVENT_MASK;
458+		values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
459+		xcb_change_window_attributes(xwm.connection, xwl_window->id,
460+		                             mask, values);
461+		mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
462+		values[0] = 0;
463+		xcb_configure_window(xwm.connection, xwl_window->id, mask, values);
464+		update_name(xwl_window);
465+		update_protocols(xwl_window);
466+		window_manage(&xwl_window->window);
467+	}
468+
469+	wl_list_remove(&xwl_window->link);
470+	wl_list_insert(&xwm.windows, &xwl_window->link);
471+
472+	return true;
473 }
474 
475-static void handle_new_surface(struct wl_listener * listener, void * data)
476+static void
477+handle_new_surface(struct wl_listener *listener, void *data)
478 {
479-    struct surface * surface = data;
480-    struct xwl_window * window;
481+	struct surface *surface = data;
482+	struct xwl_window *window;
483 
484-    window = find_window_by_surface_id(&xwm.unpaired_windows,
485-                                       wl_resource_get_id(surface->resource));
486+	window = find_window_by_surface_id(&xwm.unpaired_windows,
487+	                                   wl_resource_get_id(surface->resource));
488 
489-    if (!window)
490-        return;
491+	if (!window)
492+		return;
493 
494-    manage_window(window);
495+	manage_window(window);
496 }
497 
498 static struct wl_listener new_surface_listener = {
499-    .notify = &handle_new_surface
500+	.notify = &handle_new_surface
501 };
502 
503 /* X event handlers */
504-static void create_notify(xcb_create_notify_event_t * event)
505+static void
506+create_notify(xcb_create_notify_event_t *event)
507 {
508-    struct xwl_window * xwl_window;
509+	struct xwl_window *xwl_window;
510 
511-    if (!(xwl_window = malloc(sizeof *xwl_window)))
512-        return;
513+	if (!(xwl_window = malloc(sizeof *xwl_window)))
514+		return;
515 
516-    xwl_window->id = event->window;
517-    xwl_window->surface_id = 0;
518-    xwl_window->override_redirect = event->override_redirect;
519-    wl_list_insert(&xwm.unpaired_windows, &xwl_window->link);
520+	xwl_window->id = event->window;
521+	xwl_window->surface_id = 0;
522+	xwl_window->override_redirect = event->override_redirect;
523+	wl_list_insert(&xwm.unpaired_windows, &xwl_window->link);
524 }
525 
526-static void destroy_notify(xcb_destroy_notify_event_t * event)
527+static void
528+destroy_notify(xcb_destroy_notify_event_t *event)
529 {
530-    struct xwl_window * xwl_window;
531+	struct xwl_window *xwl_window;
532 
533-    if ((xwl_window = find_window(&xwm.windows, event->window)))
534-    {
535-        wl_list_remove(&xwl_window->surface_destroy_listener.link);
536-        window_finalize(&xwl_window->window);
537-    }
538-    else if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window)))
539-        return;
540-
541-    wl_list_remove(&xwl_window->link);
542-    free(xwl_window);
543+	if ((xwl_window = find_window(&xwm.windows, event->window))) {
544+		wl_list_remove(&xwl_window->surface_destroy_listener.link);
545+		window_finalize(&xwl_window->window);
546+	} else if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window)))
547+		return;
548+
549+	wl_list_remove(&xwl_window->link);
550+	free(xwl_window);
551 }
552 
553-static void map_request(xcb_map_request_event_t * event)
554+static void
555+map_request(xcb_map_request_event_t *event)
556 {
557-    xcb_map_window(xwm.connection, event->window);
558+	xcb_map_window(xwm.connection, event->window);
559 }
560 
561-static void configure_request(xcb_configure_request_event_t * event)
562+static void
563+configure_request(xcb_configure_request_event_t *event)
564 {
565 }
566 
567-static void property_notify(xcb_property_notify_event_t * event)
568+static void
569+property_notify(xcb_property_notify_event_t *event)
570 {
571-    struct xwl_window * xwl_window;
572+	struct xwl_window *xwl_window;
573 
574-    if (!(xwl_window = find_window(&xwm.windows, event->window)))
575-        return;
576+	if (!(xwl_window = find_window(&xwm.windows, event->window)))
577+		return;
578 
579-    if (event->atom == xwm.ewmh._NET_WM_NAME
580-        && event->state == XCB_PROPERTY_NEW_VALUE)
581-    {
582-        update_name(xwl_window);
583-    }
584-    else if (event->atom == xwm.atoms[ATOM_WM_PROTOCOLS].value)
585-        update_protocols(xwl_window);
586+	if (event->atom == xwm.ewmh._NET_WM_NAME
587+	    && event->state == XCB_PROPERTY_NEW_VALUE) {
588+		update_name(xwl_window);
589+	} else if (event->atom == xwm.atoms[ATOM_WM_PROTOCOLS].value)
590+		update_protocols(xwl_window);
591 }
592 
593-static void client_message(xcb_client_message_event_t * event)
594+static void
595+client_message(xcb_client_message_event_t *event)
596 {
597-    if (event->type == xwm.atoms[ATOM_WL_SURFACE_ID].value)
598-    {
599-        struct xwl_window * xwl_window;
600+	if (event->type == xwm.atoms[ATOM_WL_SURFACE_ID].value) {
601+		struct xwl_window *xwl_window;
602 
603-        if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window)))
604-            return;
605+		if (!(xwl_window = find_window(&xwm.unpaired_windows, event->window)))
606+			return;
607 
608-        xwl_window->surface_id = event->data.data32[0];
609-        manage_window(xwl_window);
610-    }
611+		xwl_window->surface_id = event->data.data32[0];
612+		manage_window(xwl_window);
613+	}
614 }
615 
616-static int connection_data(int fd, uint32_t mask, void * data)
617+static int
618+connection_data(int fd, uint32_t mask, void *data)
619 {
620-    xcb_generic_event_t * event;
621-    uint32_t count = 0;
622-
623-    while ((event = xcb_poll_for_event(xwm.connection)))
624-    {
625-        switch (event->response_type & ~0x80)
626-        {
627-            case XCB_CREATE_NOTIFY:
628-                create_notify((xcb_create_notify_event_t *) event);
629-                break;
630-            case XCB_DESTROY_NOTIFY:
631-                destroy_notify((xcb_destroy_notify_event_t *) event);
632-                break;
633-            case XCB_MAP_REQUEST:
634-                map_request((xcb_map_request_event_t *) event);
635-                break;
636-            case XCB_CONFIGURE_REQUEST:
637-                configure_request((xcb_configure_request_event_t *) event);
638-                break;
639-            case XCB_PROPERTY_NOTIFY:
640-                property_notify((xcb_property_notify_event_t *) event);
641-                break;
642-            case XCB_CLIENT_MESSAGE:
643-                client_message((xcb_client_message_event_t *) event);
644-                break;
645-        }
646-
647-        free(event);
648-        ++count;
649-    }
650-
651-    xcb_flush(xwm.connection);
652-
653-    return count;
654+	xcb_generic_event_t *event;
655+	uint32_t count = 0;
656+
657+	while ((event = xcb_poll_for_event(xwm.connection))) {
658+		switch (event->response_type & ~0x80) {
659+		case XCB_CREATE_NOTIFY:
660+			create_notify((xcb_create_notify_event_t *)event);
661+			break;
662+		case XCB_DESTROY_NOTIFY:
663+			destroy_notify((xcb_destroy_notify_event_t *)event);
664+			break;
665+		case XCB_MAP_REQUEST:
666+			map_request((xcb_map_request_event_t *)event);
667+			break;
668+		case XCB_CONFIGURE_REQUEST:
669+			configure_request((xcb_configure_request_event_t *)event);
670+			break;
671+		case XCB_PROPERTY_NOTIFY:
672+			property_notify((xcb_property_notify_event_t *)event);
673+			break;
674+		case XCB_CLIENT_MESSAGE:
675+			client_message((xcb_client_message_event_t *)event);
676+			break;
677+		}
678+
679+		free(event);
680+		++count;
681+	}
682+
683+	xcb_flush(xwm.connection);
684+
685+	return count;
686 }
687 
688-bool xwm_initialize(int fd)
689+bool
690+xwm_initialize(int fd)
691 {
692-    const xcb_setup_t * setup;
693-    xcb_screen_iterator_t screen_iterator;
694-    uint32_t mask;
695-    uint32_t values[1];
696-    xcb_void_cookie_t change_attributes_cookie, redirect_subwindows_cookie;
697-    xcb_generic_error_t * error;
698-    xcb_intern_atom_cookie_t * ewmh_cookies;
699-    xcb_intern_atom_reply_t * atom_reply;
700-    unsigned index;
701-    const char * name;
702-    const xcb_query_extension_reply_t * composite_extension;
703-
704-    xwm.connection = xcb_connect_to_fd(fd, NULL);
705-
706-    if (xcb_connection_has_error(xwm.connection))
707-    {
708-        ERROR("xwm: Could not connect to X server\n");
709-        goto error0;
710-    }
711-
712-    xcb_prefetch_extension_data(xwm.connection, &xcb_composite_id);
713-    ewmh_cookies = xcb_ewmh_init_atoms(xwm.connection, &xwm.ewmh);
714-
715-    if (!ewmh_cookies)
716-    {
717-        ERROR("xwm: Failed to initialize EWMH atoms\n");
718-        goto error1;
719-    }
720-
721-    for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index)
722-    {
723-        name = xwm.atoms[index].name;
724-        xwm.atoms[index].cookie = xcb_intern_atom(xwm.connection, 0,
725-                                                  strlen(name), name);
726-    }
727-
728-    setup = xcb_get_setup(xwm.connection);
729-    screen_iterator = xcb_setup_roots_iterator(setup);
730-    xwm.screen = screen_iterator.data;
731-
732-    /* Try to select for substructure redirect. */
733-    mask = XCB_CW_EVENT_MASK;
734-    values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY
735-              | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
736-    change_attributes_cookie = xcb_change_window_attributes
737-        (xwm.connection, xwm.screen->root, mask, values);
738-
739-    xwm.source = wl_event_loop_add_fd(swc.event_loop, fd, WL_EVENT_READABLE,
740-                                      &connection_data, NULL);
741-    wl_list_init(&xwm.windows);
742-    wl_list_init(&xwm.unpaired_windows);
743-
744-    if (!xwm.source)
745-    {
746-        ERROR("xwm: Failed to create X connection event source\n");
747-        goto error2;
748-    }
749-
750-    composite_extension = xcb_get_extension_data(xwm.connection, &xcb_composite_id);
751-
752-    if (!composite_extension->present)
753-    {
754-        ERROR("xwm: X server does not have composite extension\n");
755-        goto error3;
756-    }
757-
758-    redirect_subwindows_cookie = xcb_composite_redirect_subwindows_checked
759-            (xwm.connection, xwm.screen->root, XCB_COMPOSITE_REDIRECT_MANUAL);
760-
761-    if ((error = xcb_request_check(xwm.connection, change_attributes_cookie)))
762-    {
763-        ERROR("xwm: Another window manager is running\n");
764-        free(error);
765-        goto error3;
766-    }
767-
768-    if ((error = xcb_request_check(xwm.connection, redirect_subwindows_cookie)))
769-    {
770-        ERROR("xwm: Could not redirect subwindows of root for compositing\n");
771-        free(error);
772-        goto error3;
773-    }
774-
775-    xwm.window = xcb_generate_id(xwm.connection);
776-    xcb_create_window(xwm.connection, 0, xwm.window, xwm.screen->root,
777-                      0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY,
778-                      XCB_COPY_FROM_PARENT, 0, NULL);
779-
780-    xcb_ewmh_init_atoms_replies(&xwm.ewmh, ewmh_cookies, &error);
781-
782-    if (error)
783-    {
784-        ERROR("xwm: Failed to get EWMH atom replies: %u\n", error->error_code);
785-        goto error3;
786-    }
787-
788-    for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index)
789-    {
790-        atom_reply = xcb_intern_atom_reply(xwm.connection,
791-                                           xwm.atoms[index].cookie, &error);
792-
793-        if (error)
794-        {
795-            ERROR("xwm: Failed to get atom reply: %u\n", error->error_code);
796-            return false;
797-        }
798-
799-        xwm.atoms[index].value = atom_reply->atom;
800-        free(atom_reply);
801-    }
802-
803-    xcb_set_selection_owner(xwm.connection, xwm.window,
804-                            xwm.atoms[ATOM_WM_S0].value, XCB_CURRENT_TIME);
805-    xcb_flush(xwm.connection);
806-
807-    wl_signal_add(&swc.compositor->signal.new_surface, &new_surface_listener);
808-
809-    return true;
810-
811-  error3:
812-    wl_event_source_remove(xwm.source);
813-  error2:
814-    xcb_ewmh_connection_wipe(&xwm.ewmh);
815-  error1:
816-    xcb_disconnect(xwm.connection);
817-  error0:
818-    return false;
819+	const xcb_setup_t *setup;
820+	xcb_screen_iterator_t screen_iterator;
821+	uint32_t mask;
822+	uint32_t values[1];
823+	xcb_void_cookie_t change_attributes_cookie, redirect_subwindows_cookie;
824+	xcb_generic_error_t *error;
825+	xcb_intern_atom_cookie_t *ewmh_cookies;
826+	xcb_intern_atom_reply_t *atom_reply;
827+	unsigned index;
828+	const char *name;
829+	const xcb_query_extension_reply_t *composite_extension;
830+
831+	xwm.connection = xcb_connect_to_fd(fd, NULL);
832+
833+	if (xcb_connection_has_error(xwm.connection)) {
834+		ERROR("xwm: Could not connect to X server\n");
835+		goto error0;
836+	}
837+
838+	xcb_prefetch_extension_data(xwm.connection, &xcb_composite_id);
839+	ewmh_cookies = xcb_ewmh_init_atoms(xwm.connection, &xwm.ewmh);
840+
841+	if (!ewmh_cookies) {
842+		ERROR("xwm: Failed to initialize EWMH atoms\n");
843+		goto error1;
844+	}
845+
846+	for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index) {
847+		name = xwm.atoms[index].name;
848+		xwm.atoms[index].cookie = xcb_intern_atom(xwm.connection, 0,
849+		                                          strlen(name), name);
850+	}
851+
852+	setup = xcb_get_setup(xwm.connection);
853+	screen_iterator = xcb_setup_roots_iterator(setup);
854+	xwm.screen = screen_iterator.data;
855+
856+	/* Try to select for substructure redirect. */
857+	mask = XCB_CW_EVENT_MASK;
858+	values[0] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY
859+	            | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
860+	change_attributes_cookie = xcb_change_window_attributes(xwm.connection, xwm.screen->root, mask, values);
861+
862+	xwm.source = wl_event_loop_add_fd(swc.event_loop, fd, WL_EVENT_READABLE,
863+	                                  &connection_data, NULL);
864+	wl_list_init(&xwm.windows);
865+	wl_list_init(&xwm.unpaired_windows);
866+
867+	if (!xwm.source) {
868+		ERROR("xwm: Failed to create X connection event source\n");
869+		goto error2;
870+	}
871+
872+	composite_extension = xcb_get_extension_data(xwm.connection, &xcb_composite_id);
873+
874+	if (!composite_extension->present) {
875+		ERROR("xwm: X server does not have composite extension\n");
876+		goto error3;
877+	}
878+
879+	redirect_subwindows_cookie = xcb_composite_redirect_subwindows_checked(xwm.connection, xwm.screen->root, XCB_COMPOSITE_REDIRECT_MANUAL);
880+
881+	if ((error = xcb_request_check(xwm.connection, change_attributes_cookie))) {
882+		ERROR("xwm: Another window manager is running\n");
883+		free(error);
884+		goto error3;
885+	}
886+
887+	if ((error = xcb_request_check(xwm.connection, redirect_subwindows_cookie))) {
888+		ERROR("xwm: Could not redirect subwindows of root for compositing\n");
889+		free(error);
890+		goto error3;
891+	}
892+
893+	xwm.window = xcb_generate_id(xwm.connection);
894+	xcb_create_window(xwm.connection, 0, xwm.window, xwm.screen->root,
895+	                  0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY,
896+	                  XCB_COPY_FROM_PARENT, 0, NULL);
897+
898+	xcb_ewmh_init_atoms_replies(&xwm.ewmh, ewmh_cookies, &error);
899+
900+	if (error) {
901+		ERROR("xwm: Failed to get EWMH atom replies: %u\n", error->error_code);
902+		goto error3;
903+	}
904+
905+	for (index = 0; index < ARRAY_LENGTH(xwm.atoms); ++index) {
906+		atom_reply = xcb_intern_atom_reply(xwm.connection,
907+		                                   xwm.atoms[index].cookie, &error);
908+
909+		if (error) {
910+			ERROR("xwm: Failed to get atom reply: %u\n", error->error_code);
911+			return false;
912+		}
913+
914+		xwm.atoms[index].value = atom_reply->atom;
915+		free(atom_reply);
916+	}
917+
918+	xcb_set_selection_owner(xwm.connection, xwm.window,
919+	                        xwm.atoms[ATOM_WM_S0].value, XCB_CURRENT_TIME);
920+	xcb_flush(xwm.connection);
921+
922+	wl_signal_add(&swc.compositor->signal.new_surface, &new_surface_listener);
923+
924+	return true;
925+
926+error3:
927+	wl_event_source_remove(xwm.source);
928+error2:
929+	xcb_ewmh_connection_wipe(&xwm.ewmh);
930+error1:
931+	xcb_disconnect(xwm.connection);
932+error0:
933+	return false;
934 }
935 
936-void xwm_finalize(void)
937+void
938+xwm_finalize(void)
939 {
940-    wl_event_source_remove(xwm.source);
941-    xcb_ewmh_connection_wipe(&xwm.ewmh);
942-    xcb_disconnect(xwm.connection);
943+	wl_event_source_remove(xwm.source);
944+	xcb_ewmh_connection_wipe(&xwm.ewmh);
945+	xcb_disconnect(xwm.connection);
946 }
947-
+0, -1
1@@ -30,4 +30,3 @@ bool xwm_initialize(int fd);
2 void xwm_finalize(void);
3 
4 #endif
5-