kbgwm

sucklessy floating window manager
git clone https://git.neuralcrash.com/kbgwm.git
Log | Files | Refs | README | LICENSE

commit 27509045622e155f3fa7be97a07e50939a487e3a
parent ac39f5d141b39ee9d8a09c8eb6859d6908bd04e0
Author: Kebigon <git@kebigon.xyz>
Date:   Fri,  3 Jul 2020 07:32:52 +0900

Add basic makefile

Diffstat:
AMakefile | 13+++++++++++++
Rsrc/config.h -> config.h | 0
Akbgwm.c | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsrc/kbgwm.c | 100-------------------------------------------------------------------------------
4 files changed, 113 insertions(+), 100 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,13 @@ +SRC = kbgwm.c +OBJ = kbgwm.o + +CFLAGS+=-g -std=c99 -Wall -Wextra -I/usr/local/include +LDFLAGS+=-L/usr/local/lib -lxcb -lxcb-keysyms + +kbgwm: ${OBJ} + ${CC} ${CFLAGS} ${OBJ} ${LDFLAGS} -o $@ + +kbgwm.o: kbgwm.c config.h + +clean: + rm -f kbgwm ${OBJ} diff --git a/src/config.h b/config.h diff --git a/kbgwm.c b/kbgwm.c @@ -0,0 +1,100 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +#include <xcb/xcb.h> +#include <xcb/xcb_keysyms.h> +#include <X11/keysym.h> + +#define LENGTH(X) (sizeof X / sizeof X[0]) + +typedef struct { + uint16_t modifiers; + xcb_keysym_t key; +} Key; + +#include "config.h" + +bool quit = false; +xcb_connection_t *c; +xcb_window_t root; + +void setupEvents() +{ + /* + * Get all the key symbols + */ + xcb_key_symbols_t *syms = xcb_key_symbols_alloc(c); + + for (int i = 0; i != LENGTH(keys); i++) + { + xcb_keycode_t *keycode = xcb_key_symbols_get_keycode(syms, keys[i].key); + + xcb_grab_key(c, 1, root, keys[i].modifiers, *keycode, + XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); + + free(keycode); + } + + xcb_key_symbols_free(syms); +} + +void eventLoop() +{ + xcb_generic_event_t *event; + + while (!quit) + { + event = xcb_wait_for_event(c); + + switch (event->response_type & ~0x80) + { + } + + free(event); + } +} + +int main(void) +{ + /* + * displayname = NULL -> use DISPLAY environment variable + */ + int screenp; + c = xcb_connect(NULL, &screenp); + if (xcb_connection_has_error(c)) + { + perror("xcb_connect"); + exit(1); + } + + /* + * Find the screen + */ + xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(c)); + for (int i = 0; i < screenp; ++i) + { + xcb_screen_next(&iter); + } + + xcb_screen_t *screen = iter.data; + if (!screen) + { + xcb_disconnect(c); + perror("screen not found"); + exit(1); + } + + root = screen->root; + + xcb_flush(c); + + setupEvents(); + + // Event loop + eventLoop(); + + xcb_disconnect(c); + + return 0; +} diff --git a/src/kbgwm.c b/src/kbgwm.c @@ -1,100 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stdbool.h> - -#include <xcb/xcb.h> -#include <xcb/xcb_keysyms.h> -#include <X11/keysym.h> - -#define LENGTH(X) (sizeof X / sizeof X[0]) - -typedef struct { - uint16_t modifiers; - xcb_keysym_t key; -} Key; - -#include "config.h" - -bool quit = false; -xcb_connection_t *c; -xcb_window_t root; - -void setupEvents() -{ - /* - * Get all the key symbols - */ - xcb_key_symbols_t *syms = xcb_key_symbols_alloc(c); - - for (int i = 0; i != LENGTH(keys); i++) - { - xcb_keycode_t *keycode = xcb_key_symbols_get_keycode(syms, keys[i].key); - - xcb_grab_key(c, 1, root, keys[i].modifiers, keycode, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); - - free(keycode); - } - - xcb_key_symbols_free(syms); -} - -void eventLoop() -{ - xcb_generic_event_t *event; - - while (!quit) - { - event = xcb_wait_for_event(c); - - switch (event->response_type & ~0x80) - { - } - - free(event); - } -} - -int main(void) -{ - /* - * displayname = NULL -> use DISPLAY environment variable - */ - int screenp; - c = xcb_connect(NULL, &screenp); - if (xcb_connection_has_error(c)) - { - perror("xcb_connect"); - exit(1); - } - - /* - * Find the screen - */ - xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(c)); - for (int i = 0; i < screenp; ++i) - { - xcb_screen_next(&iter); - } - - xcb_screen_t *screen = iter.data; - if (!screen) - { - xcb_disconnect(c); - perror("screen not found"); - exit(1); - } - - root = screen->root; - - xcb_flush(c); - - setupEvents(); - - // Event loop - eventLoop(); - - xcb_disconnect(c); - - return 0; -}