[wiki] [sites] st hide_X_cursor patch: update for st 0.6 + FRIGN messing with st's style || Ivan Delalande
commit 7be2de1e3ea89d7c59cad678f227694d4b33215a
Author: Ivan Delalande <colona_AT_ycc.fr>
Date: Thu Jul 9 20:38:37 2015 -0700
st hide_X_cursor patch: update for st 0.6 + FRIGN messing with st's style
diff --git a/st.suckless.org/patches/hide_X_cursor.md b/st.suckless.org/patches/hide_X_cursor.md
index a3aafdd..7bb4d48 100644
--- a/st.suckless.org/patches/hide_X_cursor.md
+++ b/st.suckless.org/patches/hide_X_cursor.md
_AT_@ -11,6 +11,7 @@ Download
--------
* [st-0.5-hidexcursor.diff](st-0.5-hidexcursor.diff)
+* [st-0.6-hidexcursor.diff](st-0.6-hidexcursor.diff)
* [st-git-hidexcursor.diff](st-git-hidexcursor.diff)
Author
diff --git a/st.suckless.org/patches/st-0.6-hidexcursor.diff b/st.suckless.org/patches/st-0.6-hidexcursor.diff
new file mode 100644
index 0000000..f5d2142
--- /dev/null
+++ b/st.suckless.org/patches/st-0.6-hidexcursor.diff
_AT_@ -0,0 +1,100 @@
+From 700158aa952756a52b043fa6c665053d48cb2de2 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.
+
+[ s/cursor/pointer - Alex Pilon ]
+---
+ st.c | 36 ++++++++++++++++++++++++++++++------
+ 1 file changed, 30 insertions(+), 6 deletions(-)
+
+diff --git a/st.c b/st.c
+index 39d3fee..b95a4a5 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -248,6 +248,11 @@ typedef struct {
+ Draw draw;
+ Visual *vis;
+ XSetWindowAttributes attrs;
++ /* Here, we use the term *pointer* to differentiate the cursor
++ * one sees when hovering the mouse over the terminal from, e.g.,
++ * a green rectangle where text would be entered. */
++ Cursor vpointer, bpointer; /* visible and hidden pointers */
++ bool pointerisvisible;
+ int scr;
+ bool isfixed; /* is fixed geometry? */
+ int l, t; /* left and top offset */
+_AT_@ -1155,6 +1160,13 @@ void
+ bmotion(XEvent *e) {
+ int oldey, oldex, oldsby, oldsey;
+
++ if(!xw.pointerisvisible) {
++ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
++ xw.pointerisvisible = true;
++ if(!IS_SET(MODE_MOUSEMANY))
++ xsetpointermotion(0);
++ }
++
+ if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
+ mousereport(e);
+ return;
+_AT_@ -3173,9 +3185,11 @@ xzoomreset(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_@ -3248,11 +3262,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.vpointer = XCreateFontCursor(xw.dpy, XC_xterm);
++ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
++ XRecolorCursor(xw.dpy, xw.vpointer, &xcwhite, &xcblack);
++ xw.pointerisvisible = true;
++ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
++ xw.bpointer = 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_@ -3739,6 +3755,8 @@ unmap(XEvent *ev) {
+
+ void
+ xsetpointermotion(int set) {
++ if(!set && !xw.pointerisvisible)
++ return;
+ MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
+ XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
+ }
+_AT_@ -3832,6 +3850,12 @@ kpress(XEvent *ev) {
+ Status status;
+ Shortcut *bp;
+
++ if(xw.pointerisvisible) {
++ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
++ xsetpointermotion(1);
++ xw.pointerisvisible = false;
++ }
++
+ if(IS_SET(MODE_KBDLOCK))
+ return;
+
+--
+2.3.3
+
diff --git a/st.suckless.org/patches/st-git-hidexcursor.diff b/st.suckless.org/patches/st-git-hidexcursor.diff
index f5d2142..bf91bb5 100644
--- a/st.suckless.org/patches/st-git-hidexcursor.diff
+++ b/st.suckless.org/patches/st-git-hidexcursor.diff
_AT_@ -1,6 +1,6 @@
-From 700158aa952756a52b043fa6c665053d48cb2de2 Mon Sep 17 00:00:00 2001
-From: Colona <colona_AT_ycc.fr>
-Date: Mon, 9 Jun 2014 01:00:20 -0700
+From e428b2c12c6e471f5134c9c886eaf850a0e3c4f2 Mon Sep 17 00:00:00 2001
+From: Ivan Delalande <colona_AT_ycc.fr>
+Date: Thu, 9 Jul 2015 20:24:23 -0700
Subject: [PATCH] Hide X cursor when typing.
Hide the X cursor when typing in the terminal. The cursor is displayed again
_AT_@ -12,10 +12,10 @@ when the mouse is moved.
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/st.c b/st.c
-index 39d3fee..b95a4a5 100644
+index b052b2b..3f703f6 100644
--- a/st.c
+++ b/st.c
-_AT_@ -248,6 +248,11 @@ typedef struct {
+_AT_@ -256,6 +256,11 @@ typedef struct {
Draw draw;
Visual *vis;
XSetWindowAttributes attrs;
_AT_@ -23,17 +23,17 @@ index 39d3fee..b95a4a5 100644
+ * one sees when hovering the mouse over the terminal from, e.g.,
+ * a green rectangle where text would be entered. */
+ Cursor vpointer, bpointer; /* visible and hidden pointers */
-+ bool pointerisvisible;
++ int pointerisvisible;
int scr;
- bool isfixed; /* is fixed geometry? */
+ int isfixed; /* is fixed geometry? */
int l, t; /* left and top offset */
-_AT_@ -1155,6 +1160,13 @@ void
+_AT_@ -1180,6 +1185,13 @@ void
bmotion(XEvent *e) {
int oldey, oldex, oldsby, oldsey;
+ if(!xw.pointerisvisible) {
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
-+ xw.pointerisvisible = true;
++ xw.pointerisvisible = 1;
+ if(!IS_SET(MODE_MOUSEMANY))
+ xsetpointermotion(0);
+ }
_AT_@ -41,7 +41,7 @@ index 39d3fee..b95a4a5 100644
if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
mousereport(e);
return;
-_AT_@ -3173,9 +3185,11 @@ xzoomreset(const Arg *arg) {
+_AT_@ -3179,9 +3191,11 @@ xzoomreset(const Arg *arg) {
void
xinit(void) {
XGCValues gcvalues;
_AT_@ -54,7 +54,7 @@ index 39d3fee..b95a4a5 100644
if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display
");
-_AT_@ -3248,11 +3262,13 @@ xinit(void) {
+_AT_@ -3254,11 +3268,13 @@ xinit(void) {
die("XCreateIC failed. Could not obtain input method.
");
/* white cursor, black outline */
_AT_@ -66,14 +66,14 @@ index 39d3fee..b95a4a5 100644
+ xw.vpointer = XCreateFontCursor(xw.dpy, XC_xterm);
+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+ XRecolorCursor(xw.dpy, xw.vpointer, &xcwhite, &xcblack);
-+ xw.pointerisvisible = true;
++ xw.pointerisvisible = 1;
+ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
+ xw.bpointer = 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_@ -3739,6 +3755,8 @@ unmap(XEvent *ev) {
+_AT_@ -3721,6 +3737,8 @@ unmap(XEvent *ev) {
void
xsetpointermotion(int set) {
_AT_@ -82,19 +82,19 @@ index 39d3fee..b95a4a5 100644
MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
}
-_AT_@ -3832,6 +3850,12 @@ kpress(XEvent *ev) {
+_AT_@ -3814,6 +3832,12 @@ kpress(XEvent *ev) {
Status status;
Shortcut *bp;
+ if(xw.pointerisvisible) {
+ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
+ xsetpointermotion(1);
-+ xw.pointerisvisible = false;
++ xw.pointerisvisible = 0;
+ }
+
if(IS_SET(MODE_KBDLOCK))
return;
--
-2.3.3
+2.4.5
Received on Fri Jul 10 2015 - 05:39:50 CEST
This archive was generated by hypermail 2.3.0
: Fri Jul 10 2015 - 05:48:11 CEST