Mouse/Frame: Add resize corner area left and mouse resize left and right.
This commit is contained in:
parent
73f04fa5ac
commit
cb1cfb5d8e
@ -228,7 +228,7 @@ client_focus(Client *c)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c && c->resize != w; c = c->next);
|
||||
for(c = clients; (c && c->resize[Right] != w) && (c && c->resize[Left] != w); c = c->next);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
25
src/frame.c
25
src/frame.c
@ -100,13 +100,19 @@ frame_create(Client *c)
|
||||
at.event_mask &= ~(EnterWindowMask | LeaveWindowMask); /* <- Delete useless mask */
|
||||
|
||||
/* Create resize area */
|
||||
at.cursor = cursor[CurResize];
|
||||
CWIN(c->resize, c->frame,
|
||||
at.cursor = cursor[CurRightResize];
|
||||
CWIN(c->resize[Right], c->frame,
|
||||
c->frame_geo.width - RESHW,
|
||||
c->frame_geo.height - RESHW,
|
||||
RESHW,
|
||||
RESHW, 0,
|
||||
CWEventMask|CWBackPixel|CWCursor,
|
||||
RESHW, RESHW, 0,
|
||||
CWEventMask | CWBackPixel | CWCursor,
|
||||
c->colors.resizecorner, &at);
|
||||
|
||||
at.cursor = cursor[CurLeftResize];
|
||||
CWIN(c->resize[Left], c->frame,
|
||||
0, c->frame_geo.height - RESHW,
|
||||
RESHW, RESHW, 0,
|
||||
CWEventMask | CWBackPixel | CWCursor,
|
||||
c->colors.resizecorner, &at);
|
||||
|
||||
/* Border (for shadow) */
|
||||
@ -170,7 +176,8 @@ frame_moveresize(Client *c, XRectangle geo)
|
||||
barwin_resize(c->titlebar, c->frame_geo.width, TBARH);
|
||||
|
||||
/* Resize area */
|
||||
XMoveWindow(dpy, c->resize, c->frame_geo.width - RESHW, c->frame_geo.height - RESHW);
|
||||
XMoveWindow(dpy, c->resize[Right], c->frame_geo.width - RESHW, c->frame_geo.height - RESHW);
|
||||
XMoveWindow(dpy, c->resize[Left], 0, c->frame_geo.height - RESHW);
|
||||
|
||||
/* Border */
|
||||
if(conf.client.border_shadow)
|
||||
@ -230,9 +237,11 @@ frame_update(Client *c)
|
||||
}
|
||||
|
||||
XSetWindowBackground(dpy, c->frame, c->colors.frame);
|
||||
XSetWindowBackground(dpy, c->resize, c->colors.resizecorner);
|
||||
XSetWindowBackground(dpy, c->resize[Right], c->colors.resizecorner);
|
||||
XSetWindowBackground(dpy, c->resize[Left], c->colors.resizecorner);
|
||||
XClearWindow(dpy, c->frame);
|
||||
XClearWindow(dpy, c->resize);
|
||||
XClearWindow(dpy, c->resize[Right]);
|
||||
XClearWindow(dpy, c->resize[Left]);
|
||||
|
||||
|
||||
if(conf.client.border_shadow)
|
||||
|
||||
@ -99,9 +99,11 @@ init_gc(void)
|
||||
void
|
||||
init_cursor(void)
|
||||
{
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurRightResize] = XCreateFontCursor(dpy, XC_lr_angle);
|
||||
cursor[CurLeftResize] = XCreateFontCursor(dpy, XC_ll_angle);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
30
src/mouse.c
30
src/mouse.c
@ -168,6 +168,7 @@ mouse_resize(Client *c)
|
||||
XRectangle geo = c->geo, ogeo = c->geo;
|
||||
int ocx = c->geo.x;
|
||||
int ocy = c->geo.y;
|
||||
Position pos = Right;
|
||||
XEvent ev;
|
||||
Window w;
|
||||
int d, u, omx, omy;
|
||||
@ -179,10 +180,15 @@ mouse_resize(Client *c)
|
||||
|| c->state_fullscreen || c->state_dock)
|
||||
return;
|
||||
|
||||
|
||||
XQueryPointer(dpy, ROOT, &w, &w, &omx, &omy, &d, &d, (uint *)&u);
|
||||
|
||||
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
if((omx - c->geo.x) < (c->geo.width / 2))
|
||||
pos = Left;
|
||||
|
||||
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync, None,
|
||||
cursor[((c->tile) ? CurResize : ((pos == Right) ? CurRightResize : CurLeftResize))],
|
||||
CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
|
||||
XGrabServer(dpy);
|
||||
@ -195,7 +201,10 @@ mouse_resize(Client *c)
|
||||
|
||||
if(!c->tile)
|
||||
{
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width + conf.client.borderheight, c->geo.height);
|
||||
if(pos == Right)
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width + conf.client.borderheight, c->geo.height);
|
||||
else
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, 0, c->geo.height);
|
||||
mouse_dragborder(c->geo, gci);
|
||||
}
|
||||
|
||||
@ -227,8 +236,19 @@ mouse_resize(Client *c)
|
||||
{
|
||||
mouse_dragborder(geo, gci);
|
||||
|
||||
geo.width = ((ev.xmotion.x - ocx <= 1) ? 1 : ev.xmotion.x - ocx);
|
||||
geo.height = ((ev.xmotion.y - ocy <= 1) ? 1 : ev.xmotion.y - ocy);
|
||||
if(pos == Right)
|
||||
{
|
||||
geo.width = ((ev.xmotion.x - ocx < c->minw) ? c->minw : ev.xmotion.x - ocx);
|
||||
geo.height = ((ev.xmotion.y - ocy < c->minh) ? c->minh : ev.xmotion.y - ocy);
|
||||
}
|
||||
else
|
||||
{
|
||||
geo.x = ocx - (ocx - ev.xmotion.x);
|
||||
geo.width = ((c->geo.width + (ocx - geo.x) < c->minw)
|
||||
? c->minw && (geo.x = (c->geo.x + c->geo.width) - c->minw)
|
||||
: c->geo.width + (ocx - geo.x));
|
||||
geo.height = ((ev.xmotion.y - ocy <= 1) ? 1 : ev.xmotion.y - ocy);
|
||||
}
|
||||
|
||||
client_geo_hints(&geo, c);
|
||||
|
||||
|
||||
@ -47,10 +47,12 @@ typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
/* Enum */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
enum { CurNormal, CurResize, CurRightResize, CurLeftResize, CurMove, CurLast };
|
||||
|
||||
/* Infobar position */
|
||||
enum { IB_Hide = 0, IB_Bottom = 1, IB_Top = 2 };
|
||||
typedef enum { Top, Bottom, Right, Left, Center, PositionLast } Position;
|
||||
|
||||
typedef enum { Right, Left, Top, Bottom, Center, PositionLast } Position;
|
||||
|
||||
|
||||
/* Ewmh hints list */
|
||||
@ -147,7 +149,7 @@ struct Client
|
||||
Window *button;
|
||||
int button_last_x;
|
||||
BarWindow *titlebar;
|
||||
Window frame, resize;
|
||||
Window frame, resize[2];
|
||||
/* Border */
|
||||
Window right, left, top, bottom;
|
||||
/* }}} */
|
||||
|
||||
@ -100,9 +100,8 @@ quit(void)
|
||||
IFREE(seltag);
|
||||
|
||||
XftFontClose(dpy, font);
|
||||
XFreeCursor(dpy, cursor[CurNormal]);
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
for(i = 0; i < CurLast; ++i)
|
||||
XFreeCursor(dpy, cursor[i]);
|
||||
XFreeGC(dpy, gc_stipple);
|
||||
infobar_destroy();
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
#define FRAMEW(w) ((w) + BORDH * 2)
|
||||
#define FRAMEH(h) ((h) + (BORDH + TBARH))
|
||||
#define ROUND(x) (float)((x > 0) ? x + (float)0.5 : x - (float)0.5)
|
||||
#define RESHW (5 * BORDH)
|
||||
#define RESHW (6 * BORDH)
|
||||
#define BUTTONWH (TBARH / 2)
|
||||
#define CHECK(x) if(!(x)) return
|
||||
#define IFREE(x) if(x) free(x)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user