From 535af11c2d36a31478558c2eb5b675d011b55a5d Mon Sep 17 00:00:00 2001 From: siduck Date: Sat, 31 Aug 2024 12:12:09 +0530 Subject: [PATCH] add swapmouse patch --- README.md | 2 +- x.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a4c874a76babefb848590270e36f2c010bbcf81..36e1be2613b1389536b42ca66b3e886c393bc600 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Add `st.url = "github:siduck/st";` to your inputs and install `inputs.st.package - xresources - sync patch ( Better draw timing to reduce flicker/tearing and improve animation smoothness ) - live reload ( change colors/fonts on the fly ) - and more... +- st-swapmouse
## Xresources live-reload diff --git a/x.c b/x.c index ad1339f8f3ab3917360dc47ae04ff728e156959b..cf40e31ceb9a50469f2cb4c1dd8f93d81f8aafe5 100644 --- a/x.c +++ b/x.c @@ -269,6 +269,9 @@ static char *opt_title = NULL; static int oldbutton = 3; /* button event on startup: 3 = release */ static int cursorblinks = 0; +static Cursor cursor; +static XColor xmousefg, xmousebg; + void clipcopy(const Arg *dummy) { @@ -1216,10 +1219,8 @@ void xinit(int cols, int rows) { XGCValues gcvalues; - Cursor cursor; Window parent; pid_t thispid = getpid(); - XColor xmousefg, xmousebg; XWindowAttributes attr; XVisualInfo vis; @@ -1875,6 +1876,12 @@ xsetmode(int set, unsigned int flags) { int mode = win.mode; MODBIT(win.mode, set, flags); + if (flags & MODE_MOUSE) { + if (win.mode & MODE_MOUSE) + XUndefineCursor(xw.dpy, xw.win); + else + XDefineCursor(xw.dpy, xw.win, cursor); + } if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE)) redraw(); }