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

Commit bd5a4d4b16c4f539f474da9da2931c720af254fb
Parent: 6842b39a19cbc44edc00699dfdcd6f257ba2814c
Author: mcol <mcol@posteo.net>
Date: 2021-01-23 21:39:22 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-01-23 21:39:22 +0000

make things that are static explicitly static

src/shell.c Modified

@@ -86,13 +86,13 @@
 }
 
 
-void on_map(struct wl_listener *listener, void *data) {
+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)
 	focus_view(view, view->surface->surface);
 }
 
-void on_unmap(struct wl_listener *listener, void *data) {
+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) {
 	wl_list_remove(&view->link);
@@ -103,14 +103,14 @@
 }
 
 
-void on_surface_destroy(struct wl_listener *listener, void *data) {
+static void on_surface_destroy(struct wl_listener *listener, void *data) {
     struct view *view = wl_container_of(listener, view, destroy_listener);
     wl_list_remove(&view->link);
     free(view);
 }
 
 
-void process_move_resize(struct view *view, enum cursor_mode mode, uint32_t edges) {
+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;
@@ -134,27 +134,27 @@
 }
 
 
-void on_request_move(struct wl_listener *listener, void *data) {
+static void on_request_move(struct wl_listener *listener, void *data) {
     struct view *view = wl_container_of(listener, view, request_move_listener);
     process_move_resize(view, CURSOR_MOVE, 0);
 }
 
 
-void on_request_resize(struct wl_listener *listener, void *data) {
+static void on_request_resize(struct wl_listener *listener, void *data) {
     struct wlr_xdg_toplevel_resize_event *event = data;
     struct view *view = wl_container_of(listener, view, request_resize_listener);
     process_move_resize(view, CURSOR_RESIZE, event->edges);
 }
 
 
-void on_request_fullscreen(struct wl_listener *listener, void *data) {
+static void on_request_fullscreen(struct wl_listener *listener, void *data) {
     struct wlr_xdg_toplevel_set_fullscreen_event *event = data;
     struct view *view = wl_container_of(listener, view, request_fullscreen_listener);
     fullscreen_xdg_surface(view, event->surface, event->output);
 }
 
 
-void on_new_xdg_surface(struct wl_listener *listener, void *data) {
+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) {

src/output.c Modified

@@ -23,7 +23,7 @@
 };
 
 
-void render_surface(
+static void render_surface(
     struct wlr_surface *surface, int sx, int sy, void *data
 ) {
     struct render_data *rdata = data;
@@ -68,7 +68,7 @@
 }
 
 
-void on_frame(struct wl_listener *listener, void *data) {
+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;
@@ -133,7 +133,7 @@
 }
 
 
-void on_new_output(struct wl_listener *listener, void *data) {
+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;
 

src/log.c Modified

@@ -3,18 +3,18 @@
 #include <wlr/util/log.h>
 
 
-enum wlr_log_importance log_importance;
+static enum wlr_log_importance log_importance;
 
 
-const char *verbosity_headers[] = {
-	[WLR_SILENT] = "",
-	[WLR_ERROR] = "[ERROR]",
-	[WLR_INFO] = "[INFO]",
-	[WLR_DEBUG] = "[DEBUG]",
+static const char *verbosity_headers[] = {
+    [WLR_SILENT] = "",
+    [WLR_ERROR] = "[ERROR]",
+    [WLR_INFO] = "[INFO]",
+    [WLR_DEBUG] = "[DEBUG]",
 };
 
 
-void log_stdout(enum wlr_log_importance verbosity, const char *fmt, va_list args) {
+static void log_stdout(enum wlr_log_importance verbosity, const char *fmt, va_list args) {
     if (verbosity > log_importance) {
 	return;
     }

src/keyboard.c Modified

@@ -9,7 +9,7 @@
 #include "types.h"
 
 
-void on_modifier(struct wl_listener *listener, void *data) {
+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(
@@ -41,7 +41,7 @@
 }
 
 
-void on_key(struct wl_listener *listener, void *data) {
+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;
@@ -89,7 +89,7 @@
 }
 
 
-void on_new_keyboard(struct server *server, struct wlr_input_device *device) {
+static void on_new_keyboard(struct server *server, struct wlr_input_device *device) {
     struct keyboard *keyboard = calloc(1, sizeof(struct keyboard));
     keyboard->server = server;
     keyboard->device = device;
@@ -114,7 +114,7 @@
 }
 
 
-void on_request_set_selection(struct wl_listener *listener, void *data) {
+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;
@@ -122,7 +122,7 @@
 }
 
 
-void on_request_cursor(struct wl_listener *listener, void *data) {
+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 =
@@ -136,7 +136,7 @@
 }
 
 
-void on_new_input(struct wl_listener *listener, void *data) {
+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;

src/cursor.c Modified

@@ -9,13 +9,13 @@
 #include "types.h"
 
 
-void process_cursor_move(struct server *server, uint32_t time, double zoom) {
+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;
 }
 
 
-void process_cursor_resize(struct server *server, uint32_t time, double 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;
@@ -44,7 +44,7 @@
 }
 
 
-bool view_at(
+static bool view_at(
     struct view *view, double lx, double ly, struct wlr_surface **surface,
     double *sx, double *sy
 ) {
@@ -66,7 +66,7 @@
 }
 
 
-struct view *desktop_view_at(
+static struct view *desktop_view_at(
     struct server *server, double lx, double ly, struct wlr_surface **surface,
     double *sx, double *sy
 ) {
@@ -80,7 +80,7 @@
 }
 
 
-void process_cursor_motion(struct server *server, uint32_t time, double dx, double dy) {
+static void process_cursor_motion(struct server *server, uint32_t time, double dx, double dy) {
     double sx, sy;
     struct wlr_seat *seat;
     struct wlr_surface *surface;
@@ -132,7 +132,7 @@
 }
 
 
-void on_cursor_motion(struct wl_listener *listener, void *data){
+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);
@@ -140,7 +140,7 @@
 }
 
 
-void on_cursor_motion_absolute(struct wl_listener *listener, void *data) {
+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;
@@ -149,7 +149,7 @@
 }
 
 
-void on_cursor_button(struct wl_listener *listener, void *data) {
+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(
@@ -169,7 +169,7 @@
 }
 
 
-void on_cursor_axis(struct wl_listener *listener, void *data) {
+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) {
@@ -194,7 +194,7 @@
 }
 
 
-void on_cursor_frame(struct wl_listener *listener, void *data) {
+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);
 }

src/config.c Modified

@@ -27,7 +27,7 @@
 
 struct value_map {
     const char *name;
-    int value;
+    const int value;
 };
 
 
@@ -61,7 +61,7 @@
  * them to the getter so the macro hides this. */
 #define get(arr, name) _get(arr, sizeof(arr) / sizeof(arr[0]), name)
 
-int _get(struct value_map *values, int len, const char *name) {
+static int _get(struct value_map *values, const int len, const char *name) {
     for (int i = 0; i < len; i++) {
 	if (strcasecmp(values[i].name, name) == 0)
 	    return values[i].value;
@@ -70,13 +70,13 @@
 }
 
 
-void dir_handler(struct binding *kb, char *data) {
+static void dir_handler(struct binding *kb, const char *data) {
     kb->data = calloc(1, sizeof(enum direction));
     *(enum direction *)(kb->data) = get(dirs, data);
 }
 
 
-void str_handler(struct binding *kb, char *data) {
+static void str_handler(struct binding *kb, const char *data) {
     if (is_number(data)) {
 	kb->data = calloc(1, sizeof(double));
 	*(double *)(kb->data) = strtod(data, NULL);
@@ -89,8 +89,8 @@
 
 static struct {
     const char *name;
-    action action;
-    void (*data_handler)(struct binding *kb, char *data);
+    const action action;
+    void (*data_handler)(struct binding *kb, const char *data);
 } action_map[] = {
     { "shutdown", &shutdown, NULL },
     { "exec", &exec_command, &str_handler },
@@ -109,10 +109,10 @@
     { "reload_config", &reload_config, NULL },
 };
 
-static int num_actions = sizeof(action_map) / sizeof(action_map[0]);
+static const int num_actions = sizeof(action_map) / sizeof(action_map[0]);
 
 
-bool assign_action(char *name, char *data, struct binding *kb) {
+static bool assign_action(const char *name, const char *data, struct binding *kb) {
     kb->action = NULL;
     kb->data = NULL;
 
@@ -128,7 +128,7 @@
 }
 
 
-void free_binding(struct binding *kb) {
+static void free_binding(struct binding *kb) {
     if (kb->data)
 	free(kb->data);
     wl_list_remove(&kb->link);
@@ -136,7 +136,7 @@
 }
 
 
-void add_binding(struct server *server, char *data, int line) {
+static void add_binding(struct server *server, 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");
@@ -303,7 +303,7 @@
 }
 
 
-void parse_config(struct server *server, FILE *stream) {
+static void parse_config(struct server *server, FILE *stream) {
     char *s;
     char linebuf[1024];
     int line = 0;