[736] in testers
xterm/mwm interaction bug is FIXED
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Mon May 14 23:04:29 1990
Date: Mon, 14 May 90 23:03:42 -0400
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: testers@ATHENA.MIT.EDU
Cc: vanharen@ATHENA.MIT.EDU, cfields@ATHENA.MIT.EDU, swick@ATHENA.MIT.EDU
Working together tonight, Craig and I have, as far as we can tell,
completely solved the mwm/xterm interaction problems. No changes were
required to mwm, and the "only" changes to xterm where in the file
scrollbar.c.
I put "only" in quotes because the changes were extensive, and
frankly, I'm disgusted that the code was as bad as it was. But then
again, we all knew that xterm wasn't exactly beautiful code.
I would like to get the patch (which I will include below) installed
in the release as soon as possible. However, before doing that, I
would like Chris, Craig and Ralph all to examine it carefully and make
sure nothing is wrong. In addition to including the patch below, I
have included a detailed description of all the changes which were
made.
Compiled versions of the fixed xterm can be found in the release.dev
locker, in
/mit/release.dev/build/{vax,rt}/third/common/X11R4/clients/xterm/xterm.
jik
*************************
1. The function IsEventType has been removed; it is no longer used.
2. XSetWMNormalHints and XGetWMNormalHints are no longer used at all.
Instead, an XtVaSetValues on the shell widget is used to set the
necessary hints.
3. There was an XtSetValues on the shell widget, using a constant args
array, in the original. First of all, the args array has been
removed, since we're using XtVaSetValues now. Second, the
arguments put into the arglist in the original XtSetValues call
were quite simply the wrong numbers. This has been corrected in
the new XtVaSetValues call.
4. Don't try to use bit gravity, since we cannot insure that the
window manager will resize the window automatically, and our
attempts to wait until the resize are feeble at best (and besides,
the window manager is allowed to override bit gravity). Instead,
use XCopyArea's and XClearArea's to do what the bit gravity would
have done.
5. Don't set the width and height hints on the shell, because it
doesn't provide any method for setting them, and because they're
obsolete.
6. If the XtMakeResizeRequest returns XtGeometryAlmost, then
immediately make another XtResizeRequest with the suggested values.
7. Use XtMapWidget and XtUnmapWidget, rather than XMapWindow and
XUnmapWindow, to map and unmap the scrollbar.
*************************
*** /tmp/,RCSt1003391 Mon May 14 22:54:24 1990
--- scrollbar.c Mon May 14 22:26:14 1990
***************
*** 54,68 ****
static void ScrollTextTo();
static void ScrollTextUpDownBy();
- static Bool IsEventType( display, event, type )
- Display *display;
- XEvent *event;
- int type;
- {
- return (event->type == type);
- }
-
/* resize the text window for a terminal screen, modifying the
* appropriate WM_SIZE_HINTS and taking advantage of bit gravity.
*/
--- 54,60 ----
***************
*** 72,136 ****
int min_width, min_height;
{
register TScreen *screen = &xw->screen;
- XSizeHints sizehints;
- XSetWindowAttributes newAttributes;
- XWindowAttributes oldAttributes;
- XEvent event;
XtGeometryResult geomreqresult;
Dimension oldWidth, oldHeight;
Dimension reqWidth, reqHeight, repWidth, repHeight;
- static Arg argList[] = {
- {XtNminWidth, 0},
- {XtNminHeight, 0},
- /* %%% the next two should move to VTInitialize, VTSetValues */
- {XtNwidthInc, 0},
- {XtNheightInc, 0}
- };
#ifndef nothack
! long supp;
!
! /* %%% gross hack caused by our late processing of geometry
! (in VTRealize) and setting of size hints there, leaving
! Shell with insufficient information to do the job properly here.
! Instead of doing it properly, we save and restore the
! size hints around Shell.SetValues and Shell.GeometryManager
*/
! if (!XGetWMNormalHints (screen->display, XtWindow(XtParent(xw)),
! &sizehints, &supp))
! sizehints.flags = 0;
! sizehints.base_width = min_width;
! sizehints.base_height = min_height;
! sizehints.width_inc = FontWidth(screen);
! sizehints.height_inc = FontHeight(screen);
! sizehints.min_width = sizehints.base_width + sizehints.width_inc;
! sizehints.min_height = sizehints.base_height + sizehints.height_inc;
! sizehints.width = (screen->max_col + 1) * FontWidth(screen)
! + min_width;
! sizehints.height = FontHeight(screen) * (screen->max_row + 1)
! + min_height;
! sizehints.flags |= (PBaseSize|PMinSize|PResizeInc);
#endif
- argList[0].value = (XtArgVal)min_width;
- argList[1].value = (XtArgVal)min_height;
- argList[2].value = (XtArgVal)FontWidth(screen);
- argList[3].value = (XtArgVal)FontHeight(screen);
- XtSetValues( XtParent(xw), argList, XtNumber(argList) );
-
- XGetWindowAttributes( screen->display, TextWindow(screen),
- &oldAttributes );
-
- newAttributes.event_mask =
- oldAttributes.your_event_mask | StructureNotifyMask;
- newAttributes.bit_gravity = EastGravity;
-
- /* The following statement assumes scrollbar is on Left!
- If we ever have scrollbars on the right, then the
- bit-gravity should be left alone, NOT changed to EastGravity. */
- XChangeWindowAttributes( screen->display, TextWindow(screen),
- CWEventMask|CWBitGravity, &newAttributes );
-
oldWidth = xw->core.width;
oldHeight = xw->core.height;
reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;
--- 64,91 ----
int min_width, min_height;
{
register TScreen *screen = &xw->screen;
XtGeometryResult geomreqresult;
Dimension oldWidth, oldHeight;
Dimension reqWidth, reqHeight, repWidth, repHeight;
#ifndef nothack
! /*
! * Note: width and height are not set here because they are
! * obsolete.
*/
! XtVaSetValues(XtParent(xw),
! XtNbaseWidth, min_width,
! XtNbaseHeight, min_height,
! XtNwidthInc, FontWidth(screen),
! XtNheightInc, FontHeight(screen),
! XtNminWidth, min_width + FontWidth(screen),
! XtNminHeight, min_height + FontHeight(screen),
! NULL);
! /* Need to sync so that the changes reach the window manager */
! /* before we make the resize request. */
! XSync(screen->display, False);
#endif
oldWidth = xw->core.width;
oldHeight = xw->core.height;
reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;
***************
*** 138,157 ****
geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight,
&repWidth, &repHeight);
! #ifndef nothack
! XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints);
! #endif
!
! if (oldWidth != reqWidth || oldHeight != reqHeight) {
! /* wait for a window manager to actually do it */
! XIfEvent (screen->display, &event, IsEventType, (char *)ConfigureNotify);
}
-
- newAttributes.event_mask = oldAttributes.your_event_mask;
- newAttributes.bit_gravity = NorthWestGravity;
- XChangeWindowAttributes( screen->display, TextWindow(screen),
- CWEventMask|CWBitGravity,
- &newAttributes );
}
void DoResizeScreen (xw)
--- 93,102 ----
geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight,
&repWidth, &repHeight);
! if (geomreqresult == XtGeometryAlmost) {
! geomreqresult = XtMakeResizeRequest ((Widget)xw, repWidth,
! repHeight, NULL, NULL);
}
}
void DoResizeScreen (xw)
***************
*** 379,386 ****
ScrollBarDrawThumb(screen->scrollWidget);
DoResizeScreen (xw);
! /* map afterwards so BitGravity can be used profitably */
! XMapWindow(screen->display, XtWindow(screen->scrollWidget));
update_scrollbar ();
}
--- 324,340 ----
ScrollBarDrawThumb(screen->scrollWidget);
DoResizeScreen (xw);
! XCopyArea(screen->display, XtWindow(xw), XtWindow(xw),
! screen->normalGC,
! xw->screen.border, xw->screen.border,
! (unsigned) (xw->core.width - screen->scrollbar),
! (unsigned) xw->core.height,
! xw->screen.border + screen->scrollbar,
! xw->screen.border);
! XClearArea(screen->display, XtWindow(xw),
! xw->screen.border, xw->screen.border,
! screen->scrollbar, xw->core.height, False);
! XtMapWidget(screen->scrollWidget);
update_scrollbar ();
}
***************
*** 389,396 ****
{
if(!screen->scrollbar)
return;
screen->scrollbar = 0;
- XUnmapWindow(screen->display, XtWindow(screen->scrollWidget));
DoResizeScreen (term);
update_scrollbar ();
}
--- 343,358 ----
{
if(!screen->scrollbar)
return;
+ XtUnmapWidget(screen->scrollWidget);
+ XCopyArea(screen->display, XtWindow(term), XtWindow(term),
+ screen->normalGC,
+ term->screen.border + screen->scrollbar,
+ term->screen.border,
+ (unsigned) (term->core.width - screen->scrollbar),
+ (unsigned) term->core.height,
+ term->screen.border,
+ term->screen.border);
screen->scrollbar = 0;
DoResizeScreen (term);
update_scrollbar ();
}