diff options
| author | joe <rbo@gmx.us> | 2025-09-27 18:02:33 +0200 |
|---|---|---|
| committer | joe <rbo@gmx.us> | 2025-09-27 18:02:33 +0200 |
| commit | 512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba (patch) | |
| tree | 6dd9489526a238f21775cb7d2521928ac09db21e /x.c | |
| parent | up (diff) | |
| download | st-512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba.tar.gz st-512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba.tar.bz2 st-512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba.tar.xz st-512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba.tar.zst st-512d13d85de55f4a7d5bf3ab87c440b5eb8b8aba.zip | |
patches
Diffstat (limited to 'x.c')
| -rw-r--r-- | x.c | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -103,6 +103,8 @@ typedef struct { Draw draw; Visual *vis; XSetWindowAttributes attrs; + Cursor vpointer, bpointer; /* visible and hidden pointers */ + int pointerisvisible; int scr; int isfixed; /* is fixed geometry? */ int l, t; /* left and top offset */ @@ -716,6 +718,13 @@ brelease(XEvent *e) void bmotion(XEvent *e) { + if (!xw.pointerisvisible) { + XDefineCursor(xw.dpy, xw.win, xw.vpointer); + xw.pointerisvisible = 1; + if (!IS_SET(MODE_MOUSEMANY)) + xsetpointermotion(0); + } + if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) { mousereport(e); return; @@ -1130,10 +1139,10 @@ void xinit(int cols, int rows) { XGCValues gcvalues; - Cursor cursor; Window parent, root; pid_t thispid = getpid(); XColor xmousefg, xmousebg; + Pixmap blankpm; if (!(xw.dpy = XOpenDisplay(NULL))) die("can't open display\n"); @@ -1200,8 +1209,9 @@ xinit(int cols, int rows) } /* white cursor, black outline */ - cursor = XCreateFontCursor(xw.dpy, mouseshape); - XDefineCursor(xw.dpy, xw.win, cursor); + 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; @@ -1215,7 +1225,10 @@ xinit(int cols, int rows) 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, + &xmousefg, &xmousebg, 0, 0); xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); @@ -1415,10 +1428,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i bg = &dc.col[base.bg]; } - /* Change basic system colors [0-7] to bright system colors [8-15] */ - if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7)) - fg = &dc.col[base.fg + 8]; - if (IS_SET(MODE_REVERSE)) { if (fg == &dc.col[defaultfg]) { fg = &dc.col[defaultbg]; @@ -1730,6 +1739,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); } @@ -1849,6 +1860,12 @@ kpress(XEvent *ev) Status status; Shortcut *bp; + if (xw.pointerisvisible) { + XDefineCursor(xw.dpy, xw.win, xw.bpointer); + xsetpointermotion(1); + xw.pointerisvisible = 0; + } + if (IS_SET(MODE_KBDLOCK)) return; |
