mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
move cursor in DC
This commit is contained in:
parent
2c6a71f358
commit
c96d88975f
4 changed files with 14 additions and 15 deletions
17
awesome.c
17
awesome.c
|
@ -38,7 +38,6 @@
|
|||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
Client *stack = NULL;
|
||||
Cursor cursor[CurLast];
|
||||
DC dc;
|
||||
|
||||
/* static */
|
||||
|
@ -63,9 +62,9 @@ cleanup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
|||
XFreePixmap(disp, drawcontext->drawable);
|
||||
XFreeGC(disp, drawcontext->gc);
|
||||
XDestroyWindow(disp, awesomeconf->statusbar.window);
|
||||
XFreeCursor(disp, cursor[CurNormal]);
|
||||
XFreeCursor(disp, cursor[CurResize]);
|
||||
XFreeCursor(disp, cursor[CurMove]);
|
||||
XFreeCursor(disp, drawcontext->cursor[CurNormal]);
|
||||
XFreeCursor(disp, drawcontext->cursor[CurResize]);
|
||||
XFreeCursor(disp, drawcontext->cursor[CurMove]);
|
||||
XSetInputFocus(disp, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(disp, False);
|
||||
}
|
||||
|
@ -138,13 +137,13 @@ setup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
|||
XChangeProperty(disp, DefaultRootWindow(disp), netatom[NetSupported],
|
||||
XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(disp, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(disp, XC_fleur);
|
||||
drawcontext->cursor[CurNormal] = XCreateFontCursor(disp, XC_left_ptr);
|
||||
drawcontext->cursor[CurResize] = XCreateFontCursor(disp, XC_sizing);
|
||||
drawcontext->cursor[CurMove] = XCreateFontCursor(disp, XC_fleur);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
wa.cursor = drawcontext->cursor[CurNormal];
|
||||
XChangeWindowAttributes(disp, DefaultRootWindow(disp), CWEventMask | CWCursor, &wa);
|
||||
XSelectInput(disp, DefaultRootWindow(disp), wa.event_mask);
|
||||
grabkeys(disp, awesomeconf);
|
||||
|
@ -158,7 +157,7 @@ setup(Display *disp, DC *drawcontext, awesome_config *awesomeconf)
|
|||
DefaultDepth(disp, DefaultScreen(disp)), CopyFromParent,
|
||||
DefaultVisual(disp, DefaultScreen(disp)),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(disp, awesomeconf->statusbar.window, cursor[CurNormal]);
|
||||
XDefineCursor(disp, awesomeconf->statusbar.window, drawcontext->cursor[CurNormal]);
|
||||
updatebarpos(disp, awesomeconf->statusbar);
|
||||
XMapRaised(disp, awesomeconf->statusbar.window);
|
||||
/* pixmap for everything */
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
enum
|
||||
{ CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
|
||||
Bool gettextprop(Display *, Window, Atom, char *, unsigned int); /* return text property, UTF-8 compliant */
|
||||
void updatebarpos(Display *, Statusbar); /* updates the bar position */
|
||||
void uicb_quit(Display *, DC *, awesome_config *, const char *); /* quit awesome nicely */
|
||||
|
|
4
config.h
4
config.h
|
@ -33,6 +33,9 @@ enum
|
|||
enum
|
||||
{ ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
enum
|
||||
{ CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
@ -40,6 +43,7 @@ typedef struct
|
|||
unsigned long sel[ColLast];
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
Cursor cursor[CurLast];
|
||||
struct
|
||||
{
|
||||
int ascent;
|
||||
|
|
5
event.c
5
event.c
|
@ -32,7 +32,6 @@
|
|||
|
||||
/* extern */
|
||||
extern DC dc; /* global draw context */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern Client *clients, *sel; /* global client list */
|
||||
|
||||
#define CLEANMASK(mask) (mask & ~(awesomeconf->numlockmask | LockMask))
|
||||
|
@ -62,7 +61,7 @@ movemouse(Client * c, awesome_config *awesomeconf)
|
|||
ocx = nx = c->x;
|
||||
ocy = ny = c->y;
|
||||
if(XGrabPointer(c->display, DefaultRootWindow(c->display), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
None, dc.cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XQueryPointer(c->display, DefaultRootWindow(c->display), &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||
for(;;)
|
||||
|
@ -106,7 +105,7 @@ resizemouse(Client * c, awesome_config *awesomeconf)
|
|||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
if(XGrabPointer(c->display, DefaultRootWindow(c->display), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
None, dc.cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
c->ismax = False;
|
||||
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||
|
|
Loading…
Reference in a new issue