Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2018-09-28 15:20:20 +0000
committerXi Yan2018-10-02 13:34:15 +0000
commitc20eead8e2a8bedbacf2c2f44242056ae1f344de (patch)
treea31df399ccfff4d4ba8552c2754b34d190688d35
parentb0c7620b71598cfad1daed3cde1f91d6b5232d16 (diff)
downloadeclipse.platform.swt-c20eead8e2a8bedbacf2c2f44242056ae1f344de.tar.gz
eclipse.platform.swt-c20eead8e2a8bedbacf2c2f44242056ae1f344de.tar.xz
eclipse.platform.swt-c20eead8e2a8bedbacf2c2f44242056ae1f344de.zip
Bug 518714 - [GTK3] Replace deprecated gdk_screen_get_active_window()
Remove gdk_screen_get_active_window, replace it by iterating the window stack and getting the current focused window as the active window. Change-Id: Ia80b195152c7754072a8a86efc2848460468b05f Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c36
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java17
5 files changed, 60 insertions, 18 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 2917bdc75d..bf4c79de07 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
@@ -1686,18 +1686,6 @@ fail:
}
#endif
-#ifndef NO__1gdk_1screen_1get_1active_1window
-JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1active_1window)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jintLong rc = 0;
- GDK_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1active_1window_FUNC);
- rc = (jintLong)gdk_screen_get_active_window((GdkScreen *)arg0);
- GDK_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1active_1window_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gdk_1screen_1get_1default
JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1default)
(JNIEnv *env, jclass that)
@@ -1894,6 +1882,18 @@ JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1system_1visual)
}
#endif
+#ifndef NO__1gdk_1screen_1get_1window_1stack
+JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1window_1stack)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1window_1stack_FUNC);
+ rc = (jintLong)gdk_screen_get_window_stack((GdkScreen *)arg0);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1window_1stack_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1screen_1height
JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1screen_1height)
(JNIEnv *env, jclass that)
@@ -2349,6 +2349,18 @@ fail:
}
#endif
+#ifndef NO__1gdk_1window_1get_1state
+JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1window_1get_1state)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1window_1get_1state_FUNC);
+ rc = (jint)gdk_window_get_state((GdkWindow *)arg0);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1window_1get_1state_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1window_1get_1user_1data
JNIEXPORT void JNICALL GDK_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 1e94999866..59af4067d7 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
@@ -126,7 +126,6 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1rgba_1hash",
"_1gdk_1rgba_1parse",
"_1gdk_1rgba_1to_1string",
- "_1gdk_1screen_1get_1active_1window",
"_1gdk_1screen_1get_1default",
"_1gdk_1screen_1get_1monitor_1at_1point",
"_1gdk_1screen_1get_1monitor_1at_1window",
@@ -137,6 +136,7 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1screen_1get_1primary_1monitor",
"_1gdk_1screen_1get_1resolution",
"_1gdk_1screen_1get_1system_1visual",
+ "_1gdk_1screen_1get_1window_1stack",
"_1gdk_1screen_1height",
"_1gdk_1screen_1is_1composited",
"_1gdk_1screen_1width",
@@ -166,6 +166,7 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1window_1get_1parent",
"_1gdk_1window_1get_1position",
"_1gdk_1window_1get_1root_1origin",
+ "_1gdk_1window_1get_1state",
"_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 f2de4f1f22..1d6f1b6361 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
@@ -136,7 +136,6 @@ typedef enum {
_1gdk_1rgba_1hash_FUNC,
_1gdk_1rgba_1parse_FUNC,
_1gdk_1rgba_1to_1string_FUNC,
- _1gdk_1screen_1get_1active_1window_FUNC,
_1gdk_1screen_1get_1default_FUNC,
_1gdk_1screen_1get_1monitor_1at_1point_FUNC,
_1gdk_1screen_1get_1monitor_1at_1window_FUNC,
@@ -147,6 +146,7 @@ typedef enum {
_1gdk_1screen_1get_1primary_1monitor_FUNC,
_1gdk_1screen_1get_1resolution_FUNC,
_1gdk_1screen_1get_1system_1visual_FUNC,
+ _1gdk_1screen_1get_1window_1stack_FUNC,
_1gdk_1screen_1height_FUNC,
_1gdk_1screen_1is_1composited_FUNC,
_1gdk_1screen_1width_FUNC,
@@ -176,6 +176,7 @@ typedef enum {
_1gdk_1window_1get_1parent_FUNC,
_1gdk_1window_1get_1position_FUNC,
_1gdk_1window_1get_1root_1origin_FUNC,
+ _1gdk_1window_1get_1state_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/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
index 3db77050ba..b0ab102f09 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
@@ -248,6 +248,7 @@ public class GDK extends OS {
public static final int GDK_WINDOW_STATE_ICONIFIED = 1 << 1;
public static final int GDK_WINDOW_STATE_MAXIMIZED = 1 << 2;
public static final int GDK_WINDOW_STATE_FULLSCREEN = 1 << 4;
+ public static final int GDK_WINDOW_STATE_FOCUSED = 1 << 7;
public static final int GDK_UNMAP = 15;
public static final int GDK_WA_X = 1 << 2;
public static final int GDK_WA_Y = 1 << 3;
@@ -472,6 +473,18 @@ public class GDK extends OS {
}
/**
* @param window cast=(GdkWindow *)
+ */
+ public static final native int _gdk_window_get_state(long /*int*/ window);
+ public static final int gdk_window_get_state(long /*int*/ window) {
+ lock.lock();
+ try {
+ return _gdk_window_get_state(window);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @param window cast=(GdkWindow *)
* @method flags=dynamic
*/
public static final native int _gdk_window_get_width(long /*int*/ window);
@@ -1375,11 +1388,11 @@ public class GDK extends OS {
}
}
/** @param screen cast=(GdkScreen *) */
- public static final native long /*int*/ _gdk_screen_get_active_window(long /*int*/ screen);
- public static final long /*int*/ gdk_screen_get_active_window(long /*int*/ screen) {
+ public static final native long /*int*/ _gdk_screen_get_window_stack(long /*int*/ screen);
+ public static final long /*int*/ gdk_screen_get_window_stack(long /*int*/ screen) {
lock.lock();
try {
- return _gdk_screen_get_active_window(screen);
+ return _gdk_screen_get_window_stack(screen);
} finally {
lock.unlock();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 0a8a9eb16b..60195c5856 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -4223,7 +4223,22 @@ public boolean post (Event event) {
long /*int*/ gdkDisplay = GDK.gdk_display_get_default();
long /*int*/ gdkScreen = GDK.gdk_screen_get_default();
- long /*int*/ gdkWindow = GDK.gdk_screen_get_active_window(gdkScreen);
+ long /*int*/ gdkWindow = 0;
+ long /*int*/ window_list = GDK.gdk_screen_get_window_stack(gdkScreen);
+ if (window_list != 0) {
+ long /*int*/ windows = window_list;
+ while (windows != 0) {
+ long /*int*/ curr_window = OS.g_list_data(windows);
+ int state = GDK.gdk_window_get_state(curr_window);
+ if ((state & GDK.GDK_WINDOW_STATE_FOCUSED) != 0) {
+ gdkWindow = curr_window;
+ break;
+ }
+ windows = OS.g_list_next(windows);
+ }
+ OS.g_list_free(window_list);
+ }
+
int[] x = new int[1], y = new int[1];
if (gdkWindow == 0) {
// Under some window managers or wayland gdk can not determine the active window and passing null

Back to the top