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