Subject: FVWM: bug: XMapWindow/XUnmapWindow race condition

From: Jindrich Makovicka <[email-masked]>
Date: Wed, 16 Mar 2005 12:19:21 +0100

Hello,

There is a problem with XMapWindow and XUnmapWindow handling - when they 
are called too fast one after another, the window just disappears. This 
is the cause of disappearing window in official binary builds of mozilla 
and probably also in new Adobe Reader 7.

Sample code triggering the bug is attached. The created window is 
visible for one second, then disappears forever. After uncommenting the 
delay between map and unmap, the window vanishes for 1 second, then 
appears again.

-- 
Jindrich Makovicka
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <unistd.h>

Display *dpy;
Screen *scr;
Window root_win;
int scr_width, scr_height;
int depth;

XSizeHints hint;
XSetWindowAttributes attrib;

Window win;
int win_width, win_height;

int main(int argc, char **argv)
{
  XEvent ev;
  int i, j;
  int x;

  dpy = XOpenDisplay(":0.0");
  scr = DefaultScreenOfDisplay(dpy);
  root_win = RootWindowOfScreen(scr);
  scr_height = XHeightOfScreen(scr);
  scr_width = XWidthOfScreen(scr);
  depth = DefaultDepth(dpy, 0);

  win_width = 100;
  win_height = 100;

  win = XCreateWindow(dpy, root_win, 500, 500, win_width, win_height, 0, CopyFromParent, InputOutput,
                      CopyFromParent, 0, &attrib);
  XMapWindow(dpy, win);
  XFlush(dpy);
  sleep(1);
  
  XUnmapWindow(dpy, win);
  XFlush(dpy);
//  sleep(1); // uncomment to make it work
  XMapWindow(dpy, win);
  XFlush(dpy);

  sleep(5);

  XCloseDisplay(dpy);
  return 0;
}

---

From: Dan Espen <[email-masked]>
Date: Wed, 16 Mar 2005 23:14:52 -0500

> and probably also in new Adobe Reader 7.

How do I make a mozilla window disappear?

> delay between map and unmap, the window vanishes for 1 second, then 

Shouldn't that be using

Xsync(dpy,True)

if you really want to have the server display something?

-- 
Dan Espen                           E-mail: [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Jindrich Makovicka <[email-masked]>
Date: Thu, 17 Mar 2005 09:48:15 +0100

Dan Espen wrote:
>> There is a problem with XMapWindow and XUnmapWindow handling - when
>> they are called too fast one after another, the window just
>> disappears. This is the cause of disappearing window in official
>> binary builds of mozilla and probably also in new Adobe Reader 7.
> 
> 

Try to do fullscreen (press f11) several times. Note that most
distribution builds don't do it, as they use EWMH, only the official
build has this problem. See also "FVWM: firefox disapera on full screen" 
thread on this list. Same with Reader 7.0.

>> visible for one second, then disappears forever. After uncommenting
>> the delay between map and unmap, the window vanishes for 1 second,
>> then appears again.
> 
> 
> Shouldn't that be using
> 
> Xsync(dpy,True)
> 

When I replace XFlush(dpy) with XSync(dpy,False), it behaves the same.
XSync(dpy, True) discards queued events and is almost never used, IMO.

---

From: Vincent Bernat <[email-masked]>
Date: Thu, 17 Mar 2005 11:28:51 +0100

OoO En  cette matinée ensoleillée du  jeudi 17 mars  2005, vers 09:48,

> thread on this list. Same with Reader 7.0.

I confirm this bug too.
-- 
I WILL NOT FILE FRIVOLOUS LAWSUITS
I WILL NOT FILE FRIVOLOUS LAWSUITS
I WILL NOT FILE FRIVOLOUS LAWSUITS
-+- Bart Simpson on chalkboard in episode 5F21
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].