1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 import gnu
.gcj
.xlib
.Display
;
12 import java
.awt
.AWTEvent
;
13 import java
.awt
.Component
;
14 import java
.awt
.Container
;
15 import java
.awt
.EventQueue
;
16 import java
.awt
.event
.ComponentEvent
;
17 import java
.awt
.event
.ContainerEvent
;
20 * The main difference here from a standard EventQueue is that the X
21 * display connection is flushed before waiting for more events.
23 public class XEventQueue
extends EventQueue
27 public XEventQueue(Display display
)
29 this.display
= display
;
32 public AWTEvent
getNextEvent() throws InterruptedException
34 if ((peekEvent() == null) && (display
!= null))
36 AWTEvent event
= super.getNextEvent();
39 switch (event
.getID ())
41 case ContainerEvent
.COMPONENT_ADDED
:
43 /* If a component has been added to a container, it needs to be
44 * invalidated, to ensure that it ultimately gets an addNotify.
45 * If it's not invalidated, the component will never display in
46 * an already-showing container (probably applies only to CardLayout).
47 * Perhaps this code should be in java.awt, but the problem only seems
48 * to happen with xlib peers (not with gtk peers) so it's here instead.
50 ContainerEvent ce
= (ContainerEvent
)event
;
51 ce
.getChild ().invalidate ();
52 ce
.getContainer ().validate ();
56 case ComponentEvent
.COMPONENT_RESIZED
:
58 ComponentEvent ce
= (ComponentEvent
)event
;
59 // FIXME: there may be opportunities to coalesce resize events
60 ce
.getComponent ().validate ();
64 case ComponentEvent
.COMPONENT_SHOWN
:
66 ComponentEvent ce
= (ComponentEvent
)event
;
67 Component comp
= ce
.getComponent ();
70 /* Try to validate, going up the tree to the highest-level invalid
71 * Container. The idea is to ensure that addNotify gets called for
72 * any non-top-level component being shown, to make it create a peer.
74 Container parent
= comp
.getParent ();
75 while (parent
!= null)
77 Container next
= parent
.getParent ();
78 if (next
== null || next
.isValid ())
86 if (comp
instanceof Container
)