commit 274180f9ec2000a34430874b8cddb89b63d34aec
parent 6a560c413a84485b4d42b6dc06d3dc49ee81524b
Author: Dylan Araps <dylan.araps@gmail.com>
Date: Mon, 14 Oct 2019 10:51:23 +0300
sowm: rounded corners patch, rebase
Diffstat:
1 file changed, 120 insertions(+), 92 deletions(-)
diff --git a/patches/sowm-rounded-corners.patch b/patches/sowm-rounded-corners.patch
@@ -21,95 +21,123 @@ index 864c9a7..1525894 100644
const char* menu[] = {"dmenu_run", 0};
const char* term[] = {"st", 0};
-diff --git a/sowm.c b/sowm.c
-index 1618a65..29794cb 100644
---- a/sowm.c
-+++ b/sowm.c
-@@ -5,6 +5,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>
-@@ -53,6 +54,7 @@ static void win_fs(Window w);
- static void win_fs_current();
- 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);
-@@ -87,6 +89,8 @@ void notify_destroy(XEvent *e) {
- }
-
- void notify_enter(XEvent *e) {
-+ while(XCheckTypedEvent(dis, EnterNotify, e));
-+
- if (e->xcrossing.window != root) FOC(e->xcrossing.window)
- }
-
-@@ -104,6 +108,8 @@ void notify_motion(XEvent *e) {
- attr.y + (start.button==1 ? yd : 0),
- attr.width + (start.button==3 ? xd : 0),
- attr.height + (start.button==3 ? yd : 0));
-+
-+ win_round_corners(start.subwindow, ROUND_CORNERS);
- }
-
- for WIN if (c->win == start.subwindow) c->f = 0;
-@@ -219,7 +225,45 @@ void win_fs(Window w) {
-
- } else
- XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height);
-+
-+ win_round_corners(w, c->f ? 0 : ROUND_CORNERS);
-+ }
-+}
-+
-+void win_round_corners(Window w, int rad) {
-+ XWindowAttributes attr2;
-+ XGetWindowAttributes(dis, w, &attr2);
-+
-+ int dia = 2 * rad;
-+ int ww = attr2.width;
-+ int wh = attr2.height;
-+
-+ if (ww < dia || wh < dia) return;
-+
-+ Pixmap mask = XCreatePixmap(dis, w, ww, wh, 1);
-+
-+ if (!mask) return;
-+
-+ XGCValues xgcv;
-+ 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);
- }
+diff --git a/patches/sowm-rounded-corners.patch b/patches/sowm-rounded-corners.patch
+index a2a3554..6b0cd21 100644
+--- a/patches/sowm-rounded-corners.patch
++++ b/patches/sowm-rounded-corners.patch
+@@ -1,115 +0,0 @@
+-diff --git a/Makefile b/Makefile
+-index 2420660..d03d5e7 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 1618a65..29794cb 100644
+---- a/sowm.c
+-+++ b/sowm.c
+-@@ -5,6 +5,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>
+-@@ -53,6 +54,7 @@ static void win_fs(Window w);
+- static void win_fs_current();
+- 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);
+-@@ -87,6 +89,8 @@ void notify_destroy(XEvent *e) {
+- }
+-
+- void notify_enter(XEvent *e) {
+-+ while(XCheckTypedEvent(dis, EnterNotify, e));
+-+
+- if (e->xcrossing.window != root) FOC(e->xcrossing.window)
+- }
+-
+-@@ -104,6 +108,8 @@ void notify_motion(XEvent *e) {
+- attr.y + (start.button==1 ? yd : 0),
+- attr.width + (start.button==3 ? xd : 0),
+- attr.height + (start.button==3 ? yd : 0));
+-+
+-+ win_round_corners(start.subwindow, ROUND_CORNERS);
+- }
+-
+- for WIN if (c->win == start.subwindow) c->f = 0;
+-@@ -219,7 +225,45 @@ void win_fs(Window w) {
+-
+- } else
+- XMoveResizeWindow(dis, w, c->a.x, c->a.y, c->a.width, c->a.height);
+-+
+-+ win_round_corners(w, c->f ? 0 : ROUND_CORNERS);
+-+ }
+-+}
+-+
+-+void win_round_corners(Window w, int rad) {
+-+ XWindowAttributes attr2;
+-+ XGetWindowAttributes(dis, w, &attr2);
+-+
+-+ int dia = 2 * rad;
+-+ int ww = attr2.width;
+-+ int wh = attr2.height;
+-+
+-+ if (ww < dia || wh < dia) return;
+-+
+-+ Pixmap mask = XCreatePixmap(dis, w, ww, wh, 1);
+-+
+-+ if (!mask) return;
+-+
+-+ XGCValues xgcv;
+-+ 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);
+- }