Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/devdraw: make "big arrow" the default cursor in X11 #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions src/cmd/devdraw/x11-screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <thread.h>
#include "x11-memdraw.h"
#include "devdraw.h"
#include "bigarrow.h"

#undef time

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -731,6 +733,8 @@ xattach(Client *client, char *label, char *winsize)
XFreePixmap(_x.display, pmid);
}

_xsetcursor(w, nil);

return w->screenimage;
}

Expand Down Expand Up @@ -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]);
Expand All @@ -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();
}

Expand Down