gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

Commit 6810fa61401d6c5c6f8a4dde9e8e0d745a139404
Parent: 89beb04f1de7c99459cfc438f4dd8b14dca42051
Author: mcol <mcol@posteo.net>
Date: 2021-01-24 20:52:37 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-01-24 20:52:37 +0000

make server a global instance as "wimp"

Closes #8

src/types.h Modified

@@ -24,16 +24,14 @@
     CURSOR_RESIZE,
 };
 
-struct server;
-
-typedef void (*action)(struct server *server, void *data);
+typedef void (*action)(void *data);
 
 struct mark_indicator {
     float colour[4];
     struct wlr_box box;
 };
 
-struct server {
+struct wimp {
     struct wl_display *display;
     struct wlr_backend *backend;
     struct wlr_renderer *renderer;
@@ -86,9 +84,10 @@
     bool vt_switching;
 };
 
+extern struct wimp wimp;
+
 struct view {
     struct wl_list link;
-    struct server *server;
     struct wlr_xdg_surface *surface;
     struct wl_listener map_listener;
     struct wl_listener unmap_listener;
@@ -101,7 +100,6 @@
 
 struct keyboard {
     struct wl_list link;
-    struct server *server;
     struct wlr_input_device *device;
     struct wl_listener modifier_listener;
     struct wl_listener key_listener;
@@ -114,7 +112,6 @@
 
 struct desk {
     struct wl_list link;
-    struct server *server;
     struct wl_list views;
     float background[4];
     float border_normal[4];

src/shell.h Modified

@@ -10,6 +10,6 @@
 void fullscreen_xdg_surface(
     struct view *view, struct wlr_xdg_surface *xdg_surface, struct wlr_output *output
 );
-void set_up_shell(struct server *server);
+void set_up_shell();
 
 #endif

src/shell.c Modified

@@ -19,8 +19,7 @@
     if (view == NULL) {
 	return;
     }
-    struct server *server = view->server;
-    struct wlr_seat *seat = server->seat;
+    struct wlr_seat *seat = wimp.seat;
     struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface;
     if (prev_surface == surface) {
 	return;
@@ -34,7 +33,7 @@
     struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
     /* Move the view to the front */
     wl_list_remove(&view->link);
-    wl_list_insert(&server->current_desk->views, &view->link);
+    wl_list_insert(&wimp.current_desk->views, &view->link);
     /* Activate the new surface */
     wlr_xdg_toplevel_set_activated(view->surface, true);
     wlr_seat_keyboard_notify_enter(
@@ -45,13 +44,12 @@
 
 
 void pan_to_view(struct view *view) {
-    struct server *server = view->server;
-    int border_width = server->current_desk->border_width;
+    int border_width = wimp.current_desk->border_width;
     double x = view->x - border_width;
     double y = view->y - border_width;
     double width = view->surface->geometry.width + border_width * 2;
     double height = view->surface->geometry.height + border_width * 2;
-    struct wlr_box *extents = wlr_output_layout_get_box(server->output_layout, NULL);
+    struct wlr_box *extents = wlr_output_layout_get_box(wimp.output_layout, NULL);
     struct motion motion = {
 	.dx = 0,
 	.dy = 0,
@@ -68,7 +66,7 @@
     } else if (y + height > extents->height) {
 	motion.dy = y + height - extents->height;
     }
-    pan_desk(server, &motion);
+    pan_desk(&motion);
 }
 
 
@@ -76,10 +74,9 @@
     struct view *view, struct wlr_xdg_surface *xdg_surface, struct wlr_output *output
 ) {
     /* output can be NULL, in which case it is calculated using the surface's position */
-    struct server *server = view->server;
-    struct wlr_box *saved_geo = &server->current_desk->fullscreened_saved_geo;
+    struct wlr_box *saved_geo = &wimp.current_desk->fullscreened_saved_geo;
 
-    struct wlr_xdg_surface *prev_surface = server->current_desk->fullscreened;
+    struct wlr_xdg_surface *prev_surface = wimp.current_desk->fullscreened;
     if (prev_surface) {
 	wlr_xdg_toplevel_set_fullscreen(prev_surface, false);
 	wlr_xdg_toplevel_set_size(prev_surface, saved_geo->width, saved_geo->height);
@@ -88,7 +85,7 @@
     }
 
     if (prev_surface == xdg_surface) {
-	server->current_desk->fullscreened = NULL;
+	wimp.current_desk->fullscreened = NULL;
 	return;
     }
 
@@ -99,34 +96,34 @@
 	double x = view->x + xdg_surface->geometry.width / 2;
 	double y = view->y + xdg_surface->geometry.height / 2;
 	double lx, ly;
-	wlr_output_layout_closest_point(server->output_layout, NULL, x, y, &lx, &ly);
-	output = wlr_output_layout_output_at(server->output_layout, lx, ly);
+	wlr_output_layout_closest_point(wimp.output_layout, NULL, x, y, &lx, &ly);
+	output = wlr_output_layout_output_at(wimp.output_layout, lx, ly);
     }
 
-    server->current_desk->fullscreened = xdg_surface;
+    wimp.current_desk->fullscreened = xdg_surface;
     saved_geo->x = view->x;
     saved_geo->y = view->y;
     view->x = view->y = 0;
     saved_geo->width = xdg_surface->geometry.width;
     saved_geo->height = xdg_surface->geometry.height;
     wlr_xdg_toplevel_set_fullscreen(xdg_surface, true);
-    double zoom = server->current_desk->zoom;
+    double zoom = wimp.current_desk->zoom;
     wlr_xdg_toplevel_set_size(xdg_surface, output->width / zoom, output->height / zoom);
 }
 
 
 static void on_map(struct wl_listener *listener, void *data) {
     struct view *view = wl_container_of(listener, view, map_listener);
-    if (view->server->can_steal_focus)
+    if (wimp.can_steal_focus)
 	focus_view(view, view->surface->surface);
 }
 
 static void on_unmap(struct wl_listener *listener, void *data) {
     struct view *view = wl_container_of(listener, view, unmap_listener);
-    if (view->server->can_steal_focus) {
+    if (wimp.can_steal_focus) {
 	wl_list_remove(&view->link);
-	wl_list_insert(view->server->current_desk->views.prev, &view->link);
-	struct view *next_view = wl_container_of(view->server->current_desk->views.next, view, link);
+	wl_list_insert(wimp.current_desk->views.prev, &view->link);
+	struct view *next_view = wl_container_of(wimp.current_desk->views.next, view, link);
 	focus_view(next_view, next_view->surface->surface);
     }
 }
@@ -140,25 +137,23 @@
 
 
 static void process_move_resize(struct view *view, enum cursor_mode mode, uint32_t edges) {
-    struct server *server = view->server;
-    struct wlr_surface *focused_surface =
-	server->seat->pointer_state.focused_surface;
+    struct wlr_surface *focused_surface = wimp.seat->pointer_state.focused_surface;
 
     if (view->surface->surface != focused_surface) {
 	    return;
     }
-    server->grabbed_view = view;
-    server->cursor_mode = mode;
+    wimp.grabbed_view = view;
+    wimp.cursor_mode = mode;
 
-    double zoom = server->current_desk->zoom;
-    server->grab_x = server->cursor->x - view->x * zoom;
-    server->grab_y = server->cursor->y - view->y * zoom;
+    double zoom = wimp.current_desk->zoom;
+    wimp.grab_x = wimp.cursor->x - view->x * zoom;
+    wimp.grab_y = wimp.cursor->y - view->y * zoom;
 
     if (mode == CURSOR_RESIZE) {
-	wlr_xdg_surface_get_geometry(view->surface, &server->grab_geobox);
-	server->grab_geobox.x = view->x;
-	server->grab_geobox.y = view->y;
-	server->resize_edges = edges;
+	wlr_xdg_surface_get_geometry(view->surface, &wimp.grab_geobox);
+	wimp.grab_geobox.x = view->x;
+	wimp.grab_geobox.y = view->y;
+	wimp.resize_edges = edges;
     }
 }
 
@@ -186,14 +181,12 @@
 
 
 static void on_new_xdg_surface(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, new_xdg_surface_listener);
     struct wlr_xdg_surface *surface = data;
     if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 	return;
     }
 
     struct view *view = calloc(1, sizeof(struct view));
-    view->server = server;
     view->surface = surface;
 
     view->map_listener.notify = on_map;
@@ -211,12 +204,12 @@
     view->request_fullscreen_listener.notify = on_request_fullscreen;
     wl_signal_add(&toplevel->events.request_fullscreen, &view->request_fullscreen_listener);
 
-    wl_list_insert(&server->current_desk->views, &view->link);
+    wl_list_insert(&wimp.current_desk->views, &view->link);
 }
 
 
-void set_up_shell(struct server *server) {
-    server->shell = wlr_xdg_shell_create(server->display);
-    server->new_xdg_surface_listener.notify = on_new_xdg_surface;
-    wl_signal_add(&server->shell->events.new_surface, &server->new_xdg_surface_listener);
+void set_up_shell() {
+    wimp.shell = wlr_xdg_shell_create(wimp.display);
+    wimp.new_xdg_surface_listener.notify = on_new_xdg_surface;
+    wl_signal_add(&wimp.shell->events.new_surface, &wimp.new_xdg_surface_listener);
 }

src/output.h Modified

@@ -3,6 +3,6 @@
 
 #include "types.h"
 
-void set_up_outputs(struct server *server);
+void set_up_outputs();
 
 #endif

src/output.c Modified

@@ -8,7 +8,6 @@
 
 struct output {
     struct wl_list link;
-    struct server *server;
     struct wlr_output *wlr_output;
     struct wl_listener frame_listener;
 };
@@ -30,7 +29,6 @@
     struct render_data *rdata = data;
     struct view *view = rdata->view;
     struct wlr_output *output = rdata->output;
-    struct server *server = view->server;
 
     struct wlr_texture *texture = wlr_surface_get_texture(surface);
     if (texture == NULL) {
@@ -39,7 +37,7 @@
 
     double x = 0, y = 0;
     struct wlr_output_layout_output *ol;
-    wl_list_for_each(ol, &server->output_layout->outputs, link) {
+    wl_list_for_each(ol, &wimp.output_layout->outputs, link) {
 	if (ol->output == output) {
 	    x = - (double)ol->x;
 	    y = - (double)ol->y;
@@ -50,7 +48,7 @@
     y = (y + view->y + sy) * output->scale * rdata->zoom;
     int width = surface->current.width * output->scale * rdata->zoom;
     int height = surface->current.height * output->scale * rdata->zoom;
-    int border_width = server->current_desk->border_width;
+    int border_width = wimp.current_desk->border_width;
 
     if (view->surface->surface == surface) {
 	struct wlr_box borders = {
@@ -62,7 +60,7 @@
 	wlr_render_rect(
 	    rdata->renderer,
 	    &borders,
-	    rdata->is_focussed ? server->current_desk->border_focus : server->current_desk->border_normal,
+	    rdata->is_focussed ? wimp.current_desk->border_focus : wimp.current_desk->border_normal,
 	    output->transform_matrix
 	);
     }
@@ -86,9 +84,8 @@
 
 static void on_frame(struct wl_listener *listener, void *data) {
     struct output *output = wl_container_of(listener, output, frame_listener);
-    struct server *server = output->server;
-    struct wlr_renderer *renderer = server->renderer;
-    struct desk *desk = server->current_desk;
+    struct wlr_renderer *renderer = wimp.renderer;
+    struct desk *desk = wimp.current_desk;
 
     struct timespec now;
     clock_gettime(CLOCK_MONOTONIC, &now);
@@ -120,7 +117,7 @@
 
     // paint clients
     struct view *view;
-    struct view *focussed = wl_container_of(server->current_desk->views.next, focussed, link);
+    struct view *focussed = wl_container_of(wimp.current_desk->views.next, focussed, link);
     wl_list_for_each_reverse(view, &desk->views, link) {
 	struct render_data rdata = {
 	    .output = output->wlr_output,
@@ -136,11 +133,11 @@
     }
 
     // paint mark indicator
-    if (server->mark_waiting) {
-	struct wlr_box indicator = server->mark_indicator.box;
+    if (wimp.mark_waiting) {
+	struct wlr_box indicator = wimp.mark_indicator.box;
 	indicator.y = height - indicator.height;
 	wlr_render_rect(
-	    renderer, &indicator, server->mark_indicator.colour,
+	    renderer, &indicator, wimp.mark_indicator.colour,
 	    output->wlr_output->transform_matrix
 	);
     }
@@ -152,7 +149,6 @@
 
 
 static void on_new_output(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, new_output_listener);
     struct wlr_output *wlr_output = data;
 
     if (!wl_list_empty(&wlr_output->modes)) {
@@ -166,17 +162,16 @@
 
     struct output *output = calloc(1, sizeof(struct output));
     output->wlr_output = wlr_output;
-    output->server = server;
     output->frame_listener.notify = on_frame;
     wl_signal_add(&wlr_output->events.frame, &output->frame_listener);
-    wl_list_insert(&server->outputs, &output->link);
-    wlr_output_layout_add_auto(server->output_layout, wlr_output);
+    wl_list_insert(&wimp.outputs, &output->link);
+    wlr_output_layout_add_auto(wimp.output_layout, wlr_output);
 }
 
 
-void set_up_outputs(struct server *server) {
-    server->output_layout = wlr_output_layout_create();
-    wl_list_init(&server->outputs);
-    server->new_output_listener.notify = on_new_output;
-    wl_signal_add(&server->backend->events.new_output, &server->new_output_listener);
+void set_up_outputs() {
+    wimp.output_layout = wlr_output_layout_create();
+    wl_list_init(&wimp.outputs);
+    wimp.new_output_listener.notify = on_new_output;
+    wl_signal_add(&wimp.backend->events.new_output, &wimp.new_output_listener);
 }

src/main.c Modified

@@ -22,6 +22,19 @@
 #include "types.h"
 
 
+struct wimp wimp = {
+    .mark_waiting = false,
+    .on_mouse_motion = NULL,
+    .on_mouse_scroll = NULL,
+    .can_steal_focus = true,
+    .desk_count = 0,
+    .mark_indicator.box.width = 25,
+    .mark_indicator.box.height = 25,
+    .mark_indicator.box.x = 0,
+    .mark_indicator.box.y = 0,
+};
+
+
 static const char usage[] =
     "usage: " THIS " [options...]\n"
     "    -h         show this help message\n"
@@ -35,8 +48,7 @@
 {
     int opt;
     int log_level = WLR_ERROR;
-    struct server server;
-    server.config_file = NULL;
+    wimp.config_file = NULL;
 
     while ((opt = getopt(argc, argv, "hc:di")) != -1) {
         switch (opt) {
@@ -45,7 +57,7 @@
 		return EXIT_SUCCESS;
 		break;
 	    case 'c':
-		server.config_file = strdup(optarg);
+		wimp.config_file = strdup(optarg);
 		break;
 	    case 'd':
 		log_level = WLR_DEBUG;
@@ -59,62 +71,53 @@
     init_log(log_level);
 
     // create
-    server.display = wl_display_create();
-    server.backend = wlr_backend_autocreate(server.display, NULL);
-    server.renderer = wlr_backend_get_renderer(server.backend);
-    wlr_renderer_init_wl_display(server.renderer, server.display);
-    wlr_compositor_create(server.display, server.renderer);
+    wimp.display = wl_display_create();
+    wimp.backend = wlr_backend_autocreate(wimp.display, NULL);
+    wimp.renderer = wlr_backend_get_renderer(wimp.backend);
+    wlr_renderer_init_wl_display(wimp.renderer, wimp.display);
+    wlr_compositor_create(wimp.display, wimp.renderer);
 
     // add some managers
-    wlr_screencopy_manager_v1_create(server.display);
-    wlr_data_device_manager_create(server.display);
-    wlr_primary_selection_v1_device_manager_create(server.display);
+    wlr_screencopy_manager_v1_create(wimp.display);
+    wlr_data_device_manager_create(wimp.display);
+    wlr_primary_selection_v1_device_manager_create(wimp.display);
 
     // initialise
-    wl_list_init(&server.desks);
-    wl_list_init(&server.key_bindings);
-    wl_list_init(&server.mouse_bindings);
-    wl_list_init(&server.marks);
-    server.mark_waiting = false;
-    server.on_mouse_motion = NULL;
-    server.on_mouse_scroll = NULL;
-    server.can_steal_focus = true;
-    server.mark_indicator.box.width = 25;
-    server.mark_indicator.box.height = 25;
-    server.mark_indicator.box.x = 0;
-    server.mark_indicator.box.y = 0;
-    server.desk_count = 0;
-    add_desk(&server);
-    server.current_desk = wl_container_of(server.desks.next, server.current_desk, link);
+    wl_list_init(&wimp.desks);
+    wl_list_init(&wimp.key_bindings);
+    wl_list_init(&wimp.mouse_bindings);
+    wl_list_init(&wimp.marks);
+    add_desk();
+    wimp.current_desk = wl_container_of(wimp.desks.next, wimp.current_desk, link);
 
     // configure
-    locate_config(&server);
-    load_config(&server);
-    set_up_outputs(&server);
-    set_up_shell(&server);
-    set_up_cursor(&server);
-    set_up_keyboard(&server);
-    set_up_decorations(&server);
+    locate_config();
+    load_config();
+    set_up_outputs();
+    set_up_shell();
+    set_up_cursor();
+    set_up_keyboard();
+    set_up_decorations();
 
     // start
-    const char *socket = wl_display_add_socket_auto(server.display);
+    const char *socket = wl_display_add_socket_auto(wimp.display);
     if (!socket) {
-	wlr_backend_destroy(server.backend);
-	wl_display_destroy(server.display);
+	wlr_backend_destroy(wimp.backend);
+	wl_display_destroy(wimp.display);
 	return EXIT_FAILURE;
     }
-    if (!wlr_backend_start(server.backend)) {
-	wlr_backend_destroy(server.backend);
-	wl_display_destroy(server.display);
+    if (!wlr_backend_start(wimp.backend)) {
+	wlr_backend_destroy(wimp.backend);
+	wl_display_destroy(wimp.display);
 	return 1;
     }
     setenv("WAYLAND_DISPLAY", socket, true);
     wlr_log(WLR_INFO, "Starting with WAYLAND_DISPLAY=%s", socket);
-    wl_display_run(server.display);
+    wl_display_run(wimp.display);
 
     // stop
-    wl_display_destroy_clients(server.display);
-    wlr_backend_destroy(server.backend);
-    wl_display_destroy(server.display);
+    wl_display_destroy_clients(wimp.display);
+    wlr_backend_destroy(wimp.backend);
+    wl_display_destroy(wimp.display);
     return EXIT_SUCCESS;
 }

src/keyboard.h Modified

@@ -3,6 +3,6 @@
 
 #include "types.h"
 
-void set_up_keyboard(struct server *server);
+void set_up_keyboard();
 
 #endif

src/keyboard.c Modified

@@ -11,41 +11,40 @@
 
 static void on_modifier(struct wl_listener *listener, void *data) {
     struct keyboard *keyboard = wl_container_of(listener, keyboard, modifier_listener);
-    struct server *server = keyboard->server;
     wlr_seat_keyboard_notify_modifiers(
-	server->seat, &keyboard->device->keyboard->modifiers
+	wimp.seat, &keyboard->device->keyboard->modifiers
     );
 
     uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard);
     struct binding *kb;
     bool handled = false;
-    if ((modifiers & server->mod)) {
-	modifiers &= ~server->mod;
-	wl_list_for_each(kb, &server->mouse_bindings, link) {
+    if ((modifiers & wimp.mod)) {
+	modifiers &= ~wimp.mod;
+	wl_list_for_each(kb, &wimp.mouse_bindings, link) {
 	    if (modifiers == kb->mods) {
 		switch (kb->key) {
 		    case MOTION:
-			server->on_mouse_motion = kb->action;
+			wimp.on_mouse_motion = kb->action;
 			break;
 		    case SCROLL:
-			server->on_mouse_scroll = kb->action;
+			wimp.on_mouse_scroll = kb->action;
 			break;
 		}
-		keyboard->server->cursor_mode = CURSOR_MOD;
+		wimp.cursor_mode = CURSOR_MOD;
 		handled = true;
 	    }
 	}
     }
-    if (!handled)
-	keyboard->server->cursor_mode = CURSOR_PASSTHROUGH;
+    if (!handled) {
+	wimp.cursor_mode = CURSOR_PASSTHROUGH;
+    }
 }
 
 
 static void on_key(struct wl_listener *listener, void *data) {
     struct keyboard *keyboard = wl_container_of(listener, keyboard, key_listener);
-    struct server *server = keyboard->server;
     struct wlr_event_keyboard_key *event = data;
-    struct wlr_seat *seat = server->seat;
+    struct wlr_seat *seat = wimp.seat;
 
     /* Translate libinput keycode -> xkbcommon */
     uint32_t keycode = event->keycode + 8;
@@ -55,26 +54,26 @@
 	keyboard->device->keyboard->xkb_state, keycode, &syms);
 
     if (event->state == WLR_KEY_PRESSED) {
-	if (server->mark_waiting) {
-	    server->mark_waiting = false;
+	if (wimp.mark_waiting) {
+	    wimp.mark_waiting = false;
 	    struct mark *mark;
-	    mark = wl_container_of(server->marks.next, mark, link);
+	    mark = wl_container_of(wimp.marks.next, mark, link);
 	    if (mark->key == 0) {
-		actually_set_mark(server, syms[0]);
+		actually_set_mark(syms[0]);
 	    } else {
-		actually_go_to_mark(server, syms[0]);
+		actually_go_to_mark(syms[0]);
 	    }
 	    return;
 	}
 
 	uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard);
 	struct binding *kb;
-	if ((modifiers & server->mod)) {
-	    modifiers &= ~server->mod;
+	if ((modifiers & wimp.mod)) {
+	    modifiers &= ~wimp.mod;
 	    for (int i = 0; i < nsyms; i++) {
-		wl_list_for_each(kb, &server->key_bindings, link) {
+		wl_list_for_each(kb, &wimp.key_bindings, link) {
 		    if (syms[i] == kb->key && modifiers == kb->mods) {
-			kb->action(server, kb->data);
+			kb->action(kb->data);
 			return;
 		    }
 		}
@@ -89,9 +88,8 @@
 }
 
 
-static void on_new_keyboard(struct server *server, struct wlr_input_device *device) {
+static void on_new_keyboard(struct wlr_input_device *device) {
     struct keyboard *keyboard = calloc(1, sizeof(struct keyboard));
-    keyboard->server = server;
     keyboard->device = device;
 
     // currently assumes default "us"
@@ -109,66 +107,61 @@
     wl_signal_add(&device->keyboard->events.modifiers, &keyboard->modifier_listener);
     keyboard->key_listener.notify = on_key;
     wl_signal_add(&device->keyboard->events.key, &keyboard->key_listener);
-    wlr_seat_set_keyboard(server->seat, device);
-    wl_list_insert(&server->keyboards, &keyboard->link);
+    wlr_seat_set_keyboard(wimp.seat, device);
+    wl_list_insert(&wimp.keyboards, &keyboard->link);
 }
 
 
 static void on_request_set_selection(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(
-	listener, server, request_set_selection_listener);
     struct wlr_seat_request_set_selection_event *event = data;
-    wlr_seat_set_selection(server->seat, event->source, event->serial);
+    wlr_seat_set_selection(wimp.seat, event->source, event->serial);
 }
 
 
 static void on_request_cursor(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, request_cursor_listener);
     struct wlr_seat_pointer_request_set_cursor_event *event = data;
     struct wlr_seat_client *focused_client =
-	server->seat->pointer_state.focused_client;
+	wimp.seat->pointer_state.focused_client;
 
     if (focused_client == event->seat_client) {
 	wlr_cursor_set_surface(
-	    server->cursor, event->surface, event->hotspot_x, event->hotspot_y
+	    wimp.cursor, event->surface, event->hotspot_x, event->hotspot_y
 	);
     }
 }
 
 
 static void on_new_input(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, new_input_listener);
-
     struct wlr_input_device *device = data;
     switch (device->type) {
 	case WLR_INPUT_DEVICE_KEYBOARD:
-	    on_new_keyboard(server, device);
+	    on_new_keyboard(device);
 	    break;
 	case WLR_INPUT_DEVICE_POINTER:
-	    wlr_cursor_attach_input_device(server->cursor, device);
+	    wlr_cursor_attach_input_device(wimp.cursor, device);
 	    break;
 	default:
 	    break;
     }
 
     uint32_t capabilities = WL_SEAT_CAPABILITY_POINTER;
-    if (!wl_list_empty(&server->keyboards))
+    if (!wl_list_empty(&wimp.keyboards))
 	capabilities |= WL_SEAT_CAPABILITY_KEYBOARD;
-    wlr_seat_set_capabilities(server->seat, capabilities);
+    wlr_seat_set_capabilities(wimp.seat, capabilities);
 }
 
 
-void set_up_keyboard(struct server *server) {
-    wl_list_init(&server->keyboards);
+void set_up_keyboard() {
+    wl_list_init(&wimp.keyboards);
 
-    server->new_input_listener.notify = on_new_input;
-    wl_signal_add(&server->backend->events.new_input, &server->new_input_listener);
+    wimp.new_input_listener.notify = on_new_input;
+    wl_signal_add(&wimp.backend->events.new_input, &wimp.new_input_listener);
 
-    server->seat = wlr_seat_create(server->display, "seat0");
-    server->request_cursor_listener.notify = on_request_cursor;
-    wl_signal_add(&server->seat->events.request_set_cursor, &server->request_cursor_listener);
+    wimp.seat = wlr_seat_create(wimp.display, "seat0");
+    wimp.request_cursor_listener.notify = on_request_cursor;
+    wl_signal_add(&wimp.seat->events.request_set_cursor, &wimp.request_cursor_listener);
 
-    server->request_set_selection_listener.notify = on_request_set_selection;
-    wl_signal_add(&server->seat->events.request_set_selection,
-	&server->request_set_selection_listener);
+    wimp.request_set_selection_listener.notify = on_request_set_selection;
+    wl_signal_add(&wimp.seat->events.request_set_selection,
+	&wimp.request_set_selection_listener);
 }

src/desk.h Modified

@@ -3,7 +3,7 @@
 
 #include "types.h"
 
-void add_desk(struct server *server);
-void set_desk(struct server *server, struct desk *desk);
+void add_desk();
+void set_desk(struct desk *desk);
 
 #endif

src/desk.c Modified

@@ -4,34 +4,33 @@
 #include "types.h"
 
 
-void add_desk(struct server *server) {
+void add_desk() {
     struct desk *desk = calloc(1, sizeof(struct desk));
-    wl_list_insert(server->desks.prev, &desk->link);
-    desk->server = server;
+    wl_list_insert(wimp.desks.prev, &desk->link);
     wl_list_init(&desk->views);
     assign_colour("#5D479D", desk->background);
     assign_colour("#3e3e73", desk->border_normal);
     assign_colour("#998dd1", desk->border_focus);
     desk->border_width = 4;
     desk->wallpaper = NULL;
-    desk->index = server->desk_count;
+    desk->index = wimp.desk_count;
     desk->zoom = 1;
     desk->fullscreened = NULL;
-    server->desk_count++;
+    wimp.desk_count++;
 }
 
 
-void set_desk(struct server *server, struct desk *desk) {
+void set_desk(struct desk *desk) {
     struct view *view;
-    server->can_steal_focus = false;
-    wl_list_for_each(view, &server->current_desk->views, link) {
+    wimp.can_steal_focus = false;
+    wl_list_for_each(view, &wimp.current_desk->views, link) {
 	unmap_view(view);
     }
-    server->current_desk = desk;
-    wl_list_for_each(view, &server->current_desk->views, link) {
+    wimp.current_desk = desk;
+    wl_list_for_each(view, &wimp.current_desk->views, link) {
 	map_view(view);
     }
-    server->can_steal_focus = true;
+    wimp.can_steal_focus = true;
     if (!wl_list_empty(&desk->views)) {
 	view = wl_container_of(desk->views.next, view, link);
 	focus_view(view, view->surface->surface);

src/decorations.h Modified

@@ -3,6 +3,6 @@
 
 #include "types.h"
 
-void set_up_decorations(struct server *server);
+void set_up_decorations();
 
 #endif

src/decorations.c Modified

@@ -46,20 +46,20 @@
 }
 
 
-void set_up_decorations(struct server *server) {
+void set_up_decorations() {
     // xdg_decoration
-    server->decoration_manager = wlr_xdg_decoration_manager_v1_create(server->display);
+    wimp.decoration_manager = wlr_xdg_decoration_manager_v1_create(wimp.display);
 
-    server->decoration_listener.notify = on_new_decoration;
+    wimp.decoration_listener.notify = on_new_decoration;
     wl_signal_add(
-        &server->decoration_manager->events.new_toplevel_decoration,
-        &server->decoration_listener
+        &wimp.decoration_manager->events.new_toplevel_decoration,
+        &wimp.decoration_listener
     );
 
     // server_decoration
-    server->server_decoration_manager = wlr_server_decoration_manager_create(server->display);
+    wimp.server_decoration_manager = wlr_server_decoration_manager_create(wimp.display);
     wlr_server_decoration_manager_set_default_mode(
-	server->server_decoration_manager,
+	wimp.server_decoration_manager,
 	WLR_SERVER_DECORATION_MANAGER_MODE_SERVER
     );
 }

src/cursor.h Modified

@@ -3,6 +3,6 @@
 
 #include "types.h"
 
-void set_up_cursor(struct server *server);
+void set_up_cursor();
 
 #endif

src/cursor.c Modified

@@ -9,32 +9,32 @@
 #include "types.h"
 
 
-static void process_cursor_move(struct server *server, uint32_t time, double zoom) {
-    server->grabbed_view->x = (server->cursor->x - server->grab_x) / zoom;
-    server->grabbed_view->y = (server->cursor->y - server->grab_y) / zoom;
+static void process_cursor_move(uint32_t time, double zoom) {
+    wimp.grabbed_view->x = (wimp.cursor->x - wimp.grab_x) / zoom;
+    wimp.grabbed_view->y = (wimp.cursor->y - wimp.grab_y) / zoom;
 }
 
 
-static void process_cursor_resize(struct server *server, uint32_t time, double zoom) {
-    struct view *view = server->grabbed_view;
-    int x = server->grab_geobox.x;
-    int width = server->grab_geobox.width;
-    int y = server->grab_geobox.y;
-    int height = server->grab_geobox.height;
+static void process_cursor_resize(uint32_t time, double zoom) {
+    struct view *view = wimp.grabbed_view;
+    int x = wimp.grab_geobox.x;
+    int width = wimp.grab_geobox.width;
+    int y = wimp.grab_geobox.y;
+    int height = wimp.grab_geobox.height;
 
-    double cx = (server->cursor->x - server->grab_x) / zoom;
-    double cy = (server->cursor->y - server->grab_y) / zoom;
+    double cx = (wimp.cursor->x - wimp.grab_x) / zoom;
+    double cy = (wimp.cursor->y - wimp.grab_y) / zoom;
 
-    if (server->resize_edges & WLR_EDGE_TOP) {
+    if (wimp.resize_edges & WLR_EDGE_TOP) {
 	height -= cy - y;
 	y = cy;
-    } else if (server->resize_edges & WLR_EDGE_BOTTOM) {
+    } else if (wimp.resize_edges & WLR_EDGE_BOTTOM) {
         height += cy - y;
     }
-    if (server->resize_edges & WLR_EDGE_LEFT) {
+    if (wimp.resize_edges & WLR_EDGE_LEFT) {
         width -= cx - x;
 	x = cx;
-    } else if (server->resize_edges & WLR_EDGE_RIGHT) {
+    } else if (wimp.resize_edges & WLR_EDGE_RIGHT) {
         width += cx - x;
     }
 
@@ -67,11 +67,10 @@
 
 
 static struct view *desktop_view_at(
-    struct server *server, double lx, double ly, struct wlr_surface **surface,
-    double *sx, double *sy
+    double lx, double ly, struct wlr_surface **surface, double *sx, double *sy
 ) {
     struct view *view;
-    wl_list_for_each(view, &server->current_desk->views, link) {
+    wl_list_for_each(view, &wimp.current_desk->views, link) {
 	if (view_at(view, lx, ly, surface, sx, sy)) {
 	    return view;
 	}
@@ -80,25 +79,23 @@
 }
 
 
-static void process_cursor_motion(struct server *server, uint32_t time, double dx, double dy) {
+static void process_cursor_motion(uint32_t time, double dx, double dy) {
     double sx, sy;
     struct wlr_seat *seat;
     struct wlr_surface *surface;
     struct view *view;
-    double zoom = server->current_desk->zoom;
+    double zoom = wimp.current_desk->zoom;
     dx /= zoom;
     dy /= zoom;
 
-    switch (server->cursor_mode) {
+    switch (wimp.cursor_mode) {
 	case CURSOR_PASSTHROUGH:
-	    seat = server->seat;
+	    seat = wimp.seat;
 	    surface = NULL;
-	    view = desktop_view_at(server, server->cursor->x / zoom,
-		server->cursor->y / zoom, &surface, &sx, &sy);
+	    view = desktop_view_at(wimp.cursor->x / zoom,
+		wimp.cursor->y / zoom, &surface, &sx, &sy);
 	    if (!view) {
-		wlr_xcursor_manager_set_cursor_image(
-		    server->cursor_manager, "left_ptr", server->cursor
-		);
+		wlr_xcursor_manager_set_cursor_image(wimp.cursor_manager, "left_ptr", wimp.cursor);
 	    }
 	    if (surface) {
 		bool focus_changed = seat->pointer_state.focused_surface != surface;
@@ -112,58 +109,52 @@
 	    break;
 
 	case CURSOR_MOD:
-	    if (server->on_mouse_motion) {
+	    if (wimp.on_mouse_motion) {
 		struct motion motion = {
 		    .dx = dx,
 		    .dy = dy,
 		    .is_percentage = false,
 		};
-		server->on_mouse_motion(server, &motion);
+		wimp.on_mouse_motion(&motion);
 	    }
 	    break;
 
 	case CURSOR_MOVE:
-	    process_cursor_move(server, time, zoom);
+	    process_cursor_move(time, zoom);
 	    break;
 
 	case CURSOR_RESIZE:
-	    process_cursor_resize(server, time, zoom);
+	    process_cursor_resize(time, zoom);
 	    break;
     }
 }
 
 
 static void on_cursor_motion(struct wl_listener *listener, void *data){
-    struct server *server = wl_container_of(listener, server, cursor_motion_listener);
     struct wlr_event_pointer_motion *event = data;
-    wlr_cursor_move(server->cursor, event->device, event->delta_x, event->delta_y);
-    process_cursor_motion(server, event->time_msec, event->delta_x, event->delta_y);
+    wlr_cursor_move(wimp.cursor, event->device, event->delta_x, event->delta_y);
+    process_cursor_motion(event->time_msec, event->delta_x, event->delta_y);
 }
 
 
 static void on_cursor_motion_absolute(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server,
-	cursor_motion_absolute_listener);
     struct wlr_event_pointer_motion_absolute *event = data;
-    wlr_cursor_warp_absolute(server->cursor, event->device, event->x, event->y);
-    process_cursor_motion(server, event->time_msec, 0, 0);
+    wlr_cursor_warp_absolute(wimp.cursor, event->device, event->x, event->y);
+    process_cursor_motion(event->time_msec, 0, 0);
 }
 
 
 static void on_cursor_button(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, cursor_button_listener);
     struct wlr_event_pointer_button *event = data;
-    wlr_seat_pointer_notify_button(
-	server->seat, event->time_msec, event->button, event->state
-    );
+    wlr_seat_pointer_notify_button(wimp.seat, event->time_msec, event->button, event->state);
 
     if (event->state == WLR_BUTTON_RELEASED) {
-	server->cursor_mode = CURSOR_PASSTHROUGH;
+	wimp.cursor_mode = CURSOR_PASSTHROUGH;
     } else {
 	double sx, sy;
 	struct wlr_surface *surface;
 	struct view *view = desktop_view_at(
-	    server, server->cursor->x, server->cursor->y, &surface, &sx, &sy
+	    wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy
 	);
 	focus_view(view, surface);
     }
@@ -171,25 +162,24 @@
 
 
 static void on_cursor_axis(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, cursor_axis_listener);
     struct wlr_event_pointer_axis *event = data;
-    if (server->cursor_mode == CURSOR_MOD) {
-	if (server->on_mouse_scroll) {
+    if (wimp.cursor_mode == CURSOR_MOD) {
+	if (wimp.on_mouse_scroll) {
 	    struct motion motion = {
 		.dx = 0,
 		.dy = 0,
 		.is_percentage = false,
 	    };
 	    if (event->orientation == WLR_AXIS_ORIENTATION_VERTICAL) {
-		motion.dy = server->reverse_scrolling ? - event->delta : event->delta;
+		motion.dy = wimp.reverse_scrolling ? - event->delta : event->delta;
 	    } else {
-		motion.dx = server->reverse_scrolling ? - event->delta : event->delta;
+		motion.dx = wimp.reverse_scrolling ? - event->delta : event->delta;
 	    };
-	    server->on_mouse_scroll(server, &motion);
+	    wimp.on_mouse_scroll(&motion);
 	}
     } else {
 	wlr_seat_pointer_notify_axis(
-	    server->seat, event->time_msec, event->orientation, event->delta,
+	    wimp.seat, event->time_msec, event->orientation, event->delta,
 	    event->delta_discrete, event->source
 	);
     }
@@ -197,30 +187,29 @@
 
 
 static void on_cursor_frame(struct wl_listener *listener, void *data) {
-    struct server *server = wl_container_of(listener, server, cursor_frame_listener);
-    wlr_seat_pointer_notify_frame(server->seat);
+    wlr_seat_pointer_notify_frame(wimp.seat);
 }
 
 
-void set_up_cursor(struct server *server) {
-    server->cursor = wlr_cursor_create();
-    wlr_cursor_attach_output_layout(server->cursor, server->output_layout);
-    server->cursor_manager = wlr_xcursor_manager_create(NULL, 24);
-    wlr_xcursor_manager_load(server->cursor_manager, 1);
+void set_up_cursor() {
+    wimp.cursor = wlr_cursor_create();
+    wlr_cursor_attach_output_layout(wimp.cursor, wimp.output_layout);
+    wimp.cursor_manager = wlr_xcursor_manager_create(NULL, 24);
+    wlr_xcursor_manager_load(wimp.cursor_manager, 1);
 
-    server->cursor_motion_listener.notify = on_cursor_motion;
-    wl_signal_add(&server->cursor->events.motion, &server->cursor_motion_listener);
+    wimp.cursor_motion_listener.notify = on_cursor_motion;
+    wl_signal_add(&wimp.cursor->events.motion, &wimp.cursor_motion_listener);
 
-    server->cursor_motion_absolute_listener.notify = on_cursor_motion_absolute;
-    wl_signal_add(&server->cursor->events.motion_absolute,
-	&server->cursor_motion_absolute_listener);
+    wimp.cursor_motion_absolute_listener.notify = on_cursor_motion_absolute;
+    wl_signal_add(&wimp.cursor->events.motion_absolute,
+	&wimp.cursor_motion_absolute_listener);
 
-    server->cursor_button_listener.notify = on_cursor_button;
-    wl_signal_add(&server->cursor->events.button, &server->cursor_button_listener);
+    wimp.cursor_button_listener.notify = on_cursor_button;
+    wl_signal_add(&wimp.cursor->events.button, &wimp.cursor_button_listener);
 
-    server->cursor_axis_listener.notify = on_cursor_axis;
-    wl_signal_add(&server->cursor->events.axis, &server->cursor_axis_listener);
+    wimp.cursor_axis_listener.notify = on_cursor_axis;
+    wl_signal_add(&wimp.cursor->events.axis, &wimp.cursor_axis_listener);
 
-    server->cursor_frame_listener.notify = on_cursor_frame;
-    wl_signal_add(&server->cursor->events.frame, &server->cursor_frame_listener);
+    wimp.cursor_frame_listener.notify = on_cursor_frame;
+    wl_signal_add(&wimp.cursor->events.frame, &wimp.cursor_frame_listener);
 }

src/config.h Modified

@@ -4,7 +4,7 @@
 #include "types.h"
 
 void assign_colour(char *hex, float dest[4]);
-void load_config(struct server *server);
-void locate_config(struct server *server);
+void load_config();
+void locate_config();
 
 #endif

src/config.c Modified

@@ -168,7 +168,7 @@
 }
 
 
-static void add_binding(struct server *server, char *data, const int line) {
+static void add_binding(char *data, const int line) {
     struct binding *kb = calloc(1, sizeof(struct binding));
     enum wlr_keyboard_modifier mod;
     char *s = strtok(data, " \t\n\r");
@@ -210,9 +210,9 @@
     struct binding *kb_existing, *tmp;
     struct wl_list *bindings;
     if (is_mouse_binding) {
-	bindings = &server->mouse_bindings;
+	bindings = &wimp.mouse_bindings;
     } else {
-	bindings = &server->key_bindings;
+	bindings = &wimp.key_bindings;
     }
     wl_list_for_each_safe(kb_existing, tmp, bindings, link) {
 	if (kb_existing->key == kb->key && kb_existing->mods == kb->mods) {
@@ -239,9 +239,7 @@
 }
 
 
-static void load_wallpaper(
-    struct server *server, struct desk *desk, char *path
-) {
+static void load_wallpaper(struct desk *desk, char *path) {
     cairo_surface_t *image = cairo_image_surface_create_from_png(path);
 
     if (!image || cairo_surface_status(image) != CAIRO_STATUS_SUCCESS) {
@@ -263,7 +261,7 @@
     cairo_paint(cr);
 
     wallpaper->texture = wlr_texture_from_pixels(
-	server->renderer, WL_SHM_FORMAT_ARGB8888, stride, wallpaper->width,
+	wimp.renderer, WL_SHM_FORMAT_ARGB8888, stride, wallpaper->width,
 	wallpaper->height, cairo_image_surface_get_data(canvas)
     );
     desk->wallpaper = wallpaper;
@@ -273,8 +271,8 @@
 }
 
 
-static void set_wallpaper(struct server *server, char *wallpaper) {
-    struct desk *desk = wl_container_of(server->desks.prev, desk, link);
+static void set_wallpaper(char *wallpaper) {
+    struct desk *desk = wl_container_of(wimp.desks.prev, desk, link);
 
     // wallpaper is a colour
     if (strlen(wallpaper) == 7 && wallpaper[0] == '#') {
@@ -285,14 +283,15 @@
     // wallpaper is a path to an image
     wordexp_t p;
     wordexp(wallpaper, &p, WRDE_NOCMD | WRDE_UNDEF);
-    load_wallpaper(server, desk, p.we_wordv[0]);
+    load_wallpaper(desk, p.we_wordv[0]);
     wordfree(&p);
 }
 
 
-static void setup_vt_switching(struct server *server) {
-    if (!server->vt_switching)
+static void setup_vt_switching() {
+    if (!wimp.vt_switching) {
 	return;
+    }
 
     /* If the configured mod key is alt then we have to bind the VT key combos
      * otherwise they interfere with the alt. With other mods we don't get this
@@ -314,7 +313,7 @@
 	XKB_KEY_XF86Switch_VT_6
     };
     uint32_t *keys;
-    if (server->mod == WLR_MODIFIER_ALT) {
+    if (wimp.mod == WLR_MODIFIER_ALT) {
 	keys = switch_keys;
     } else {
 	keys = func_keys;
@@ -330,12 +329,12 @@
 	kb->action = &change_vt;
 	kb->data = calloc(1, sizeof(unsigned));
 	*(unsigned *)(kb->data) = i + 1;
-	wl_list_insert(server->key_bindings.prev, &kb->link);
+	wl_list_insert(wimp.key_bindings.prev, &kb->link);
     }
 }
 
 
-static void parse_config(struct server *server, FILE *stream) {
+static void parse_config(FILE *stream) {
     char *s;
     char linebuf[1024];
     int line = 0;
@@ -346,40 +345,40 @@
 	    continue;
 	}
 	if (!strcasecmp(s, "add_desk")) {
-	    add_desk(server);
+	    add_desk();
 	} else if (!strcasecmp(s, "background")) {
 	    if ((s = strtok(NULL, " \t\n\r"))) {
-		set_wallpaper(server, s);
+		set_wallpaper(s);
 	    }
 	} else if (!strcasecmp(s, "set_modifier")) {
 	    if ((s = strtok(NULL, " \t\n\r"))) {
 		enum wlr_keyboard_modifier mod = get(mods, s);
 		if (mod)
-		    server->mod = mod;
+		    wimp.mod = mod;
 		else
 		    wlr_log(WLR_ERROR, "Config line %i: invalid modifier name '%s'.", line, s);
 	    }
 	} else if (!strcasecmp(s, "zoom_min")) {
 	    if ((s = strtok(NULL, " \t\n\r")) && is_number(s)) {
-		server->zoom_min = strtod(s, NULL);
+		wimp.zoom_min = strtod(s, NULL);
 	    }
 	} else if (!strcasecmp(s, "zoom_max")) {
 	    if ((s = strtok(NULL, " \t\n\r")) && is_number(s)) {
-		server->zoom_max = strtod(s, NULL);
+		wimp.zoom_max = strtod(s, NULL);
 	    }
 	} else if (!strcasecmp(s, "bind")) {
-	    add_binding(server, strtok(NULL, ""), line);
+	    add_binding(strtok(NULL, ""), line);
 	} else if (!strcasecmp(s, "mark_indicator")) {
-	    assign_colour(strtok(NULL, " \t\n\r"), server->mark_indicator.colour);
+	    assign_colour(strtok(NULL, " \t\n\r"), wimp.mark_indicator.colour);
 	} else if (!strcasecmp(s, "vt_switching")) {
 	    s = strtok(NULL, " \t\n\r");
 	    if (!strcasecmp(s, "off"))
-		server->vt_switching = false;
+		wimp.vt_switching = false;
 	    else if (!strcasecmp(s, "on"))
-		server->vt_switching = true;
+		wimp.vt_switching = true;
 	} else if (!strcasecmp(s, "borders")) {
 	    s = strtok(NULL, " \t\n\r");
-	    struct desk *desk = wl_container_of(server->desks.prev, desk, link);
+	    struct desk *desk = wl_container_of(wimp.desks.prev, desk, link);
 	    if (!strcasecmp(s, "normal"))
 		assign_colour(strtok(NULL, " \t\n\r"), desk->border_normal);
 	    else if (!strcasecmp(s, "focus"))
@@ -390,23 +389,23 @@
 	} else if (!strcasecmp(s, "scroll_direction")) {
 	    s = strtok(NULL, " \t\n\r");
 	    if (!strcasecmp(s, "natural"))
-		server->reverse_scrolling = false;
+		wimp.reverse_scrolling = false;
 	    else if (!strcasecmp(s, "reverse"))
-		server->reverse_scrolling = true;
+		wimp.reverse_scrolling = true;
 	}
     }
 }
 
 
-void load_config(struct server *server) {
+void load_config() {
     FILE *stream;
 
     // remove existing keybindings
     struct binding *kb, *tmp;
-    wl_list_for_each_safe(kb, tmp, &server->mouse_bindings, link) {
+    wl_list_for_each_safe(kb, tmp, &wimp.mouse_bindings, link) {
 	free_binding(kb);
     }
-    wl_list_for_each_safe(kb, tmp, &server->key_bindings, link) {
+    wl_list_for_each_safe(kb, tmp, &wimp.key_bindings, link) {
 	free_binding(kb);
     }
 
@@ -416,41 +415,41 @@
     stream = open_memstream(&buffer, &size);
     fprintf(stream, DEFAULT_CONFIG);
     rewind(stream);
-    parse_config(server, stream);
+    parse_config(stream);
     free(buffer);
     fclose(stream);
 
     // load custom configuration file
-    if (server->config_file) {
-	stream = fopen(server->config_file, "r");
-	parse_config(server, stream);
+    if (wimp.config_file) {
+	stream = fopen(wimp.config_file, "r");
+	parse_config(stream);
 	fclose(stream);
     }
 
-    setup_vt_switching(server);
+    setup_vt_switching();
 }
 
 
-void locate_config(struct server *server)
+void locate_config()
 {
     char *config;
     char *xdg_config;
 
-    if (server->config_file == NULL) {
+    if (wimp.config_file == NULL) {
 	xdg_config = getenv("XDG_CONFIG_HOME");
 	config = (xdg_config && *xdg_config) ? CONFIG_HOME_XDG : CONFIG_HOME;
-	server->config_file = strdup(config);
+	wimp.config_file = strdup(config);
     };
 
     wordexp_t p;
-    wordexp(server->config_file, &p, WRDE_NOCMD | WRDE_UNDEF);
-    free(server->config_file);
+    wordexp(wimp.config_file, &p, WRDE_NOCMD | WRDE_UNDEF);
+    free(wimp.config_file);
 
     if (access(p.we_wordv[0], R_OK) == -1) {
 	wlr_log(WLR_ERROR, "%s not accessible. Using defaults.", p.we_wordv[0]);
-	server->config_file = NULL;
+	wimp.config_file = NULL;
     } else {
-	server->config_file = strdup(p.we_wordv[0]);
+	wimp.config_file = strdup(p.we_wordv[0]);
     }
 
     wordfree(&p);

src/action.h Modified

@@ -3,23 +3,23 @@
 
 #include "types.h"
 
-void shutdown(struct server *server, void *data);
-void exec_command(struct server *server, void *data);
-void change_vt(struct server *server, void *data);
-void close_window(struct server *server, void *data);
-void focus_in_direction(struct server *server, void *data);
-void next_desk(struct server *server, void *data);
-void prev_desk(struct server *server, void *data);
-void pan_desk(struct server *server, void *data);
-void reset_zoom(struct server *server, void *data);
-void zoom(struct server *server, void *data);
-void zoom_mouse(struct server *server, void *data);
-void set_mark(struct server *server, void *data);
-void actually_set_mark(struct server *server, const xkb_keysym_t sym);
-void go_to_mark(struct server *server, void *data);
-void actually_go_to_mark(struct server *server, const xkb_keysym_t sym);
-void toggle_fullscreen(struct server *server, void *data);
-void halfimize(struct server *server, void *data);
-void reload_config(struct server *server, void *data);
+void shutdown(void *data);
+void exec_command(void *data);
+void change_vt(void *data);
+void close_window(void *data);
+void focus_in_direction(void *data);
+void next_desk(void *data);
+void prev_desk(void *data);
+void pan_desk(void *data);
+void reset_zoom(void *data);
+void zoom(void *data);
+void zoom_mouse(void *data);
+void set_mark(void *data);
+void actually_set_mark(const xkb_keysym_t sym);
+void go_to_mark(void *data);
+void actually_go_to_mark(const xkb_keysym_t sym);
+void toggle_fullscreen(void *data);
+void halfimize(void *data);
+void reload_config(void *data);
 
 #endif

src/action.c Modified

@@ -10,12 +10,12 @@
 #include "types.h"
 
 
-void shutdown(struct server *server, void *data) {
-    wl_display_terminate(server->display);
+void shutdown(void *data) {
+    wl_display_terminate(wimp.display);
 }
 
 
-void exec_command(struct server *server, void *data) {
+void exec_command(void *data) {
     if (fork() == 0) {
 	execl("/bin/sh", "/bin/sh", "-c", data, (void *)NULL);
     } else {
@@ -24,15 +24,15 @@
 }
 
 
-void change_vt(struct server *server, void *data) {
+void change_vt(void *data) {
     unsigned vt = *(unsigned*)data;
-    struct wlr_session *session = wlr_backend_get_session(server->backend);
+    struct wlr_session *session = wlr_backend_get_session(wimp.backend);
     wlr_session_change_vt(session, vt);
 }
 
 
-void close_window(struct server *server, void *data) {
-    struct wlr_surface *surface = server->seat->keyboard_state.focused_surface;
+void close_window(void *data) {
+    struct wlr_surface *surface = wimp.seat->keyboard_state.focused_surface;
     if (surface) {
 	struct wlr_xdg_surface *xdg_surface = surface->role_data;
 	if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && xdg_surface->toplevel) {
@@ -42,11 +42,11 @@
 }
 
 
-void focus_in_direction(struct server *server, void *data) {
-    if (wl_list_empty(&server->current_desk->views))
+void focus_in_direction(void *data) {
+    if (wl_list_empty(&wimp.current_desk->views))
 	return;
 
-    struct view *current = wl_container_of(server->current_desk->views.next, current, link);
+    struct view *current = wl_container_of(wimp.current_desk->views.next, current, link);
     enum direction dir = *(enum direction*)data;
 
     struct view *next = NULL;
@@ -59,7 +59,7 @@
     bool above_c = dir & (DOWN | LEFT);
     bool above_n = dir & (DOWN | RIGHT);
 
-    wl_list_for_each(view, &server->current_desk->views, link) {
+    wl_list_for_each(view, &wimp.current_desk->views, link) {
 	vx = view->x + view->surface->geometry.width / 2;
 	vy = view->y + view->surface->geometry.height / 2;
 	dx = x - vx;
@@ -83,36 +83,36 @@
 }
 
 
-void next_desk(struct server *server, void *data) {
+void next_desk(void *data) {
     struct desk *desk;
-    if (server->current_desk->index + 1 == server->desk_count) {
-	desk = wl_container_of(server->desks.next, desk, link);
+    if (wimp.current_desk->index + 1 == wimp.desk_count) {
+	desk = wl_container_of(wimp.desks.next, desk, link);
     } else {
-	desk = wl_container_of(server->current_desk->link.next, desk, link);
+	desk = wl_container_of(wimp.current_desk->link.next, desk, link);
     }
-    set_desk(server, desk);
+    set_desk(desk);
 }
 
 
-void prev_desk(struct server *server, void *data) {
+void prev_desk(void *data) {
     struct desk *desk;
-    if (server->current_desk->index == 0) {
-	desk = wl_container_of(server->desks.prev, desk, link);
+    if (wimp.current_desk->index == 0) {
+	desk = wl_container_of(wimp.desks.prev, desk, link);
     } else {
-	desk = wl_container_of(server->current_desk->link.prev, desk, link);
+	desk = wl_container_of(wimp.current_desk->link.prev, desk, link);
     }
-    set_desk(server, desk);
+    set_desk(desk);
 }
 
 
-void pan_desk(struct server *server, void *data) {
-    struct desk *desk = server->current_desk;
+void pan_desk(void *data) {
+    struct desk *desk = wimp.current_desk;
     struct motion motion = *(struct motion*)data;
     double dx = motion.dx;
     double dy = motion.dy;
     if (motion.is_percentage) {
 	struct wlr_box *extents =
-	    wlr_output_layout_get_box(server->output_layout, NULL);
+	    wlr_output_layout_get_box(wimp.output_layout, NULL);
 	dx = extents->width * (dx / 100);
 	dy = extents->height * (dy / 100);
     }
@@ -126,10 +126,10 @@
 }
 
 
-void reset_zoom(struct server *server, void *data) {
-    struct desk *desk = server->current_desk;
+void reset_zoom(void *data) {
+    struct desk *desk = wimp.current_desk;
     double f = 1 / desk->zoom;
-    struct wlr_box *extents = wlr_output_layout_get_box(server->output_layout, NULL);
+    struct wlr_box *extents = wlr_output_layout_get_box(wimp.output_layout, NULL);
     double fx = extents->width * (f - 1) / 2;
     double fy = extents->height * (f - 1) / 2;
     struct view *view;
@@ -143,19 +143,19 @@
 }
 
 
-void zoom(struct server *server, void *data) {
+void zoom(void *data) {
     /* Passed value (data) is the percentage step (+ve or -ve) */
-    struct desk *desk = server->current_desk;
+    struct desk *desk = wimp.current_desk;
     double f = 1 + (*(double*)data / 100);
     if (
-	(f > 1 && desk->zoom >= server->zoom_max) ||
-	(f < 1 && desk->zoom <= server->zoom_min)
+	(f > 1 && desk->zoom >= wimp.zoom_max) ||
+	(f < 1 && desk->zoom <= wimp.zoom_min)
     ) {
 	return;
     }
     desk->zoom *= f;
-    double fx = server->cursor->x * (f - 1) / desk->zoom;
-    double fy = server->cursor->y * (f - 1) / desk->zoom;
+    double fx = wimp.cursor->x * (f - 1) / desk->zoom;
+    double fy = wimp.cursor->y * (f - 1) / desk->zoom;
     struct view *view;
     wl_list_for_each(view, &desk->views, link) {
 	view->x -= fx;
@@ -166,38 +166,38 @@
 }
 
 
-void zoom_mouse(struct server *server, void *data) {
+void zoom_mouse(void *data) {
     struct motion motion = *(struct motion*)data;
     double dz = motion.dx + motion.dy;
-    zoom(server, &dz);
+    zoom(&dz);
 }
 
 
-void set_mark(struct server *server, void *data) {
+void set_mark(void *data) {
     struct mark *mark = calloc(1, sizeof(struct mark));
-    struct desk *desk = server->current_desk;
+    struct desk *desk = wimp.current_desk;
     mark->desk = desk;
     mark->x = desk->panned_x;
     mark->y = desk->panned_y;
     mark->zoom = desk->zoom;
     mark->key = 0;
-    server->mark_waiting = true;
-    wl_list_insert(&server->marks, &mark->link);
+    wimp.mark_waiting = true;
+    wl_list_insert(&wimp.marks, &mark->link);
 }
 
 
-void actually_set_mark(struct server *server, const xkb_keysym_t sym) {
+void actually_set_mark(const xkb_keysym_t sym) {
     struct mark *mark;
     struct mark *existing = NULL;
 
     if (sym == XKB_KEY_Escape) {
-	mark = wl_container_of(server->marks.next, mark, link);
+	mark = wl_container_of(wimp.marks.next, mark, link);
 	wl_list_remove(&mark->link);
 	free(mark);
 	return;
     }
 
-    wl_list_for_each(mark, &server->marks, link) {
+    wl_list_for_each(mark, &wimp.marks, link) {
 	if (mark->key == sym) {
 	    existing = mark;
 	    break;
@@ -208,62 +208,63 @@
 	free(existing);
     }
 
-    mark = wl_container_of(server->marks.next, mark, link);
+    mark = wl_container_of(wimp.marks.next, mark, link);
     mark->key = sym;
 }
 
 
-void go_to_mark(struct server *server, void *data) {
-    server->mark_waiting = true;
+void go_to_mark(void *data) {
+    wimp.mark_waiting = true;
 }
 
 
-void actually_go_to_mark(struct server *server, const xkb_keysym_t sym) {
+void actually_go_to_mark(const xkb_keysym_t sym) {
     struct mark *mark;
 
     if (sym == XKB_KEY_Escape)
 	return;
 
-    wl_list_for_each(mark, &server->marks, link) {
+    wl_list_for_each(mark, &wimp.marks, link) {
 	if (mark->key == sym) {
 	    struct motion motion = {
 		.dx = mark->x - mark->desk->panned_x,
 		.dy = mark->y - mark->desk->panned_y,
 	    };
 	    mark->desk->zoom = mark->zoom;
-	    set_desk(server, mark->desk);
-	    pan_desk(server, &motion);
+	    set_desk(mark->desk);
+	    pan_desk(&motion);
 	    return;
 	}
     }
 }
 
 
-void toggle_fullscreen(struct server *server, void *data) {
-    struct wlr_surface *surface = server->seat->keyboard_state.focused_surface;
+void toggle_fullscreen(void *data) {
+    struct wlr_surface *surface = wimp.seat->keyboard_state.focused_surface;
     if (!surface)
 	return;
     struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(surface);
-    struct view *view = wl_container_of(server->current_desk->views.next, view, link);
+    struct view *view = wl_container_of(wimp.current_desk->views.next, view, link);
     fullscreen_xdg_surface(view, xdg_surface, NULL);
 }
 
 
-void halfimize(struct server *server, void *data) {
-    if (wl_list_empty(&server->current_desk->views))
+void halfimize(void *data) {
+    if (wl_list_empty(&wimp.current_desk->views))
 	return;
 
-    struct view *view = wl_container_of(server->current_desk->views.next, view, link);
+    struct view *view = wl_container_of(wimp.current_desk->views.next, view, link);
 
-    if  (server->current_desk->fullscreened == view->surface)
+    if (wimp.current_desk->fullscreened == view->surface) {
 	fullscreen_xdg_surface(view, view->surface, NULL);
+    }
 
     enum direction dir = *(enum direction*)data;
     double vx = view->x + view->surface->geometry.width / 2;
     double vy = view->y + view->surface->geometry.height / 2;
     double x, y, width, height;
-    wlr_output_layout_closest_point(server->output_layout, NULL, vx, vy, &x, &y);
-    struct wlr_output *output = wlr_output_layout_output_at(server->output_layout, x, y);
+    wlr_output_layout_closest_point(wimp.output_layout, NULL, vx, vy, &x, &y);
+    struct wlr_output *output = wlr_output_layout_output_at(wimp.output_layout, x, y);
 
     switch (dir) {
 	case RIGHT:
@@ -294,7 +295,7 @@
 	    return;
     }
 
-    double zoom = server->current_desk->zoom;
+    double zoom = wimp.current_desk->zoom;
     view->x = x / zoom;
     view->y = y / zoom;
     wlr_xdg_toplevel_set_size(view->surface, width / zoom, height / zoom);
@@ -302,6 +303,6 @@
 }
 
 
-void reload_config(struct server *server, void *data) {
-    load_config(server);
+void reload_config(void *data) {
+    load_config();
 }