sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8a2630787a02654229cd7994904be11c47e4290a
parent 03997ebb78edc2b174cd4b6972d95f967d22fe62
Author: Colona <colona@ycc.fr>
Date:   Mon,  9 Jun 2014 01:13:47 -0700

Add patch "Hide X cursor" to st patches page.

Diffstat:
Ast.suckless.org/patches/hide_X_cursor.md | 19+++++++++++++++++++
Ast.suckless.org/patches/st-0.5-hidexcursor.diff | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ast.suckless.org/patches/st-git-hidexcursor.diff | 95+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/hide_X_cursor.md b/st.suckless.org/patches/hide_X_cursor.md @@ -0,0 +1,19 @@ +Hide X cursor +============= + +Description +----------- + +Hide the X cursor whenever a key is pressed and show it back when the mouse is +moved in the terminal window. + +Download +-------- + +* [st-0.5-hidexcursor.diff](st-0.5-hidexcursor.diff) +* [st-git-hidexcursor.diff](st-git-hidexcursor.diff) + +Author +------ + + * Ivan Delalande - colona diff --git a/st.suckless.org/patches/st-0.5-hidexcursor.diff b/st.suckless.org/patches/st-0.5-hidexcursor.diff @@ -0,0 +1,96 @@ +From d081963fc75e1656f5ee4305947384a00b9e5f39 Mon Sep 17 00:00:00 2001 +From: Colona <colona@ycc.fr> +Date: Mon, 9 Jun 2014 00:55:54 -0700 +Subject: [PATCH] Hide X cursor when typing. + +Hide the X cursor when typing in the terminal. The cursor is displayed again +when the mouse is moved. +--- + st.c | 33 +++++++++++++++++++++++++++------ + 1 file changed, 27 insertions(+), 6 deletions(-) + +diff --git a/st.c b/st.c +index 392f12d..52deb92 100644 +--- a/st.c ++++ b/st.c +@@ -248,6 +248,8 @@ typedef struct { + Draw draw; + Visual *vis; + XSetWindowAttributes attrs; ++ Cursor cursor, bcursor; /* visible and blank cursors */ ++ bool cursorstate; /* is cursor currently visible */ + int scr; + bool isfixed; /* is fixed geometry? */ + int fx, fy, fw, fh; /* fixed geometry */ +@@ -1112,6 +1114,13 @@ void + bmotion(XEvent *e) { + int oldey, oldex, oldsby, oldsey; + ++ if(!xw.cursorstate) { ++ XDefineCursor(xw.dpy, xw.win, xw.cursor); ++ xw.cursorstate = true; ++ if(!IS_SET(MODE_MOUSEMANY)) ++ xsetpointermotion(0); ++ } ++ + if(IS_SET(MODE_MOUSE)) { + mousereport(e); + return; +@@ -2984,10 +2993,12 @@ xzoom(const Arg *arg) { + void + xinit(void) { + XGCValues gcvalues; +- Cursor cursor; + Window parent; + int sw, sh; + pid_t thispid = getpid(); ++ XColor xcwhite = {.red = 0xffff, .green = 0xffff, .blue = 0xffff}; ++ XColor xcblack = {.red = 0x0000, .green = 0x0000, .blue = 0x0000}; ++ Pixmap blankpm; + + if(!(xw.dpy = XOpenDisplay(NULL))) + die("Can't open display\n"); +@@ -3071,11 +3082,13 @@ xinit(void) { + die("XCreateIC failed. Could not obtain input method.\n"); + + /* white cursor, black outline */ +- cursor = XCreateFontCursor(xw.dpy, XC_xterm); +- XDefineCursor(xw.dpy, xw.win, cursor); +- XRecolorCursor(xw.dpy, cursor, +- &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, +- &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); ++ xw.cursor = XCreateFontCursor(xw.dpy, XC_xterm); ++ XDefineCursor(xw.dpy, xw.win, xw.cursor); ++ XRecolorCursor(xw.dpy, xw.cursor, &xcwhite, &xcblack); ++ xw.cursorstate = true; ++ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1); ++ xw.bcursor = XCreatePixmapCursor(xw.dpy, blankpm, blankpm, ++ &xcblack, &xcblack, 0, 0); + + xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); + xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); +@@ -3537,6 +3550,8 @@ unmap(XEvent *ev) { + + void + xsetpointermotion(int set) { ++ if(!set && !xw.cursorstate) ++ return; + MODBIT(xw.attrs.event_mask, set, PointerMotionMask); + XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); + } +@@ -3630,6 +3645,12 @@ kpress(XEvent *ev) { + Status status; + Shortcut *bp; + ++ if(xw.cursorstate) { ++ XDefineCursor(xw.dpy, xw.win, xw.bcursor); ++ xsetpointermotion(1); ++ xw.cursorstate = false; ++ } ++ + if(IS_SET(MODE_KBDLOCK)) + return; + +-- +2.0.0 + diff --git a/st.suckless.org/patches/st-git-hidexcursor.diff b/st.suckless.org/patches/st-git-hidexcursor.diff @@ -0,0 +1,95 @@ +From 724b832c56384bb770fe6bd09ef38c7ac5657228 Mon Sep 17 00:00:00 2001 +From: Colona <colona@ycc.fr> +Date: Mon, 9 Jun 2014 01:00:20 -0700 +Subject: [PATCH] Hide X cursor when typing. + +Hide the X cursor when typing in the terminal. The cursor is displayed again +when the mouse is moved. +--- + st.c | 33 +++++++++++++++++++++++++++------ + 1 file changed, 27 insertions(+), 6 deletions(-) + +diff --git a/st.c b/st.c +index 3681776..53b7e70 100644 +--- a/st.c ++++ b/st.c +@@ -249,6 +249,8 @@ typedef struct { + Draw draw; + Visual *vis; + XSetWindowAttributes attrs; ++ Cursor cursor, bcursor; /* visible and blank cursors */ ++ bool cursorstate; /* is cursor currently visible */ + int scr; + bool isfixed; /* is fixed geometry? */ + int l, t; /* left and top offset */ +@@ -1115,6 +1117,13 @@ void + bmotion(XEvent *e) { + int oldey, oldex, oldsby, oldsey; + ++ if(!xw.cursorstate) { ++ XDefineCursor(xw.dpy, xw.win, xw.cursor); ++ xw.cursorstate = true; ++ if(!IS_SET(MODE_MOUSEMANY)) ++ xsetpointermotion(0); ++ } ++ + if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { + mousereport(e); + return; +@@ -2998,9 +3007,11 @@ xzoom(const Arg *arg) { + void + xinit(void) { + XGCValues gcvalues; +- Cursor cursor; + Window parent; + pid_t thispid = getpid(); ++ XColor xcwhite = {.red = 0xffff, .green = 0xffff, .blue = 0xffff}; ++ XColor xcblack = {.red = 0x0000, .green = 0x0000, .blue = 0x0000}; ++ Pixmap blankpm; + + if(!(xw.dpy = XOpenDisplay(NULL))) + die("Can't open display\n"); +@@ -3073,11 +3084,13 @@ xinit(void) { + die("XCreateIC failed. Could not obtain input method.\n"); + + /* white cursor, black outline */ +- cursor = XCreateFontCursor(xw.dpy, XC_xterm); +- XDefineCursor(xw.dpy, xw.win, cursor); +- XRecolorCursor(xw.dpy, cursor, +- &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, +- &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); ++ xw.cursor = XCreateFontCursor(xw.dpy, XC_xterm); ++ XDefineCursor(xw.dpy, xw.win, xw.cursor); ++ XRecolorCursor(xw.dpy, xw.cursor, &xcwhite, &xcblack); ++ xw.cursorstate = true; ++ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1); ++ xw.bcursor = XCreatePixmapCursor(xw.dpy, blankpm, blankpm, ++ &xcblack, &xcblack, 0, 0); + + xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); + xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); +@@ -3533,6 +3546,8 @@ unmap(XEvent *ev) { + + void + xsetpointermotion(int set) { ++ if(!set && !xw.cursorstate) ++ return; + MODBIT(xw.attrs.event_mask, set, PointerMotionMask); + XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); + } +@@ -3626,6 +3641,12 @@ kpress(XEvent *ev) { + Status status; + Shortcut *bp; + ++ if(xw.cursorstate) { ++ XDefineCursor(xw.dpy, xw.win, xw.bcursor); ++ xsetpointermotion(1); ++ xw.cursorstate = false; ++ } ++ + if(IS_SET(MODE_KBDLOCK)) + return; + +-- +2.0.0 +