🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.graphics.pixutils
Article #716

A tenth patch for 'Xv'. (xv.patch.3j.pos)

#716
From: Matthew Stier - Sun Video and Im...
Date: Fri, 15 Nov 1991 22:38
317 lines
11106 bytes
Okay, here is another patch to 'Xv'.  I want to classify this one experimental,
and would like everyones response on it. It has been tested with the following
window managers:

	olwm:	OpenWindows v2.0 & v3.0
	olvwm:	v2.2
        twm:	OpenWindows v3.0
        tvtwm:	patchlevel 6 (export.lcs.mit.edu:/contrib)

I've been trying to fix Xv's misplacement of the top_level window during 
cropping and image changes.  After asking a few question, I got a helpful
pointer from John Helm (John.Helm@West.Sun.COM). Its frustrating, trying 
to figure out how each window manager handles reparented windows, and 
to figure a way to get all of them to behave.

This patch needs xv.patch.3a installed.  If xv.patch.3a is not installed,
you'll need to do a little editing to do the patch. 

Hunk 1 adds to global variables.

Hunk 2 adds code to nab the parent window offset during a ReparentNotify 
       event.

Hunk 3 eliminates a retest of 'mainW'.

Hunk 4 replaces 'GetWindowPos()' in its entirety.

Hunk 5 replaces 'SetWindowPos()' in its entirety.

--
Matthew Lee Stier                          |
Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
Email: matthew.stier@East.Sun.COM          |
Phone: (919) 469-8300 fax: (919) 460-8355  | 

#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 11/15/1991 22:33 UTC by matthew@superdave
# Source directory /auto/home/matthew/src/X11/Xv
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   7719 -rw-r--r-- xv.patch.3j.pos
#
# ============= xv.patch.3j.pos ==============
if test -f 'xv.patch.3j.pos' -a X"$1" != X"-c"; then
	echo 'x - skipping xv.patch.3j.pos (File already exists)'
else
echo 'x - extracting xv.patch.3j.pos (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'xv.patch.3j.pos' &&
*** /dev/null	Fri Nov 15 16:42:01 1991
--- README.3J.POS	Fri Nov 15 17:29:22 1991
***************
*** 0 ****
--- 1,36 ----
+ 
+ Okay, here is another patch to 'Xv'.  I want to classify this one experimental,
+ and would like everyones response on it. It has been tested with the following
+ window managers:
+ 
+ 	olwm:	OpenWindows v2.0 & v3.0
+ 	olvwm:	v2.2
+         twm:	OpenWindows v3.0
+         tvtwm:	patchlevel 6 (export.lcs.mit.edu:/contrib)
+ 
+ I've been trying to fix Xv's misplacement of the top_level window during 
+ cropping and image changes.  After asking a few question, I got a helpful
+ pointer from John Helm (John.Helm@West.Sun.COM). Its frustrating, trying 
+ to figure out how each window manager handles reparented windows, and 
+ to figure a way to get all of them to behave.
+ 
+ This patch needs xv.patch.3a installed.  If xv.patch.3a is not installed,
+ you'll need to do a little editing to do the patch. 
+ 
+ Hunk 1 adds to global variables.
+ 
+ Hunk 2 adds code to nab the parent window offset during a ReparentNotify 
+        event.
+ 
+ Hunk 3 eliminates a retest of 'mainW'.
+ 
+ Hunk 4 replaces 'GetWindowPos()' in its entirety.
+ 
+ Hunk 5 replaces 'SetWindowPos()' in its entirety.
+ 
+ --
+ Matthew Lee Stier                          |
+ Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
+ Email: matthew.stier@East.Sun.COM          |
+ Phone: (919) 469-8300 fax: (919) 460-8355  | 
+ 
*** xv.c.orig	Sun Nov 10 15:16:32 1991
--- xv.c	Fri Nov 15 17:05:27 1991
***************
*** 67,72 ****
--- 67,74 ----
X  static char   initpath[MAXPATHLEN];
X  static int    rotatesLeft = 0;
X  static Atom   __SWM_VROOT = None;
+ static int    parent_x = 0;
+ static int    parent_y = 0;
X  
X  /* used in XResource reading... */
X  static char *def_str;
***************
*** 1391,1399 ****
X        case MapNotify:
X        case DestroyNotify:
X        case GravityNotify:
-       case ReparentNotify:
X        case UnmapNotify:         break;
X  
X        case EnterNotify:
X        case LeaveNotify: {
X  	XCrossingEvent *cross_event = (XCrossingEvent *) &event;
--- 1393,1408 ----
X        case MapNotify:
X        case DestroyNotify:
X        case GravityNotify:
X        case UnmapNotify:         break;
+       case ReparentNotify: {
+         XReparentEvent *reparent_event = (XReparentEvent *) &event;
+ 
+         if (reparent_event->window == mainW)
+           parent_x = reparent_event->x;
+           parent_y = reparent_event->y;
+       }
+       break;
X  
X        case EnterNotify:
X        case LeaveNotify: {
X  	XCrossingEvent *cross_event = (XCrossingEvent *) &event;
***************
*** 1505,1514 ****
X      SetWindowPos(&xwa);
X      hints.flags = PSize | PMaxSize;
X    }
! 
!   if (!mainW)
X      mainW = XCreateWindow(theDisp,rootW,x,y,eWIDE,eHIGH,bwidth,CopyFromParent,
X  			  CopyFromParent, CopyFromParent, xswamask, &xswa);
X  
X    sprintf(winname,"xv %s",name);
X    sprintf(iconname,"xv %s",name);
--- 1514,1524 ----
X      SetWindowPos(&xwa);
X      hints.flags = PSize | PMaxSize;
X    }
!   else {
!     /* Initialize cn with starting configuration */
X      mainW = XCreateWindow(theDisp,rootW,x,y,eWIDE,eHIGH,bwidth,CopyFromParent,
X  			  CopyFromParent, CopyFromParent, xswamask, &xswa);
+   }
X  
X    sprintf(winname,"xv %s",name);
X    sprintf(iconname,"xv %s",name);
***************
*** 1695,1728 ****
X  static void GetWindowPos(xwa)
X  XWindowAttributes *xwa;
X  {
!   Window            root,parent,*children,child;
!   unsigned int      nchildren;
!   XWindowAttributes pxwa;
!   int ox1,oy1;
X  
!   /* returns the x,y,w,h coords of mainW.  x,y are relative to rootW 
!      the border is not included (x,y map to top-left pixel in window) */
! 
X    XGetWindowAttributes(theDisp,mainW,xwa);
! 
!   /* see if mainW has been re-parented by a window manager */
!   XQueryTree(theDisp,mainW,&root,&parent,&children,&nchildren);
!   if (nchildren>0 || children!=NULL) XFree((char *) children);
! 
!   if (parent != rootW) {     /* has been reparented */
!     XGetWindowAttributes(theDisp,parent,&pxwa);
! 
!     XTranslateCoordinates(theDisp,mainW,rootW,0,0,
! 			  &xwa->x,&xwa->y,&child);
! 
!     XTranslateCoordinates(theDisp,parent,rootW,0,0,
! 			  &ox1,&oy1,&child);
!   }
! 
!   else {
!     xwa->x += xwa->border_width;
!     xwa->y += xwa->border_width;
!   }
X  }
X  
X  
--- 1705,1716 ----
X  static void GetWindowPos(xwa)
X  XWindowAttributes *xwa;
X  {
!   Window child;
X  
!   /* Get the window width/height */
X    XGetWindowAttributes(theDisp,mainW,xwa);
!   /* Get the window origin */
!   XTranslateCoordinates(theDisp,mainW,rootW,0,0,&xwa->x,&xwa->y,&child);
X  }
X  
X  
***************
*** 1730,1797 ****
X  static void SetWindowPos(xwa)
X  XWindowAttributes *xwa;
X  {
-   /* sets window x,y,w,h values */
-   /*  XSizeHints        xsh; */
X    Window            root, parent, *children, child;
X    unsigned int      nchildren;
!   XWindowAttributes pxwa;
!   int               xoff, yoff, x1, y1, x2, y2;
X  
!   xoff = yoff = 0;
!   /* check for reparented window */
!   XQueryTree(theDisp,mainW,&root,&parent,&children,&nchildren);
!   if (nchildren>0 || children!=NULL) XFree((char *) children);
!   if (parent != root) {
!     XTranslateCoordinates(theDisp,mainW,rootW,0,0,&x1,&y1,&child);
!     XTranslateCoordinates(theDisp,mainW,parent,0,0,&xoff,&yoff,&child);
!     XTranslateCoordinates(theDisp,parent,rootW,0,0,&x2,&y2,&child);
!     XGetWindowAttributes(theDisp,parent,&pxwa);
X  
!     if (xoff == 0 && yoff == 0) {
!       /* NASTY MOTIF/DXWM KLUDGES */
!       xoff = pxwa.x;  yoff = pxwa.y;
!       if (xwa->x<xoff && (xwa->width + xoff)<dispWIDE) xwa->x = xoff;
!       if (xwa->y<yoff && (xwa->height + yoff)<dispHIGH) xwa->y = yoff;
!     }
!     else {
!       /* NICE, PERFECTLY NORMAL TWM KLUDGES */
!       xwa->x = xwa->x - xoff;
!       xwa->y = xwa->y - yoff;
!       if (xwa->x<0 && (xwa->width + xoff)<dispWIDE) xwa->x = 0;
!       if (xwa->y<0 && (xwa->height + yoff)<dispHIGH) xwa->y = 0;
!     }
!   }
!   else {
!     xwa->x -= xwa->border_width;
!     xwa->y -= xwa->border_width;
! 
!     if (xwa->x < -(xwa->border_width)) xwa->x = -(xwa->border_width);
!     if (xwa->y < -(xwa->border_width)) xwa->y = -(xwa->border_width);
!     xoff = yoff = xwa->border_width;
!   }
!     
!   XMoveResizeWindow(theDisp, mainW, xwa->x, xwa->y, xwa->width, xwa->height);
! 
!   /*
!    * all this bogus stuff is a work-around for weirdness in
!    * twm where resize was giving 23 extra lines...
!    * should do no harm if this bug is not present.
!    */
! #ifdef TWMKLUDGE
!   XSync(theDisp,False);
!   XGetWindowAttributes(theDisp, mainW, &pxwa);
!   if (pxwa.height != xwa->height) {
!     XEvent xev;
!     /* eat configure event (and any Exposes) if there is one */
!     if (XCheckTypedWindowEvent(theDisp, mainW, ConfigureNotify, &xev)) {
!       while (XCheckTypedWindowEvent(theDisp, mainW, Expose, &xev));
!     }
! 
!     XResizeWindow(theDisp, mainW, xwa->width, 
! 		  xwa->height - (pxwa.height - xwa->height));
!   }
! #endif /* TWMKLUDGE */
! 
X  }
X  
X  
--- 1718,1738 ----
X  static void SetWindowPos(xwa)
X  XWindowAttributes *xwa;
X  {
X    Window            root, parent, *children, child;
X    unsigned int      nchildren;
!   int               x, y, w, h, xact, yact;
!   XWindowChanges    xwc;
X  
!   /* Adjust from window origin, to border origin */
!   xwc.x = xwa->x - xwa->border_width - parent_x;
!   xwc.y = xwa->y - xwa->border_width - parent_y;
!   xwc.width  = xwa->width;
!   xwc.height = xwa->height;
!   xwc.border_width = xwa->border_width;
X  
!   /* Move/Resize the window. */
!   XConfigureWindow(theDisp, mainW, 
!                    CWX | CWY | CWWidth | CWHeight | CWBorderWidth, xwc);
X  }
X  
X  
SHAR_EOF
chmod 0644 xv.patch.3j.pos ||
echo 'restore of xv.patch.3j.pos failed'
Wc_c="`wc -c < 'xv.patch.3j.pos'`"
test 7719 -eq "$Wc_c" ||
	echo 'xv.patch.3j.pos: original size 7719, current size' "$Wc_c"
fi
exit 0
-- 
Matthew Lee Stier                          |
Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
Email: matthew.stier@East.Sun.COM          |
Phone: (919) 469-8300 fax: (919) 460-8355  | 
Technical Details
Message-ID: <5498@southeast.East.Sun.COM>
Path: arc1-ca.pugleaf.net!wupost!decwrl!amdcad!pyramid!amdahl!charon.amdahl.com!uunet!sun-barr!cronkite.Central.Sun.COM!newstop!southeast!matthew

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!decwrl!amdcad!pyramid!amdahl!charon.amdahl.com!uunet!sun-barr!cronkite.Central.Sun.COM!newstop!southeast!matthew
From: matthew@sunpix.East.Sun.COM (Matthew Stier - Sun Video and Imaging Products)
Newsgroups: alt.graphics.pixutils,alt.sources,alt.sources.patches
Subject: A tenth patch for 'Xv'. (xv.patch.3j.pos)
Message-ID: <5498@southeast.East.Sun.COM>
Date: 15 Nov 91 22:38:04 GMT
Sender: news@East.Sun.COM
Followup-To: alt.graphics.pixutils
Organization: Sun Microsystems, Research Triangle Park, NC
Lines: 317