diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sxwm.c | 46 | ||||
-rw-r--r-- | src/sxwm.h | 6 | ||||
-rw-r--r-- | src/user.config | 6 | ||||
-rw-r--r-- | src/util.h | 4 | ||||
-rw-r--r-- | src/utils.c | 30 |
5 files changed, 55 insertions, 37 deletions
@@ -1,5 +1,36 @@ +/* See LICENSE for more info + + sxwm is a user-friendly, easily configurable yet powerful + tiling window manager inspired by window managers such as + DWM and i3 + + The userconfig is designed to be as user-friendly as + possible, and I hope it is easy to configure even without + knowledge of C or programming, although most people who + will use this will probably be programmers :) + +*/// (C) Abhinav Prasai 2025 + #include "sxwm.h" -#include "util.h" + +static void +otherwm(void) +{ + XSetErrorHandler(otherwmerr); + XChangeWindowAttributes(dpy, root, CWEventMask, + &(XSetWindowAttributes){.event_mask = SubstructureRedirectMask}); + XSync(dpy, False); + XSetErrorHandler(xerr); + XSync(dpy, False); +} + +static int +otherwmerr(Display *dpy, XErrorEvent *ee) +{ + errx(0, "sxwm: another window manager is already running, please close it"); + return 0; + if (dpy && ee) return 0; +} static void run(void) @@ -10,7 +41,7 @@ run(void) } } -void +static void setup(void) { dpy = XOpenDisplay(NULL); @@ -24,6 +55,15 @@ setup(void) ); } +static int +xerr(Display *dpy, XErrorEvent *ee) +{ + fprintf(stderr, "sxwm: fatal error\nrequest code:%d\nerror code:%d", + ee->request_code, ee->error_code); + return 0; + if (dpy && ee) return 0; +} + int main(int ac, char **av) { @@ -33,7 +73,7 @@ main(int ac, char **av) else errx(0, "usage:\n[-v || --version]: See the version of sxwm\n"); } + setup(); run(); - dpy = XOpenDisplay(NULL); return 0; } @@ -1,10 +1,13 @@ #ifndef SXWM_H #define SXWM_H +#include <stdio.h> #include <string.h> #include <err.h> #include <X11/Xlib.h> +#include "user.config" + #define SXWM_VERSION "sxwm ver. 0.1.0" #define SXWM_AUTHOR "(C) Abhinav Prasai 2025" #define SXWM_LICINFO "See LICENSE for more info" @@ -13,8 +16,11 @@ #define SUPER Mod4Mask #define SHIFT ShiftMask +static void otherwm(void); +static int otherwmerr(Display *dpy, XErrorEvent *ee); static void run(void); static void setup(void); +static int xerr(Display *dpy, XErrorEvent *ee); static Display *dpy; static Window root; diff --git a/src/user.config b/src/user.config new file mode 100644 index 0000000..f946501 --- /dev/null +++ b/src/user.config @@ -0,0 +1,6 @@ +#ifndef USER_CONFIG +#define USER_CONFIG + +#define MODCONF Mod1Mask + +#endif @@ -1,8 +1,4 @@ #ifndef UTIL_H #define UTIL_H -#include <X11/Xlib.h> - -void otherwm(void); -int otherwmerr(Display *dpy, XErrorEvent *ee); #endif diff --git a/src/utils.c b/src/utils.c index c99e74c..408a76a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,31 +1 @@ -#include <err.h> -#include <X11/Xlib.h> #include "util.h" - -void -otherwm(void) -{ - XSetErrorHandler(otherwmerr); - XChangeWindowAttributes(dpy, root, CWEventMask, - &(XSetWindowAttributes){.event_mask = SubstructureRedirectMask}); - XSync(dpy, False); - XSetErrorHandler(xerr); - XSync(dpy, False); -} - -int -otherwmerr(Display *dpy, XErrorEvent *ee) -{ - errx(0, "sxwm: another window manager is already running, please close it"); - return 0; - if (dpy && ee) return 0; -} - -int -xerr(Display *dpy, XErrorEvent *ee) -{ - fprintf(stderr, "sxwm: fatal error\nrequest code:%d\nerror code:%d", - ee->request_code, ee->error_code); - return 0; - if (dpy && ee) return 0; -} |