mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
107 lines
2.9 KiB
Diff
107 lines
2.9 KiB
Diff
diff --git a/Makefile b/Makefile
|
|
index 3154a2f..243b744 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -1,5 +1,5 @@
|
|
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
|
|
-LDADD+= -lX11
|
|
+LDADD+= -lX11 -lXext
|
|
LDFLAGS=
|
|
PREFIX?= /usr
|
|
BINDIR?= $(PREFIX)/bin
|
|
diff --git a/config.def.h b/config.def.h
|
|
index 3cef34b..e7f1518 100644
|
|
--- a/config.def.h
|
|
+++ b/config.def.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 126aca0..5c99c5c 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>
|
|
@@ -41,6 +42,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 int xerror() { return 0;}
|
|
@@ -105,6 +107,9 @@ void notify_motion(XEvent *e) {
|
|
wy + (mouse.button == 1 ? yd : 0),
|
|
ww + (mouse.button == 3 ? xd : 0),
|
|
wh + (mouse.button == 3 ? yd : 0));
|
|
+
|
|
+ if (mouse.button == 3)
|
|
+ win_round_corners(mouse.subwindow, ROUND_CORNERS);
|
|
}
|
|
|
|
void key_press(XEvent *e) {
|
|
@@ -201,9 +206,44 @@ void win_fs() {
|
|
|
|
} else
|
|
XMoveResizeWindow(d, cur, c->wx, c->wy, c->ww, c->wh);
|
|
+
|
|
+ win_round_corners(cur, c->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) {
|
|
int tmp = ws;
|
|
win_current();
|
|
@@ -275,6 +315,7 @@ void map_request(XEvent *e) {
|
|
if (wx == 0 && wy == 0) win_center((Arg){.i = w});
|
|
|
|
XMapWindow(d, w);
|
|
+ win_round_corners(w, ROUND_CORNERS);
|
|
win_focus(w);
|
|
win_add(w);
|
|
}
|