From ab491b03d652231d249915fc8eb8a38969e92bf4 Mon Sep 17 00:00:00 2001 From: MadcowOG Date: Tue, 21 Feb 2023 17:36:29 -0800 Subject: [PATCH] Shortened some if statements. --- src/bar.c | 6 ++---- src/main.c | 13 +++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/bar.c b/src/bar.c index c68e417..23cdbf5 100644 --- a/src/bar.c +++ b/src/bar.c @@ -87,9 +87,8 @@ void layerSurface(void* data, zwlr_layer_surface_v1* _, uint32_t serial, uint32_ zwlr_layer_surface_v1_ack_configure(bar->layer_surface, serial); if (bar->shm) { - if (bar->shm->width == width && bar->shm->height) { + if (bar->shm->width == width && bar->shm->height) return; - } shm_destroy(bar->shm); } @@ -384,9 +383,8 @@ void bar_invalidate(Bar* bar) { } void bar_show(Bar* bar, wl_output* output) { - if (!bar || !output || bar_is_visible(bar)) { + if (!bar || !output || bar_is_visible(bar)) return; - } bar->surface = wl_compositor_create_surface(compositor); bar->layer_surface = zwlr_layer_shell_v1_get_layer_surface(shell, bar->surface, output, ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "doom.dwl-bar"); diff --git a/src/main.c b/src/main.c index 236e242..6ce42fc 100644 --- a/src/main.c +++ b/src/main.c @@ -275,13 +275,11 @@ void button(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, static void frame(void* data, wl_pointer* pointer) { Seat seat = *(Seat*)data; Monitor* monitor = seat.pointer->focused_monitor; - if (!monitor) { + if (!monitor) return; - } - for (int i = 0; i < seat.pointer->size; i++) { + for (int i = 0; i < seat.pointer->size; i++) bar_click(monitor->bar, monitor, seat.pointer->x, seat.pointer->y, seat.pointer->buttons[i]); - } free(seat.pointer->buttons); seat.pointer->buttons = NULL; @@ -303,9 +301,9 @@ void capabilites(void* data, wl_seat* wl_seat, uint32_t capabilities) { if (seat->pointer && !has_pointer) { wl_pointer_release(seat->pointer->pointer); seat->pointer->focused_monitor = NULL; - if (seat->pointer->buttons) { + if (seat->pointer->buttons) free(seat->pointer->buttons); - } + free(seat->pointer); } } @@ -865,9 +863,8 @@ void die(const char *fmt, ...) { void* ecalloc(size_t amnt, size_t size) { void *p; - if (!(p = calloc(amnt, size))) { + if (!(p = calloc(amnt, size))) die("calloc did not allocate"); - } return p; }