summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe <gheorghe>2008-08-26 20:32:22 +0000
committerBogdan Gheorghe <gheorghe>2008-08-26 20:32:22 +0000
commit9309510417c504bcafbd967087551fc387739261 (patch)
tree8491871f0f8946cb0771495c7f85b674694d7ee9
parent5a9d0980e4c56f49cd3e1d33e0b56e04218b6d4f (diff)
downloadeclipse.platform.swt-9309510417c504bcafbd967087551fc387739261.tar.gz
eclipse.platform.swt-9309510417c504bcafbd967087551fc387739261.tar.xz
eclipse.platform.swt-9309510417c504bcafbd967087551fc387739261.zip
173218 [SWT_AWT] SWT needs to support ModalityListener interface
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java9
8 files changed, 59 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index de04600d45..4edd702666 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -867,6 +867,11 @@ OS__XSetInputFocus_1=cast=Window
OS__XSetInputFocus_2=
OS__XSetInputFocus_3=
+OS__XSetTransientForHint=
+OS__XSetTransientForHint_0=cast=(Display *)
+OS__XSetTransientForHint_1=cast=(Window)
+OS__XSetTransientForHint_2=cast=(Window)
+
OS__XSynchronize=
OS__XSynchronize_0=cast=(Display *)
OS__XSynchronize_1=
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
index df261568f3..24fcdd5496 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java
@@ -26,10 +26,13 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Event;
/* AWT Imports */
+import java.awt.AWTEvent;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Canvas;
import java.awt.Frame;
+import java.awt.Window;
+import java.awt.event.AWTEventListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowEvent;
@@ -60,7 +63,7 @@ public class SWT_AWT {
static boolean loaded, swingInitialized;
-static native final int /*long*/ getAWTHandle (Canvas canvas);
+static native final int /*long*/ getAWTHandle (Object canvas);
static native final void setDebug (Frame canvas, boolean debug);
static synchronized void loadLibrary () {
@@ -186,6 +189,27 @@ public static Frame new_Frame (final Composite parent) {
Method method = clazz.getMethod("registerListeners", null);
if (method != null) method.invoke(value, null);
} catch (Throwable e) {}
+ final AWTEventListener awtListener = new AWTEventListener() {
+ public void eventDispatched(AWTEvent event) {
+ if (event.getID() == WindowEvent.WINDOW_OPENED) {
+ final Window window = (Window) event.getSource();
+ if (window.getParent() == frame) {
+ parent.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (parent.isDisposed()) return;
+ Shell shell = parent.getShell();
+ loadLibrary();
+ int /*long*/ awtHandle = getAWTHandle(window);
+ if (awtHandle == 0) return;
+ int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid(OS.GTK_WIDGET_WINDOW(OS.gtk_widget_get_toplevel(shell.handle)));
+ OS.XSetTransientForHint(OS.GDK_DISPLAY(), awtHandle, xWindow);
+ }
+ });
+ }
+ }
+ }
+ };
+ frame.getToolkit().addAWTEventListener(awtListener, AWTEvent.WINDOW_EVENT_MASK);
final Listener shellListener = new Listener () {
public void handleEvent (Event e) {
switch (e.type) {
@@ -220,6 +244,7 @@ public static Frame new_Frame (final Composite parent) {
parent.setVisible(false);
EventQueue.invokeLater(new Runnable () {
public void run () {
+ frame.getToolkit().removeAWTEventListener(awtListener);
frame.dispose ();
}
});
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 6bd3dabcdd..070b3ddfc5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -2104,6 +2104,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1XSetInputFocus)
}
#endif
+#ifndef NO__1XSetTransientForHint
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSetTransientForHint)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1XSetTransientForHint_FUNC);
+ rc = (jint)XSetTransientForHint((Display *)arg0, (Window)arg1, (Window)arg2);
+ OS_NATIVE_EXIT(env, that, _1XSetTransientForHint_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1XSynchronize
JNIEXPORT jint JNICALL OS_NATIVE(_1XSynchronize)
(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index ea3597c548..e930b9b1c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
@@ -59,6 +59,7 @@
#define NO__1XSynchronize
#define NO__1XSetErrorHandler
#define NO__1XSetIOErrorHandler
+#define NO__1XSetTransientForHint
#define NO__1XTestFakeButtonEvent
#define NO__1XTestFakeKeyEvent
#define NO__1XTestFakeMotionEvent
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 8911e9181c..d878c6c383 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1265;
-int OS_nativeFunctionCallCount[1265];
+int OS_nativeFunctionCount = 1266;
+int OS_nativeFunctionCallCount[1266];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1EVENT_1TYPE",
@@ -178,6 +178,7 @@ char * OS_nativeFunctionNames[] = {
"_1XSetErrorHandler",
"_1XSetIOErrorHandler",
"_1XSetInputFocus",
+ "_1XSetTransientForHint",
"_1XSynchronize",
"_1XTestFakeButtonEvent",
"_1XTestFakeKeyEvent",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 7ab714e0e0..df709727a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -186,6 +186,7 @@ typedef enum {
_1XSetErrorHandler_FUNC,
_1XSetIOErrorHandler_FUNC,
_1XSetInputFocus_FUNC,
+ _1XSetTransientForHint_FUNC,
_1XSynchronize_FUNC,
_1XTestFakeButtonEvent_FUNC,
_1XTestFakeKeyEvent_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h
index 16c7e051b8..4c1a302d8c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_structs.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 79ab3ab4a3..7613168141 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -826,6 +826,15 @@ public static final int XSetInputFocus(int /*long*/ display, int /*long*/ window
lock.unlock();
}
}
+public static final native int _XSetTransientForHint(int /*long*/ display, int /*long*/ w, int /*long*/ prop_window);
+public static final int XSetTransientForHint(int /*long*/ display, int /*long*/ w, int /*long*/ prop_window) {
+ lock.lock();
+ try {
+ return _XSetTransientForHint(display, w, prop_window);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int /*long*/ _XSynchronize(int /*long*/ display, boolean onoff);
public static final int /*long*/ XSynchronize(int /*long*/ display, boolean onoff) {
lock.lock();