summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-02-20 02:51:13 -0600
committerzachir <zachir@librem.one>2023-02-20 02:51:13 -0600
commit2920f5918b511c913cf3830a38c684a841753f8b (patch)
tree89e80cb95163d43221ee84441098a6457c75c244
parent3eb31f62dbac02f0a62e3bdb5d2cd35820b1e046 (diff)
Revert "Revert "add hidecursor patch""
This reverts commit 3eb31f62dbac02f0a62e3bdb5d2cd35820b1e046.
-rw-r--r--patches/st-hidecursor-0.8.3.diff88
-rw-r--r--x.c31
2 files changed, 116 insertions, 3 deletions
diff --git a/patches/st-hidecursor-0.8.3.diff b/patches/st-hidecursor-0.8.3.diff
new file mode 100644
index 0000000..4895a66
--- /dev/null
+++ b/patches/st-hidecursor-0.8.3.diff
@@ -0,0 +1,88 @@
+diff --git a/x.c b/x.c
+index e5f1737..7e759b0 100644
+--- a/x.c
++++ b/x.c
+@@ -103,6 +103,11 @@ typedef struct {
+ Draw draw;
+ Visual *vis;
+ XSetWindowAttributes attrs;
++ /* Here, we use the term *pointer* to differentiate the cursor
++ * one sees when hovering the mouse over the terminal from, e.g.,
++ * a green rectangle where text would be entered. */
++ Cursor vpointer, bpointer; /* visible and hidden pointers */
++ int pointerisvisible;
+ int scr;
+ int isfixed; /* is fixed geometry? */
+ int l, t; /* left and top offset */
+@@ -698,6 +703,13 @@ brelease(XEvent *e)
+ void
+ bmotion(XEvent *e)
+ {
++ if (!xw.pointerisvisible) {
++ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
++ xw.pointerisvisible = 1;
++ if (!IS_SET(MODE_MOUSEMANY))
++ xsetpointermotion(0);
++ }
++
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
+ mousereport(e);
+ return;
+@@ -1099,10 +1111,10 @@ void
+ xinit(int cols, int rows)
+ {
+ XGCValues gcvalues;
+- Cursor cursor;
+ Window parent;
+ pid_t thispid = getpid();
+ XColor xmousefg, xmousebg;
++ Pixmap blankpm;
+
+ if (!(xw.dpy = XOpenDisplay(NULL)))
+ die("can't open display\n");
+@@ -1166,8 +1178,9 @@ xinit(int cols, int rows)
+ }
+
+ /* white cursor, black outline */
+- cursor = XCreateFontCursor(xw.dpy, mouseshape);
+- XDefineCursor(xw.dpy, xw.win, cursor);
++ xw.pointerisvisible = 1;
++ xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
++ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
+ xmousefg.red = 0xffff;
+@@ -1181,7 +1194,10 @@ xinit(int cols, int rows)
+ xmousebg.blue = 0x0000;
+ }
+
+- XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
++ XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
++ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
++ xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
++ &xmousefg, &xmousebg, 0, 0);
+
+ xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
+ xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
+@@ -1673,6 +1689,8 @@ unmap(XEvent *ev)
+ void
+ xsetpointermotion(int set)
+ {
++ if (!set && !xw.pointerisvisible)
++ return;
+ MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
+ XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
+ }
+@@ -1793,6 +1811,12 @@ kpress(XEvent *ev)
+ Status status;
+ Shortcut *bp;
+
++ if (xw.pointerisvisible) {
++ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
++ xsetpointermotion(1);
++ xw.pointerisvisible = 0;
++ }
++
+ if (IS_SET(MODE_KBDLOCK))
+ return;
+
diff --git a/x.c b/x.c
index 14ad2f1..ff736f7 100644
--- a/x.c
+++ b/x.c
@@ -110,6 +110,11 @@ typedef struct {
Draw draw;
Visual *vis;
XSetWindowAttributes attrs;
+ /* Here, we use the term *pointer* to differentiate the cursor
+ * one sees when hovering the mouse over the terminal from, e.g.,
+ * a green rectangle where text would be entered. */
+ Cursor vpointer, bpointer; /* visible and hidden pointers */
+ int pointerisvisible;
int scr;
int isfixed; /* is fixed geometry? */
int depth; /* bit depth */
@@ -733,6 +738,13 @@ brelease(XEvent *e)
void
bmotion(XEvent *e)
{
+ if (!xw.pointerisvisible) {
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+ xw.pointerisvisible = 1;
+ if (!IS_SET(MODE_MOUSEMANY))
+ xsetpointermotion(0);
+ }
+
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
mousereport(e);
return;
@@ -1259,6 +1271,7 @@ xinit(int cols, int rows)
Window parent;
pid_t thispid = getpid();
XColor xmousefg, xmousebg;
+ Pixmap blankpm;
XWindowAttributes attr;
XVisualInfo vis;
@@ -1333,8 +1346,9 @@ xinit(int cols, int rows)
}
/* white cursor, black outline */
- cursor = XCreateFontCursor(xw.dpy, mouseshape);
- XDefineCursor(xw.dpy, xw.win, cursor);
+ xw.pointerisvisible = 1;
+ xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
xmousefg.red = 0xffff;
@@ -1348,7 +1362,10 @@ xinit(int cols, int rows)
xmousebg.blue = 0x0000;
}
- XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
+ XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
+ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
+ xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
+ &xmousefg, &xmousebg, 0, 0);
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
@@ -1905,6 +1922,8 @@ unmap(XEvent *ev)
void
xsetpointermotion(int set)
{
+ if (!set && !xw.pointerisvisible)
+ return;
MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
}
@@ -2034,6 +2053,12 @@ kpress(XEvent *ev)
Status status;
Shortcut *bp;
+ if (xw.pointerisvisible) {
+ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
+ xsetpointermotion(1);
+ xw.pointerisvisible = 0;
+ }
+
if (IS_SET(MODE_KBDLOCK))
return;