>Synopsis: cwm sent a window to the bottom of the stacking order when it
>asked to be raised.
>Category: user
>Environment:
System : OpenBSD 5.3
Details : OpenBSD 5.3-current (GENERIC) #0: Sun Mar 17 10:21:01 EDT
2013
[email protected]:/usr/src/sys/arch/macppc/compile/GENERIC
Architecture: OpenBSD.macppc
Machine : macppc
>Description:
While using emacs org mode and entering a timestamp using [C-c !] the
emacs window would drop to the bottom of the X stacking order. This
command can be traced to the raise-frame function which sends a raise
window request to cwm.
It happened consistently for me, but when I asked another user on
daemonforums to try it he found it only happened on his macppc and not
his i386 machine. Also, I had it go away briefly when I fumbled in
getting debugging information (unstripped but no -g or maybe a mix of
object files with -g and without, not sure now). I mention this in
case you don't see the problem yourself. There's an uninitialized auto
involved, which I believe to be the cause of the pseudo-intermittency.
With debugging info I could step through xevents.c::xev_handle_configurerequest
and see the following:
1. The call to XConfigureWindow reuses the value mask from the
incoming XConfigureReqestEvent.
2. The value of that mask was 64. i.e. CWStackMode (defined as 1 << 6 in X.h)
3. CWStackMode is not one of the bits looked for in the preceding
check masks and set corresponding wc field statements.
4. Not involved in my scenario I don't think, but CWSibling is also missing.
5. The XWindowChanges variable wc used for the XConfigureWindow call
happens to have the value 1 for its stack_mode field for me. 1 is
defined as Below in X.h. Above is 0.
When I add checks for CWStackMode and CWSibling with appropriate sets
of the corresponding wc fields (excuse the pun) the problem seems
fixed. If it's on top it stays on top. If it's lower it raises.
A couple other things puzzled me in this function that don't affect me
and may not be important:
1. wc.border_width will be set if the incoming event has CWBorderWidth
in it's value mask, but a few lines later that value will be overwritten with
cc->bwidth.
2. In the else clause the CWStackMode of the value mask is cleared but
the wc.stack_mode field is set. Is this for documentation that the
window will be raised by other means when the window eventually gets mapped?
>How-To-Repeat:
1. with cwm running start emacs and an xterm
2. place the emacs window so it overlaps the xterm window
3. in the scratch buffer evaluate the emacs lisp expression
(raise-frame)
4. you may see the emacs window fall to the bottom.
Or, if you don't want to run emacs, compile and run this
program (I wanted to eliminate emacs as a culprit at one
point). If you overlap another window with it and click on it
you may see it fall to the back, or something.
========================================================================
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <err.h>
#include <stdlib.h>
const char msg_raise[] = "Click to raise.";
const char msg_quit[] = "Q to quit.";
int
main()
{
Display *dpy;
Screen *s;
Window win;
XEvent ev;
GC gc;
XGCValues values;
KeySym k;
unsigned long black;
dpy = XOpenDisplay(NULL);
if (!dpy)
errx(1, "XOpenDpy: Couldn't open X dpy.");
s = DefaultScreenOfDisplay(dpy);
black = BlackPixelOfScreen(s);
win = XCreateSimpleWindow(dpy, RootWindowOfScreen(s),
WidthOfScreen(s)/2 - 100, HeightOfScreen(s)/2
- 100,
180, 150, 2,
black, WhitePixelOfScreen(s));
XSelectInput(dpy, win, ButtonPressMask|KeyReleaseMask|ExposureMask);
XMapWindow(dpy, win);
values.font = XLoadFont(dpy, "fixed");
gc = XCreateGC(dpy, win, GCFont, &values);
while (1) {
XNextEvent(dpy, &ev);
switch (ev.type) {
case ButtonPress:
XRaiseWindow(dpy, win);
break;
case KeyRelease:
k = XkbKeycodeToKeysym(dpy, ev.xkey.keycode, 0, 0);
if (k == XK_q || k == XK_Q) {
XCloseDisplay(dpy);
return 0;
}
break;
case Expose:
XDrawString(dpy, win, gc, 20, 20, msg_raise,
sizeof(msg_raise) - 1);
XDrawString(dpy, win, gc, 20, 75, msg_quit,
sizeof(msg_quit) - 1);
break;
}
}
return 1;
}
========================================================================
>Fix:
Index: xevents.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/xevents.c,v
retrieving revision 1.72
diff -u -r1.72 xevents.c
--- xevents.c 29 Apr 2013 00:56:48 -0000 1.72
+++ xevents.c 2 May 2013 04:03:54 -0000
@@ -151,6 +151,10 @@
cc->geom.y = e->y;
if (e->value_mask & CWBorderWidth)
wc.border_width = e->border_width;
+ if (e->value_mask & CWSibling)
+ wc.sibling = e->above;
+ if (e->value_mask & CWStackMode)
+ wc.stack_mode = e->detail;
if (cc->geom.x == 0 && cc->geom.w >= sc->view.w)
cc->geom.x -= cc->bwidth;
dmesg:
OpenBSD 5.3-current (GENERIC) #0: Sun Mar 17 10:21:01 EDT 2013
[email protected]:/usr/src/sys/arch/macppc/compile/GENERIC
real mem = 402653184 (384MB)
avail mem = 376856576 (359MB)
mainbus0 at root: model PowerMac3,4
cpu0 at mainbus0: 7400 (Revision 0x209): 466 MHz: 1MB backside cache
mem0 at mainbus0
spdmem0 at mem0: 128MB SDRAM non-parity PC133CL2
spdmem1 at mem0: 256MB SDRAM non-parity PC133CL3
memc0 at mainbus0: uni-n rev 0x11
kiic0 at memc0 offset 0xf8001000
iic0 at kiic0
mpcpcibr0 at mainbus0 pci: uni-north
pci0 at mpcpcibr0 bus 0
pchb0 at pci0 dev 11 function 0 "Apple Uni-N2 AGP" rev 0x00
appleagp0 at pchb0
agp0 at appleagp0: aperture at 0x0, size 0x10000000
vgafb0 at pci0 dev 16 function 0 "ATI Rage Fury" rev 0x00, mmio
wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation)
mpcpcibr1 at mainbus0 pci: uni-north
pci1 at mpcpcibr1 bus 0
pchb1 at pci1 dev 11 function 0 "Apple Uni-N2 Host" rev 0x00
macobio0 at pci1 dev 23 function 0 "Apple Keylargo" rev 0x03
openpic0 at macobio0 offset 0x40000: version 0x4614 feature 3f0302 LE
macgpio0 at macobio0 offset 0x50
macgpio1 at macgpio0 irq 47
pgs0 at macgpio0: irq 55
"gpio5" at macgpio0 not configured
"gpio6" at macgpio0 not configured
"gpio11" at macgpio0 not configured
"extint-gpio15" at macgpio0 not configured
"extint-gpio16" at macgpio0 not configured
"escc-legacy" at macobio0 offset 0x12000 not configured
zsc0 at macobio0 offset 0x13000: irq 22,50
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
tumbler0 at macobio0 offset 0x10000: irq 30,1,2
"timer" at macobio0 offset 0x15000 not configured
adb0 at macobio0 offset 0x16000apm0 at adb0: battery flags 0x9, 0% charged
kiic1 at macobio0 offset 0x18000
iic1 at kiic1
wdc0 at macobio0 offset 0x1f000 irq 19: DMA
wd0 at wdc0 channel 0 drive 0: <WDC WD5000AAKB-00H8A0>
wd0: 16-sector PIO, LBA48, 476940MB, 976773168 sectors
wd0(wdc0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 4
wdc1 at macobio0 offset 0x20000 irq 20: DMA
atapiscsi0 at wdc1 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <PIONEER, DVD-RW DVR-115D, 1.18> ATAPI 5/cdrom
removable
cd0(wdc1:0:0): using BIOS timings, DMA mode 2
wdc2 at macobio0 offset 0x21000 irq 21: DMA
audio0 at tumbler0
ohci0 at pci1 dev 24 function 0 "Apple USB" rev 0x00: irq 27, version 1.0
ohci1 at pci1 dev 25 function 0 "Apple USB" rev 0x00: irq 28, version 1.0
usb0 at ohci0: USB revision 1.0
uhub0 at usb0 "Apple OHCI root hub" rev 1.00/1.00 addr 1
usb1 at ohci1: USB revision 1.0
uhub1 at usb1 "Apple OHCI root hub" rev 1.00/1.00 addr 1
mpcpcibr2 at mainbus0 pci: uni-north
pci2 at mpcpcibr2 bus 0
pchb2 at pci2 dev 11 function 0 "Apple Uni-N2 Host" rev 0x00
"AT&T/Lucent FW322 1394" rev 0x00 at pci2 dev 14 function 0 not configured
gem0 at pci2 dev 15 function 0 "Apple Uni-N GMAC" rev 0x01: irq 41, address
00:03:93:04:f9:b2
brgphy0 at gem0 phy 0: BCM5401 10/100/1000baseT PHY, rev. 3
uhub2 at uhub0 port 1 "Chicony Generic USB Hub" rev 1.10/1.00 addr 2
uhidev0 at uhub2 port 1 configuration 1 interface 0 "Chicony PFU-65 USB
Keyboard" rev 1.10/1.00 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd0 at ukbd0: console keyboard, using wsdisplay0
uhidev1 at uhub2 port 3 configuration 1 interface 0 "Microsoft Microsoft
3-Button Mouse with IntelliEye(TM)" rev 1.10/3.00 addr 4
uhidev1: iclass 3/1
ums0 at uhidev1: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
bootpath: /pci@f2000000/mac-io@17/ata-4@1f000/disk@0:/bsd
root on wd0a (3f97fe9f914a8e3b.a) swap on wd0b dump on wd0b
usbdevs:
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000),
Apple(0x106b), rev 1.00
port 1 addr 2: full speed, power 90 mA, config 1, Generic USB Hub(0x0065),
Chicony(0x0472), rev 1.00
port 1 addr 3: full speed, self powered, config 1, PFU-65 USB
Keyboard(0x0065), Chicony(0x0472), rev 1.00
port 2 powered
port 3 addr 4: low speed, power 100 mA, config 1, Microsoft 3-Button Mouse
with IntelliEye(TM)(0x0040), Microsoft(0x045e), rev 3.00
port 2 powered
Controller /dev/usb1:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000),
Apple(0x106b), rev 1.00
port 1 powered
port 2 powered