Subject: Menu and Rectangle position argument

From: [email-masked]
Date: Sat, 3 Jul 1999 10:04:25 -0500 (CDT)

Full_Name: Ian Corner
Version: 2.2.2
CVS_Date: 
OS: Debian Slink/Linux 2.2.9
X_Server: XFree86 Version 3.3.3.1
Submission from: (NULL) (203.13.236.10)

While trying do a:

    *FvwmButtons(Icon mini-raise.xpm , Action `Menu MENU Rectangle 1x1+3-67
0p -100m-1p`)

I notice the menu did not position the way I thought the documentation
said
it would. I tried it a number of other ways and kept getting errors in the
xsession log (errors were about incorrect rectangle geometry).

Perhaps I was using the Menu option incorrectly (I couldn't tell).

Anyway I searched through the code and made the following modifications:

ian@roadrunner:/itc/home/ian/src/fvwm-2.2.2/fvwm > diff misc.c.original
misc.c      
542a543,544
>   Bool fUseRectangle ;
>   fUseRectangle = FALSE ;
608a611
>       taction = naction;
610c613
<       if (tok == NULL) {
---
>       if (!tok) {
620,621c623,626
<       if (flags & XNegative) x = Scr.MyDisplayWidth - x - width;
<       if (flags & YNegative) y = Scr.MyDisplayHeight - y - height;
---
>       if (flags & XNegative) x = Scr.MyDisplayWidth + x ;
>       if (flags & YNegative) y = Scr.MyDisplayHeight + y ;
>       context_window = Scr.Root;
>       fUseRectangle = TRUE ;
636,647c641,654
<     if (!context_window || !fHasContext
<       || !XGetGeometry(dpy, context_window, &JunkRoot, &JunkX, &JunkY,
<                        &width, &height, &JunkBW, &JunkDepth)
<       || !XTranslateCoordinates(
<         dpy, context_window, Scr.Root, 0, 0, &x, &y, &JunkChild)) {
<       /* now window or could not get geometry */
<       XQueryPointer(dpy,Scr.Root,&JunkRoot,&JunkChild,&x,&y,&JunkX,&JunkY,
<                   &JunkMask);
<       width = height = 1;
<     } else if (fUseItemOffset) {
<       y += mi->y_offset;
<       height = mi->y_height;
---
>     if ( ! fUseRectangle ) {
>       if (!context_window || !fHasContext
>         || !XGetGeometry(dpy, context_window, &JunkRoot, &JunkX, &JunkY,
>               &width, &height, &JunkBW, &JunkDepth)
>         || !XTranslateCoordinates(dpy, context_window, Scr.Root, 0, 0,
>               &x, &y, &JunkChild)) {
>         /* now window or could not get geometry */
>         XQueryPointer(dpy,Scr.Root,&JunkRoot,&JunkChild,&x,&y,
>            &JunkX,&JunkY,&JunkMask);
>         width = height = 1;
>       } else if (fUseItemOffset) {
>         y += mi->y_offset;
>         height = mi->y_height;
>       }
654a662
ian@roadrunner:/itc/home/ian/src/fvwm-2.2.2/fvwm > 

Now the options works and works the way I wanted.  However,
I'm still not sure if I had missed something originally.

Heres the diff again for use with patch:

ian@roadrunner:/itc/home/ian/src/fvwm-2.2.2/fvwm > diff -Naur
misc.c.original misc.c
--- misc.c.original     Sat Jul  3 23:07:52 1999
+++ misc.c      Sat Jul  3 23:14:03 1999
@@ -540,6 +540,8 @@
   Bool fHasContext, fUseItemOffset;
   Bool fValidPosHints = fLastMenuPosHintsValid;
 
+  Bool fUseRectangle ;
+  fUseRectangle = FALSE ;
   fLastMenuPosHintsValid = FALSE;
   if (pops == NULL) {
     fvwm_msg(ERR,"GetMenuOptions","no MenuOptions pointer passed");
@@ -606,8 +608,9 @@
       int flags;
       /* parse the rectangle */
       free(tok);
+      taction = naction;
       naction = GetNextToken(taction, &tok);
-      if (tok == NULL) {
+      if (!tok) {
        fvwm_msg(ERR,"GetMenuOptions","missing rectangle geometry");
        return action;
       }
@@ -617,8 +620,10 @@
        fvwm_msg(ERR,"GetMenuOptions","invalid rectangle geometry");
        return action;
       }
-      if (flags & XNegative) x = Scr.MyDisplayWidth - x - width;
-      if (flags & YNegative) y = Scr.MyDisplayHeight - y - height;
+      if (flags & XNegative) x = Scr.MyDisplayWidth + x ;
+      if (flags & YNegative) y = Scr.MyDisplayHeight + y ;
+      context_window = Scr.Root;
+      fUseRectangle = TRUE ;
       pops->pos_hints.fRelative = FALSE;
     } else if (StrEquals(tok,"this")) {
       context_window = w;
@@ -633,18 +638,20 @@
       taction = naction;
     else naction = action;
 
-    if (!context_window || !fHasContext
-       || !XGetGeometry(dpy, context_window, &JunkRoot, &JunkX, &JunkY,
-                        &width, &height, &JunkBW, &JunkDepth)
-       || !XTranslateCoordinates(
-         dpy, context_window, Scr.Root, 0, 0, &x, &y, &JunkChild)) {
-      /* now window or could not get geometry */
-      XQueryPointer(dpy,Scr.Root,&JunkRoot,&JunkChild,&x,&y,&JunkX,&JunkY,
-                   &JunkMask);
-      width = height = 1;
-    } else if (fUseItemOffset) {
-      y += mi->y_offset;
-      height = mi->y_height;
+    if ( ! fUseRectangle ) {
+      if (!context_window || !fHasContext
+        || !XGetGeometry(dpy, context_window, &JunkRoot, &JunkX, &JunkY,
+              &width, &height, &JunkBW, &JunkDepth)
+        || !XTranslateCoordinates(dpy, context_window, Scr.Root, 0, 0,
+              &x, &y, &JunkChild)) {
+        /* now window or could not get geometry */
+        XQueryPointer(dpy,Scr.Root,&JunkRoot,&JunkChild,&x,&y,
+           &JunkX,&JunkY,&JunkMask);
+        width = height = 1;
+      } else if (fUseItemOffset) {
+        y += mi->y_offset;
+        height = mi->y_height;
+      }
     }
 
     /* parse position arguments */
@@ -652,6 +659,7 @@
       naction, x, width, &(pops->pos_hints.x),
&(pops->pos_hints.x_factor));
     naction = GetOneMenuPositionArgument(
       taction, y, height, &(pops->pos_hints.y),
&(pops->pos_hints.y_factor));
+
     if (naction == taction) {
       /* argument is missing or invalid */
       if (fHasContext)
ian@roadrunner:/itc/home/ian/src/fvwm-2.2.2/fvwm > 

thanks
Ian

--
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]