Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / gnu / awt / xlib / XEventQueue.java
blobb068daf1b52fe69770f80d6266fbaa8b9e493d73
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
7 details. */
9 package gnu.awt.xlib;
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;
19 /**
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
25 Display display;
27 public XEventQueue(Display display)
29 this.display = display;
32 public AWTEvent getNextEvent() throws InterruptedException
34 if ((peekEvent() == null) && (display != null))
35 display.flush();
36 AWTEvent event = super.getNextEvent();
37 if (event != null)
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 ();
54 break;
56 case ComponentEvent.COMPONENT_RESIZED:
58 ComponentEvent ce = (ComponentEvent)event;
59 // FIXME: there may be opportunities to coalesce resize events
60 ce.getComponent ().validate ();
62 break;
64 case ComponentEvent.COMPONENT_SHOWN:
66 ComponentEvent ce = (ComponentEvent)event;
67 Component comp = ce.getComponent ();
68 if (!comp.isValid ())
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 ())
80 parent.validate ();
81 break;
83 else
84 parent = next;
86 if (comp instanceof Container)
87 comp.validate ();
89 comp.repaint ();
91 break;
93 default:
94 break;
97 return event;