Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-08-23 12:20:12 +0000
committerAlexander Kurtakov2017-11-14 14:03:03 +0000
commite5e75504009602f5576d60d4117362c69c6fc3b0 (patch)
tree6b060665552c72f3ae1a061651f383a975936489
parent9de5be8832286e9657e88362f7a2e30f4e9ab0cd (diff)
downloadeclipse.platform.swt-e5e75504009602f5576d60d4117362c69c6fc3b0.tar.gz
eclipse.platform.swt-e5e75504009602f5576d60d4117362c69c6fc3b0.tar.xz
eclipse.platform.swt-e5e75504009602f5576d60d4117362c69c6fc3b0.zip
Bug 519808 - [GTK] Shell.getBounds returns obsolete values
Function gtk_window_get_position is unreliable due to specifics of WMs. Use gdk_window_get_root_origin to get position in root window coordinates. Note: This will stay broken on Wayland as there are no root coordinates on Wayland Using gdk_window_get_root_origin before it's mapped returns 0,0 coordinates. As gtk_window_get_position returns correct coordinates in general except after unmap when it returns the last "set" coordinates gdk_window_get_root_origin should be used only for DISPOSE_SENT to retrieve the last real coordinates. Change-Id: I3b217410901fb7506f5d34b603711002bc0553ee Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-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/org/eclipse/swt/internal/gtk/OS.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java6
5 files changed, 38 insertions, 1 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 9a6c13ba35..0442861c93 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
@@ -6632,6 +6632,23 @@ fail:
}
#endif
+#ifndef NO__1gdk_1window_1get_1root_1origin
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1root_1origin)
+ (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2)
+{
+ jint *lparg1=NULL;
+ jint *lparg2=NULL;
+ OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1root_1origin_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;
+ gdk_window_get_root_origin((GdkWindow *)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, _1gdk_1window_1get_1root_1origin_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1window_1get_1user_1data
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1user_1data)
(JNIEnv *env, jclass that, jintLong arg0, jintLongArray 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 e805238381..a9aea6bd47 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
@@ -547,6 +547,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1window_1get_1parent",
"_1gdk_1window_1get_1pointer",
"_1gdk_1window_1get_1position",
+ "_1gdk_1window_1get_1root_1origin",
"_1gdk_1window_1get_1user_1data",
"_1gdk_1window_1get_1visible_1region",
"_1gdk_1window_1get_1width",
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 26cfdb606b..57376f32a3 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
@@ -557,6 +557,7 @@ typedef enum {
_1gdk_1window_1get_1parent_FUNC,
_1gdk_1window_1get_1pointer_FUNC,
_1gdk_1window_1get_1position_FUNC,
+ _1gdk_1window_1get_1root_1origin_FUNC,
_1gdk_1window_1get_1user_1data_FUNC,
_1gdk_1window_1get_1visible_1region_FUNC,
_1gdk_1window_1get_1width_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 0f1178b890..1b25377fd8 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
@@ -5514,6 +5514,20 @@ public static final void gdk_window_get_position(long /*int*/ window, int[] x, i
}
/**
* @param window cast=(GdkWindow *)
+ * @param x cast=(gint *)
+ * @param y cast=(gint *)
+ */
+public static final native void _gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y);
+public static final void gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y) {
+ lock.lock();
+ try {
+ _gdk_window_get_root_origin(window, x, y);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @param window cast=(GdkWindow *)
* @param data cast=(gpointer *)
*/
public static final native void _gdk_window_get_user_data(long /*int*/ window, long /*int*/[] data);
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 94596626b9..894a473886 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
@@ -2730,7 +2730,11 @@ public void forceActive () {
Rectangle getBoundsInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
- OS.gtk_window_get_position (shellHandle, x, y);
+ if ((state & Widget.DISPOSE_SENT) == 0) {
+ OS.gtk_window_get_position (shellHandle, x, y);
+ } else {
+ OS.gdk_window_get_root_origin(OS.gtk_widget_get_window(shellHandle), x, y);
+ }
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (vboxHandle, allocation);
int width = allocation.width;

Back to the top