Subject: New window placement mode

From: Arwed von Merkatz <[email-masked]>
Date: Sat, 8 Nov 2003 13:39:43 +0100

Hi,

i've recently switched to fvwm and am a very happy user now, but i was
missing one feature: window placement under mouse.
I'm using sloppy focus and like to have new windows placed centered
under the mouse pointer. So here's a patch to add the
'UnderMousePlacement' placement mode to fvwm.
Placement is done like this:
1. get the current mouse position, center the window below it
2. if the window goes over the right or bottom screen edge, move it so
it doesn't
3. if the window goes over the left or top screen edge, move it

Does the use of screen_g.x and screen_g.y for left/top ensure that it
also works with xinerama? I don't have a xinerama setup to test that.

-- 
Arwed v. Merkatz
Grimoire Guru for video
Grimoire Guru for xfce
Sourcemage GNU/Linux
http://www.sourcemage.org
Index: fvwm/fvwm.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.h,v
retrieving revision 1.228
diff -u -r1.228 fvwm.h
--- fvwm/fvwm.h	24 Sep 2003 09:15:20 -0000	1.228
+++ fvwm/fvwm.h	8 Nov 2003 12:07:52 -0000
@@ -467,8 +467,9 @@
 #define PLACE_TILECASCADE       0x5
 #define PLACE_CASCADE_B         0x6
 #define PLACE_MINOVERLAP        0x7
-#define PLACE_MASK              0x7
-	unsigned placement_mode : 3;
+#define PLACE_UNDERMOUSE        0x8
+#define PLACE_MASK              0x8
+	unsigned placement_mode : 4;
 	unsigned ewmh_placement_mode : 2; /* see ewmh.h */
 #define WS_CR_MOTION_METHOD_AUTO CR_MOTION_METHOD_AUTO
 #define WS_CR_MOTION_METHOD_USE_GRAV CR_MOTION_METHOD_USE_GRAV
Index: fvwm/placement.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/placement.c,v
retrieving revision 1.129
diff -u -r1.129 placement.c
--- fvwm/placement.c	7 Jul 2003 22:22:20 -0000	1.129
+++ fvwm/placement.c	8 Nov 2003 12:07:54 -0000
@@ -1157,6 +1157,34 @@
 				pdeltay, 0);
 			flags.is_smartly_placed = True;
 			break;
+    case PLACE_UNDERMOUSE:
+      {
+        int mx;
+        int my;
+        FQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild,
+          &mx, &my, &JunkX, &JunkY, &JunkMask);
+        xl = mx - (fw->frame_g.width / 2);
+        yt = my - (fw->frame_g.height / 2);
+        if (xl + fw->frame_g.width > screen_g.x + screen_g.width)
+        {
+          xl = screen_g.x + screen_g.width - fw->frame_g.width;
+        }
+        if (yt + fw->frame_g.height > screen_g.y + screen_g.height)
+        {
+          yt = screen_g.y + screen_g.height - fw->frame_g.height;
+        }
+        if (xl < screen_g.x)
+        {
+          xl = screen_g.x;
+        }
+        if (yt < screen_g.y)
+        {
+          yt = screen_g.y;
+        }
+        attr_g->x = xl;
+        attr_g->y = yt;
+      }
+      break;
 		default:
 			/* can't happen */
 			break;
Index: fvwm/style.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.c,v
retrieving revision 1.220
diff -u -r1.220 style.c
--- fvwm/style.c	23 Aug 2003 04:27:43 -0000	1.220
+++ fvwm/style.c	8 Nov 2003 12:08:04 -0000
@@ -3738,7 +3738,13 @@
 		break;
 
 	case 'u':
-		if (StrEquals(token, "UsePPosition"))
+		if (StrEquals(token, "UnderMousePlacement"))
+		{
+			ps->flags.placement_mode = PLACE_UNDERMOUSE;
+			ps->flag_mask.placement_mode = PLACE_MASK;
+			ps->change_mask.placement_mode = PLACE_MASK;
+		}
+    else if (StrEquals(token, "UsePPosition"))
 		{
 			ps->flags.use_no_pposition = !on;
 			ps->flag_mask.use_no_pposition = 1;

---

From: Marcus Lundblad <[email-masked]>
Date: Tue, 11 Nov 2003 19:56:41 +0100 (CET)

> also works with xinerama? I don't have a xinerama setup to test that.

Hi

Since FVWM is currently in feature-freeze before version 2.6.0 is released
I think the patch will have to wait until after that (and the next beta
branch towards 3.0 is started). But it's an interseting patch, and I think
it'll be of use to some people.

//Marcus

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Cameron Simpson <[email-masked]>
Date: Thu, 13 Nov 2003 16:23:05 +1100

On 13:39 08 Nov 2003, Arwed von Merkatz <[email-masked]> wrote:
| i've recently switched to fvwm and am a very happy user now, but i was
| missing one feature: window placement under mouse.
[... useful patch snipped ...]

Not to mention "window placement _not_ under mouse", which I prefer.
I get very annoyed when a new window pops up (in belated response to
something I've dispatched ealier) on top of my working window, snatching
the keyboard focus because I like focus-follows-mouse. Ah, wishes:-)
And of course SmartPlacement nearly avoids this occurence. But I would
occasionally like "place the window partly or mostly off-screen if that's
necessary to avoid my mouse".

Cheers,
-- 
Cameron Simpson <[email-masked]> DoD#743
http://www.cskk.ezoshosting.com/cs/

Wind catches lily
scatt'ring petals to the wind:
segmentation fault
- Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]