mirror of
https://github.com/0intro/wmii
synced 2024-11-22 22:02:30 +03:00
Changed the behavior of dragging moving windows to better move them offscreen. Added function prototype to wmii.h.
This commit is contained in:
parent
cd1c1a1bd9
commit
4fd35b90d0
15
client.c
15
client.c
@ -465,7 +465,6 @@ void
|
||||
resize_client(Client *c, XRectangle *r, Bool ignore_xcall) {
|
||||
Frame *f = c->sel;
|
||||
Bool floating = f->area->floating;
|
||||
int max_height;
|
||||
|
||||
BlitzAlign stickycorner = 0;
|
||||
if(f->rect.x != r->x && f->rect.x + f->rect.width == r->x + r->width)
|
||||
@ -479,7 +478,6 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall) {
|
||||
f->rect = *r;
|
||||
if((f->area->mode != Colstack) || (f->area->sel == f))
|
||||
match_sizehints(c, &c->sel->rect, floating, stickycorner);
|
||||
max_height = screen->rect.height - labelh(&def.font);
|
||||
if(!ignore_xcall) {
|
||||
if(floating) {
|
||||
if((c->rect.width == screen->rect.width) &&
|
||||
@ -487,18 +485,7 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall) {
|
||||
f->rect.x = -def.border;
|
||||
f->rect.y = -labelh(&def.font);
|
||||
}else{
|
||||
if(f->rect.height > max_height)
|
||||
f->rect.height = max_height;
|
||||
if(f->rect.width > screen->rect.width)
|
||||
f->rect.width = screen->rect.width;
|
||||
if(f->rect.x + screen->brect.height > screen->rect.width)
|
||||
f->rect.x = screen->rect.width - screen->brect.height;
|
||||
if(f->rect.y + screen->brect.height > max_height)
|
||||
f->rect.y = max_height - screen->brect.height;
|
||||
if(f->rect.x + f->rect.width < screen->brect.height)
|
||||
f->rect.x = screen->brect.height - f->rect.width;
|
||||
if(f->rect.y + f->rect.height < screen->brect.height)
|
||||
f->rect.y = screen->brect.height - f->rect.height;
|
||||
check_frame_constraints(&f->rect);
|
||||
}
|
||||
}
|
||||
if(f->area->view == screen->sel)
|
||||
|
@ -19,7 +19,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -L${PREFIX}/lib -lixp -lm
|
||||
# flags
|
||||
#CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
CFLAGS = -g -Wall ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = -g ${LIBS}
|
||||
|
||||
# Solaris
|
||||
|
19
frame.c
19
frame.c
@ -101,3 +101,22 @@ draw_frames() {
|
||||
draw_frame(c->sel);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
check_frame_constraints(XRectangle *rect) {
|
||||
int max_height;
|
||||
max_height = screen->rect.height - labelh(&def.font);
|
||||
|
||||
if(rect->height > max_height)
|
||||
rect->height = max_height;
|
||||
if(rect->width > screen->rect.width)
|
||||
rect->width = screen->rect.width;
|
||||
if(rect->x + screen->brect.height > screen->rect.width)
|
||||
rect->x = screen->rect.width - screen->brect.height;
|
||||
if(rect->y + screen->brect.height > max_height)
|
||||
rect->y = max_height - screen->brect.height;
|
||||
if(rect->x + rect->width < screen->brect.height)
|
||||
rect->x = screen->brect.height - rect->width;
|
||||
if(rect->y + rect->height < screen->brect.height)
|
||||
rect->y = screen->brect.height - rect->height;
|
||||
}
|
||||
|
9
main.c
9
main.c
@ -103,10 +103,19 @@ init_atoms() {
|
||||
|
||||
static void
|
||||
init_cursors() {
|
||||
Pixmap pix;
|
||||
XColor black, dummy;
|
||||
|
||||
XAllocNamedColor(blz.dpy, DefaultColormap(blz.dpy, blz.screen), "black", &black, &dummy);
|
||||
pix = XCreateBitmapFromData(blz.dpy, blz.root, (char[]){0}, 1, 1);
|
||||
|
||||
cursor[CurNormal] = XCreateFontCursor(blz.dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(blz.dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(blz.dpy, XC_fleur);
|
||||
cursor[CurInput] = XCreateFontCursor(blz.dpy, XC_xterm);
|
||||
cursor[CurInvisible] = XCreatePixmapCursor(blz.dpy, pix, pix, &black, &black, 0, 0);
|
||||
|
||||
XFreePixmap(blz.dpy, pix);
|
||||
}
|
||||
|
||||
static void
|
||||
|
48
mouse.c
48
mouse.c
@ -162,7 +162,8 @@ draw_xor_border(XRectangle *r) {
|
||||
void
|
||||
do_mouse_resize(Client *c, BlitzAlign align) {
|
||||
BlitzAlign grav;
|
||||
int px, py, ox, oy, i;
|
||||
Cursor cur;
|
||||
int px, py, ox, oy, hr_x, hr_y, i;
|
||||
float rx, ry;
|
||||
Window dummy;
|
||||
XEvent ev;
|
||||
@ -178,7 +179,9 @@ do_mouse_resize(Client *c, BlitzAlign align) {
|
||||
XQueryPointer(blz.dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &di);
|
||||
rx = (float)ox / frect.width;
|
||||
ry = (float)oy / frect.height;
|
||||
if (floating || align != CENTER) {
|
||||
cur = cursor[CurResize];
|
||||
|
||||
if (align != CENTER) {
|
||||
px = ox = frect.width / 2;
|
||||
py = oy = frect.height / 2;
|
||||
if(align&NORTH)
|
||||
@ -190,12 +193,18 @@ do_mouse_resize(Client *c, BlitzAlign align) {
|
||||
if(align&WEST)
|
||||
ox -= px;
|
||||
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0, ox, oy);
|
||||
} else if(floating) {
|
||||
hr_x = screen->rect.width / 2;
|
||||
hr_y = screen->rect.height / 2;
|
||||
XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
|
||||
cur = cursor[CurInvisible];
|
||||
}
|
||||
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ox, oy, &ox, &oy, &dummy);
|
||||
pt.x = ox; pt.y = oy;
|
||||
XSync(blz.dpy, False);
|
||||
if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
None, cur, CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XGrabServer(blz.dpy);
|
||||
draw_xor_border(&frect);
|
||||
@ -213,24 +222,43 @@ do_mouse_resize(Client *c, BlitzAlign align) {
|
||||
XUngrabServer(blz.dpy);
|
||||
XUngrabPointer(blz.dpy, CurrentTime);
|
||||
XSync(blz.dpy, False);
|
||||
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0,
|
||||
frect.width * rx, frect.height * ry);
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
|
||||
frect.width * rx, frect.height * ry,
|
||||
&px, &py, &dummy);
|
||||
if(py > screen->brect.y)
|
||||
py = screen->brect.y - 1;
|
||||
XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, px, py);
|
||||
return;
|
||||
break;
|
||||
case MotionNotify:
|
||||
ofrect = frect;
|
||||
pt.x = ev.xmotion.x;
|
||||
pt.y = ev.xmotion.y;
|
||||
XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ev.xmotion.x,
|
||||
ev.xmotion.y, &px, &py, &dummy);
|
||||
px = ev.xmotion.x_root;
|
||||
py = ev.xmotion.y_root;
|
||||
|
||||
if(floating && align == CENTER) {
|
||||
if(px == hr_x && py == hr_y)
|
||||
continue;
|
||||
XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
|
||||
px = px - hr_x + ox;
|
||||
py = py - hr_y + oy;
|
||||
}
|
||||
|
||||
pt.x = px;
|
||||
pt.y = py;
|
||||
|
||||
rect_morph_xy(&origin, px-ox, py-oy, &align);
|
||||
if(floating);
|
||||
check_frame_constraints(&origin);
|
||||
frect=origin;
|
||||
ox=px; oy=py;
|
||||
ox=px;
|
||||
oy=py;
|
||||
|
||||
if(floating)
|
||||
grav = snap_rect(rects, num, &frect, &align, snap);
|
||||
else
|
||||
grav = align ^ CENTER;
|
||||
match_sizehints(c, &frect, floating, grav);
|
||||
|
||||
draw_xor_border(&ofrect);
|
||||
draw_xor_border(&frect);
|
||||
break;
|
||||
|
4
wmii.h
4
wmii.h
@ -76,7 +76,7 @@ enum { NetSupported, NetWMName, NetLast };
|
||||
enum { Coldefault, Colstack, Colmax };
|
||||
|
||||
/* Cursor */
|
||||
enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
|
||||
enum { CurNormal, CurResize, CurMove, CurInput, CurInvisible, CurLast };
|
||||
|
||||
enum { NCOL = 16 };
|
||||
enum { WM_PROTOCOL_DELWIN = 1 };
|
||||
@ -253,6 +253,7 @@ extern Client *sel_client_of_area(Area *a);
|
||||
extern Bar *create_bar(Bar **b_link, char *name);
|
||||
extern void destroy_bar(Bar **b_link, Bar *b);
|
||||
extern void draw_bar(WMScreen *s);
|
||||
void draw_border(BlitzBrush *b);
|
||||
extern void resize_bar();
|
||||
extern Bar *bar_of_name(Bar *b_link, const char *name);
|
||||
|
||||
@ -318,6 +319,7 @@ extern void insert_frame(Frame *pos, Frame *f, Bool before);
|
||||
extern void draw_frame(Frame *f);
|
||||
extern void draw_frames();
|
||||
extern void update_frame_widget_colors(Frame *f);
|
||||
void check_frame_constraints(XRectangle *rect);
|
||||
|
||||
/* fs.c */
|
||||
extern void fs_attach(P9Req *r);
|
||||
|
Loading…
Reference in New Issue
Block a user