diff options
| author | Fuwn <[email protected]> | 2024-01-23 19:13:47 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-23 19:13:47 -0800 |
| commit | efaf5bdd206e4b8d3d07c5867d1d8c44c37b178d (patch) | |
| tree | 09eb0d1638afb474199cd3331fc15f68623637a7 | |
| parent | docs(readme): recommend zig cc (diff) | |
| download | seiwm-efaf5bdd206e4b8d3d07c5867d1d8c44c37b178d.tar.xz seiwm-efaf5bdd206e4b8d3d07c5867d1d8c44c37b178d.zip | |
ci(ninja): clang format
| -rw-r--r-- | build.ninja | 6 | ||||
| -rw-r--r-- | shiftview.c | 109 | ||||
| -rw-r--r-- | transient.c | 60 | ||||
| -rw-r--r-- | util.c | 38 | ||||
| -rw-r--r-- | util.h | 6 |
5 files changed, 108 insertions, 111 deletions
diff --git a/build.ninja b/build.ninja index e7d920b..14c1d6f 100644 --- a/build.ninja +++ b/build.ninja @@ -27,10 +27,16 @@ rule compile rule link command = ${CC} ${in} -o ${out} ${LDFLAGS} +rule clang_format + command = clang-format -i -style=LLVM ./*.c ./*.h + build _options: _options build _install: _install build _uninstall: _uninstall +build _format: clang_format +build format: phony _format + build options: phony _options pool = console diff --git a/shiftview.c b/shiftview.c index bb43969..7462794 100644 --- a/shiftview.c +++ b/shiftview.c @@ -3,63 +3,58 @@ * @param: "arg->i" stores the number of tags to shift right (positive value) * or left (negative value) */ -void -shiftview(const Arg *arg) -{ - Arg shifted; - Client *c; - unsigned int tagmask = 0; - - for (c = selmon->clients; c; c = c->next) - if (!(c->tags & SPTAGMASK)) - tagmask = tagmask | c->tags; - - shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK; - if (arg->i > 0) /* left circular shift */ - do { - shifted.ui = (shifted.ui << arg->i) - | (shifted.ui >> (LENGTH(tags) - arg->i)); - shifted.ui &= ~SPTAGMASK; - } while (tagmask && !(shifted.ui & tagmask)); - else /* right circular shift */ - do { - shifted.ui = (shifted.ui >> (- arg->i) - | shifted.ui << (LENGTH(tags) + arg->i)); - shifted.ui &= ~SPTAGMASK; - } while (tagmask && !(shifted.ui & tagmask)); - - view(&shifted); +void shiftview(const Arg *arg) { + Arg shifted; + Client *c; + unsigned int tagmask = 0; + + for (c = selmon->clients; c; c = c->next) + if (!(c->tags & SPTAGMASK)) + tagmask = tagmask | c->tags; + + shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK; + if (arg->i > 0) /* left circular shift */ + do { + shifted.ui = + (shifted.ui << arg->i) | (shifted.ui >> (LENGTH(tags) - arg->i)); + shifted.ui &= ~SPTAGMASK; + } while (tagmask && !(shifted.ui & tagmask)); + else /* right circular shift */ + do { + shifted.ui = + (shifted.ui >> (-arg->i) | shifted.ui << (LENGTH(tags) + arg->i)); + shifted.ui &= ~SPTAGMASK; + } while (tagmask && !(shifted.ui & tagmask)); + + view(&shifted); } -void -shifttag(const Arg *arg) -{ - Arg a; - Client *c; - unsigned visible = 0; - int i = arg->i; - int count = 0; - int nextseltags, curseltags = selmon->tagset[selmon->seltags]; - - do { - if(i > 0) // left circular shift - nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i)); - - else // right circular shift - nextseltags = (curseltags >> - i) | (curseltags << (LENGTH(tags) + i)); - - // Check if tag is visible - for (c = selmon->clients; c && !visible; c = c->next) - if (nextseltags & c->tags) { - visible = 1; - break; - } - i += arg->i; - } while (!visible && ++count < 10); - - if (count < 10) { - a.i = nextseltags; - tag(&a); - } +void shifttag(const Arg *arg) { + Arg a; + Client *c; + unsigned visible = 0; + int i = arg->i; + int count = 0; + int nextseltags, curseltags = selmon->tagset[selmon->seltags]; + + do { + if (i > 0) // left circular shift + nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i)); + + else // right circular shift + nextseltags = (curseltags >> -i) | (curseltags << (LENGTH(tags) + i)); + + // Check if tag is visible + for (c = selmon->clients; c && !visible; c = c->next) + if (nextseltags & c->tags) { + visible = 1; + break; + } + i += arg->i; + } while (!visible && ++count < 10); + + if (count < 10) { + a.i = nextseltags; + tag(&a); + } } - diff --git a/transient.c b/transient.c index 040adb5..4e7fc13 100644 --- a/transient.c +++ b/transient.c @@ -1,42 +1,42 @@ /* cc transient.c -o transient -lX11 */ -#include <stdlib.h> -#include <unistd.h> #include <X11/Xlib.h> #include <X11/Xutil.h> +#include <stdlib.h> +#include <unistd.h> int main(void) { - Display *d; - Window r, f, t = None; - XSizeHints h; - XEvent e; + Display *d; + Window r, f, t = None; + XSizeHints h; + XEvent e; - d = XOpenDisplay(NULL); - if (!d) - exit(1); - r = DefaultRootWindow(d); + d = XOpenDisplay(NULL); + if (!d) + exit(1); + r = DefaultRootWindow(d); - f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0); - h.min_width = h.max_width = h.min_height = h.max_height = 400; - h.flags = PMinSize | PMaxSize; - XSetWMNormalHints(d, f, &h); - XStoreName(d, f, "floating"); - XMapWindow(d, f); + f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0); + h.min_width = h.max_width = h.min_height = h.max_height = 400; + h.flags = PMinSize | PMaxSize; + XSetWMNormalHints(d, f, &h); + XStoreName(d, f, "floating"); + XMapWindow(d, f); - XSelectInput(d, f, ExposureMask); - while (1) { - XNextEvent(d, &e); + XSelectInput(d, f, ExposureMask); + while (1) { + XNextEvent(d, &e); - if (t == None) { - sleep(5); - t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0); - XSetTransientForHint(d, t, f); - XStoreName(d, t, "transient"); - XMapWindow(d, t); - XSelectInput(d, t, ExposureMask); - } - } + if (t == None) { + sleep(5); + t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0); + XSetTransientForHint(d, t, f); + XStoreName(d, t, "transient"); + XMapWindow(d, t); + XSelectInput(d, t, ExposureMask); + } + } - XCloseDisplay(d); - exit(0); + XCloseDisplay(d); + exit(0); } @@ -6,31 +6,27 @@ #include "util.h" -void -die(const char *fmt, ...) -{ - va_list ap; +void die(const char *fmt, ...) { + va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); - if (fmt[0] && fmt[strlen(fmt)-1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } + if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } - exit(1); + exit(1); } -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; +void *ecalloc(size_t nmemb, size_t size) { + void *p; - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; } @@ -1,8 +1,8 @@ /* See LICENSE file for copyright and license details. */ -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#define MIN(A, B) ((A) < (B) ? (A) : (B)) -#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) +#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) void die(const char *fmt, ...); void *ecalloc(size_t nmemb, size_t size); |