sowm: rounded corners patch, rebase

This commit is contained in:
Dylan Araps committed 2019-10-14 10:51:23 +03:00
1 parent 6a560c413a
commit 274180f9ec
1 file changed
+120 -92
+120 -92
View File
@@ -21,95 +21,123 @@ index 864c9a7..1525894 100644
const char* menu[] = {"dmenu_run", 0}; const char* menu[] = {"dmenu_run", 0};
const char* term[] = {"st", 0}; const char* term[] = {"st", 0};
diff --git a/sowm.c b/sowm.c diff --git a/patches/sowm-rounded-corners.patch b/patches/sowm-rounded-corners.patch
index 1618a65..29794cb 100644 index a2a3554..6b0cd21 100644
--- a/sowm.c --- a/patches/sowm-rounded-corners.patch
+++ b/sowm.c +++ b/patches/sowm-rounded-corners.patch
@@ -5,6 +5,7 @@ @@ -1,115 +0,0 @@
#include <X11/Xlib.h> -diff --git a/Makefile b/Makefile
#include <X11/XF86keysym.h> -index 2420660..d03d5e7 100644
#include <X11/keysym.h> ---- a/Makefile
+#include <X11/extensions/shape.h> -+++ b/Makefile
#include <stdlib.h> -@@ -1,5 +1,5 @@
#include <signal.h> - CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
#include <unistd.h> --LDADD+= -lX11
@@ -53,6 +54,7 @@ static void win_fs(Window w); -+LDADD+= -lX11 -lXext
static void win_fs_current(); - LDFLAGS=
static void win_kill(); - PREFIX?= /usr
static void win_next(); - BINDIR?= $(PREFIX)/bin
+static void win_round_corners(Window w, int rad); -diff --git a/config.h b/config.h
static void win_to_ws(const Arg arg); -index 864c9a7..1525894 100644
static void ws_go(const Arg arg); ---- a/config.h
static void ws_save(int i); -+++ b/config.h
@@ -87,6 +89,8 @@ void notify_destroy(XEvent *e) { -@@ -2,6 +2,7 @@
} - #define CONFIG_H
-
void notify_enter(XEvent *e) { - #define MOD Mod4Mask
+ while(XCheckTypedEvent(dis, EnterNotify, e)); -+#define ROUND_CORNERS 20
+ -
if (e->xcrossing.window != root) FOC(e->xcrossing.window) - const char* menu[] = {"dmenu_run", 0};
} - const char* term[] = {"st", 0};
-diff --git a/sowm.c b/sowm.c
@@ -104,6 +108,8 @@ void notify_motion(XEvent *e) { -index 1618a65..29794cb 100644
attr.y + (start.button==1 ? yd : 0), ---- a/sowm.c
attr.width + (start.button==3 ? xd : 0), -+++ b/sowm.c
attr.height + (start.button==3 ? yd : 0)); -@@ -5,6 +5,7 @@
+ - #include <X11/Xlib.h>
+ win_round_corners(start.subwindow, ROUND_CORNERS); - #include <X11/XF86keysym.h>
} - #include <X11/keysym.h>
-+#include <X11/extensions/shape.h>
for WIN if (c->win == start.subwindow) c->f = 0; - #include <stdlib.h>
@@ -219,7 +225,45 @@ void win_fs(Window w) { - #include <signal.h>
- #include <unistd.h>
} else -@@ -53,6 +54,7 @@ static void win_fs(Window w);
XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height); - static void win_fs_current();
+ - static void win_kill();
+ win_round_corners(w, c->f ? 0 : ROUND_CORNERS); - 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);
+void win_round_corners(Window w, int rad) { - static void ws_save(int i);
+ XWindowAttributes attr2; -@@ -87,6 +89,8 @@ void notify_destroy(XEvent *e) {
+ XGetWindowAttributes(dis, w, &attr2); - }
+ -
+ int dia = 2 * rad; - void notify_enter(XEvent *e) {
+ int ww = attr2.width; -+ while(XCheckTypedEvent(dis, EnterNotify, e));
+ int wh = attr2.height; -+
+ - if (e->xcrossing.window != root) FOC(e->xcrossing.window)
+ if (ww < dia || wh < dia) return; - }
+ -
+ Pixmap mask = XCreatePixmap(dis, w, ww, wh, 1); -@@ -104,6 +108,8 @@ void notify_motion(XEvent *e) {
+ - attr.y + (start.button==1 ? yd : 0),
+ if (!mask) return; - attr.width + (start.button==3 ? xd : 0),
+ - attr.height + (start.button==3 ? yd : 0));
+ XGCValues xgcv; -+
+ GC shape_gc = XCreateGC(dis, mask, 0, &xgcv); -+ win_round_corners(start.subwindow, ROUND_CORNERS);
+ - }
+ if (!shape_gc) { -
+ XFreePixmap(dis, mask); - for WIN if (c->win == start.subwindow) c->f = 0;
+ return; -@@ -219,7 +225,45 @@ void win_fs(Window w) {
} -
+ - } else
+ XSetForeground(dis, shape_gc, 0); - XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height);
+ XFillRectangle(dis, mask, shape_gc, 0, 0, ww, wh); -+
+ XSetForeground(dis, shape_gc, 1); -+ win_round_corners(w, c->f ? 0 : ROUND_CORNERS);
+ XFillArc(dis, mask, shape_gc, 0, 0, dia, dia, 0, 23040); -+ }
+ XFillArc(dis, mask, shape_gc, ww-dia-1, 0, dia, dia, 0, 23040); -+}
+ XFillArc(dis, mask, shape_gc, 0, wh-dia-1, dia, dia, 0, 23040); -+
+ XFillArc(dis, mask, shape_gc, ww-dia-1, wh-dia-1, dia, dia, 0, 23040); -+void win_round_corners(Window w, int rad) {
+ XFillRectangle(dis, mask, shape_gc, rad, 0, ww-dia, wh); -+ XWindowAttributes attr2;
+ XFillRectangle(dis, mask, shape_gc, 0, rad, ww, wh-dia); -+ XGetWindowAttributes(dis, w, &attr2);
+ XShapeCombineMask(dis, w, ShapeBounding, 0, 0, mask, ShapeSet); -+
+ XFreePixmap(dis, mask); -+ int dia = 2 * rad;
+ XFreeGC(dis, shape_gc); -+ int ww = attr2.width;
} -+ int wh = attr2.height;
-+
void win_to_ws(const Arg arg) { -+ if (ww < dia || wh < dia) return;
@@ -310,6 +354,7 @@ void map_request(XEvent *e) { -+
EnterWindowMask|FocusChangeMask); -+ Pixmap mask = XCreatePixmap(dis, w, ww, wh, 1);
win_center(w); -+
XMapWindow(dis, w); -+ if (!mask) return;
+ win_round_corners(w, ROUND_CORNERS); -+
FOC(w); -+ XGCValues xgcv;
win_add(w); -+ GC shape_gc = XCreateGC(dis, mask, 0, &xgcv);
} -+
-+ if (!shape_gc) {
-+ XFreePixmap(dis, mask);
-+ return;
- }
-+
-+ XSetForeground(dis, shape_gc, 0);
-+ XFillRectangle(dis, mask, shape_gc, 0, 0, ww, wh);
-+ XSetForeground(dis, shape_gc, 1);
-+ XFillArc(dis, mask, shape_gc, 0, 0, dia, dia, 0, 23040);
-+ XFillArc(dis, mask, shape_gc, ww-dia-1, 0, dia, dia, 0, 23040);
-+ XFillArc(dis, mask, shape_gc, 0, wh-dia-1, dia, dia, 0, 23040);
-+ XFillArc(dis, mask, shape_gc, ww-dia-1, wh-dia-1, dia, dia, 0, 23040);
-+ XFillRectangle(dis, mask, shape_gc, rad, 0, ww-dia, wh);
-+ XFillRectangle(dis, mask, shape_gc, 0, rad, ww, wh-dia);
-+ XShapeCombineMask(dis, w, ShapeBounding, 0, 0, mask, ShapeSet);
-+ XFreePixmap(dis, mask);
-+ XFreeGC(dis, shape_gc);
- }
-
- void win_to_ws(const Arg arg) {
-@@ -310,6 +354,7 @@ void map_request(XEvent *e) {
- EnterWindowMask|FocusChangeMask);
- win_center(w);
- XMapWindow(dis, w);
-+ win_round_corners(w, ROUND_CORNERS);
- FOC(w);
- win_add(w);
- }