changeset: 2064:690988de6e3f
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Apr 07 02:44:39 2007 -0400
summary: New window moving algorithm which doesn't require (but suggests) warping.
diff -r 8cdb3c2708d1 -r 690988de6e3f cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sat Apr 07 01:28:49 2007 -0400
+++ b/cmd/wmii/mouse.c Sat Apr 07 02:44:39 2007 -0400
@@ -2,6 +2,7 @@
* See LICENSE file for license details.
*/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <util.h>
#include "dat.h"
@@ -361,7 +362,7 @@ do_mouse_resize(Client *c, Bool opaque,
int snap, dx, dy, pt_x, pt_y, hr_x, hr_y;
uint num;
Bool floating;
- float rx, ry;
+ float rx, ry, hrx, hry;
Frame *f;
f = c->sel;
@@ -423,9 +424,11 @@ do_mouse_resize(Client *c, Bool opaque,
else if(f->client->fullscreen)
return;
else if(!opaque) {
- hr_x = screen->rect.width / 2;
- hr_y = screen->rect.height / 2;
- warppointer(hr_x, hr_y);
+ hrx = (double)(screen->rect.width + frect.width - 2 * labelh(&def.font)) / screen->rect.width;
+ hry = (double)(screen->rect.height + frect.height - 3 * labelh(&def.font)) / screen->rect.height;
+ pt_x = r_east(&frect) - labelh(&def.font);
+ pt_y = r_south(&frect) - labelh(&def.font);
+ warppointer(pt_x / hrx, pt_y / hry);
flushevents(PointerMotionMask, False);
}
@@ -449,14 +452,13 @@ do_mouse_resize(Client *c, Bool opaque,
resize_client(c, &frect);
if(!opaque) {
- if(align != CENTER)
- XTranslateCoordinates(blz.dpy,
- /* src, dst */ c->framewin, blz.root,
- /* src_x */ (frect.width * rx),
- /* src_y */ (frect.height * ry),
- /* dest x,y */ &pt_x, &pt_y,
- /* child */ &dummy
- );
+ XTranslateCoordinates(blz.dpy,
+ /* src, dst */ c->framewin, blz.root,
+ /* src_x */ (frect.width * rx),
+ /* src_y */ (frect.height * ry),
+ /* dest x,y */ &pt_x, &pt_y,
+ /* child */ &dummy
+ );
if(pt_y > screen->brect.y)
pt_y = screen->brect.y - 1;
warppointer(pt_x, pt_y);
@@ -475,11 +477,8 @@ do_mouse_resize(Client *c, Bool opaque,
dy = ev.xmotion.y_root;
if(align == CENTER && !opaque) {
- if(dx == hr_x && dy == hr_y)
- continue;
- warppointer(hr_x, hr_y);
- dx -= hr_x;
- dy -= hr_y;
+ dx = (dx * hrx) - pt_x;
+ dy = (dy * hry) - pt_y;
}else{
dx -= pt_x;
dy -= pt_y;
@@ -488,8 +487,7 @@ do_mouse_resize(Client *c, Bool opaque,
pt_y += dy;
rect_morph_xy(&origin, dx, dy, &align);
- if(align != CENTER)
- check_frame_constraints(&origin);
+ check_frame_constraints(&origin);
frect = origin;
if(floating)
@@ -498,6 +496,7 @@ do_mouse_resize(Client *c, Bool opaque,
grav = align ^ CENTER;
apply_sizehints(c, &frect, floating, True, grav);
+ check_frame_constraints(&frect);
if(opaque) {
XMoveWindow(blz.dpy, c->framewin, frect.x, frect.y);
diff -r 8cdb3c2708d1 -r 690988de6e3f cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat Apr 07 01:28:49 2007 -0400
+++ b/cmd/wmii/view.c Sat Apr 07 02:44:39 2007 -0400
@@ -171,7 +171,7 @@ restack_view(View *v) {
Area *a;
Frame *f;
Client *c;
- uint n, i, fs;
+ uint n, i;
if(v != screen->sel)
return;
@@ -188,14 +188,14 @@ restack_view(View *v) {
wins = erealloc(wins, sizeof(Window) * winssz);
}
- fs = 0;
- for(f=v->area->stack; f; f=f->snext) {
+ wins[n++] = screen->barwin;
+ for(f=v->area->stack; f; f=f->snext)
+ if(f->client->fullscreen) {
+ n--;
+ break;
+ }
+ for(f=v->area->stack; f; f=f->snext)
wins[n++] = f->client->framewin;
- if(f->client->fullscreen)
- fs++;
- }
- if(fs == 0)
- wins[n++] = screen->barwin;
for(a=v->area->next; a; a=a->next) {
if(a->frame) {
wins[n++] = a->sel->client->framewin;
Received on Sat Apr 07 2007 - 08:44:58 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:34 UTC