[wiki] [sites] Add patch "Hide X cursor" to st patches page. || Colona

From: <git_AT_suckless.org>
Date: Mon, 09 Jun 2014 10:16:19 +0200

commit 8a2630787a02654229cd7994904be11c47e4290a
Author: Colona <colona_AT_ycc.fr>
Date: Mon Jun 9 01:13:47 2014 -0700

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

diff --git a/st.suckless.org/patches/hide_X_cursor.md b/st.suckless.org/patches/hide_X_cursor.md
new file mode 100644
index 0000000..a3aafdd
--- /dev/null
+++ b/st.suckless.org/patches/hide_X_cursor.md
_AT_@ -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
new file mode 100644
index 0000000..3bbe602
--- /dev/null
+++ b/st.suckless.org/patches/st-0.5-hidexcursor.diff
_AT_@ -0,0 +1,96 @@
+From d081963fc75e1656f5ee4305947384a00b9e5f39 Mon Sep 17 00:00:00 2001
+From: Colona <colona_AT_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
+_AT_@ -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 */
+_AT_@ -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;
+_AT_@ -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
");
+_AT_@ -3071,11 +3082,13 @@ xinit(void) {
+ die("XCreateIC failed. Could not obtain input method.
");
+
+ /* 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);
+_AT_@ -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);
+ }
+_AT_@ -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
new file mode 100644
index 0000000..2087436
--- /dev/null
+++ b/st.suckless.org/patches/st-git-hidexcursor.diff
_AT_@ -0,0 +1,95 @@
+From 724b832c56384bb770fe6bd09ef38c7ac5657228 Mon Sep 17 00:00:00 2001
+From: Colona <colona_AT_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
+_AT_@ -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 */
+_AT_@ -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;
+_AT_@ -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
");
+_AT_@ -3073,11 +3084,13 @@ xinit(void) {
+ die("XCreateIC failed. Could not obtain input method.
");
+
+ /* 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);
+_AT_@ -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);
+ }
+_AT_@ -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
+
Received on Mon Jun 09 2014 - 10:16:19 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:39:01 CEST