Compare commits

...

174 Commits
0.1 ... master

Author SHA1 Message Date
Dylan Araps
f4cb48d7af
update 2020-10-21 15:36:42 +03:00
dylan
ccb96521c1
Merge pull request #101 from venam/master
Refresh keyboard mapping uppon MappingNotify event
2020-10-02 13:35:12 +03:00
Patrick Louis
5663175d57 Refresh keyboard mapping uppon MappingNotify event
When dynamically switching between layout the keys that are grabbed need
to also be refreshed. This is a fix similar to venam/2bwm@148d832

fixes dylanaraps#100
2020-10-02 11:35:03 +03:00
dylan
95596f43aa
Merge pull request #93 from Yul3n/master
Added links to the window managers in the thanks
2020-07-08 12:53:20 +03:00
yul3n
e595bfb365
Added links to the window managers in the thanks 2020-07-08 10:12:36 +02:00
dylan
d327a0978a
Merge pull request #89 from zsugabubus/makefile
sowm: fix Makefile dependencies
2020-06-16 12:24:10 +03:00
zsugabubus
0964d47d07
sowm: fix Makefile dependencies
So the binary no longer need to be deleted for a recompilation.
2020-06-16 10:30:13 +02:00
Dylan Araps
6ca1ff91a4
docs: update 2020-05-03 22:14:12 +03:00
Dylan Araps
dabe77272b
sowm: revert normal kill 2020-04-25 10:47:50 +03:00
Dylan Araps
ea47780ab0
sowm: Fix normal kill 2020-04-23 08:40:08 +03:00
Dylan Araps
0ed080b99c
sowm: small fixes 2020-04-23 08:27:13 +03:00
dylan
7e4466e38e
Merge pull request #60 from dylanaraps/kill
sowm: normal window close
2020-04-23 08:21:27 +03:00
Dylan Araps
56bdacaa84
docs: update. Closes #66 and #67 2020-03-30 08:56:41 +03:00
Dylan Araps
e22087856b
sowm: Compress window events after compressing all events. 2020-03-11 22:21:41 +02:00
Dylan Araps
f201a467ea
sowm: Fix linker errors. Closes #61 2020-02-21 18:08:47 +02:00
Dylan Araps
7821aac0d2
sowm: Fix Makefile 2020-02-20 18:41:45 +02:00
Dylan Araps
a1c80d9b23
sowm: Fix Makefile 2020-02-20 18:40:29 +02:00
Dylan Araps
0df345e1da
sowm: Fix compiler warning 2020-02-20 18:37:19 +02:00
Dylan Araps
b5087acaac
docs: update 2020-02-20 18:34:57 +02:00
Dylan Araps
3ed647f467
sowm: simpler kill 2020-02-20 18:02:11 +02:00
Dylan Araps
e491a637fe
sowm: Changes for easier patching 2020-02-20 16:08:47 +02:00
Dylan Araps
21a35be863
Merge branch 'master' of github.com:dylanaraps/sowm 2020-02-20 16:00:23 +02:00
Dylan Araps
5547cc3a51
sowm: Set minimum resize amount. 2020-02-20 15:59:48 +02:00
dylan
67d323458c
Merge pull request #56 from noxgeek/patch-1
Add uninstall to Makefile
2020-02-16 20:02:40 +02:00
noxgeek
0004ff3e18
Add uninstall to Makefile 2020-02-16 18:39:15 +01:00
Dylan Araps
5cc5d25823
Makefile: GNUisms 2020-02-16 13:38:57 +02:00
Dylan Araps
0e8cc9fe86
sowm: Fix errors. Closes #51 2020-01-24 06:40:37 +02:00
Dylan Araps
2c3c353d74
docs: update 2020-01-23 17:03:56 +02:00
Dylan Araps
69f2c71fb7
sowm: proper prototypes 2020-01-23 17:00:26 +02:00
Dylan Araps
a31091472a
docs: update 2020-01-23 16:14:22 +02:00
Dylan Araps
1d249a96ef
sowm: Add header file 2020-01-23 02:54:13 +02:00
Dylan Araps
f558535e19
docs: update 2020-01-23 02:40:13 +02:00
Dylan Araps
243cab5deb
docs: update 2020-01-23 02:39:13 +02:00
Dylan Araps
4f18161758
docs: update 2020-01-23 02:37:32 +02:00
dylan
087e276736
Merge pull request #49 from SeungheonOh/master
Patch: Wheel resize update
2020-01-22 10:57:24 +02:00
Seungheon Oh
c1b252bc6d Patch: Wheel resize update 2020-01-21 15:17:58 -06:00
dylan
4aa7d1a4d6
Merge pull request #48 from SeungheonOh/master
Patch: 2bswm-style fixed
2020-01-21 02:31:16 +02:00
Seungheon Oh
facbfcf061 Patch: 2bswm-style fixed 2020-01-20 13:11:42 -06:00
Dylan Araps
e0d0415d06
Fix keybinds issue. Closes #15.
This is rather verbose and I personally find it disgusting but
it's required to make key bindings behave.

A big thank you to DWM and other window managers for saving me
a crippling headache.

This increases the code an amount doesn't it?
2020-01-20 01:45:57 +02:00
Dylan Araps
ec79ff991a
docs: update 2020-01-17 15:05:24 +02:00
dylan
5675787b03
Merge pull request #46 from SeungheonOh/master
Patch: init windows
2020-01-17 11:23:59 +02:00
Seungheon Oh
e3306e109b Patch: init windows 2020-01-16 15:21:11 -06:00
dylan
893b45b2de
Merge pull request #43 from SeungheonOh/master
Fix: issue #42: Workspaces(Shiftmask) + Scary warnings
2020-01-15 10:01:37 +02:00
Seungheon Oh
1cce61e186 Fix: disabled 'missing-prototypes' warning 2020-01-14 15:28:19 -06:00
Seungheon Oh
66336521ed Fix: Shift mask now being recognized 2020-01-14 15:16:06 -06:00
dylan
85ee7ec48e
Merge pull request #41 from SeungheonOh/master
New Patch: 2bswm style
2020-01-13 06:05:15 +00:00
Seungheon Oh
307001f472 2bswm style 2020-01-12 16:47:23 -06:00
dylan
d9b0c72fc9
Merge pull request #39 from Leon-Plickat/master
Fix #31
2019-12-25 08:53:22 +00:00
Leon Plickat
a199d34a45 Fix #31 2019-12-25 04:57:26 +01:00
dylan
13f874ead7
Merge pull request #38 from AnusReaper/fix-patches
Updated patches to conform with new changes
2019-12-18 12:05:47 +00:00
Dylan Araps
09a514cd5e
sowm: Enable missing prototypes warning and define win_prev. 2019-12-18 11:41:21 +00:00
Dylan Araps
8ee3294adf Merge branch 'master' of github.com:dylanaraps/sowm 2019-12-18 11:30:21 +00:00
AnusReaper
bac7f781b6 Updated patches 2019-12-18 10:26:45 +00:00
dylan
623f4d8bc1
Merge pull request #36 from kiedtl/patch-1
add win_prev() function for focusing previous window
2019-12-16 09:49:36 +00:00
Kiëd Llaentenn
dcaf873fec
add win_prev() 2019-12-15 18:53:52 -05:00
dylan
aaabcb8049
Merge pull request #34 from SeungheonOh/master
README.md: Instruction for applying multiple patches/Patch: Wheel for window resizing.
2019-12-15 09:26:46 +00:00
Seungheon Oh
3efaa6decc Patch: Bug fix 2019-12-14 23:16:33 -06:00
Seungheon Oh
1d37651391 Patch: Wheel for resizing window 2019-12-14 22:41:15 -06:00
Seungheon Oh
62959ded52 README.md: Instruction for applying multiple patches 2019-12-14 21:58:12 -06:00
dylan
5423c9172b
Merge pull request #32 from SeungheonOh/master
New Patch: Rectangular style window launcher/mover + README.md
2019-12-14 09:32:37 +00:00
Seungheon Oh
8acd15de63 README.md: Installation 4th step for applying patch 2019-12-14 02:00:37 -06:00
Seungheon Oh
f7fd37e326 Patch: Rectangle style window launcher/mover 2019-12-14 01:56:48 -06:00
dylan
6d6889e3cf
Merge pull request #30 from Leon-Plickat/master
Add handlebar patch
2019-11-28 02:17:01 +02:00
Leon Plickat
8ff3eee874 Style 2019-11-28 00:47:39 +01:00
Leon Plickat
0b7a277b22 Add handlebar patch 2019-11-27 13:53:12 +01:00
Dylan Araps
124ec67579
Merge branch 'master' of github.com:dylanaraps/sowm 2019-11-25 23:12:21 +00:00
Dylan Araps
93135664c2
sowm: Another possible fix for key bug 2019-11-25 23:12:05 +00:00
dylan
3e4010a0ca
Merge pull request #28 from Leon-Plickat/master
Add patch which provides primitive multimonitor functionality
2019-11-25 19:01:50 +02:00
Leon Plickat
6b12178131 Double bug fix
Fixes bug where loop would continue even after window is configured.
Fixes bug where the window origins instead of window center is the
relevant coordinates for determining on which monitor a window is
displayed.
2019-11-25 17:54:27 +01:00
Leon Plickat
9a634e6134 Style 2019-11-25 17:20:49 +01:00
Dylan Araps
275488384a
sowm: Run CI on pull requests 2019-11-25 14:50:51 +00:00
Dylan Araps
9a206d6c9d
sowm: Test patches in CI. 2019-11-25 14:36:48 +00:00
Dylan Araps
51a96547ef
sowm: Test patches in CI. 2019-11-25 14:35:50 +00:00
Dylan Araps
1fb75817aa
sowm: prevent fullscreen windows from being moved or resized. 2019-11-25 14:30:34 +00:00
Dylan Araps
df34385548
sowm: revert key change 2019-11-25 14:30:00 +00:00
Leon Plickat
c6ff8d06a0 Simplify multimonitor_center_fs() 2019-11-25 13:52:55 +01:00
Leon Plickat
4dd50e6f4f Remove coords_in_box() 2019-11-25 13:47:20 +01:00
Leon Plickat
4867928d57 Monitor iterating now in its own function 2019-11-25 13:37:04 +01:00
Leon Plickat
afa8b1871f Make number_of_monitors global 2019-11-25 13:22:44 +01:00
Leon Plickat
216e462841 Simply coords_in_box() 2019-11-25 13:12:06 +01:00
Leon Plickat
425ae0f698 Style
Whitespace
2019-11-25 13:02:21 +01:00
Leon Plickat
8f1b7c28df Remove dependency on stdbool.h 2019-11-25 09:50:53 +01:00
Leon Plickat
818480983f Check center of window instead of origin.
Checking on what monitor the center of a window is, is more intuitive.
2019-11-25 04:58:46 +01:00
Leon Plickat
b7b08941d5 Add patch which provides primitive multimonitor functionality
With this patch, center and fullscreen will work as expected when using
multiple outputs.
2019-11-24 22:39:47 +01:00
Dylan Araps
d37d04ef32 Merge branch 'master' of github.com:dylanaraps/sowm 2019-11-24 14:24:28 +00:00
Dylan Araps
2292f86d7f
sowm: potential fix for key bug 2019-11-24 14:24:13 +00:00
dylan
31bf57b69a
Merge pull request #24 from eti0/patch-1
fix EWMH typo
2019-11-14 17:45:28 +02:00
eti
d79361b13e
fix EWMH typo 2019-11-14 16:11:30 +01:00
dylan
7921a93eef
Merge pull request #23 from tjtf2/master
update tj's tags patch
2019-11-09 22:51:43 +02:00
Timothy Joseph
a5853ab69a update tj's patch 2019-11-09 22:45:52 +02:00
Dylan Araps
e4965417f7
patches: rebase kill patch 2019-10-28 21:55:17 +00:00
Dylan Araps
bc9a9b14a5
patches: rebase rounded corners 2019-10-28 21:52:28 +00:00
Dylan Araps
421f79c47b
sowm: rebase rounded corners 2019-10-25 22:42:26 +03:00
Dylan Araps
cb03ac9664
sowm: revert ungrab key change 2019-10-25 22:37:47 +03:00
Dylan Araps
5b012c10be
sowm: attempt to fix key issue 2019-10-25 02:23:19 +03:00
Dylan Araps
35b12c7969
sowm: swap to new keycode to keysym func 2019-10-24 23:33:41 +03:00
Dylan Araps
e9df9ac570
docs: update 2019-10-20 23:39:12 +03:00
Dylan Araps
f14acc3b68 Merge branch 'master' of github.com:dylanaraps/sowm 2019-10-20 23:39:05 +03:00
Dylan Araps
117b04d4a6
sowm: fix workspace issue 2019-10-20 23:34:29 +03:00
dylan
0d4af0e4fa
Merge pull request #14 from tjtf2/master
patches: added tj's tags patch
2019-10-20 14:09:17 +00:00
Timothy Joseph
43c7194066 patches: added tj's patch 2019-10-20 15:18:46 +03:00
Dylan Araps
144c153844
sowm: check mod first. 2019-10-19 23:29:21 +03:00
Dylan Araps
2d1e5c2654
sowm: clean up 2019-10-19 17:23:26 +03:00
Dylan Araps
d70ecee07d
sowm: clean up 2019-10-19 13:40:28 +03:00
Dylan Araps
fa3c276ce6
sowm: remove now pointless checks 2019-10-19 13:24:17 +03:00
Dylan Araps
7316c149b8
sowm: use Window for window and not int 2019-10-19 10:55:21 +03:00
Dylan Araps
589bb768d9
sowm: fix current 2019-10-19 10:27:18 +03:00
Dylan Araps
84119dd331
sowm: simpler button release 2019-10-19 08:17:17 +03:00
Dylan Araps
5c075a359a
sowm: simpler center 2019-10-19 08:14:03 +03:00
Dylan Araps
b48c9b6add
sowm: remove root global 2019-10-19 07:49:26 +03:00
Dylan Araps
a4293a63a7
sowm: send client to focus func directly 2019-10-19 00:54:06 +03:00
Dylan Araps
e60a3bcb30
docs: update 2019-10-19 00:31:21 +03:00
Dylan Araps
4ed0c0919f
sowm: track current window 2019-10-19 00:30:59 +03:00
Dylan Araps
d6b7a98586
docs: update 2019-10-19 00:18:27 +03:00
Dylan Araps
3f66256197
sowm: simpler alt tab 2019-10-19 00:18:03 +03:00
Dylan Araps
7fe47aefc1
sowm: swap to circular doubly linked list 2019-10-19 00:16:19 +03:00
Dylan Araps
0fa485eb7b
docs: update 2019-10-18 20:12:59 +03:00
Dylan Araps
d1e8ee5e67
sowm: more broken (for now) 2019-10-18 19:55:26 +03:00
Dylan Araps
ef61316b5f
sowm: we circular now (we also a little broken too) 2019-10-18 17:40:04 +03:00
Dylan Araps
116ebcfc74
docs: update 2019-10-18 13:55:50 +03:00
Dylan Araps
493302d38b
sowm: simpler window add 2019-10-18 13:45:02 +03:00
Dylan Araps
f10cec8509
sowm: formatting 2019-10-18 13:05:25 +03:00
Dylan Araps
02b10e8585
sowm: track current client to simplify linked list implementation. 2019-10-18 12:43:09 +03:00
Dylan Araps
8917b6ddb2
sowm: revert oops 2019-10-18 12:32:36 +03:00
Dylan Araps
522defba1e
sowm: simpler del 2019-10-18 12:05:13 +03:00
Dylan Araps
e0bd38091a
sowm: fix crashes with cur 2019-10-18 11:42:57 +03:00
Dylan Araps
68257b329d
sowm: track current window 2019-10-18 11:31:28 +03:00
Dylan Araps
009f1cd017
sowm: clean up 2019-10-17 21:12:41 +03:00
Dylan Araps
b0a8d244e0
patches: rebase 2019-10-17 19:48:23 +03:00
Dylan Araps
cd03f2e3d1
patches: optimize rounded corners further. 2019-10-17 19:47:34 +03:00
Dylan Araps
9353c2be35
patches: rebase 2019-10-17 19:43:06 +03:00
Dylan Araps
cada809f65
sowm: use simpler structure for storing workspaces. 2019-10-17 18:45:47 +03:00
Dylan Araps
0ae4e7918f
sowm: move tiny tiny functions to macros. 2019-10-17 18:10:22 +03:00
Dylan Araps
1248c93bcd
sowm: clean up 2019-10-17 17:02:42 +03:00
Dylan Araps
ec1f32020e
sowm: removed comments for now. Will be added back in a better format. 2019-10-17 15:44:49 +03:00
Dylan Araps
f098fde9cd
sowm: Shorter math for window centering. 2019-10-17 15:41:19 +03:00
Dylan Araps
518bb08dc0
sowm: None is just 0 and it's shorter 2019-10-17 15:11:14 +03:00
Dylan Araps
7a995a4970
sowm: skip setting unneeded variables. 2019-10-17 14:28:17 +03:00
Dylan Araps
c4d0b2ee8c
sowm: clean up 2019-10-17 14:24:33 +03:00
Dylan Araps
ce819bd126
sowm: subscribe to even less events 2019-10-17 13:43:05 +03:00
Dylan Araps
fa90c629df
docs: update 2019-10-17 13:22:28 +03:00
Dylan Araps
fa5526c842
sowm: Don't force window location when the window wants to be put elsewhere. 2019-10-17 11:26:31 +03:00
Dylan Araps
c1f3193b0f Merge branch 'master' of github.com:dylanaraps/sowm 2019-10-17 09:40:41 +03:00
Dylan Araps
3662ca427d
sowm: turns out we can't pass 0 as an error handler. :P 2019-10-17 09:40:24 +03:00
Dylan Araps
fdcf245866
docs: update 2019-10-17 09:16:32 +03:00
Dylan Araps
60d88980fb
sowm: subscribe to less window events! 2019-10-17 09:16:22 +03:00
Dylan Araps
4af0d54147
sowm: remove unneeded function 2019-10-17 09:03:03 +03:00
Dylan Araps
8e3c9da820
sowm: Remove unneeded call to ws_go on start 2019-10-17 08:53:59 +03:00
Dylan Araps
de4a08ace0
sowm: avoid branch and variable. 2019-10-17 08:39:40 +03:00
Dylan Araps
669ca21407
sowm: simpler window geometry 2019-10-16 17:25:40 +03:00
Dylan Araps
a5503f8159
sowm: avoid global and remove uneeded initial value. 2019-10-16 15:50:10 +03:00
Dylan Araps
42e126009f
sowm: void unneeded variable 2019-10-16 15:46:09 +03:00
Dylan Araps
72a0f32dd4
docs: update 2019-10-16 15:22:28 +03:00
Dylan Araps
fa96cc7b18
sowm: reduce scope of client 2019-10-16 14:15:34 +03:00
Dylan Araps
f36c78d9bb
sowm: move two overly simple functions to macros. 2019-10-16 13:21:36 +03:00
Dylan Araps
d6de000725
docs: update 2019-10-16 12:50:18 +03:00
Dylan Araps
2c17908a78
docs: update 2019-10-16 11:50:38 +03:00
Dylan Araps
5161ad72f8
docs: update 2019-10-16 11:45:27 +03:00
Dylan Araps
43025432ac
sowm: intialize cursor buttons using loop to remove duplicate code 2019-10-16 11:44:59 +03:00
Dylan Araps
8bdffcacda
docs: update 2019-10-16 09:19:56 +03:00
Dylan Araps
446ad2e02c
sowm: Use modifier from config for mouse controls. 2019-10-16 09:17:46 +03:00
Dylan Araps
19e3078aea
docs: update 2019-10-16 09:16:11 +03:00
Dylan Araps
41ad0ff832
patches: rebase 2019-10-16 08:32:46 +03:00
Dylan Araps
abb9445bfb
patches: rebase 2019-10-16 08:31:27 +03:00
Dylan Araps
2928148534
patches: rebase 2019-10-16 08:29:58 +03:00
Dylan Araps
f19fd045a8
sowm: resize optimization 2019-10-15 23:44:04 +03:00
Dylan Araps
d271e266e6
patches: Added normal kill. 2019-10-15 20:03:50 +03:00
Dylan Araps
cd37b0ad39
patches: Added normal kill. 2019-10-15 20:01:41 +03:00
Dylan Araps
69499117c2
patches: rebase 2019-10-15 19:50:26 +03:00
Dylan Araps
1866f5ff02
patches: rebase 2019-10-15 19:49:30 +03:00
Dylan Araps
70dda04916
patches: rebase 2019-10-15 19:48:44 +03:00
Dylan Araps
5668ad1259
sowm: fixed all compiler warnings. 2019-10-15 19:45:24 +03:00
Dylan Araps
c4e64e27b7
docs: update 2019-10-15 17:33:40 +03:00
Dylan Araps
a20543402c
sowm: provide config.def.h instead 2019-10-15 17:12:10 +03:00
7 changed files with 254 additions and 585 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
sowm
sowm.o
config.h

View File

@ -1,18 +1,24 @@
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
LDADD+= -lX11
LDFLAGS=
PREFIX?= /usr
BINDIR?= $(PREFIX)/bin
CC ?= gcc
CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wold-style-declaration
CFLAGS += -Wmissing-prototypes -Wno-unused-parameter
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
CC ?= gcc
all: sowm
sowm: sowm.o
$(CC) $(LDFLAGS) -Os -o $@ $+ $(LDADD)
config.h:
cp config.def.h config.h
sowm: sowm.c sowm.h config.h Makefile
$(CC) -O3 $(CFLAGS) -o $@ $< -lX11 $(LDFLAGS)
install: all
install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
uninstall:
rm -f $(DESTDIR)$(BINDIR)/sowm
clean:
rm -f sowm *.o
.PHONY: all install uninstall clean

View File

@ -1,29 +1,31 @@
# sowm
# sowm (*~~Simple~~ Shitty Opinionated Window Manager*)
<a href="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687576-9747c200-ec72-11e9-947d-5b96753eab03.jpg" width="43%" align="right"></a>
An itsy bitsy floating window manager (*270~ sloc / 24kb compiled!*).
An itsy bitsy floating window manager (*220~ sloc!*).
- Floating only.
- Fullscreen toggle.
- Window centering.
- Mix of mouse and keyboard workflow.
- Focus with cursor.
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm/blob/master/patches/sowm-rounded-corners.patch)*)
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm/pull/58)*)
- Titlebars (*[through patch](https://github.com/dylanaraps/sowm/pull/57)*)
<a href="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg" width="43%" align="right"></a>
- Alt-Tab window focusing.
- All windows die on exit.
- No borders.
- No bar support.
- No ICCCM.
- No EMWH.
- No window borders.
- [No ICCCM](https://web.archive.org/web/20190617214524/https://raw.githubusercontent.com/kfish/xsel/1a1c5edf0dc129055f7764c666da2dd468df6016/rant.txt).
- No EWMH.
- etc etc etc
<br>
Patches available here: https://github.com/dylanaraps/sowm/pulls
## Default Keybindings
**Window Management**
@ -36,8 +38,8 @@ An itsy bitsy floating window manager (*270~ sloc / 24kb compiled!*).
| `MOD4` + `f` | maximize toggle |
| `MOD4` + `c` | center window |
| `MOD4` + `q` | kill window |
| `MOD4` + `1-9` | desktop swap |
| `MOD4` + `Shift` +`1-9` | send window to desktop |
| `MOD4` + `1-6` | desktop swap |
| `MOD4` + `Shift` +`1-6` | send window to desktop |
| `MOD1` + `TAB` (*alt-tab*) | focus cycle |
**Programs**
@ -62,22 +64,35 @@ An itsy bitsy floating window manager (*270~ sloc / 24kb compiled!*).
## Installation
1) Modify `config.h` to suit your needs.
1) Copy `config.def.h` to `config.h` and modify it to suit your needs.
2) Run `make` to build `sowm`.
3) Copy it to your path or run `make install`.
- `DESTDIR` and `PREFIX` are supported.
4) (Optional) Apply patch with `git apply patches/patch-name`
- In case of applying multiple patches, it has to be done **manually**.
If you are using GDM, save the following to `/usr/share/xsessions/sowm.desktop`. It is still recommended to start `sowm` from `.xinitrc` or through
[your own xinit implementation](https://github.com/dylanaraps/bin/blob/dfd9a9ff4555efb1cc966f8473339f37d13698ba/x).
```
[Desktop Entry]
Name=sowm
Comment=This session runs sowm as desktop manager
Exec=sowm
Type=Application
```
## Thanks
- 2bwm
- SmallWM
- berry
- catwm
- dminiwm
- dwm
- monsterwm
- openbox
- possumwm
- swm
- tinywm
- [2bwm](https://github.com/venam/2bwm)
- [SmallWM](https://github.com/adamnew123456/SmallWM)
- [berry](https://github.com/JLErvin/berry)
- [catwm](https://github.com/pyknite/catwm)
- [dminiwm](https://github.com/moetunes/dminiwm)
- [dwm](https://dwm.suckless.org)
- [monsterwm](https://github.com/c00kiemon5ter/monsterwm)
- [openbox](https://github.com/danakj/openbox)
- [possum-wm](https://github.com/duckinator/possum-wm)
- [swm](https://github.com/dcat/swm)
- [tinywm](http://incise.org/tinywm.html)

View File

@ -15,9 +15,11 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
static struct key keys[] = {
{MOD, XK_q, win_kill, {0}},
{MOD, XK_c, win_center, {.i = 0}},
{MOD, XK_c, win_center, {0}},
{MOD, XK_f, win_fs, {0}},
{Mod1Mask, XK_Tab, win_next, {0}},
{Mod1Mask, XK_Tab, win_next, {0}},
{Mod1Mask|ShiftMask, XK_Tab, win_prev, {0}},
{MOD, XK_d, run, {.com = menu}},
{MOD, XK_w, run, {.com = colors}},

View File

@ -1,119 +0,0 @@
diff --git a/Makefile b/Makefile
index 2549d3a..04c2222 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
-LDADD+= -lX11
+LDADD+= -lX11 -lXext
LDFLAGS=
PREFIX?= /usr
BINDIR?= $(PREFIX)/bin
diff --git a/config.h b/config.h
index 864c9a7..1525894 100644
--- a/config.h
+++ b/config.h
@@ -2,6 +2,7 @@
#define CONFIG_H
#define MOD Mod4Mask
+#define ROUND_CORNERS 20
const char* menu[] = {"dmenu_run", 0};
const char* term[] = {"st", 0};
diff --git a/sowm.c b/sowm.c
index b9e8867..4c0b3fa 100644
--- a/sowm.c
+++ b/sowm.c
@@ -3,6 +3,7 @@
#include <X11/Xlib.h>
#include <X11/XF86keysym.h>
#include <X11/keysym.h>
+#include <X11/extensions/shape.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
@@ -59,6 +59,7 @@ static void win_del(Window w);
static void win_fs();
static void win_kill();
static void win_next();
+static void win_round_corners(Window w, int rad);
static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
static void ws_save(int i);
@@ -183,6 +185,8 @@ void notify_motion(XEvent *e) {
attr.width + (mouse.button==3 ? xd : 0),
attr.height + (mouse.button==3 ? yd : 0));
+ win_round_corners(mouse.subwindow, ROUND_CORNERS);
+
for WIN if (c->w == mouse.subwindow) c->f = 0;
}
}
@@ -367,9 +367,58 @@ void win_fs() {
} else
XMoveResizeWindow(d, cur, c->a.x, c->a.y, c->a.width, c->a.height);
+
+ win_round_corners(cur, c->f ? 0 : ROUND_CORNERS);
}
}
+/*
+ Round the corners of the desired window.
+
+ This isn't included in the actual source as it
+ requires the 'shape' extension to Xorg and I'd
+ like to keep the original source simple.
+
+ This is very similar to the rounded corners
+ implementations in the 'dwm' and 'openbox'
+ patches.
+*/
+void win_round_corners(Window w, int rad) {
+ XWindowAttributes attr2;
+ XGetWindowAttributes(d, w, &attr2);
+
+ int dia = 2 * rad;
+ int ww = attr2.width;
+ int wh = attr2.height;
+
+ if (ww < dia || wh < dia) return;
+
+ Pixmap mask = XCreatePixmap(d, w, ww, wh, 1);
+
+ if (!mask) return;
+
+ XGCValues xgcv;
+ GC shape_gc = XCreateGC(d, mask, 0, &xgcv);
+
+ if (!shape_gc) {
+ XFreePixmap(d, mask);
+ return;
+ }
+
+ XSetForeground(d, shape_gc, 0);
+ XFillRectangle(d, mask, shape_gc, 0, 0, ww, wh);
+ XSetForeground(d, shape_gc, 1);
+ XFillArc(d, mask, shape_gc, 0, 0, dia, dia, 0, 23040);
+ XFillArc(d, mask, shape_gc, ww-dia-1, 0, dia, dia, 0, 23040);
+ XFillArc(d, mask, shape_gc, 0, wh-dia-1, dia, dia, 0, 23040);
+ XFillArc(d, mask, shape_gc, ww-dia-1, wh-dia-1, dia, dia, 0, 23040);
+ XFillRectangle(d, mask, shape_gc, rad, 0, ww-dia, wh);
+ XFillRectangle(d, mask, shape_gc, 0, rad, ww, wh-dia);
+ XShapeCombineMask(d, w, ShapeBounding, 0, 0, mask, ShapeSet);
+ XFreePixmap(d, mask);
+ XFreeGC(d, shape_gc);
+ }
+
/*
This function simply moves the focused window to
the desired desktop.
@@ -510,6 +510,7 @@ void map_request(XEvent *e) {
EnterWindowMask|FocusChangeMask);
win_center((Arg){.i = w});
XMapWindow(d, w);
+ win_round_corners(w, ROUND_CORNERS);
FOC(w);
win_add(w);
}

570
sowm.c
View File

@ -3,439 +3,180 @@
#include <X11/Xlib.h>
#include <X11/XF86keysym.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
/*
This iterates over the current desktop's
window list and is inserted where needed.
*/
#define WIN (c=list;c;c=c->next)
#include "sowm.h"
/*
This sets focus to the given window. It
could very well be a function but I feel
it belongs here.
*/
#define FOC(W) XSetInputFocus(d, W, RevertToParent, CurrentTime);
static client *list = {0}, *ws_list[10] = {0}, *cur;
static int ws = 1, sw, sh, wx, wy, numlock = 0;
static unsigned int ww, wh;
typedef union {
const char** com;
const int i;
} Arg;
static Display *d;
static XButtonEvent mouse;
static Window root;
struct key {
unsigned int mod;
KeySym keysym;
void (*function)(const Arg arg);
const Arg arg;
};
typedef struct client client;
struct client{
client *next, *prev;
Window w;
XWindowAttributes a;
int f;
};
typedef struct desktop desktop;
struct desktop{client *list;};
static void button_press(XEvent *e);
static void button_release();
static void configure_request(XEvent *e);
static void key_grab();
static void key_press(XEvent *e);
static void map_request(XEvent *e);
static void notify_destroy(XEvent *e);
static void notify_enter(XEvent *e);
static void notify_motion(XEvent *e);
static void run(const Arg arg);
static void win_add(Window w);
static void win_center(const Arg arg);
static void win_del(Window w);
static void win_fs();
static void win_kill();
static void win_next();
static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
static void ws_save(int i);
static void ws_sel(int i);
static client *list = {0};
static desktop ws_list[10];
static int ws = 1, sh, sw, s, j;
static Display *d;
static Window root, cur;
static XButtonEvent mouse;
static XWindowAttributes attr;
#include "config.h"
/*
The list of events to subscribe to and the paired functions
to call on an event.
*/
static void (*events[LASTEvent])(XEvent *e) = {
[ButtonPress] = button_press,
[ButtonRelease] = button_release,
[ConfigureRequest] = configure_request,
[KeyPress] = key_press,
[MapRequest] = map_request,
[MappingNotify] = mapping_notify,
[DestroyNotify] = notify_destroy,
[EnterNotify] = notify_enter,
[MotionNotify] = notify_motion
};
/*
'sowm' doesn't keep track of the currently focused window
and instead grabs window under the cursor when needed.
#include "config.h"
This is a super lazy way of handling current focus, however
it aligns perfectly with mouse-follows-focus.
Logic below will select a real window if this function
returns the 'root' window.
This function returns the current window while at the same
time defining a global variable to contain its value. This
allows for stupidily simple usage.
Example: if (win_current() != root) XKillClient(d, cur);
The value can be used as function output and then
the same value can be used as a variable directly afterwards.
*/
Window win_current() {
XGetInputFocus(d, &cur, &j);
return cur;
void win_focus(client *c) {
cur = c;
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
}
/*
When a window is destroyed it is first removed from the
current desktop's window list and finally focus is shifted.
Focus goes to the window under the cursor if it is *not*
the root window. If it is the root window, focus goes to
the first window in the desktop.
*/
void notify_destroy(XEvent *e) {
win_del(e->xdestroywindow.window);
if (list) FOC(win_current() == root ? list->w : cur);
if (list) win_focus(list->prev);
}
/*
When the mouse enters or leaves a window this function
handles which window shall be focused next.
The while loop firstly compresses all 'EnterNotify'
events down to only the latest which is an optimization
when focus changes very quickly (e.g a desktop focus).
There's no use in computing each and every event as we
only really care about the newest one.
Focus is only then changed if the mouse has entered a
window which is *not* the root window.
*/
void notify_enter(XEvent *e) {
while(XCheckTypedEvent(d, EnterNotify, e));
if (e->xcrossing.window != root) FOC(e->xcrossing.window)
for win if (c->w == e->xcrossing.window) win_focus(c);
}
/*
When the mouse is moved and the paired modifier is
pressed this function handles a window move or a window
resize.
'mouse' is defined on a modifier+mouse press and then
discarded on a modifier+mouse release.
The while loop firstly compresses all 'MotionNotify'
events down to only the latest which is an optimization
when motion happens very quickly.
There's no use in computing each and every event as we
only really care about the newest one.
The window is then moved or resized and finally its
fullscreen value is reset to '0' (False).
*/
void notify_motion(XEvent *e) {
client *c;
if (!mouse.subwindow || cur->f) return;
if (mouse.subwindow != None) {
int xd = e->xbutton.x_root - mouse.x_root;
int yd = e->xbutton.y_root - mouse.y_root;
while(XCheckTypedEvent(d, MotionNotify, e));
while(XCheckTypedEvent(d, MotionNotify, e));
int xd = e->xbutton.x_root - mouse.x_root;
int yd = e->xbutton.y_root - mouse.y_root;
XMoveResizeWindow(d, mouse.subwindow,
attr.x + (mouse.button==1 ? xd : 0),
attr.y + (mouse.button==1 ? yd : 0),
attr.width + (mouse.button==3 ? xd : 0),
attr.height + (mouse.button==3 ? yd : 0));
for WIN if (c->w == mouse.subwindow) c->f = 0;
}
XMoveResizeWindow(d, mouse.subwindow,
wx + (mouse.button == 1 ? xd : 0),
wy + (mouse.button == 1 ? yd : 0),
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
}
/*
This function initializes all key bindings defined in 'config.h'.
Simple stuff, nothing fancy or different from other window
managers happens here.
*/
void key_grab() {
KeyCode code;
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
XGrabKey(d, code, keys[i].mod, root,
True, GrabModeAsync, GrabModeAsync);
}
/*
This function fires on a key press and checks to see if there
is a matching and defined key binding. If there is a match the
function bound to the key is executed.
The deprecated 'XKeycodeToKeysym' is used as the replacement
requires an additional include and I want to keep them to a
minimum.
I highly doubt this deprecated function goes away any time soon
and worst case, I simply update this code. Win-win.
*/
void key_press(XEvent *e) {
KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0);
KeySym keysym = XkbKeycodeToKeysym(d, e->xkey.keycode, 0, 0);
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state)
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if (keys[i].keysym == keysym &&
mod_clean(keys[i].mod) == mod_clean(e->xkey.state))
keys[i].function(keys[i].arg);
}
/*
On a mouse button press the window below the cursor's
attributes are stored, the window is raised and the 'mouse'
global is set.
Setting the 'mouse' global tells the motion handling function
that it should operate on the window as the user desires a move
or resize.
*/
void button_press(XEvent *e) {
if (e->xbutton.subwindow == None) return;
if (!e->xbutton.subwindow) return;
XGetWindowAttributes(d, e->xbutton.subwindow, &attr);
win_size(e->xbutton.subwindow, &wx, &wy, &ww, &wh);
XRaiseWindow(d, e->xbutton.subwindow);
mouse = e->xbutton;
}
/*
On a mouse button release we simply unset the 'mouse' global
as all of this mouse pointer nonsense is done.
*/
void button_release() {
mouse.subwindow = None;
void button_release(XEvent *e) {
mouse.subwindow = 0;
}
/*
This function is called whenever a window is mapped to the
screen or moved to another desktop.
Memory is allocated for the new window and the current
desktop's window list is updated.
*/
void win_add(Window w) {
client *c, *t;
client *c;
if (!(c = (client *)calloc(1, sizeof(client))))
if (!(c = (client *) calloc(1, sizeof(client))))
exit(1);
if (!list) {
c->next = 0;
c->prev = 0;
c->w = w;
list = c;
c->w = w;
if (list) {
list->prev->next = c;
c->prev = list->prev;
list->prev = c;
c->next = list;
} else {
for (t=list;t->next;t=t->next);
c->next = 0;
c->prev = t;
c->w = w;
t->next = c;
list = c;
list->prev = list->next = list;
}
ws_save(ws);
}
/*
This function is called whenever a window is destoyed
or moved to another desktop.
Memory is freed and the current desktop's window list
is updated.
*/
void win_del(Window w) {
client *c;
client *x = 0;
for WIN if (c->w == w) {
if (!c->prev && !c->next) {
free(list);
list = 0;
ws_save(ws);
return;
}
for win if (c->w == w) x = c;
if (!c->prev) {
list = c->next;
c->next->prev = 0;
if (!list || !x) return;
if (x->prev == x) list = 0;
if (list == x) list = x->next;
if (x->next) x->next->prev = x->prev;
if (x->prev) x->prev->next = x->next;
} else if (!c->next) {
c->prev->next = 0;
} else {
c->prev->next = c->next;
c->next->prev = c->prev;
}
free(c);
ws_save(ws);
return;
}
free(x);
ws_save(ws);
}
/*
This function is called from a key binding to
close the currently focused window.
This differs from other window managers as we skip
the questions and go straight to the killing of
the window.
When I want to close a window I'm not asking, I
want the window closed and so it should immediately
close.
"Shoot first and don't ask questions later?.."
*/
void win_kill() {
if (win_current() != root) XKillClient(d, cur);
void win_kill(const Arg arg) {
if (cur) XKillClient(d, cur->w);
}
/*
This function simply centers the window passed as
an argument. If the argument is '0', use the
currently focused window.
*/
void win_center(const Arg arg) {
Window w = arg.i ? arg.i : win_current();
if (!cur) return;
XGetWindowAttributes(d, w, &attr);
XMoveWindow(d, w, sw / 2 - attr.width / 2,
sh / 2 - attr.height / 2);
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
}
/*
This function toggles the fullscreen state for the
window passed as an argument.
void win_fs(const Arg arg) {
if (!cur) return;
The window's data stucture holds an integer which
is set to '0' for False and '1' for True.
if ((cur->f = cur->f ? 0 : 1)) {
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
When a window is set to fullscreen it is simply
resized to fit the screen and the prior size and
positioning is stored so it can be restored when
the window is un-fullscreened.
*/
void win_fs() {
client *c;
win_current();
for WIN if (c->w == cur) {
if ((c->f = c->f == 0 ? 1 : 0)) {
XGetWindowAttributes(d, cur, &c->a);
XMoveResizeWindow(d, cur, 0, 0, sw, sh);
} else
XMoveResizeWindow(d, cur, c->a.x, c->a.y, c->a.width, c->a.height);
} else {
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
}
}
/*
This function simply moves the focused window to
the desired desktop.
It firstly adds the window to the destination
desktop's window list and secondly deletes it
from the current desktop's window list.
The window is then unmapped from the screen and
the focus is shifted to the first window in the
list.
*/
void win_to_ws(const Arg arg) {
int tmp = ws;
win_current();
if (arg.i == tmp) return;
ws_sel(arg.i);
win_add(cur);
win_add(cur->w);
ws_save(arg.i);
ws_sel(tmp);
win_del(cur);
XUnmapWindow(d, cur);
win_del(cur->w);
XUnmapWindow(d, cur->w);
ws_save(tmp);
if (list) FOC(list->w);
if (list) win_focus(list);
}
/*
This function focuses the next window in the
current desktop's window list.
void win_prev(const Arg arg) {
if (!cur) return;
If the end of the window list is reached it
wraps back around to the start of the list.
The newly focused window is then raised to
the top of the stack.
*/
void win_next() {
win_current();
client *c;
if (list) {
for WIN if (c->w == cur) break;
c = c->next ? c->next : list;
FOC(c->w);
XRaiseWindow(d, c->w);
}
XRaiseWindow(d, cur->prev->w);
win_focus(cur->prev);
}
/*
This function changes the focus to another desktop.
void win_next(const Arg arg) {
if (!cur) return;
To make this operation invisible the destination
desktop's windows are mapped first and the previous
desktop's windows are then unmapped afterwards.
XRaiseWindow(d, cur->next->w);
win_focus(cur->next);
}
Finally, focus is shifted to the first window on the
destination desktop's window list.
*/
void ws_go(const Arg arg) {
client *c;
int tmp = ws;
if (arg.i == ws) return;
@ -443,81 +184,53 @@ void ws_go(const Arg arg) {
ws_save(ws);
ws_sel(arg.i);
if (list) for WIN XMapWindow(d, c->w);
for win XMapWindow(d, c->w);
ws_sel(tmp);
if (list) for WIN XUnmapWindow(d, c->w);
for win XUnmapWindow(d, c->w);
ws_sel(arg.i);
if (list) FOC(list->w);
if (list) win_focus(list); else cur = 0;
}
/*
This function saves the current desktop's window list.
Simple, nothing to see here.
*/
void ws_save(int i) {
ws_list[i].list = list;
}
/*
This function restores a saved desktop's window list.
Simple, nothing to see here.
*/
void ws_sel(int i) {
list = ws_list[i].list;
ws = i;
}
/*
This function allows a window to request a size,
position and other attributes.
This is required so programs like Firefox or MPV
are able to display and function correctly.
*/
void configure_request(XEvent *e) {
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc;
wc.x = ev->x;
wc.y = ev->y;
wc.width = ev->width;
wc.height = ev->height;
wc.sibling = ev->above;
wc.stack_mode = ev->detail;
XConfigureWindow(d, ev->window, ev->value_mask, &wc);
XConfigureWindow(d, ev->window, ev->value_mask, &(XWindowChanges) {
.x = ev->x,
.y = ev->y,
.width = ev->width,
.height = ev->height,
.sibling = ev->above,
.stack_mode = ev->detail
});
}
/*
This function is executed whenever a window is mapped to
the screen.
The window is centered, mapped to the screen, focused and
finally added to the current desktop's window list.
'XSelectInput' is called to subscribe to various events
related to the window. For example, this is used to get
focus-follows-cursor to work.
*/
void map_request(XEvent *e) {
Window w = e->xmaprequest.window;
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
EnterWindowMask|FocusChangeMask);
win_center((Arg){.i = w});
XMapWindow(d, w);
FOC(w);
XSelectInput(d, w, StructureNotifyMask|EnterWindowMask);
win_size(w, &wx, &wy, &ww, &wh);
win_add(w);
cur = list->prev;
if (wx + wy == 0) win_center((Arg){0});
XMapWindow(d, w);
win_focus(list->prev);
}
void mapping_notify(XEvent *e) {
XMappingEvent *ev = &e->xmapping;
if (ev->request == MappingKeyboard || ev->request == MappingModifier) {
XRefreshKeyboardMapping(ev);
input_grab(root);
}
}
/*
This function is executed by keybindings to run the
specified program. Simple enough.
*/
void run(const Arg arg) {
if (fork()) return;
if (d) close(ConnectionNumber(d));
@ -526,60 +239,51 @@ void run(const Arg arg) {
execvp((char*)arg.com[0], (char**)arg.com);
}
/*
This window manager ignores all Xorg related errors.
void input_grab(Window root) {
unsigned int i, j, modifiers[] = {0, LockMask, numlock, numlock|LockMask};
XModifierKeymap *modmap = XGetModifierMapping(d);
KeyCode code;
The window manager either crashes (due to Xorg or
itself) or it continues on its merry way.
for (i = 0; i < 8; i++)
for (int k = 0; k < modmap->max_keypermod; k++)
if (modmap->modifiermap[i * modmap->max_keypermod + k]
== XKeysymToKeycode(d, 0xff7f))
numlock = (1 << i);
The only errors which are handled are failed memory
allocations or a failure to open the display on start.
*/
int xerror(Display *d, XErrorEvent *e) {
return 0;
XUngrabKey(d, AnyKey, AnyModifier, root);
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
XGrabKey(d, code, keys[i].mod | modifiers[j], root,
True, GrabModeAsync, GrabModeAsync);
for (i = 1; i < 4; i += 2)
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
XGrabButton(d, i, MOD | modifiers[j], root, True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
GrabModeAsync, GrabModeAsync, 0, 0);
XFreeModifiermap(modmap);
}
/*
Initialize the window manager by registering all
keybindings, setting some globals and starting the
event loop.
There's no 'XClosDisplay' or clean up as the only way
to exit this window manager is to kill the process.
This fires up Xorg's internal clean up which covers
everything allocated and executed here. It's free!
*/
int main(void) {
XEvent ev;
if (!(d = XOpenDisplay(0x0))) return 0;
if (!(d = XOpenDisplay(0))) exit(1);
signal(SIGCHLD, SIG_IGN);
XSetErrorHandler(xerror);
s = DefaultScreen(d);
root = RootWindow(d, s);
sw = XDisplayWidth(d, s);
sh = XDisplayHeight(d, s);
key_grab();
ws_go((Arg){.i = 1});
XSelectInput(d, root, SubstructureNotifyMask|
SubstructureRedirectMask|EnterWindowMask|LeaveWindowMask);
XGrabButton(d, 1, Mod4Mask, root, True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(d, 3, Mod4Mask, root, True,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
GrabModeAsync, GrabModeAsync, None, None);
int s = DefaultScreen(d);
root = RootWindow(d, s);
sw = XDisplayWidth(d, s);
sh = XDisplayHeight(d, s);
XSelectInput(d, root, SubstructureRedirectMask);
XDefineCursor(d, root, XCreateFontCursor(d, 68));
input_grab(root);
while(1 && !XNextEvent(d, &ev))
while (1 && !XNextEvent(d, &ev)) // 1 && will forever be here.
if (events[ev.type]) events[ev.type](&ev);
}

58
sowm.h Normal file
View File

@ -0,0 +1,58 @@
#include <X11/Xlib.h>
#define win (client *t=0, *c=list; c && t!=list->prev; t=c, c=c->next)
#define ws_save(W) ws_list[W] = list
#define ws_sel(W) list = ws_list[ws = W]
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define win_size(W, gx, gy, gw, gh) \
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
&(unsigned int){0}, &(unsigned int){0})
// Taken from DWM. Many thanks. https://git.suckless.org/dwm
#define mod_clean(mask) (mask & ~(numlock|LockMask) & \
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
typedef struct {
const char** com;
const int i;
const Window w;
} Arg;
struct key {
unsigned int mod;
KeySym keysym;
void (*function)(const Arg arg);
const Arg arg;
};
typedef struct client {
struct client *next, *prev;
int f, wx, wy;
unsigned int ww, wh;
Window w;
} client;
void button_press(XEvent *e);
void button_release(XEvent *e);
void configure_request(XEvent *e);
void input_grab(Window root);
void key_press(XEvent *e);
void map_request(XEvent *e);
void mapping_notify(XEvent *e);
void notify_destroy(XEvent *e);
void notify_enter(XEvent *e);
void notify_motion(XEvent *e);
void run(const Arg arg);
void win_add(Window w);
void win_center(const Arg arg);
void win_del(Window w);
void win_fs(const Arg arg);
void win_focus(client *c);
void win_kill(const Arg arg);
void win_prev(const Arg arg);
void win_next(const Arg arg);
void win_to_ws(const Arg arg);
void ws_go(const Arg arg);
static int xerror() { return 0; }