Introduction
Introduction Statistics Contact Development Disclaimer Help
st-hidecursor-0.6.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-hidecursor-0.6.diff (2672B)
---
1 diff --git a/st.c b/st.c
2 index b89d094..d2979ff 100644
3 --- a/st.c
4 +++ b/st.c
5 @@ -257,6 +257,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 + bool pointerisvisible;
14 int scr;
15 bool isfixed; /* is fixed geometry? */
16 int l, t; /* left and top offset */
17 @@ -1181,6 +1186,13 @@ void
18 bmotion(XEvent *e) {
19 int oldey, oldex, oldsby, oldsey;
20
21 + if(!xw.pointerisvisible) {
22 + XDefineCursor(xw.dpy, xw.win, xw.vpointer);
23 + xw.pointerisvisible = true;
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 @@ -3182,9 +3194,11 @@ xzoomreset(const Arg *arg) {
32 void
33 xinit(void) {
34 XGCValues gcvalues;
35 - Cursor cursor;
36 Window parent;
37 pid_t thispid = getpid();
38 + XColor xcwhite = {.red = 0xffff, .green = 0xffff, .blue = 0xfff…
39 + XColor xcblack = {.red = 0x0000, .green = 0x0000, .blue = 0x000…
40 + Pixmap blankpm;
41
42 if(!(xw.dpy = XOpenDisplay(NULL)))
43 die("Can't open display\n");
44 @@ -3257,11 +3271,13 @@ xinit(void) {
45 die("XCreateIC failed. Could not obtain input method.\n…
46
47 /* white cursor, black outline */
48 - cursor = XCreateFontCursor(xw.dpy, XC_xterm);
49 - XDefineCursor(xw.dpy, xw.win, cursor);
50 - XRecolorCursor(xw.dpy, cursor,
51 - &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xfff…
52 - &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x000…
53 + xw.vpointer = XCreateFontCursor(xw.dpy, XC_xterm);
54 + XDefineCursor(xw.dpy, xw.win, xw.vpointer);
55 + XRecolorCursor(xw.dpy, xw.vpointer, &xcwhite, &xcblack);
56 + xw.pointerisvisible = true;
57 + blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, …
58 + xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
59 + &xcblack, &xcblack, 0, 0);
60
61 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
62 xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
63 @@ -3725,6 +3741,8 @@ unmap(XEvent *ev) {
64
65 void
66 xsetpointermotion(int set) {
67 + if(!set && !xw.pointerisvisible)
68 + return;
69 MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
70 XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
71 }
72 @@ -3818,6 +3836,12 @@ kpress(XEvent *ev) {
73 Status status;
74 Shortcut *bp;
75
76 + if(xw.pointerisvisible) {
77 + XDefineCursor(xw.dpy, xw.win, xw.bpointer);
78 + xsetpointermotion(1);
79 + xw.pointerisvisible = false;
80 + }
81 +
82 if(IS_SET(MODE_KBDLOCK))
83 return;
84
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.