GtkDialogPeer.java (handleEvent): Remove method.
2003-10-24 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/awt/peer/gtk/GtkDialogPeer.java (handleEvent): Remove method. * gnu/java/awt/peer/gtk/GtkWindowPeer.java (postWindowEvent): New method. * java/awt/Window.java (Window(Window,GraphicsConfiguration), show, hide, dispose, getOwnedWindows): Synchronize on tree lock. (dispose): Post WINDOW_CLOSED event. (addWindowFocusListener, addWindowStateListener): Assign result of multicaster add back to window listener. (removeWindowFocusListener, removeWindowStateListener): Assign result of multicaster remove back to window listener. (dispatchEventImpl): Add null checks for focus and state listeners. (processWindowEvent): Handle case where windowListener is null but state or focus listeners exist. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c: Add JNI glue for postWindowEvent. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (window_delete_cb, window_destroy_cb, window_show_cb, window_focus_in_cb, window_focus_out_cb, window_window_state_cb, window_get_new_state): New functions. * jni/gtk-peer/gtkpeer.h: Define window event and frame state macros. Declare postWindowEventID. From-SVN: r72906
This commit is contained in:
parent
6545596245
commit
f2d0e05d4e
7 changed files with 335 additions and 60 deletions
|
@ -144,13 +144,12 @@ public class Window extends Container implements Accessible
|
|||
{
|
||||
this ();
|
||||
|
||||
if (owner == null)
|
||||
throw new IllegalArgumentException ("owner must not be null");
|
||||
|
||||
parent = owner;
|
||||
|
||||
synchronized (owner.ownedWindows)
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
if (owner == null)
|
||||
throw new IllegalArgumentException ("owner must not be null");
|
||||
|
||||
parent = owner;
|
||||
owner.ownedWindows.add(new WeakReference(this));
|
||||
}
|
||||
|
||||
|
@ -220,7 +219,7 @@ public class Window extends Container implements Accessible
|
|||
addNotify();
|
||||
|
||||
// Show visible owned windows.
|
||||
synchronized (ownedWindows)
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while(e.hasNext())
|
||||
|
@ -247,7 +246,7 @@ public class Window extends Container implements Accessible
|
|||
public void hide()
|
||||
{
|
||||
// Hide visible owned windows.
|
||||
synchronized (ownedWindows)
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while(e.hasNext())
|
||||
|
@ -280,7 +279,7 @@ public class Window extends Container implements Accessible
|
|||
{
|
||||
hide();
|
||||
|
||||
synchronized (ownedWindows)
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while(e.hasNext())
|
||||
|
@ -292,11 +291,15 @@ public class Window extends Container implements Accessible
|
|||
// Remove null weak reference from ownedWindows.
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
component[i].removeNotify();
|
||||
this.removeNotify();
|
||||
for (int i = 0; i < ncomponents; ++i)
|
||||
component[i].removeNotify();
|
||||
this.removeNotify();
|
||||
|
||||
// Post a WINDOW_CLOSED event.
|
||||
WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
|
||||
getToolkit().getSystemEventQueue().postEvent(we);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -386,7 +389,7 @@ public class Window extends Container implements Accessible
|
|||
public Window[] getOwnedWindows()
|
||||
{
|
||||
Window [] trimmedList;
|
||||
synchronized (ownedWindows)
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
// Windows with non-null weak references in ownedWindows.
|
||||
Window [] validList = new Window [ownedWindows.size()];
|
||||
|
@ -479,7 +482,7 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void addWindowFocusListener (WindowFocusListener wfl)
|
||||
{
|
||||
AWTEventMulticaster.add (windowFocusListener, wfl);
|
||||
windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -489,7 +492,7 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void addWindowStateListener (WindowStateListener wsl)
|
||||
{
|
||||
AWTEventMulticaster.add (windowStateListener, wsl);
|
||||
windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -497,7 +500,7 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void removeWindowFocusListener (WindowFocusListener wfl)
|
||||
{
|
||||
AWTEventMulticaster.remove (windowFocusListener, wfl);
|
||||
windowFocusListener = AWTEventMulticaster.remove (windowFocusListener, wfl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -507,7 +510,7 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void removeWindowStateListener (WindowStateListener wsl)
|
||||
{
|
||||
AWTEventMulticaster.remove (windowStateListener, wsl);
|
||||
windowStateListener = AWTEventMulticaster.remove (windowStateListener, wsl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -532,7 +535,9 @@ public class Window extends Container implements Accessible
|
|||
// Make use of event id's in order to avoid multiple instanceof tests.
|
||||
if (e.id <= WindowEvent.WINDOW_LAST
|
||||
&& e.id >= WindowEvent.WINDOW_FIRST
|
||||
&& (windowListener != null
|
||||
&& (windowListener != null
|
||||
|| windowFocusListener != null
|
||||
|| windowStateListener != null
|
||||
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
|
@ -565,39 +570,51 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
protected void processWindowEvent(WindowEvent evt)
|
||||
{
|
||||
if (windowListener != null)
|
||||
int id = evt.getID();
|
||||
|
||||
if (id == WindowEvent.WINDOW_GAINED_FOCUS
|
||||
|| id == WindowEvent.WINDOW_LOST_FOCUS)
|
||||
processWindowFocusEvent (evt);
|
||||
else if (id == WindowEvent.WINDOW_STATE_CHANGED)
|
||||
processWindowStateEvent (evt);
|
||||
else
|
||||
{
|
||||
switch (evt.getID())
|
||||
{
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
windowListener.windowActivated(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
windowListener.windowClosed(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
windowListener.windowClosing(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
windowListener.windowDeactivated(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
windowListener.windowDeiconified(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
windowListener.windowIconified(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
windowListener.windowOpened(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_GAINED_FOCUS:
|
||||
case WindowEvent.WINDOW_LOST_FOCUS:
|
||||
processWindowFocusEvent (evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
processWindowStateEvent (evt);
|
||||
break;
|
||||
}
|
||||
if (windowListener != null)
|
||||
{
|
||||
switch (evt.getID())
|
||||
{
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
windowListener.windowActivated(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
windowListener.windowClosed(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
windowListener.windowClosing(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
windowListener.windowDeactivated(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
windowListener.windowDeiconified(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
windowListener.windowIconified(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
windowListener.windowOpened(evt);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue