From 2da86b690ac69f50dde992416bc4cacccf72903e Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 15 Dec 2021 20:27:14 +0100 Subject: [PATCH] cmd/devdraw: make "big arrow" the default cursor in X11 --- src/cmd/devdraw/x11-screen.c | 39 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 0bbc25d69..5caa1a5a4 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -12,6 +12,7 @@ #include #include "x11-memdraw.h" #include "devdraw.h" +#include "bigarrow.h" #undef time @@ -39,6 +40,7 @@ static int _xtoplan9mouse(Xwin *w, XEvent *e, Mouse *m); static void _xmovewindow(Xwin *w, Rectangle r); static int _xtoplan9kbd(XEvent *e); static int _xselect(XEvent *e); +static void _xsetcursor(Xwin *w, Cursor *c); static void rpc_resizeimg(Client*); static void rpc_resizewindow(Client*, Rectangle); @@ -731,6 +733,8 @@ xattach(Client *client, char *label, char *winsize) XFreePixmap(_x.display, pmid); } + _xsetcursor(w, nil); + return w->screenimage; } @@ -1375,35 +1379,17 @@ revbyte(int b) } static void -xcursorarrow(Xwin *w) +_xsetcursor(Xwin *w, Cursor *c) { - if(_x.cursor != 0){ - XFreeCursor(_x.display, _x.cursor); - _x.cursor = 0; - } - XUndefineCursor(_x.display, w->drawable); - XFlush(_x.display); -} - - -void -rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) -{ - Xwin *w = (Xwin*)client->view; XColor fg, bg; XCursor xc; Pixmap xsrc, xmask; int i; uchar src[2*16], mask[2*16]; - USED(c2); + if(c == nil) + c = &bigarrow; - xlock(); - if(c == nil){ - xcursorarrow(w); - xunlock(); - return; - } for(i=0; i<2*16; i++){ src[i] = revbyte(c->set[i]); mask[i] = revbyte(c->set[i] | c->clr[i]); @@ -1423,6 +1409,17 @@ rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) XFreePixmap(_x.display, xsrc); XFreePixmap(_x.display, xmask); XFlush(_x.display); +} + +void +rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) +{ + Xwin *w = (Xwin*)client->view; + + USED(c2); + + xlock(); + _xsetcursor(w, c); xunlock(); }