From b91d836e96cfc22805386c76534a13b3407a180f Mon Sep 17 00:00:00 2001 From: Tudor Date: Sat, 3 Sep 2016 13:09:19 +0300 Subject: [PATCH] sloppy focus flag in config.h and license-related changes --- .gitignore | 3 +++ BUGS | 1 + LICENSE | 4 ++-- Makefile | 2 +- client.c | 2 ++ common.h | 4 +++- config.h | 3 +++ config.mk | 2 +- ipc.h | 2 ++ list.c | 2 ++ list.h | 2 ++ types.h | 3 +++ wm.c | 9 ++++++++- 13 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 BUGS diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d2eacaf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +windowchef +waitron diff --git a/BUGS b/BUGS new file mode 100644 index 0000000..250d84a --- /dev/null +++ b/BUGS @@ -0,0 +1 @@ +- If compiled with -O2 fullscreen does not work as expected. diff --git a/LICENSE b/LICENSE index c26699e..d2c3029 100644 --- a/LICENSE +++ b/LICENSE @@ -7,9 +7,9 @@ any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT diff --git a/Makefile b/Makefile index aa32ecf..12d8c75 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ NAME_DEFINES = -D__NAME__=\"$(__NAME__)\" \ SRC = list.c wm.c client.c OBJ = $(SRC:.c=.o) BIN = $(__NAME__) $(__NAME_CLIENT__) -CFLAGS += $(NAME_DEFINES) -DD +CFLAGS += $(NAME_DEFINES) all: $(BIN) diff --git a/client.c b/client.c index b21af48..795330b 100644 --- a/client.c +++ b/client.c @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #include #include #include diff --git a/common.h b/common.h index 2d4f7a2..7aa4030 100644 --- a/common.h +++ b/common.h @@ -1,10 +1,12 @@ +/* See the LICENSE file for copyright and license details. */ + #ifndef _COMMON_H #define _COMMON_H #ifdef D #define DMSG(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) #else -#define DMSG +#define DMSG(fmt, ...) #endif #endif diff --git a/config.h b/config.h index 8a76ec3..ec8140d 100644 --- a/config.h +++ b/config.h @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #ifndef _CONFIG_H #define _CONFIG_H @@ -7,5 +9,6 @@ #define GAP 20 #define CURSOR_POSITION CENTER #define GROUPS 4 +#define SLOPPY_FOCUS true #endif diff --git a/config.mk b/config.mk index f338be2..cb84ce3 100644 --- a/config.mk +++ b/config.mk @@ -2,5 +2,5 @@ PREFIX = /usr/local MANPREFIX = /usr/local/share MANDIR = $(MANPREFIX)/man/man1 -CFLAGS += -std=c99 -Wextra -g +CFLAGS += -std=c99 -Wextra LDFLAGS += -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-randr diff --git a/ipc.h b/ipc.h index 775de80..b34ad07 100644 --- a/ipc.h +++ b/ipc.h @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #ifndef _WM_IPC_H #define _WM_IPC_H diff --git a/list.c b/list.c index ab204e7..bfe561a 100644 --- a/list.c +++ b/list.c @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #include #include "list.h" diff --git a/list.h b/list.h index 3a4bda7..cbe06cd 100644 --- a/list.h +++ b/list.h @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #ifndef _LIST_H #define _LIST_H diff --git a/types.h b/types.h index cedeaf2..fc10e31 100644 --- a/types.h +++ b/types.h @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #ifndef _TYPES_H #define _TYPES_H @@ -41,6 +43,7 @@ struct conf { uint32_t focus_color, unfocus_color; enum cursor_position cursor_position; uint32_t groups; + bool sloppy_focus; }; #endif diff --git a/wm.c b/wm.c index 2723afc..f444721 100644 --- a/wm.c +++ b/wm.c @@ -1,3 +1,5 @@ +/* See the LICENSE file for copyright and license details. */ + #include #include #include @@ -218,6 +220,7 @@ setup(void) conf.gap = GAP; conf.cursor_position = CURSOR_POSITION; conf.groups = GROUPS; + conf.sloppy_focus = SLOPPY_FOCUS; group_in_use = malloc(conf.groups * sizeof(bool)); for (uint32_t i = 0; i < conf.groups; i++) @@ -1434,6 +1437,8 @@ event_enter_notify(xcb_generic_event_t *ev) xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *)ev; struct client *client; + if (conf.sloppy_focus == false) + return; if (e->mode == XCB_NOTIFY_MODE_NORMAL || e->mode == XCB_NOTIFY_MODE_UNGRAB) { if (focused_win != NULL && e->event == focused_win->window) @@ -1501,8 +1506,10 @@ event_map_notify(xcb_generic_event_t *ev) xcb_map_notify_event_t *e = (xcb_map_notify_event_t *)ev; struct client *client = find_client(&e->window); - if (client != NULL) + if (client != NULL) { client->mapped = true; + set_focused(client); + } } /*