diff options
| author | Shubham Saini <shubham6405@gmail.com> | 2020-05-16 17:43:31 +0000 | 
|---|---|---|
| committer | Shubham Saini <shubham6405@gmail.com> | 2020-05-16 17:43:31 +0000 | 
| commit | 16d45c32c20d7b3db8ba2533ca9d414d8cd308f2 (patch) | |
| tree | f829957546b740e6897eba24c8f49bb4c170044e /st/patches/st-hidecursor-0.8.1.diff | |
gone full suckless
Diffstat (limited to 'st/patches/st-hidecursor-0.8.1.diff')
| -rw-r--r-- | st/patches/st-hidecursor-0.8.1.diff | 88 | 
1 files changed, 88 insertions, 0 deletions
| diff --git a/st/patches/st-hidecursor-0.8.1.diff b/st/patches/st-hidecursor-0.8.1.diff new file mode 100644 index 0000000..d27267c --- /dev/null +++ b/st/patches/st-hidecursor-0.8.1.diff | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | diff --git a/x.c b/x.c | ||
| 2 | index c343ba2..a40de8c 100644 | ||
| 3 | --- a/x.c | ||
| 4 | +++ b/x.c | ||
| 5 | @@ -96,6 +96,11 @@ typedef struct { | ||
| 6 | Draw draw; | ||
| 7 | Visual *vis; | ||
| 8 | XSetWindowAttributes attrs; | ||
| 9 | + /* Here, we use the term *pointer* to differentiate the cursor | ||
| 10 | + * one sees when hovering the mouse over the terminal from, e.g., | ||
| 11 | + * a green rectangle where text would be entered. */ | ||
| 12 | + Cursor vpointer, bpointer; /* visible and hidden pointers */ | ||
| 13 | + int pointerisvisible; | ||
| 14 | int scr; | ||
| 15 | int isfixed; /* is fixed geometry? */ | ||
| 16 | int l, t; /* left and top offset */ | ||
| 17 | @@ -652,6 +657,13 @@ brelease(XEvent *e) | ||
| 18 | void | ||
| 19 | bmotion(XEvent *e) | ||
| 20 | { | ||
| 21 | + if (!xw.pointerisvisible) { | ||
| 22 | + XDefineCursor(xw.dpy, xw.win, xw.vpointer); | ||
| 23 | + xw.pointerisvisible = 1; | ||
| 24 | + if (!IS_SET(MODE_MOUSEMANY)) | ||
| 25 | + xsetpointermotion(0); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { | ||
| 29 | mousereport(e); | ||
| 30 | return; | ||
| 31 | @@ -997,10 +1009,10 @@ void | ||
| 32 | xinit(int cols, int rows) | ||
| 33 | { | ||
| 34 | XGCValues gcvalues; | ||
| 35 | - Cursor cursor; | ||
| 36 | Window parent; | ||
| 37 | pid_t thispid = getpid(); | ||
| 38 | XColor xmousefg, xmousebg; | ||
| 39 | + Pixmap blankpm; | ||
| 40 | |||
| 41 | if (!(xw.dpy = XOpenDisplay(NULL))) | ||
| 42 | die("Can't open display\n"); | ||
| 43 | @@ -1076,8 +1088,9 @@ xinit(int cols, int rows) | ||
| 44 | die("XCreateIC failed. Could not obtain input method.\n"); | ||
| 45 | |||
| 46 | /* white cursor, black outline */ | ||
| 47 | - cursor = XCreateFontCursor(xw.dpy, mouseshape); | ||
| 48 | - XDefineCursor(xw.dpy, xw.win, cursor); | ||
| 49 | + xw.pointerisvisible = 1; | ||
| 50 | + xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape); | ||
| 51 | + XDefineCursor(xw.dpy, xw.win, xw.vpointer); | ||
| 52 | |||
| 53 | if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { | ||
| 54 | xmousefg.red = 0xffff; | ||
| 55 | @@ -1091,7 +1104,10 @@ xinit(int cols, int rows) | ||
| 56 | xmousebg.blue = 0x0000; | ||
| 57 | } | ||
| 58 | |||
| 59 | - XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg); | ||
| 60 | + XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg); | ||
| 61 | + blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1); | ||
| 62 | + xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm, | ||
| 63 | + &xmousefg, &xmousebg, 0, 0); | ||
| 64 | |||
| 65 | xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); | ||
| 66 | xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); | ||
| 67 | @@ -1574,6 +1590,8 @@ unmap(XEvent *ev) | ||
| 68 | void | ||
| 69 | xsetpointermotion(int set) | ||
| 70 | { | ||
| 71 | + if (!set && !xw.pointerisvisible) | ||
| 72 | + return; | ||
| 73 | MODBIT(xw.attrs.event_mask, set, PointerMotionMask); | ||
| 74 | XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); | ||
| 75 | } | ||
| 76 | @@ -1692,6 +1710,12 @@ kpress(XEvent *ev) | ||
| 77 | Status status; | ||
| 78 | Shortcut *bp; | ||
| 79 | |||
| 80 | + if (xw.pointerisvisible) { | ||
| 81 | + XDefineCursor(xw.dpy, xw.win, xw.bpointer); | ||
| 82 | + xsetpointermotion(1); | ||
| 83 | + xw.pointerisvisible = 0; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | if (IS_SET(MODE_KBDLOCK)) | ||
| 87 | return; | ||
| 88 | |||
