commit 1518dba7f66887938cb1785e419404d05886c466
Author: Alex Pilon <[email protected]>
Date:   Mon Mar 23 18:25:34 2015 -0400

    Update hide X cursor patch to work with latest master.
    
    The patch predates and conflicts with 580302f (Support the DECSCUSR CSI
    escape sequence) because they both introduced a 'cursor' member in
    struct XWindow.

diff --git a/st.suckless.org/patches/st-git-hidexcursor.diff 
b/st.suckless.org/patches/st-git-hidexcursor.diff
index 2087436..f5d2142 100644
--- a/st.suckless.org/patches/st-git-hidexcursor.diff
+++ b/st.suckless.org/patches/st-git-hidexcursor.diff
@@ -1,34 +1,39 @@
-From 724b832c56384bb770fe6bd09ef38c7ac5657228 Mon Sep 17 00:00:00 2001
+From 700158aa952756a52b043fa6c665053d48cb2de2 Mon Sep 17 00:00:00 2001
 From: Colona <[email protected]>
 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 | 33 +++++++++++++++++++++++++++------
- 1 file changed, 27 insertions(+), 6 deletions(-)
+ st.c | 36 ++++++++++++++++++++++++++++++------
+ 1 file changed, 30 insertions(+), 6 deletions(-)
 
 diff --git a/st.c b/st.c
-index 3681776..53b7e70 100644
+index 39d3fee..b95a4a5 100644
 --- a/st.c
 +++ b/st.c
-@@ -249,6 +249,8 @@ typedef struct {
+@@ -248,6 +248,11 @@ typedef struct {
        Draw draw;
        Visual *vis;
        XSetWindowAttributes attrs;
-+      Cursor cursor, bcursor; /* visible and blank cursors */
-+      bool cursorstate; /* is cursor currently visible */
++      /* 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 */
-@@ -1115,6 +1117,13 @@ void
+@@ -1155,6 +1160,13 @@ void
  bmotion(XEvent *e) {
        int oldey, oldex, oldsby, oldsey;
  
-+      if(!xw.cursorstate) {
-+              XDefineCursor(xw.dpy, xw.win, xw.cursor);
-+              xw.cursorstate = true;
++      if(!xw.pointerisvisible) {
++              XDefineCursor(xw.dpy, xw.win, xw.vpointer);
++              xw.pointerisvisible = true;
 +              if(!IS_SET(MODE_MOUSEMANY))
 +                      xsetpointermotion(0);
 +      }
@@ -36,7 +41,7 @@ index 3681776..53b7e70 100644
        if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
                mousereport(e);
                return;
-@@ -2998,9 +3007,11 @@ xzoom(const Arg *arg) {
+@@ -3173,9 +3185,11 @@ xzoomreset(const Arg *arg) {
  void
  xinit(void) {
        XGCValues gcvalues;
@@ -49,7 +54,7 @@ index 3681776..53b7e70 100644
  
        if(!(xw.dpy = XOpenDisplay(NULL)))
                die("Can't open display
");
-@@ -3073,11 +3084,13 @@ xinit(void) {
+@@ -3248,11 +3262,13 @@ xinit(void) {
                die("XCreateIC failed. Could not obtain input method.
");
  
        /* white cursor, black outline */
@@ -58,38 +63,38 @@ index 3681776..53b7e70 100644
 -      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;
++      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.bcursor = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
-+                                                                   &xcblack, 
&xcblack, 0, 0);
++      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);
-@@ -3533,6 +3546,8 @@ unmap(XEvent *ev) {
+@@ -3739,6 +3755,8 @@ unmap(XEvent *ev) {
  
  void
  xsetpointermotion(int set) {
-+      if(!set && !xw.cursorstate)
++      if(!set && !xw.pointerisvisible)
 +              return;
        MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
        XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
  }
-@@ -3626,6 +3641,12 @@ kpress(XEvent *ev) {
+@@ -3832,6 +3850,12 @@ kpress(XEvent *ev) {
        Status status;
        Shortcut *bp;
  
-+      if(xw.cursorstate) {
-+              XDefineCursor(xw.dpy, xw.win, xw.bcursor);
++      if(xw.pointerisvisible) {
++              XDefineCursor(xw.dpy, xw.win, xw.bpointer);
 +              xsetpointermotion(1);
-+              xw.cursorstate = false;
++              xw.pointerisvisible = false;
 +      }
 +
        if(IS_SET(MODE_KBDLOCK))
                return;
  
 -- 
-2.0.0
+2.3.3
 


Reply via email to