[4359] in Athena Bugs

home help back first fref pref prev next nref lref last post

twm configure events

daemon@ATHENA.MIT.EDU (Mark Rosenstein)
Thu Mar 1 12:27:45 1990

Date: Thu, 1 Mar 90 12:27:14 -0500
From: Mark Rosenstein <mar@MIT.EDU>
To: xbugs@EXPO.LCS.MIT.EDU
Cc: bugs@ATHENA.MIT.EDU, marc@MIT.EDU
			  X Window System Bug Report
			    xbugs@expo.lcs.mit.edu


VERSION:
    R4+fix 1

CLIENT MACHINE and OPERATING SYSTEM:
    VS3100 running 4.3 (Athena release 6.4R)

DISPLAY TYPE:
    Digital QVSS

WINDOW MANAGER:
    twm

AREA:
    twm configure event handling

SYNOPSIS:
    The Athena program zwgc attempts to change the stacking order of
it's top level windows by sending a ConfigureRequest event to the root
window.  However, twm botches the handling of this event and never
changes the stacking order.

DESCRIPTION:
    There are two problems.  The first is that in twm/events.c, when
HandleConfigureRequest() is entered, Tmp_win is not set to the proper
structure because it looked at Event.any.window and got the Root
window instead of Event.xconfigurerequest.window to get the proper
window.  The second problem is that further down in
HandleConfigureRequest(), it only attempts to pull a window to the top
or push it all the way to the bottom, not really change the stacking
sequence.

REPEAT BY:
    Here's the code fragment from the client that generates the event
in question.  I haven't tried to write a small test program to
demonstrate this.

   if (reverse_stack) {
      if (bottom_gram) {
	 XWindowChanges winchanges;
	 
	 winchanges.sibling=bottom_gram->w;
	 winchanges.stack_mode=Below;
	 begin_xerror_trap(dpy);
	 XConfigureWindow(dpy,w,CWSibling|CWStackMode,&winchanges);
	 end_xerror_trap(dpy);

	 /* ICCCM compliance code:  This will happen under reparenting
	    window managers.  This is the compliant code: */
	 if (xerror_happened) {
	    XEvent ev;
	    
	    ev.type=ConfigureRequest;
	    ev.xconfigurerequest.parent=DefaultRootWindow(dpy);
	    ev.xconfigurerequest.window=w;
	    ev.xconfigurerequest.above=bottom_gram->w;
	    ev.xconfigurerequest.detail=Below;
	    ev.xconfigurerequest.value_mask=CWSibling|CWStackMode;
	    begin_xerror_trap(dpy);
	    XSendEvent(dpy,RootWindow(dpy,DefaultScreen(dpy)),
		       False,SubstructureRedirectMask|
		       SubstructureNotifyMask,&ev);
	    end_xerror_trap(dpy);
	    if (xerror_happened) {
	       /* the event didn't go.  Print error, continue */
	       ERROR("error configuring window to the bottom of the stack\n");
	    }
	 } else {
	    xerror_happened = 0;
	 }
      }
      add_to_bottom(gram);
      if (xerror_happened)
	pull_to_top(gram);
   }


SAMPLE FIX:

*** /mit/x11/src/mit/clients/twm/events.c	Thu Dec 14 14:52:19 1989
--- /mit/mar/src/twm/events.c	Thu Mar  1 11:15:59 1990
***************
*** 2010,2015 ****
--- 2010,2019 ----
      int gravx, gravy;
      XConfigureRequestEvent *cre = &Event.xconfigurerequest;
  
+     if (XFindContext (dpy, cre->window, TwmContext,
+ 		      (caddr_t *) &Tmp_win) == XCNOENT)
+       Tmp_win = NULL;
+ 
  #ifdef DEBUG_EVENTS
      fprintf(stderr, "ConfigureRequest\n");
      if (cre->value_mask & CWX)
***************
*** 2048,2057 ****
  
      if (cre->value_mask & CWStackMode)
      {
! 	if (cre->detail == Above)
! 	    XRaiseWindow(dpy, Tmp_win->frame);
! 	else if (cre->detail == Below)
! 	    XLowerWindow(dpy, Tmp_win->frame);
  
  	return;
      }
--- 2052,2067 ----
  
      if (cre->value_mask & CWStackMode)
      {
! 	TwmWindow *twin;
! 
! 	if (XFindContext (dpy, cre->above, TwmContext,
! 			  (caddr_t *) &twin) == XCNOENT)
! 	  xwc.sibling = cre->above;
! 	else
! 	  xwc.sibling = twin->frame;
! 	xwc.stack_mode = cre->detail;
! 	XConfigureWindow(dpy, Tmp_win->frame,
! 			 cre->value_mask & (CWSibling|CWStackMode), &xwc);
  
  	return;
      }


home help back first fref pref prev next nref lref last post