diff --git a/include/client.h b/include/client.h index 3dcc3e8..0e327be 100644 --- a/include/client.h +++ b/include/client.h @@ -1,5 +1,4 @@ -#ifndef PEACHWM_CLIENT_H -#define PEACHWM_CLIENT_H +#pragma once #include #include @@ -77,21 +76,21 @@ typedef struct { } LayerSurface; /* Function declarations */ -int client_is_x11(Client *c); +[[nodiscard]] int client_is_x11(Client *c); struct wlr_surface *client_surface(Client *c); -int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl); +[[nodiscard]] int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl); void client_activate_surface(struct wlr_surface *s, int activated); uint32_t client_set_bounds(Client *c, int32_t width, int32_t height); -const char *client_get_appid(Client *c); +[[nodiscard]] const char *client_get_appid(Client *c); void client_get_clip(Client *c, struct wlr_box *clip); void client_get_geometry(Client *c, struct wlr_box *geom); -Client *client_get_parent(Client *c); -int client_has_children(Client *c); -const char *client_get_title(Client *c); -int client_is_float_type(Client *c); -int client_is_rendered_on_mon(Client *c, Monitor *m); -int client_is_stopped(Client *c); -int client_is_unmanaged(Client *c); +[[nodiscard]] Client *client_get_parent(Client *c); +[[nodiscard]] int client_has_children(Client *c); +[[nodiscard]] const char *client_get_title(Client *c); +[[nodiscard]] int client_is_float_type(Client *c); +[[nodiscard]] int client_is_rendered_on_mon(Client *c, Monitor *m); +[[nodiscard]] int client_is_stopped(Client *c); +[[nodiscard]] int client_is_unmanaged(Client *c); void client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb); void client_send_close(Client *c); void client_set_border_color(Client *c, const float color[static 4]); @@ -100,7 +99,6 @@ void client_set_scale(struct wlr_surface *s, float scale); uint32_t client_set_size(Client *c, uint32_t width, uint32_t height); void client_set_tiled(Client *c, uint32_t edges); void client_set_suspended(Client *c, int suspended); -int client_wants_focus(Client *c); -int client_wants_fullscreen(Client *c); +[[nodiscard]] int client_wants_focus(Client *c); +[[nodiscard]] int client_wants_fullscreen(Client *c); -#endif /* PEACHWM_CLIENT_H */ diff --git a/include/ext_workspace.h b/include/ext_workspace.h index 8165c01..0071bbe 100644 --- a/include/ext_workspace.h +++ b/include/ext_workspace.h @@ -1,5 +1,4 @@ -#ifndef PEACHWM_EXT_WORKSPACE_H -#define PEACHWM_EXT_WORKSPACE_H +#pragma once #include "monitor.h" @@ -20,4 +19,3 @@ void ext_workspace_cleanupmon(Monitor *m); void ext_workspace_printstatus(Monitor *m); void workspaces_init(void); -#endif /* PEACHWM_EXT_WORKSPACE_H */ diff --git a/include/ipc_socket.h b/include/ipc_socket.h index 4126715..74fda51 100644 --- a/include/ipc_socket.h +++ b/include/ipc_socket.h @@ -20,8 +20,7 @@ * 0x80000002 = mode 0x80000003 = window */ -#ifndef PEACHWM_IPC_SOCKET_H -#define PEACHWM_IPC_SOCKET_H +#pragma once #include #include @@ -88,4 +87,3 @@ void ipc_socket_send_workspace_event(const char *change); void ipc_socket_send_window_event(const char *change); void ipc_socket_send_output_event(void); -#endif /* PEACHWM_IPC_SOCKET_H */ diff --git a/include/monitor.h b/include/monitor.h index d3a34de..70420a6 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -1,5 +1,4 @@ -#ifndef PEACHWM_MONITOR_H -#define PEACHWM_MONITOR_H +#pragma once #include #include @@ -55,4 +54,3 @@ struct Monitor { struct Client *scratchpad_current; /* currently visible scratchpad client */ }; -#endif /* PEACHWM_MONITOR_H */ diff --git a/parser/parser.h b/parser/parser.h index c7f8a3c..4e0e5ad 100644 --- a/parser/parser.h +++ b/parser/parser.h @@ -1,5 +1,4 @@ -#ifndef PEACHWM_PARSER_H -#define PEACHWM_PARSER_H +#pragma once #include #include @@ -159,4 +158,3 @@ WatchState *config_watch_start( void config_watch_stop(WatchState *ws); -#endif diff --git a/src/client.c b/src/client.c index b65dfe6..5cad9f2 100644 --- a/src/client.c +++ b/src/client.c @@ -193,12 +193,12 @@ client_get_parent(Client *c) #ifdef XWAYLAND if (client_is_x11(c)) { if (c->surface.xwayland->parent) - toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, nullptr); + (void)toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, nullptr); return p; } #endif if (c->surface.xdg->toplevel->parent) - toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, nullptr); + (void)toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, nullptr); return p; } diff --git a/src/layout.h b/src/layout.h index 837fa8e..eef3942 100644 --- a/src/layout.h +++ b/src/layout.h @@ -1,5 +1,4 @@ -#ifndef PEACHWM_LAYOUT_H -#define PEACHWM_LAYOUT_H +#pragma once #include "monitor.h" #include "client.h" @@ -25,11 +24,11 @@ void master(Monitor *m); void monocle(Monitor *m); /* helpers used across modules */ -int current_tag_idx(Monitor *m); -const Layout *curlayout(Monitor *m); +[[nodiscard]] int current_tag_idx(Monitor *m); +[[nodiscard]] const Layout *curlayout(Monitor *m); /* dwindle tree helpers (exposed for swapdir) */ -DwindleNode *dwindle_find_leaf(DwindleNode *n, Client *c); +[[nodiscard]] DwindleNode *dwindle_find_leaf(DwindleNode *n, Client *c); void dwindle_recalc(DwindleNode *n, int gap); /* lifecycle helpers (called from peachwm.c unmap/cleanup) */ @@ -40,4 +39,3 @@ void master_remove_client(Client *c); /* tile drag swap (called from buttonpress handler) */ void swaptiled(Client *a, Client *b); -#endif /* PEACHWM_LAYOUT_H */ diff --git a/src/peachwm.c b/src/peachwm.c index c3569c9..201cff6 100644 --- a/src/peachwm.c +++ b/src/peachwm.c @@ -564,7 +564,7 @@ static void arrangelayers(Monitor *m) { static void dispatch_action(const char *action, const char (*args)[CFG_MAX_STRLEN], int nargs); -static void axisnotify(struct wl_listener *listener, void *data) { +static void axisnotify(struct wl_listener *listener, [[maybe_unused]] void *data) { /* This event is forwarded by the cursor when a pointer emits an axis event, * for example when you move the scroll wheel. */ struct wlr_pointer_axis_event *event = data; @@ -591,7 +591,7 @@ static void axisnotify(struct wl_listener *listener, void *data) { event->source, event->relative_direction); } -static void buttonpress(struct wl_listener *listener, void *data) { +static void buttonpress(struct wl_listener *listener, [[maybe_unused]] void *data) { struct wlr_pointer_button_event *event = data; struct wlr_keyboard *keyboard; uint32_t mods; @@ -935,7 +935,7 @@ static void createdecoration(struct wl_listener *listener, void *data) { requestdecorationmode(&c->set_decoration_mode, deco); } -static void createidleinhibitor(struct wl_listener *listener, void *data) { +static void createidleinhibitor(struct wl_listener *listener, [[maybe_unused]] void *data) { struct wlr_idle_inhibitor_v1 *idle_inhibitor = data; LISTEN_STATIC(&idle_inhibitor->events.destroy, destroyidleinhibitor); @@ -1285,7 +1285,7 @@ static void cursorwarptohint(void) { double sx = active_constraint->current.cursor_hint.x; double sy = active_constraint->current.cursor_hint.y; - toplevel_from_wlr_surface(active_constraint->surface, &c, nullptr); + (void)toplevel_from_wlr_surface(active_constraint->surface, &c, nullptr); if (c && active_constraint->current.cursor_hint.enabled) { wlr_cursor_warp(cursor, nullptr, sx + c->geom.x + c->bw, sy + c->geom.y + c->bw); @@ -1348,7 +1348,7 @@ destroy: free(lock); } -static void destroylocksurface(struct wl_listener *listener, void *data) { +static void destroylocksurface(struct wl_listener *listener, [[maybe_unused]] void *data) { Monitor *m = wl_container_of(listener, m, destroy_lock_surface); struct wlr_session_lock_surface_v1 *surface, *lock_surface = m->lock_surface; @@ -2217,7 +2217,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double if (active_constraint && cursor_mode != CurResize && cursor_mode != CurMove) { - toplevel_from_wlr_surface(active_constraint->surface, &c, nullptr); + (void)toplevel_from_wlr_surface(active_constraint->surface, &c, nullptr); if (c && active_constraint->surface == seat->pointer_state.focused_surface) { sx = cursor->x - c->geom.x - c->bw; @@ -3632,7 +3632,7 @@ static void updatetitle(struct wl_listener *listener, void *data) { static void urgent(struct wl_listener *listener, void *data) { struct wlr_xdg_activation_v1_request_activate_event *event = data; Client *c = nullptr; - toplevel_from_wlr_surface(event->surface, &c, nullptr); + (void)toplevel_from_wlr_surface(event->surface, &c, nullptr); if (!c || c == focustop(selmon)) return; diff --git a/src/util.h b/src/util.h index 2d266d6..663d70f 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,8 @@ /* Copyright and license details as described in the LICENSE file. */ +#pragma once #include [[noreturn]] void die(const char *fmt, ...); -void *ecalloc(size_t nmemb, size_t size); -int fd_set_nonblock(int fd); +[[nodiscard]] void *ecalloc(size_t nmemb, size_t size); +[[nodiscard]] int fd_set_nonblock(int fd); diff --git a/src/wlr_ext_workspace_v1.h b/src/wlr_ext_workspace_v1.h index 183d580..4314301 100644 --- a/src/wlr_ext_workspace_v1.h +++ b/src/wlr_ext_workspace_v1.h @@ -6,8 +6,7 @@ #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features" #endif -#ifndef WLR_TYPES_WLR_EXT_WORKSPACE_V1_H -#define WLR_TYPES_WLR_EXT_WORKSPACE_V1_H +#pragma once #include #include @@ -147,4 +146,4 @@ void wlr_ext_workspace_handle_v1_set_urgent( void wlr_ext_workspace_handle_v1_set_hidden( struct wlr_ext_workspace_handle_v1 *workspace, bool enabled); -#endif +