diff options
| author | Alexander Kurtakov | 2016-12-05 18:59:53 +0000 |
|---|---|---|
| committer | Alexander Kurtakov | 2017-01-13 12:30:06 +0000 |
| commit | 717cf18517f39a2ab302d2b4291c8ca527e1e067 (patch) | |
| tree | 0d53e86a3d2f3afea90e2dd963ae5c1966c9238d | |
| parent | 76f863c56648609bf77aa491944d19b82ae23423 (diff) | |
| download | eclipse.platform.swt-717cf18517f39a2ab302d2b4291c8ca527e1e067.tar.gz eclipse.platform.swt-717cf18517f39a2ab302d2b4291c8ca527e1e067.tar.xz eclipse.platform.swt-717cf18517f39a2ab302d2b4291c8ca527e1e067.zip | |
Bug 508692 - Shells has wrong size under waylandM20170118-0500M20170118-0430
Reason for that is that is the usage of GtkWindow allocation for the
shell size which would fail with CSD (Client Side Decoration) as window
decorations, shadows and etc. are part of the window allocation. It
exposes on Wayland and Broadway backends as they have no server side
decorations at all.
Change-Id: I2a17a2cd66f486c19c0ed0cb2055aa52a3c7f7e4
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
5 files changed, 46 insertions, 4 deletions
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 fb6e308430..5aac9e369c 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 @@ -19949,6 +19949,23 @@ fail: } #endif +#ifndef NO__1gtk_1window_1get_1size +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1get_1size) + (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1size_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + gtk_window_get_size((GtkWindow *)arg0, (gint *)lparg1, (gint *)lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1size_FUNC); +} +#endif + #ifndef NO__1gtk_1window_1group_1add_1window JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1group_1add_1window) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) 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 b7eb2fcb31..47021e903b 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 @@ -1479,6 +1479,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1window_1get_1modal", "_1gtk_1window_1get_1opacity", "_1gtk_1window_1get_1position", + "_1gtk_1window_1get_1size", "_1gtk_1window_1group_1add_1window", "_1gtk_1window_1group_1new", "_1gtk_1window_1group_1remove_1window", 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 f36ea694cf..1b78a7c101 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 @@ -1489,6 +1489,7 @@ typedef enum { _1gtk_1window_1get_1modal_FUNC, _1gtk_1window_1get_1opacity_FUNC, _1gtk_1window_1get_1position_FUNC, + _1gtk_1window_1get_1size_FUNC, _1gtk_1window_1group_1add_1window_FUNC, _1gtk_1window_1group_1new_FUNC, _1gtk_1window_1group_1remove_1window_FUNC, 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 34090a99b8..84467550d6 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 @@ -15412,6 +15412,20 @@ public static final void gtk_window_resize(long /*int*/ handle, int x, int y) { } } /** + * @param handle cast=(GtkWindow *) + * @param width cast=(gint *) + * @param height cast=(gint *) + */ +public static final native void _gtk_window_get_size(long /*int*/ handle, int[] width, int[] height); +public static final void gtk_window_get_size(long /*int*/ handle, int[] width, int[] height) { + lock.lock(); + try { + _gtk_window_get_size(handle, width, height); + } finally { + lock.unlock(); + } +} +/** * @param window cast=(GtkWindow *) * @param widget cast=(GtkWidget *) */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index c0a2f21817..1827a6dd21 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -1548,10 +1548,19 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { @Override long /*int*/ gtk_size_allocate (long /*int*/ widget, long /*int*/ allocation) { - GtkAllocation widgetAllocation = new GtkAllocation (); - OS.gtk_widget_get_allocation (shellHandle, widgetAllocation); - int width = widgetAllocation.width; - int height = widgetAllocation.height; + int width, height; + if (OS.GTK3) { + int[] widthA = new int [1]; + int[] heightA = new int [1]; + OS.gtk_window_get_size(shellHandle, widthA, heightA); + width = widthA[0]; + height = heightA[0]; + } else { + GtkAllocation widgetAllocation = new GtkAllocation (); + OS.gtk_widget_get_allocation (shellHandle, widgetAllocation); + width = widgetAllocation.width; + height = widgetAllocation.height; + } // Bug 474235: on Wayland gtk_size_allocate() is called more frequently, causing an // infinitely recursive resize call. This causes non-resizable Shells/Dialogs to |
