[hackers] wmii: new tip (= 1728)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Sat, 03 Feb 2007 20:40:04 +0100

changeset: 1728:0a40690e62b8
tag: tip
parent: 1727:d476403ea4a6
parent: 1721:251c7539ffb9
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 03 14:38:31 2007 -0500
description:
Dummy merge with head -r1722 to kill it

changeset: 1727:d476403ea4a6
parent: 1726:5a7df0618207
parent: 1642:54c9b6b87499
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 03 14:38:00 2007 -0500
description:
Dummy merge with head -r1642 to kill it

changeset: 1726:5a7df0618207
parent: 1725:e1ff243621c4
parent: 1431:cf635f227ba2
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 03 14:36:29 2007 -0500
description:
Dummy merge with head -r1431 to kill it

changeset: 1725:e1ff243621c4
parent: 1724:91057d8f0031
parent: 1418:3b53adc01a87
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 03 14:36:04 2007 -0500
description:
Dummy merge with head -r1418 to kill it

changeset: 1724:91057d8f0031
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 03 14:30:04 2007 -0500
files: mouse.c
description:
Had extra ;

changeset: 1723:8e0ae951e77d
user: Kris Maglione <bsdaemon_AT_wmii.de>
date: Sat Feb 03 14:27:32 2007 -0500
files: client.c config.mk frame.c main.c mouse.c wmii.h
description:
Changed the behavior of dragging moving windows to better move them offscreen. Added function prototype to wmii.h.

changeset: 1722:68e2a0655b55
parent: 1719:0410fc597b7f
user: Kris Maglione <bsdaemon_AT_wmii.de>
date: Sat Feb 03 14:22:20 2007 -0500
files: rc/wmiirc
description:
Fixed '==' in a `test` to '='

diff -r 251c7539ffb9 -r 0a40690e62b8 client.c
--- a/client.c Sat Feb 03 19:30:08 2007 +0100
+++ b/client.c Sat Feb 03 14:38:31 2007 -0500
@@ -465,7 +465,6 @@ resize_client(Client *c, XRectangle *r,
 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,
         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,
                                 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)
diff -r 251c7539ffb9 -r 0a40690e62b8 frame.c
--- a/frame.c Sat Feb 03 19:30:08 2007 +0100
+++ b/frame.c Sat Feb 03 14:38:31 2007 -0500
@@ -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;
+}
diff -r 251c7539ffb9 -r 0a40690e62b8 libcext/estrdup.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libcext/estrdup.c Sat Feb 03 14:38:31 2007 -0500
@@ -0,0 +1,21 @@
+/*
+ * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * See LICENSE file for license details.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "cext.h"
+
+char *
+cext_estrdup(const char *s)
+{
+ char *tmp;
+
+ tmp = (char *) cext_emallocz(strlen(s) + 1);
+ strcpy(tmp, (char *) s);
+
+ return tmp;
+}
diff -r 251c7539ffb9 -r 0a40690e62b8 main.c
--- a/main.c Sat Feb 03 19:30:08 2007 +0100
+++ b/main.c Sat Feb 03 14:38:31 2007 -0500
@@ -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
diff -r 251c7539ffb9 -r 0a40690e62b8 mouse.c
--- a/mouse.c Sat Feb 03 19:30:08 2007 +0100
+++ b/mouse.c Sat Feb 03 14:38:31 2007 -0500
@@ -162,7 +162,8 @@ void
 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 al
         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 al
                 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 al
                         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;
diff -r 251c7539ffb9 -r 0a40690e62b8 rc/wmiirc
--- a/rc/wmiirc Sat Feb 03 19:30:08 2007 +0100
+++ b/rc/wmiirc Sat Feb 03 14:38:31 2007 -0500
@@ -151,7 +151,7 @@ do
         parms="$@"
         case "$type" in
         Start)
- if test $1 == "wmiirc"
+ if test "$1" = "wmiirc"
                 then
                         exit
                 fi;;
diff -r 251c7539ffb9 -r 0a40690e62b8 wmii.h
--- a/wmii.h Sat Feb 03 19:30:08 2007 +0100
+++ b/wmii.h Sat Feb 03 14:38:31 2007 -0500
@@ -76,7 +76,7 @@ enum { Coldefault, Colstack, Colmax };
 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 Bar *create_bar(Bar **b_link, cha
 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 draw_frame(Frame *f);
 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);
Received on Sat Feb 03 2007 - 20:40:04 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:51 UTC