Introduction
Introduction Statistics Contact Development Disclaimer Help
st-hidecursor-0.5.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-hidecursor-0.5.diff (2423B)
---
1 diff --git a/st.c b/st.c
2 index 392f12d..52deb92 100644
3 --- a/st.c
4 +++ b/st.c
5 @@ -248,6 +248,8 @@ typedef struct {
6 Draw draw;
7 Visual *vis;
8 XSetWindowAttributes attrs;
9 + Cursor cursor, bcursor; /* visible and blank cursors */
10 + bool cursorstate; /* is cursor currently visible */
11 int scr;
12 bool isfixed; /* is fixed geometry? */
13 int fx, fy, fw, fh; /* fixed geometry */
14 @@ -1112,6 +1114,13 @@ void
15 bmotion(XEvent *e) {
16 int oldey, oldex, oldsby, oldsey;
17
18 + if(!xw.cursorstate) {
19 + XDefineCursor(xw.dpy, xw.win, xw.cursor);
20 + xw.cursorstate = true;
21 + if(!IS_SET(MODE_MOUSEMANY))
22 + xsetpointermotion(0);
23 + }
24 +
25 if(IS_SET(MODE_MOUSE)) {
26 mousereport(e);
27 return;
28 @@ -2984,10 +2993,12 @@ xzoom(const Arg *arg) {
29 void
30 xinit(void) {
31 XGCValues gcvalues;
32 - Cursor cursor;
33 Window parent;
34 int sw, sh;
35 pid_t thispid = getpid();
36 + XColor xcwhite = {.red = 0xffff, .green = 0xffff, .blue = 0xfff…
37 + XColor xcblack = {.red = 0x0000, .green = 0x0000, .blue = 0x000…
38 + Pixmap blankpm;
39
40 if(!(xw.dpy = XOpenDisplay(NULL)))
41 die("Can't open display\n");
42 @@ -3071,11 +3082,13 @@ xinit(void) {
43 die("XCreateIC failed. Could not obtain input method.\n…
44
45 /* white cursor, black outline */
46 - cursor = XCreateFontCursor(xw.dpy, XC_xterm);
47 - XDefineCursor(xw.dpy, xw.win, cursor);
48 - XRecolorCursor(xw.dpy, cursor,
49 - &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xfff…
50 - &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x000…
51 + xw.cursor = XCreateFontCursor(xw.dpy, XC_xterm);
52 + XDefineCursor(xw.dpy, xw.win, xw.cursor);
53 + XRecolorCursor(xw.dpy, xw.cursor, &xcwhite, &xcblack);
54 + xw.cursorstate = true;
55 + blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, …
56 + xw.bcursor = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
57 + &x…
58
59 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
60 xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
61 @@ -3537,6 +3550,8 @@ unmap(XEvent *ev) {
62
63 void
64 xsetpointermotion(int set) {
65 + if(!set && !xw.cursorstate)
66 + return;
67 MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
68 XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
69 }
70 @@ -3630,6 +3645,12 @@ kpress(XEvent *ev) {
71 Status status;
72 Shortcut *bp;
73
74 + if(xw.cursorstate) {
75 + XDefineCursor(xw.dpy, xw.win, xw.bcursor);
76 + xsetpointermotion(1);
77 + xw.cursorstate = false;
78 + }
79 +
80 if(IS_SET(MODE_KBDLOCK))
81 return;
82
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.