Changed the behavior of dragging moving windows to better move them offscreen. Added function prototype to wmii.h.

This commit is contained in:
Kris Maglione 2007-02-03 14:27:32 -05:00
parent cd1c1a1bd9
commit 4fd35b90d0
6 changed files with 71 additions and 26 deletions

View File

@ -465,7 +465,6 @@ void
resize_client(Client *c, XRectangle *r, Bool ignore_xcall) { resize_client(Client *c, XRectangle *r, Bool ignore_xcall) {
Frame *f = c->sel; Frame *f = c->sel;
Bool floating = f->area->floating; Bool floating = f->area->floating;
int max_height;
BlitzAlign stickycorner = 0; BlitzAlign stickycorner = 0;
if(f->rect.x != r->x && f->rect.x + f->rect.width == r->x + r->width) 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; f->rect = *r;
if((f->area->mode != Colstack) || (f->area->sel == f)) if((f->area->mode != Colstack) || (f->area->sel == f))
match_sizehints(c, &c->sel->rect, floating, stickycorner); match_sizehints(c, &c->sel->rect, floating, stickycorner);
max_height = screen->rect.height - labelh(&def.font);
if(!ignore_xcall) { if(!ignore_xcall) {
if(floating) { if(floating) {
if((c->rect.width == screen->rect.width) && 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.x = -def.border;
f->rect.y = -labelh(&def.font); f->rect.y = -labelh(&def.font);
}else{ }else{
if(f->rect.height > max_height) check_frame_constraints(&f->rect);
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;
} }
} }
if(f->area->view == screen->sel) if(f->area->view == screen->sel)

View File

@ -19,7 +19,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -L${PREFIX}/lib -lixp -lm
# flags # flags
#CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" #CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS} #LDFLAGS = ${LIBS}
CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" CFLAGS = -g -Wall ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = -g ${LIBS} LDFLAGS = -g ${LIBS}
# Solaris # Solaris

19
frame.c
View File

@ -101,3 +101,22 @@ draw_frames() {
draw_frame(c->sel); 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
View File

@ -103,10 +103,19 @@ init_atoms() {
static void static void
init_cursors() { 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[CurNormal] = XCreateFontCursor(blz.dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(blz.dpy, XC_sizing); cursor[CurResize] = XCreateFontCursor(blz.dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(blz.dpy, XC_fleur); cursor[CurMove] = XCreateFontCursor(blz.dpy, XC_fleur);
cursor[CurInput] = XCreateFontCursor(blz.dpy, XC_xterm); cursor[CurInput] = XCreateFontCursor(blz.dpy, XC_xterm);
cursor[CurInvisible] = XCreatePixmapCursor(blz.dpy, pix, pix, &black, &black, 0, 0);
XFreePixmap(blz.dpy, pix);
} }
static void static void

48
mouse.c
View File

@ -162,7 +162,8 @@ draw_xor_border(XRectangle *r) {
void void
do_mouse_resize(Client *c, BlitzAlign align) { do_mouse_resize(Client *c, BlitzAlign align) {
BlitzAlign grav; BlitzAlign grav;
int px, py, ox, oy, i; Cursor cur;
int px, py, ox, oy, hr_x, hr_y, i;
float rx, ry; float rx, ry;
Window dummy; Window dummy;
XEvent ev; 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); XQueryPointer(blz.dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &di);
rx = (float)ox / frect.width; rx = (float)ox / frect.width;
ry = (float)oy / frect.height; ry = (float)oy / frect.height;
if (floating || align != CENTER) { cur = cursor[CurResize];
if (align != CENTER) {
px = ox = frect.width / 2; px = ox = frect.width / 2;
py = oy = frect.height / 2; py = oy = frect.height / 2;
if(align&NORTH) if(align&NORTH)
@ -190,12 +193,18 @@ do_mouse_resize(Client *c, BlitzAlign align) {
if(align&WEST) if(align&WEST)
ox -= px; ox -= px;
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0, ox, oy); 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); XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ox, oy, &ox, &oy, &dummy);
pt.x = ox; pt.y = oy; pt.x = ox; pt.y = oy;
XSync(blz.dpy, False); XSync(blz.dpy, False);
if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync, if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
None, cursor[CurResize], CurrentTime) != GrabSuccess) None, cur, CurrentTime) != GrabSuccess)
return; return;
XGrabServer(blz.dpy); XGrabServer(blz.dpy);
draw_xor_border(&frect); draw_xor_border(&frect);
@ -213,24 +222,43 @@ do_mouse_resize(Client *c, BlitzAlign align) {
XUngrabServer(blz.dpy); XUngrabServer(blz.dpy);
XUngrabPointer(blz.dpy, CurrentTime); XUngrabPointer(blz.dpy, CurrentTime);
XSync(blz.dpy, False); XSync(blz.dpy, False);
XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0, XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
frect.width * rx, frect.height * ry); 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; return;
break; break;
case MotionNotify: case MotionNotify:
ofrect = frect; ofrect = frect;
pt.x = ev.xmotion.x; px = ev.xmotion.x_root;
pt.y = ev.xmotion.y; py = ev.xmotion.y_root;
XTranslateCoordinates(blz.dpy, c->framewin, blz.root, ev.xmotion.x,
ev.xmotion.y, &px, &py, &dummy); 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); rect_morph_xy(&origin, px-ox, py-oy, &align);
if(floating);
check_frame_constraints(&origin);
frect=origin; frect=origin;
ox=px; oy=py; ox=px;
oy=py;
if(floating) if(floating)
grav = snap_rect(rects, num, &frect, &align, snap); grav = snap_rect(rects, num, &frect, &align, snap);
else else
grav = align ^ CENTER; grav = align ^ CENTER;
match_sizehints(c, &frect, floating, grav); match_sizehints(c, &frect, floating, grav);
draw_xor_border(&ofrect); draw_xor_border(&ofrect);
draw_xor_border(&frect); draw_xor_border(&frect);
break; break;

4
wmii.h
View File

@ -76,7 +76,7 @@ enum { NetSupported, NetWMName, NetLast };
enum { Coldefault, Colstack, Colmax }; enum { Coldefault, Colstack, Colmax };
/* Cursor */ /* Cursor */
enum { CurNormal, CurResize, CurMove, CurInput, CurLast }; enum { CurNormal, CurResize, CurMove, CurInput, CurInvisible, CurLast };
enum { NCOL = 16 }; enum { NCOL = 16 };
enum { WM_PROTOCOL_DELWIN = 1 }; 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 Bar *create_bar(Bar **b_link, char *name);
extern void destroy_bar(Bar **b_link, Bar *b); extern void destroy_bar(Bar **b_link, Bar *b);
extern void draw_bar(WMScreen *s); extern void draw_bar(WMScreen *s);
void draw_border(BlitzBrush *b);
extern void resize_bar(); extern void resize_bar();
extern Bar *bar_of_name(Bar *b_link, const char *name); 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_frame(Frame *f);
extern void draw_frames(); extern void draw_frames();
extern void update_frame_widget_colors(Frame *f); extern void update_frame_widget_colors(Frame *f);
void check_frame_constraints(XRectangle *rect);
/* fs.c */ /* fs.c */
extern void fs_attach(P9Req *r); extern void fs_attach(P9Req *r);