Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2013-04-19 14:49:52 +0000
committerGrant Gayed2013-04-19 14:49:52 +0000
commit2f56c976aeccd242de2a882f321f32fed92b31ff (patch)
tree1bf072f494500d44ac534cc089af7490b6d457b1 /bundles/org.eclipse.swt/Eclipse SWT CEF
parent527bf06773b237e962f3d6f1e68e20bc57bac389 (diff)
downloadeclipse.platform.swt-ggayed/cef3.tar.gz
eclipse.platform.swt-ggayed/cef3.tar.xz
eclipse.platform.swt-ggayed/cef3.zip
fix CEF3 window open/close/show handlingggayed/cef3
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT CEF')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLifeSpanHandler.java31
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_window_info_t.java2
7 files changed, 89 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
index 5a7fc3f9ad..f2a62506a2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3.c
@@ -648,6 +648,43 @@ JNIEXPORT void JNICALL CEF3_NATIVE(cef_1string_1userfree_1free)
}
#endif
+#ifndef NO_cef_1window_1info_1t_1sizeof
+JNIEXPORT jint JNICALL CEF3_NATIVE(cef_1window_1info_1t_1sizeof)
+ (JNIEnv *env, jclass that)
+{
+ jint rc = 0;
+ CEF3_NATIVE_ENTER(env, that, cef_1window_1info_1t_1sizeof_FUNC);
+ rc = (jint)cef_window_info_t_sizeof();
+ CEF3_NATIVE_EXIT(env, that, cef_1window_1info_1t_1sizeof_FUNC);
+ return rc;
+}
+#endif
+
+#if (!defined(NO_memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I) && !defined(JNI64)) || (!defined(NO_memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jintLong arg2)
+#else
+JNIEXPORT void JNICALL CEF3_NATIVE(memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J)(JNIEnv *env, jclass that, jintLong arg0, jobject arg1, jintLong arg2)
+#endif
+{
+ cef_window_info_t _arg1, *lparg1=NULL;
+#ifndef JNI64
+ CEF3_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I_FUNC);
+#else
+ CEF3_NATIVE_ENTER(env, that, memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J_FUNC);
+#endif
+ if (arg1) if ((lparg1 = getcef_window_info_tFields(env, arg1, &_arg1)) == NULL) goto fail;
+ memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+ if (arg1 && lparg1) setcef_window_info_tFields(env, arg1, lparg1);
+#ifndef JNI64
+ CEF3_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I_FUNC);
+#else
+ CEF3_NATIVE_EXIT(env, that, memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2II) && !defined(JNI64)) || (!defined(NO_memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2JJ) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL CEF3_NATIVE(memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2II)(JNIEnv *env, jclass that, jobject arg0, jintLong arg1, jintLong arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
index 73baa2bd41..1f6af2d89f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.c
@@ -104,6 +104,12 @@ char * CEF3_nativeFunctionNames[] = {
"cef_1string_1set",
"cef_1string_1t_1sizeof",
"cef_1string_1userfree_1free",
+ "cef_1window_1info_1t_1sizeof",
+#ifndef JNI64
+ "memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I",
+#else
+ "memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J",
+#endif
#ifndef JNI64
"memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2II",
#else
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
index 017bd138ff..81c1f1b502 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/library/cef3_stats.h
@@ -114,6 +114,12 @@ typedef enum {
cef_1string_1set_FUNC,
cef_1string_1t_1sizeof_FUNC,
cef_1string_1userfree_1free_FUNC,
+ cef_1window_1info_1t_1sizeof_FUNC,
+#ifndef JNI64
+ memmove__ILorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2I_FUNC,
+#else
+ memmove__JLorg_eclipse_swt_internal_cef3_cef_1window_1info_1t_2J_FUNC,
+#endif
#ifndef JNI64
memmove__Lorg_eclipse_swt_internal_cef3_cef_1base_1t_2II_FUNC,
#else
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
index f15be60099..ea451b96ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEF.java
@@ -201,7 +201,8 @@ static String ExtractCEFString(long /*int*/ pString) {
static Browser FindBrowser(CEFBrowser cefBrowser) {
CEFBrowserHost host = new CEFBrowserHost(cefBrowser.get_host());
long /*int*/ windowHandle = host.get_window_handle();
- return (Browser)Display.getCurrent().findWidget(windowHandle);
+ long /*int*/ parent = OS.GetParent(windowHandle);
+ return (Browser)Display.getCurrent().findWidget(parent);
}
static boolean IsInstalled() {
@@ -671,7 +672,7 @@ void onMessageReceived(long /*int*/ pMessage) {
void onResize() {
Rectangle bounds = browser.getClientArea();
- OS.SetWindowPos(windowHandle, 0, bounds.x, bounds.y, bounds.width, bounds.height, OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS);
+ OS.SetWindowPos(windowHandle, 0, 0, 0, bounds.width, bounds.height, OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS);
}
void onStatusMessage(String status) {
@@ -703,7 +704,7 @@ void onWindowClose() {
}
}
-boolean onWindowOpen(String targetUrl, cef_popup_features_t features) {
+CEF onWindowOpen(String targetUrl, cef_popup_features_t features) {
WindowEvent newEvent = new WindowEvent(browser);
newEvent.display = browser.getDisplay();
newEvent.widget = browser;
@@ -711,18 +712,18 @@ boolean onWindowOpen(String targetUrl, cef_popup_features_t features) {
for (int i = 0; i < openWindowListeners.length; i++) {
openWindowListeners[i].open(newEvent);
}
- if (browser.isDisposed()) return false;
+ if (browser.isDisposed()) return null;
Browser childBrowser = null;
if (newEvent.browser != null && newEvent.browser.webBrowser instanceof CEF) {
childBrowser = newEvent.browser;
}
- if (childBrowser == null || childBrowser.isDisposed()) return false;
+ if (childBrowser == null || childBrowser.isDisposed()) return null;
CEF webBrowser = (CEF)childBrowser.webBrowser;
webBrowser.setUrl(targetUrl, null, null);
webBrowser.setPopupFeatures(features);
- return true;
+ return webBrowser;
}
public void refresh() {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLifeSpanHandler.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLifeSpanHandler.java
index d7db85e4e6..704e087a77 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLifeSpanHandler.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/browser/CEFLifeSpanHandler.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.swt.browser;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.internal.C;
import org.eclipse.swt.internal.cef3.*;
+import org.eclipse.swt.internal.win32.OS;
public class CEFLifeSpanHandler {
CEF3Object object;
@@ -62,24 +64,39 @@ synchronized int release() {
/* cef_life_span_handler_t */
-long /*int*/ on_before_popup(long /*int*/ browser, long /*int*/ frame, final long /*int*/ target_url, long /*int*/ target_frame_name, long /*int*/ pPopupFeatures, long /*int*/ windowInfo, long /*int*/ client, long /*int*/ settings, long /*int*/ no_javascript_access) {
+long /*int*/ on_before_popup(long /*int*/ browser, long /*int*/ frame, final long /*int*/ target_url, long /*int*/ target_frame_name, long /*int*/ pPopupFeatures, final long /*int*/ windowInfo, final long /*int*/ client, long /*int*/ settings, long /*int*/ no_javascript_access) {
if (Device.DEBUG) System.out.println("on_before_popup (impl)");
final cef_popup_features_t popupFeatures = new cef_popup_features_t();
CEF3.memmove(popupFeatures, pPopupFeatures, cef_popup_features_t.sizeof);
final String url = CEF.ExtractCEFString(target_url);
- final boolean result[] = new boolean[1];
host.browser.getDisplay().syncExec(new Runnable() {
public void run() {
- result[0] = host.onWindowOpen(url, popupFeatures);
+ long /*int*/[] pClient = new long /*int*/[1];
+ C.memmove(pClient, client, C.PTR_SIZEOF);
+ new CEFBase(pClient[0]).release();
+
+ CEF child = host.onWindowOpen(url, popupFeatures);
+ if (child != null) {
+ Browser childBrowser = child.browser;
+ cef_window_info_t newWindowInfo = new cef_window_info_t();
+ int extStyle = OS.WS_EX_NOINHERITLAYOUT;
+ if ((childBrowser.getStyle() & SWT.BORDER) != 0) extStyle |= OS.WS_EX_CLIENTEDGE;
+ if ((childBrowser.getStyle() & SWT.RIGHT_TO_LEFT) != 0) extStyle |= OS.WS_EX_LAYOUTRTL;
+ newWindowInfo.ex_style = extStyle;
+ newWindowInfo.style = OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS;
+ newWindowInfo.x = newWindowInfo.width = OS.CW_USEDEFAULT;
+ newWindowInfo.ex_style = 0;
+ newWindowInfo.window_name = CEF.CEFSTRING_EMPTY;
+ newWindowInfo.parent_window = childBrowser.handle;
+ CEF3.memmove(windowInfo, newWindowInfo, cef_window_info_t.sizeof);
+ CEF3.memmove(pClient[0], child.client.getAddress(), C.PTR_SIZEOF);
+ }
}
});
new CEFBase(browser).release();
new CEFBase(frame).release();
- long /*int*/[] pClient = new long /*int*/[1];
- C.memmove(pClient, client, C.PTR_SIZEOF);
- new CEFBase(pClient[0]).release();
- return result[0] ? 1 : 0;
+ return 0;
}
long /*int*/ on_after_created(long /*int*/ browser) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
index 5171aac5de..17e7726fbf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/CEF3.java
@@ -136,6 +136,12 @@ public static final native void memmove(cef_process_message_t dest, long /*int*/
*/
public static final native void memmove(cef_string_t dest, long /*int*/ src, long /*int*/ size);
+/**
+ * @param dest cast=(void *),flags=no_in critical
+ * @param src cast=(const void *)
+ * @param size cast=(size_t)
+ */
+public static final native void memmove(long /*int*/ dest, cef_window_info_t src, long /*int*/ size);
/* function ptr invocations */
@@ -186,5 +192,6 @@ public static final native int cef_popup_features_t_sizeof();
public static final native int cef_process_message_t_sizeof();
public static final native int cef_settings_t_sizeof();
public static final native int cef_string_t_sizeof();
+public static final native int cef_window_info_t_sizeof();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_window_info_t.java b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_window_info_t.java
index 4a8c36b849..897e592868 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_window_info_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT CEF/win32/org/eclipse/swt/internal/cef3/cef_window_info_t.java
@@ -27,4 +27,6 @@ public class cef_window_info_t {
public int transparent_painting;
/** @field cast=(cef_window_handle_t) */
public long /*int*/ window; // HWND on win32
+
+ public static final int sizeof = CEF3.cef_window_info_t_sizeof ();
}

Back to the top