[846] in testers
twm handles aspect ratios incorrectly
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue May 22 20:48:06 1990
Date: Tue, 22 May 90 20:47:20 -0400
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: xbugs@expo.lcs.mit.edu
In-Reply-To: testers[789]
Cc: testers@ATHENA.MIT.EDU
X Window System Bug Report
xbugs@expo.lcs.mit.edu
VERSION:
R4
CLIENT MACHINE and OPERATING SYSTEM:
NA
DISPLAY TYPE:
NA
WINDOW MANAGER:
twm
AREA:
twm
SYNOPSIS:
When resizing a window, twm's calculation for determining valid
aspect ratios (based on the window manager normal hints for the
window) is incorrect.
DESCRIPTION:
See the "REPEAT BY".
REPEAT BY:
Create a window that sets its min_aspect to 1/5 and its max_aspect
to 5/1. Try to resize it, using twm. Notice that twm forces the
aspect to be 5/1.
SAMPLE FIX:
Patch included at the end of this message.
Jonathan Kamens USnail:
MIT Project Athena 11 Ashford Terrace
jik@Athena.MIT.EDU Allston, MA 02134
Office: 617-253-8495 Home: 617-782-0710
*** /tmp/,RCSt1001030 Tue May 22 20:46:39 1990
--- resize.c Tue May 22 20:35:04 1990
***************
*** 556,578 ****
#define maxAspectY tmp_win->hints.max_aspect.y
#define minAspectX tmp_win->hints.min_aspect.x
#define minAspectY tmp_win->hints.min_aspect.y
if (tmp_win->hints.flags & PAspect)
{
! if (dwidth * maxAspectX > dheight * maxAspectY)
{
- delta = makemult(dwidth * maxAspectY / maxAspectX - dheight,
- yinc);
- if (dheight + delta <= maxHeight) dheight += delta;
- else
- {
- delta = makemult(dwidth - maxAspectX*dheight/maxAspectY,
- xinc);
- if (dwidth - delta >= minWidth) dwidth -= delta;
- }
- }
-
- if (dwidth * minAspectX < dheight * minAspectY)
- {
delta = makemult(minAspectX * dheight / minAspectY - dwidth,
xinc);
if (dwidth + delta <= maxWidth) dwidth += delta;
--- 556,580 ----
#define maxAspectY tmp_win->hints.max_aspect.y
#define minAspectX tmp_win->hints.min_aspect.x
#define minAspectY tmp_win->hints.min_aspect.y
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
if (tmp_win->hints.flags & PAspect)
{
! if (minAspectX * dheight > minAspectY * dwidth)
{
delta = makemult(minAspectX * dheight / minAspectY - dwidth,
xinc);
if (dwidth + delta <= maxWidth) dwidth += delta;
***************
*** 581,586 ****
--- 583,601 ----
delta = makemult(dheight - dwidth*minAspectY/minAspectX,
yinc);
if (dheight - delta >= minHeight) dheight -= delta;
+ }
+ }
+
+ if (maxAspectX * dheight < maxAspectY * dwidth)
+ {
+ delta = makemult(dwidth * maxAspectY / maxAspectX - dheight,
+ yinc);
+ if (dheight + delta <= maxHeight) dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - maxAspectX*dheight/maxAspectY,
+ xinc);
+ if (dwidth - delta >= minWidth) dwidth -= delta;
}
}
}