| Ticket UUID: | 578569 | |||
| Title: | iconified windows won't get drawn | |||
| Type: | Bug | Version: | obsolete: 8.3.4 | |
| Submitter: | nobody | Created on: | 2002-07-08 07:31:02 | |
| Subsystem: | 67. Unix Window Operations | Assigned To: | jenglish | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2002-12-28 04:34:34 | |
| Resolution: | Fixed | Closed By: | jenglish | |
| Closed on: | 2002-12-27 21:34:34 | |||
| Description: |
using the following script with parameter iconify
produces an empty window with *no* label and *no*
buttons inside !
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"
# Parameter : iconify - starts new toplevel inconified
# Parameter : withdraw - starts new toplevel withdrawn
proc noclose win {
wm protocol $win WM_DELETE_WINDOW { }
wm resizable $win 0 0
bind $win <Unmap> "wm deiconify $win"
}
wm withdraw .
set w .pw
toplevel $w
wm $argv $w
wm title $w "Toplevel"
label $w.l -font {helvetica 18 bold} -text "Test
Toplevel"
frame $w.b
button $w.b.ca -text Cancel -command "set r 0"
button $w.b.ok -text OK -command {set r 1} -default
active
pack $w.b.ca $w.b.ok -side left -padx 2m
bind $w <Return> "$w.b.ok invoke"
grid $w.l -row 0
grid $w.b -row 1
update idletasks
wm geometry $w +100+100
wm deiconify $w
noclose $w
tkwait variable r
destroy $w
exit
--- using this script under linux with fvwm produces an
empty window. I sent a bug report to the fvwm mailing
list an go the following response:
On Tue, Jul 02, 2002 at 01:34:45AM +0200, Dominik Vogt
wrote:
> On Mon, Jul 01, 2002 at 08:33:18PM +0200, Gerhard
Hintermayer wrote:> >
> > Dominik Vogt wrote:
> > >
> > > Okay, it took me quite some hours to figure this
out: It's *not*
> > > a problem with fvwm. Although you can't see it,
the application
> > > window *is* mapped. It's just that tk thinks it
is not visible
> > > and thus does not draw anything into it. I
couldn't find
> > > anything that fvwm is doing wrong. Actually, I
couldn't even
> > > find any difference in the requests that wish
sends to fvwm -
> > > regardless if the deiconify line is in the code
or not. I think
> > > there must be a bug in wish.
> > >
> >
> > Could it be the case,that fvwm>2.2.5 delivers
events to "wish" as a different
> > type. The update command distinguishes between all
events (no parameter) and> > idle callbacks (parameter
idletasks). Using no parameter for the update there
> > are no problems (if I remember correctly), but that
aim't no the way to go.
> > Seems like good old 2.2.5 delivers events the do
get processed as idle
> > callbacks, whereas all follow versions don't. I
have to take a look at the tcl
> > sources to get an idea, which event's are put into
which category.
>
> Fvwm does not send any events to the application
(well, almost,
> there are some cases, but these don't play a role here).
I am mistaken here. These events do play a role. For
some reason
(I think to make some other application happy when it
starts as an
icon), I forced an UnmapNotify event being sent to the
application
before the icon was created. I'm mystified as to why
wish thinks
the UnmapNotify negates the MapNotify that arrives later.
Maybe it processes events out of their proper order.
Anyway, I've
added a faked MapNotify event that is sent right before the
UnmapNotify, and wish seems to be happy now.
Please consider reporting this problem to the wish
developers. I
still think it's a bug in there that may well show
other symptoms.
In general processing events out of order - especially
events
that are of related types like MapNotify and
UnmapNotify - is
dangerous. It usually works as long as not much is
happening on
the desktop, but when things get really busy it may cause
problems.
Bye
Dominik ^_^ ^_^
--
Dominik Vogt, [email protected]
So there seems to be a problem with wish handling
window events. If I do an update instead of the update
idletasks, everything is fine, but that's not the way
this (window center, popup under mouse, popup at fixed
position) should be done.
Gerhard
| |||
| User Comments: |
jenglish added on 2002-12-28 04:21:22:
Logged In: YES user_id=68433 Committing patch (see attached). jenglish added on 2002-08-24 09:17:21: Logged In: YES
user_id=68433
OK, it looks like Dominik's educated guess is correct: Tk is
calling WaitForMapNotify(), which defers all events except
for ReparentNotify, ConfigureNotify, and the event being
waited for (in this case MapNotify). So the (synthetic)
UnmapNotify is deferred, the (real) MapNotify is processed,
WaitForMapNotify returns, and then the (deferred, synthetic)
UnmapNotify is processed out of order. So Tk thinks the
window is unmapped when it's really mapped.
This patch fixes the problem (tkUnixWm.c, WaitRestrictProc):
(NB: updated header comments not included!)
--- tkUnixWm.c 8 Aug 2002 23:49:50 -0000 1.33
+++ tkUnixWm.c 24 Aug 2002 01:34:58 -0000
@@ -4445,7 +4445,10 @@
infoPtr->foundEvent = 1;
return TK_PROCESS_EVENT;
}
- if (eventPtr->type == ConfigureNotify) {
+ if (eventPtr->type == ConfigureNotify
+ || eventPtr->type == MapNotify
+ || eventPtr->type == UnmapNotify
+ ) {
return TK_PROCESS_EVENT;
}
return TK_DEFER_EVENT;
----
That is, always process Map/UnmapNotify events (along with
ConfigureNotify events) regardless of what event is being
waited for.
This also makes the comments that "while waiting, all events
covered by StructureNotifyMask are processed" *slightly*
less inaccurate; to make the code fully match the comments,
DestroyNotify should also be processed (as should
CirculateNotify and GravityNotify, but Tk never receives
those two).
Forwarding to Mo for review.
nobody added on 2002-07-11 03:10:26: Logged In: NO Gerhard, you misunderstood me. The patch I suggested wasn't a fix. It was just a recommendation for debugging to make sure that the bug is not hidden behind another problem. Dominik ^_^ ^_^ nobody added on 2002-07-10 21:33:36: Logged In: NO Tried the suggested change for fvwm2 (V 2.4.8), error is still there. Gerhard (why the hell should I login if I alway show up as anonymous here ?) nobody added on 2002-07-10 16:17:02: Logged In: NO
Receiving the UnmapNotify out of order may partially be
caused by the fvwm code. If you have the fvwm-2.5.2
tarball, take a look at fvwm/events.c, line 2226 ff:
Iconify(Fw, win_opts);
if (is_new_window)
{
/* the window will not be mapped */
fake_map_unmap_notify(Fw, UnmapNotify);
}
The "Iconify()" call should be after the
fake_map_unmap_notify() call, not before it. This could
cause that the UnmapNotify for the window is received
*after* the MapNotify for the icon. In my tests it didn't
make a difference, but to make sure you're not running into
unexpected problems you should move the Iconify() call below
the curly braces.
--
The reason for the synthetic UnmapNotify event is (if I
remember correctly) that some application(s) don't like to
be initially mapped as an icon without their main window
ever being mapped. As a workaround, I've added a synthetic
MapNotify before the UnmapNotify. With this, the wish
problem goes away.
--
An educated guess about the "out of order" event processing:
It is often desirable to filter events of a certain type so
that only the last one on the event queue is processed. To
do this, I often call XCheck(Typed)WindowEvent in the fvwm
sources. wish is probably doing something similar with
(Un)MapNotify events. But the XCheck... functions don't
allow to check for both event types in a single call: you
can either give *one* event type or a mask. But the mask
(StructureNotifyMask) would selelect a whole lot more than
just (Un)MapNofify events. The only way out is using a
predicate procedure with XCheckIfEvent() (an example can be
found in the events.c file in the fvwm sources).
jenglish added on 2002-07-10 09:53:58: Logged In: YES user_id=68433 Problem replicated under fvwm 2.6.2. The unexpected <UnmapNotify> is likely the culprit. Not sure why this is being received out of order though. There may be a race condition involved too -- every once in a while the window contents _are_ displayed. This will take a bit more digging... nobody added on 2002-07-08 20:42:42: Logged In: NO Try fvwm versions 2.4.8 (stable) or 2.5.2 (latest development) to reproduce. In later releases, I wrote a workaround for the problem, so it won't show up with 2.4.9 nad later or 2.5.3 and later. Dominik ^_^ ^_^ | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki