[wiki] [sites] st/patches/hide_X_cursor: refresh the git version || Ivan Delalande

From: <git_AT_suckless.org>
Date: Thu, 30 Jul 2015 11:14:44 +0200

commit 096335345af81cc9871297d104550f71de2aa79b
Author: Ivan Delalande <colona_AT_ycc.fr>
Date: Thu Jul 30 02:07:50 2015 -0700

    st/patches/hide_X_cursor: refresh the git version
    
    We now use mouseshape introduced in ee5cad4, this simplifies a bit the changes
    in xinit() as well.

diff --git a/st.suckless.org/patches/st-git-hidexcursor.diff b/st.suckless.org/patches/st-git-hidexcursor.diff
index bf91bb5..f83ba89 100644
--- a/st.suckless.org/patches/st-git-hidexcursor.diff
+++ b/st.suckless.org/patches/st-git-hidexcursor.diff
_AT_@ -1,21 +1,21 @@
-From e428b2c12c6e471f5134c9c886eaf850a0e3c4f2 Mon Sep 17 00:00:00 2001
+From 679b7353a8a6146c81f9fbb5a4012324e87f8008 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.
+Date: Thu, 30 Jul 2015 01:53:26 -0700
+Subject: [PATCH] Hide X mouse 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(-)
+ st.c | 32 ++++++++++++++++++++++++++++----
+ 1 file changed, 28 insertions(+), 4 deletions(-)
 
 diff --git a/st.c b/st.c
-index b052b2b..3f703f6 100644
+index 1df4fde..96b58e3 100644
 --- a/st.c
 +++ b/st.c
-_AT_@ -256,6 +256,11 @@ typedef struct {
+_AT_@ -258,6 +258,11 @@ typedef struct {
          Draw draw;
          Visual *vis;
          XSetWindowAttributes attrs;
_AT_@ -27,8 +27,8 @@ index b052b2b..3f703f6 100644
          int scr;
          int isfixed; /* is fixed geometry? */
          int l, t; /* left and top offset */
-_AT_@ -1180,6 +1185,13 @@ void
- bmotion(XEvent *e) {
+_AT_@ -1285,6 +1290,13 @@ bmotion(XEvent *e)
+ {
          int oldey, oldex, oldsby, oldsey;
  
 + if(!xw.pointerisvisible) {
_AT_@ -38,51 +38,55 @@ index b052b2b..3f703f6 100644
 + xsetpointermotion(0);
 + }
 +
- if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
                  mousereport(e);
                  return;
-_AT_@ -3179,9 +3191,11 @@ xzoomreset(const Arg *arg) {
- void
- xinit(void) {
+_AT_@ -3408,10 +3420,10 @@ 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};
+ XColor xmousefg, xmousebg;
 + Pixmap blankpm;
  
- if(!(xw.dpy = XOpenDisplay(NULL)))
+ if (!(xw.dpy = XOpenDisplay(NULL)))
                  die("Can't open display
");
-_AT_@ -3254,11 +3268,13 @@ xinit(void) {
+_AT_@ -3484,8 +3496,9 @@ xinit(void)
                  die("XCreateIC failed. Could not obtain input method.
");
  
          /* white cursor, black outline */
-- cursor = XCreateFontCursor(xw.dpy, XC_xterm);
+- cursor = XCreateFontCursor(xw.dpy, mouseshape);
 - 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 = 1;
++ xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
++ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
+ xmousefg.red = 0xffff;
+_AT_@ -3499,7 +3512,10 @@ xinit(void)
+ xmousebg.blue = 0x0000;
+ }
+
+- XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
++ XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
 + blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
 + xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
-+ &xcblack, &xcblack, 0, 0);
++ &xmousefg, &xmousebg, 0, 0);
  
          xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
          xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
-_AT_@ -3721,6 +3737,8 @@ unmap(XEvent *ev) {
-
+_AT_@ -3974,6 +3990,8 @@ unmap(XEvent *ev)
  void
- xsetpointermotion(int set) {
+ xsetpointermotion(int set)
+ {
 + if(!set && !xw.pointerisvisible)
 + return;
          MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
          XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
  }
-_AT_@ -3814,6 +3832,12 @@ kpress(XEvent *ev) {
+_AT_@ -4073,6 +4091,12 @@ kpress(XEvent *ev)
          Status status;
          Shortcut *bp;
  
_AT_@ -92,9 +96,9 @@ index b052b2b..3f703f6 100644
 + xw.pointerisvisible = 0;
 + }
 +
- if(IS_SET(MODE_KBDLOCK))
+ if (IS_SET(MODE_KBDLOCK))
                  return;
  
 --
-2.4.5
+2.4.6
 
Received on Thu Jul 30 2015 - 11:14:44 CEST

This archive was generated by hypermail 2.3.0 : Thu Jul 30 2015 - 11:24:11 CEST