From 2434e83807360bfe43e3c404be12438f00a894ab Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 2 Jul 2022 21:06:24 +0600 Subject: [PATCH] make some changes prepping for clang-format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Berke Kocaoğlu --- commands.c | 8 ++++---- image.c | 9 +++++---- main.c | 25 +++++++++++++------------ window.c | 4 ++-- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/commands.c b/commands.c index a4ae38d..db1cb09 100644 --- a/commands.c +++ b/commands.c @@ -326,10 +326,10 @@ bool ci_drag(arg_t drag_mode) while (true) { if (drag_mode == DRAG_ABSOLUTE) { - px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8) - * (win.w - img.w * img.zoom); - py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) / (win.h*0.8) - * (win.h - img.h * img.zoom); + px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / + (win.w*0.8) * (win.w - img.w * img.zoom); + py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) / + (win.h*0.8) * (win.h - img.h * img.zoom); } else { px = img.x + x - ox; py = img.y + y - oy; diff --git a/image.c b/image.c index cded0fe..2f5d697 100644 --- a/image.c +++ b/image.c @@ -282,8 +282,9 @@ static bool img_load_gif(img_t *img, const fileinfo_t *file) if (i < y || i >= y + h || j < x || j >= x + w || rows[i-y][j-x] == transp) { - if (prev_frame != NULL && (prev_disposal != 2 || - i < py || i >= py + ph || j < px || j >= px + pw)) + if (prev_frame != NULL && + (prev_disposal != 2 || i < py || i >= py + ph || + j < px || j >= px + pw)) { *ptr = prev_frame[i * sw + j]; } else { @@ -412,8 +413,8 @@ static bool img_load_webp(img_t *img, const fileinfo_t *file) /* Load and decode frames (also works on images with only 1 frame) */ m->length = m->cnt = m->sel = 0; while (WebPAnimDecoderGetNext(dec, &buf, &ts)) { - im = imlib_create_image_using_copied_data( - info.canvas_width, info.canvas_height, (uint32_t *)buf); + im = imlib_create_image_using_copied_data(info.canvas_width, info.canvas_height, + (uint32_t *)buf); imlib_context_set_image(im); imlib_image_set_format("webp"); /* Get an iterator of this frame - used for frame info (duration, etc.) */ diff --git a/main.c b/main.c index 9541b6d..322fd74 100644 --- a/main.c +++ b/main.c @@ -40,15 +40,15 @@ #include #include -#define MODMASK(mask) ((mask) & USED_MODMASK) +#define MODMASK(mask) (USED_MODMASK & (mask)) #define BAR_SEP " " #define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \ ((t1)->tv_usec - (t2)->tv_usec) / 1000) -#define TV_ADD_MSEC(tv,t) { \ +#define TV_ADD_MSEC(tv,t) do { \ (tv)->tv_sec += (t) / 1000; \ (tv)->tv_usec += (t) % 1000 * 1000; \ -} +} while (0) typedef struct { int err; @@ -200,8 +200,8 @@ void remove_file(int n, bool manual) if (n + 1 < filecnt) { if (tns.thumbs != NULL) { - memmove(tns.thumbs + n, tns.thumbs + n + 1, (filecnt - n - 1) * - sizeof(*tns.thumbs)); + memmove(tns.thumbs + n, tns.thumbs + n + 1, + (filecnt - n - 1) * sizeof(*tns.thumbs)); memset(tns.thumbs + filecnt - 1, 0, sizeof(*tns.thumbs)); } memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files)); @@ -377,7 +377,7 @@ void load_image(int new) if (new >= filecnt) new = filecnt - 1; else if (new > 0 && prev) - new--; + new -= 1; } files[new].flags &= ~FF_WARN; fileidx = current = new; @@ -562,8 +562,9 @@ void handle_key_handler(bool init) return; if (init) { close_info(); - snprintf(win.bar.l.buf, win.bar.l.size, "Getting key handler input " - "(%s to abort)...", XKeysymToString(KEYHANDLER_ABORT)); + snprintf(win.bar.l.buf, win.bar.l.size, + "Getting key handler input (%s to abort)...", + XKeysymToString(KEYHANDLER_ABORT)); } else { /* abort */ open_info(); update_info(); @@ -739,8 +740,8 @@ static void run(void) init_thumb = mode == MODE_THUMB && tns.initnext < filecnt; load_thumb = mode == MODE_THUMB && tns.loadnext < tns.end; - if ((init_thumb || load_thumb || to_set || info.fd != -1 || - arl.fd != -1) && XPending(win.env.dpy) == 0) + if ((init_thumb || load_thumb || to_set || info.fd != -1 || arl.fd != -1) && + XPending(win.env.dpy) == 0) { if (load_thumb) { set_timeout(redraw, TO_REDRAW_THUMBS, false); @@ -793,8 +794,8 @@ static void run(void) discard = ev.type == nextev.type; break; case KeyPress: - discard = (nextev.type == KeyPress || nextev.type == KeyRelease) - && ev.xkey.keycode == nextev.xkey.keycode; + discard = (nextev.type == KeyPress || nextev.type == KeyRelease) && + ev.xkey.keycode == nextev.xkey.keycode; break; } } diff --git a/window.c b/window.c index 85ad542..765f67d 100644 --- a/window.c +++ b/window.c @@ -226,8 +226,8 @@ void win_open(win_t *win) if (gmask & YValue) { if (gmask & YNegative) { win->y += e->scrh - win->h; - sizehints.win_gravity = sizehints.win_gravity == NorthEastGravity - ? SouthEastGravity : SouthWestGravity; + sizehints.win_gravity = sizehints.win_gravity == NorthEastGravity ? + SouthEastGravity : SouthWestGravity; } sizehints.flags |= USPosition; } else {