mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-07-26 09:41:59 -07:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7215a4915d | ||
|
f201a467ea | ||
|
7821aac0d2 | ||
|
a1c80d9b23 | ||
|
0df345e1da | ||
|
b5087acaac |
4
Makefile
4
Makefile
@@ -9,8 +9,8 @@ all: config.h sowm
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
|
||||
sowm: sowm.o
|
||||
$(CC) $(LDFLAGS) -O3 -o sowm sowm.c -lX11
|
||||
sowm:
|
||||
$(CC) -O3 $(CFLAGS) -o sowm sowm.c -lX11 -lXext $(LDFLAGS)
|
||||
|
||||
install: all
|
||||
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||
|
@@ -9,7 +9,8 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
||||
- Window centering.
|
||||
- Mix of mouse and keyboard workflow.
|
||||
- Focus with cursor.
|
||||
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm-patches)*)
|
||||
- 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>
|
||||
|
||||
@@ -23,7 +24,7 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
||||
|
||||
<br>
|
||||
|
||||
Patches available here: https://github.com/dylanaraps/sowm-patches
|
||||
Patches available here: https://github.com/dylanaraps/sowm/pulls
|
||||
|
||||
## Default Keybindings
|
||||
|
||||
|
@@ -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};
|
||||
|
42
sowm.c
42
sowm.c
@@ -4,6 +4,7 @@
|
||||
#include <X11/XF86keysym.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@@ -61,6 +62,9 @@ void notify_motion(XEvent *e) {
|
||||
wy + (mouse.button == 1 ? yd : 0),
|
||||
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
||||
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
||||
|
||||
if (mouse.button == 3)
|
||||
win_round_corners(mouse.subwindow, ROUND_CORNERS);
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
@@ -142,6 +146,41 @@ void win_fs(const Arg arg) {
|
||||
} else {
|
||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||
}
|
||||
|
||||
win_round_corners(cur->w, cur->f ? 0 : ROUND_CORNERS);
|
||||
}
|
||||
|
||||
void win_round_corners(Window w, int rad) {
|
||||
unsigned int ww, wh, dia = 2 * rad;
|
||||
|
||||
win_size(w, &(int){1}, &(int){1}, &ww, &wh);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void win_to_ws(const Arg arg) {
|
||||
@@ -205,6 +244,8 @@ void configure_request(XEvent *e) {
|
||||
.sibling = ev->above,
|
||||
.stack_mode = ev->detail
|
||||
});
|
||||
|
||||
win_round_corners(ev->window, ROUND_CORNERS);
|
||||
}
|
||||
|
||||
void map_request(XEvent *e) {
|
||||
@@ -217,6 +258,7 @@ void map_request(XEvent *e) {
|
||||
|
||||
if (wx + wy == 0) win_center((Arg){0});
|
||||
|
||||
win_round_corners(w, ROUND_CORNERS);
|
||||
XMapWindow(d, w);
|
||||
win_focus(list->prev);
|
||||
}
|
||||
|
4
sowm.h
4
sowm.h
@@ -51,6 +51,8 @@ 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_round_corners(Window w, int rad);
|
||||
void win_to_ws(const Arg arg);
|
||||
void ws_go(const Arg arg);
|
||||
int xerror() { return 0; }
|
||||
|
||||
static int xerror() { return 0; }
|
||||
|
Reference in New Issue
Block a user