diff options
| author | Xi Yan | 2019-03-14 17:38:44 +0000 |
|---|---|---|
| committer | Xi Yan | 2019-03-18 20:13:18 +0000 |
| commit | 80a054f8bbbea9785279ba453f415ddf5c8e8484 (patch) | |
| tree | 626b4c12e8874a6118f682a4d8ef08e941c8342e | |
| parent | c4407bb1db4994474103fea04c9ab8dac9b730e9 (diff) | |
| download | eclipse.platform.swt-80a054f8bbbea9785279ba453f415ddf5c8e8484.tar.gz eclipse.platform.swt-80a054f8bbbea9785279ba453f415ddf5c8e8484.tar.xz eclipse.platform.swt-80a054f8bbbea9785279ba453f415ddf5c8e8484.zip | |
Bug 543987 - [GTK4] Replace deprecated window-state-event signal
Replaced "window-state-event" signal with "notify::state" in GdkSurface.
Tested with Snippet1, Shell property variable (i.e. maximized,
fullscreen) updated correctly.
Change-Id: If408d51a7d1182d2b8d7cfa070a7f1d324b16049
Signed-off-by: Xi Yan <xixiyan@redhat.com>
9 files changed, 79 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 7048fabb6e..ab0c471122 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 @@ -2313,6 +2313,18 @@ fail: } #endif +#ifndef NO__1gdk_1surface_1get_1state +JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1surface_1get_1state) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jint rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1state_FUNC); + rc = (jint)gdk_surface_get_state((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1state_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1surface_1get_1user_1data JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1get_1user_1data) (JNIEnv *env, jclass that, jintLong arg0, jintLongArray 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 9eaee50b41..d27c890e11 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 @@ -413,6 +413,7 @@ #define NO__1gdk_1surface_1get_1frame_1extents #define NO__1gdk_1surface_1get_1width #define NO__1gdk_1surface_1get_1height +#define NO__1gdk_1surface_1get_1state #define NO__1gdk_1surface_1resize #define NO__1gdk_1surface_1move #define NO__1gdk_1surface_1move_1resize 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 2beb0cef97..e5fd33f171 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 @@ -187,6 +187,7 @@ char * GDK_nativeFunctionNames[] = { "_1gdk_1surface_1get_1height", "_1gdk_1surface_1get_1origin", "_1gdk_1surface_1get_1root_1origin", + "_1gdk_1surface_1get_1state", "_1gdk_1surface_1get_1user_1data", "_1gdk_1surface_1get_1width", "_1gdk_1surface_1hide", 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 5dd2f7a3b8..007efa0dce 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 @@ -197,6 +197,7 @@ typedef enum { _1gdk_1surface_1get_1height_FUNC, _1gdk_1surface_1get_1origin_FUNC, _1gdk_1surface_1get_1root_1origin_FUNC, + _1gdk_1surface_1get_1state_FUNC, _1gdk_1surface_1get_1user_1data_FUNC, _1gdk_1surface_1get_1width_FUNC, _1gdk_1surface_1hide_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 fbc6670d42..ad92525ce6 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 @@ -229,6 +229,9 @@ public class GDK extends OS { public static final int GDK_SHIFT_MASK = 0x1; public static final int GDK_SIZING = 0x78; public static final int GDK_STIPPLED = 0x2; + public static final int GDK_SURFACE_STATE_ICONIFIED = 1 << 1; + public static final int GDK_SURFACE_STATE_MAXIMIZED = 1 << 2; + public static final int GDK_SURFACE_STATE_FULLSCREEN = 1 << 4; public static final int GDK_TILED = 0x1; public static final int GDK_Shift_L = 0xffe1; public static final int GDK_Shift_R = 0xffe2; @@ -559,6 +562,19 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + */ + public static final native int _gdk_surface_get_state(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final int gdk_surface_get_state(long /*int*/ surface) { + lock.lock(); + try { + return _gdk_surface_get_state(surface); + } finally { + lock.unlock(); + } + } + /** * @param window cast=(GdkWindow *) */ public static final native long /*int*/ _gdk_window_get_visible_region(long /*int*/ window); 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 5a6db5ec5c..d6163af969 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 @@ -382,6 +382,7 @@ public class OS extends C { public static final byte[] unrealize = ascii("unrealize"); public static final byte[] value_changed = ascii("value-changed"); public static final byte[] window_state_event = ascii("window-state-event"); + public static final byte[] notify_state = ascii("notify::state"); /** Properties */ public static final byte[] active = ascii("active"); 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 dcb81244a1..d803d1c60d 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 @@ -131,10 +131,12 @@ public class Display extends Device { long /*int*/ snapshotDrawProc; long /*int*/ keyPressReleaseProc, focusProc, enterMotionScrollProc, leaveProc; long /*int*/ gesturePressReleaseProc; + long /*int*/ notifyStateProc; Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6; Callback snapshotDraw; Callback keyPressReleaseCallback, focusCallback, enterMotionScrollCallback, leaveCallback; Callback gesturePressReleaseCallback; + Callback notifyStateCallback; EventTable eventTable, filterTable; static String APP_NAME = "SWT"; //$NON-NLS-1$ static String APP_VERSION = ""; //$NON-NLS-1$ @@ -3707,6 +3709,13 @@ void initializeCallbacks () { if (leaveProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); closuresProc [Widget.LEAVE] = leaveProc; + + notifyStateCallback = new Callback(this, "notifyStateProc", long.class, new Type[] { + long.class, long.class, long.class}); //$NON-NLS-1$ + notifyStateProc = notifyStateCallback.getAddress(); + if (notifyStateProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS); + + closuresProc [Widget.NOTIFY_STATE] = notifyStateProc; } closuresProc [Widget.ACTIVATE] = windowProc2; @@ -4742,6 +4751,8 @@ void releaseDisplay () { leaveProc = 0; gesturePressReleaseCallback.dispose(); gesturePressReleaseProc = 0; + notifyStateCallback.dispose(); + notifyStateProc = 0; } /* Dispose checkIfEvent callback */ @@ -6095,6 +6106,12 @@ long /*int*/ leaveProc (long /*int*/ controller, long /*int*/ user_data) { return widget.leaveProc(handle, user_data); } +long /*int*/ notifyStateProc (long /*int*/ gdk_handle, long /*int*/ param_spec, long /*int*/ user_data) { + Widget widget = getWidget (user_data); + if (widget == null) return 0; + return widget.notifyStateProc(gdk_handle, user_data); +} + long /*int*/ windowProc (long /*int*/ handle, long /*int*/ user_data) { Widget widget = getWidget (handle); if (widget == null) return 0; 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 15cf04ad51..cf33a7019c 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 @@ -922,6 +922,11 @@ void hookEvents () { if (eventHandle() == 0) { OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false); } + // Replaced "window-state-event" with GdkSurface "notify::state", pass shellHandle as user_data + long /*int*/ notifyStateAddress = display.notifyStateCallback.getAddress(); + GTK.gtk_widget_realize(shellHandle); + long /*int*/ gdkSurface = gtk_widget_get_surface (shellHandle); + OS.g_signal_connect (gdkSurface, OS.notify_state, notifyStateAddress, shellHandle); } else { OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [WINDOW_STATE_EVENT], 0, display.getClosure (WINDOW_STATE_EVENT), false); OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [CONFIGURE_EVENT], 0, display.getClosure (CONFIGURE_EVENT), false); @@ -1891,6 +1896,25 @@ long /*int*/ gtk_window_state_event (long /*int*/ widget, long /*int*/ event) { return 0; } +@Override +long /*int*/ notifyStateProc (long /*int*/ gdk_handle, long /*int*/ handle) { + // GTK4 equivalent of gtk_window_state_event + assert GTK.GTK4; + int gdkSurfaceState = GDK.gdk_surface_get_state (gdk_handle); + minimized = (gdkSurfaceState & GDK.GDK_SURFACE_STATE_ICONIFIED) != 0; + maximized = (gdkSurfaceState & GDK.GDK_SURFACE_STATE_MAXIMIZED) != 0; + fullScreen = (gdkSurfaceState & GDK.GDK_SURFACE_STATE_FULLSCREEN) != 0; + if ((gdkSurfaceState & GDK.GDK_SURFACE_STATE_ICONIFIED) != 0) { + if (minimized) { + sendEvent (SWT.Iconify); + } else { + sendEvent (SWT.Deiconify); + } + updateMinimized (minimized); + } + return 0; +} + /** * Moves the receiver to the top of the drawing order for * the display on which it was created (so that all other diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index d935f7ae49..11bb0f16fd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -234,7 +234,8 @@ public abstract class Widget { static final int CLOSE_REQUEST = 99; static final int GESTURE_PRESSED = 100; static final int GESTURE_RELEASED = 101; - static final int LAST_SIGNAL = 102; + static final int NOTIFY_STATE = 102; + static final int LAST_SIGNAL = 103; static final String IS_ACTIVE = "org.eclipse.swt.internal.control.isactive"; //$NON-NLS-1$ static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$ @@ -2170,6 +2171,10 @@ long /*int*/ leaveProc (long /*int*/ handle, long /*int*/ user_data) { return result; } +long /*int*/ notifyStateProc (long /*int*/ gdk_handle, long /*int*/ handle) { + return 0; +} + long /*int*/ windowProc (long /*int*/ handle, long /*int*/ user_data) { switch ((int)/*64*/user_data) { case ACTIVATE: return gtk_activate (handle); |
