diff options
author | Eric Williams | 2018-11-21 21:16:43 +0000 |
---|---|---|
committer | Eric Williams | 2018-11-23 19:35:50 +0000 |
commit | 66f203aed81e3fb64b92711af69e97dfe86645e6 (patch) | |
tree | ebf55198f6e6d509503ec705df2f7752fc127b52 | |
parent | 849c24f7345b8b0a01607613ef596e9e6130bdac (diff) | |
download | eclipse.platform.swt-66f203aed81e3fb64b92711af69e97dfe86645e6.tar.gz eclipse.platform.swt-66f203aed81e3fb64b92711af69e97dfe86645e6.tar.xz eclipse.platform.swt-66f203aed81e3fb64b92711af69e97dfe86645e6.zip |
Bug 540841: [GTK4] Rename GdkWindow to GdkSurface
Start porting simple wrapper functions in GtkWidget, and various
GdkWindow related methods in Control.
Change-Id: Iacbd302327b2898c9ff245aaa30127e253c575d3
Signed-off-by: Eric Williams <ericwill@redhat.com>
33 files changed, 908 insertions, 206 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 235e9f3155..a73986657f 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 @@ -2042,6 +2042,52 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1focus) } #endif +#ifndef NO__1gdk_1surface_1get_1children +JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1surface_1get_1children) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1children_FUNC); + rc = (jintLong)gdk_surface_get_children((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1children_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1surface_1get_1device_1position +JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1surface_1get_1device_1position) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintArray arg2, jintArray arg3, jintArray arg4) +{ + jint *lparg2=NULL; + jint *lparg3=NULL; + jint *lparg4=NULL; + jintLong rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1device_1position_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; + if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail; + rc = (jintLong)gdk_surface_get_device_position((GdkSurface *)arg0, (GdkDevice *)arg1, (gint *)lparg2, (gint *)lparg3, (GdkModifierType *)lparg4); +fail: + if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0); + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1device_1position_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1surface_1get_1display +JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1surface_1get_1display) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jintLong rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1display_FUNC); + rc = (jintLong)gdk_surface_get_display((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1display_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1surface_1get_1frame_1extents JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1get_1frame_1extents) (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) @@ -2056,6 +2102,137 @@ fail: } #endif +#ifndef NO__1gdk_1surface_1get_1origin +JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1surface_1get_1origin) + (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2) +{ + jint *lparg1=NULL; + jint *lparg2=NULL; + jint rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_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; + rc = (jint)gdk_surface_get_origin((GdkSurface *)arg0, (gint *)lparg1, (gint *)lparg2); +fail: + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1origin_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) +{ + jintLong *lparg1=NULL; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1user_1data_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntLongArrayElements(env, arg1, NULL)) == NULL) goto fail; + gdk_surface_get_user_data((GdkSurface *)arg0, (gpointer *)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseIntLongArrayElements(env, arg1, lparg1, 0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1user_1data_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1invalidate_1rect +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1invalidate_1rect) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + GdkRectangle _arg1, *lparg1=NULL; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1invalidate_1rect_FUNC); + if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail; + gdk_surface_invalidate_rect((GdkSurface *)arg0, (GdkRectangle *)lparg1); +fail: + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1invalidate_1rect_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1lower +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1lower) + (JNIEnv *env, jclass that, jintLong arg0) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1lower_FUNC); + gdk_surface_lower((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1lower_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1new_1child +JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1surface_1new_1child) + (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) +{ + GdkRectangle _arg1, *lparg1=NULL; + jintLong rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1new_1child_FUNC); + if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail; + rc = (jintLong)gdk_surface_new_child((GdkSurface *)arg0, lparg1); +fail: + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1new_1child_FUNC); + return rc; +} +#endif + +#ifndef NO__1gdk_1surface_1raise +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1raise) + (JNIEnv *env, jclass that, jintLong arg0) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1raise_FUNC); + gdk_surface_raise((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1raise_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1restack +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1restack) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jboolean arg2) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1restack_FUNC); + gdk_surface_restack((GdkSurface *)arg0, (GdkSurface *)arg1, (gboolean)arg2); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1restack_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1set_1cursor +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1set_1cursor) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1set_1cursor_FUNC); + gdk_surface_set_cursor((GdkSurface *)arg0, (GdkCursor *)arg1); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1set_1cursor_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1set_1user_1data +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1set_1user_1data) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1set_1user_1data_FUNC); + gdk_surface_set_user_data((GdkSurface *)arg0, (gpointer)arg1); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1set_1user_1data_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1show +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1show) + (JNIEnv *env, jclass that, jintLong arg0) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1show_FUNC); + gdk_surface_show((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1show_FUNC); +} +#endif + +#ifndef NO__1gdk_1surface_1show_1unraised +JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1show_1unraised) + (JNIEnv *env, jclass that, jintLong arg0) +{ + GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1show_1unraised_FUNC); + gdk_surface_show_unraised((GdkSurface *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1show_1unraised_FUNC); +} +#endif + #ifndef NO__1gdk_1text_1property_1to_1utf8_1list_1for_1display JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1text_1property_1to_1utf8_1list_1for_1display) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintLong arg3, jint arg4, jintLongArray arg5) @@ -2112,16 +2289,6 @@ JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1visual_1get_1depth) } #endif -#ifndef NO__1gdk_1window_1add_1filter -JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1add_1filter) - (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2) -{ - GDK_NATIVE_ENTER(env, that, _1gdk_1window_1add_1filter_FUNC); - gdk_window_add_filter((GdkWindow *)arg0, (GdkFilterFunc)arg1, (gpointer)arg2); - GDK_NATIVE_EXIT(env, that, _1gdk_1window_1add_1filter_FUNC); -} -#endif - #ifndef NO__1gdk_1window_1begin_1draw_1frame JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1window_1begin_1draw_1frame) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) @@ -2554,15 +2721,7 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1set_1background_1pattern) (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) { GDK_NATIVE_ENTER(env, that, _1gdk_1window_1set_1background_1pattern_FUNC); -/* - gdk_window_set_background_pattern(arg0, arg1); -*/ - { - GDK_LOAD_FUNCTION(fp, gdk_window_set_background_pattern) - if (fp) { - ((void (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); - } - } + gdk_window_set_background_pattern((GdkWindow *)arg0, (cairo_pattern_t *)arg1); GDK_NATIVE_EXIT(env, that, _1gdk_1window_1set_1background_1pattern_FUNC); } #endif 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 cbf8407b09..19ac102cbd 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 @@ -362,6 +362,7 @@ #define NO__1gdk_1window_1shape_1combine_1region #define NO__1gdk_1window_1show_1unraised #define NO__1gdk_1device_1get_1window_1at_1position +#define NO__1gdk_1window_1set_1background_1pattern // GdkDragContext removals #define NO__1gdk_1drag_1context_1get_1dest_1window @@ -407,6 +408,20 @@ #define NO__1gdk_1surface_1destroy #define NO__1gdk_1surface_1focus #define NO__1gdk_1device_1get_1surface_1at_1position +#define NO__1gdk_1surface_1lower +#define NO__1gdk_1surface_1raise +#define NO__1gdk_1surface_1get_1children +#define NO__1gdk_1surface_1get_1user_1data +#define NO__1gdk_1surface_1get_1origin +#define NO__1gdk_1surface_1invalidate_1rect +#define NO__1gdk_1surface_1get_1display +#define NO__1gdk_1surface_1set_1cursor +#define NO__1gdk_1surface_1new_1child +#define NO__1gdk_1surface_1set_1user_1data +#define NO__1gdk_1surface_1restack +#define NO__1gdk_1surface_1show_1unraised +#define NO__1gdk_1surface_1show +#define NO__1gdk_1surface_1get_1device_1position #define NO__1gdk_1display_1get_1monitor_1at_1surface #define NO__1gdk_1surface_1get_1frame_1extents 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 d7f03d07d8..1b0fc6f29e 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 @@ -169,12 +169,25 @@ char * GDK_nativeFunctionNames[] = { "_1gdk_1surface_1create_1similar_1surface", "_1gdk_1surface_1destroy", "_1gdk_1surface_1focus", + "_1gdk_1surface_1get_1children", + "_1gdk_1surface_1get_1device_1position", + "_1gdk_1surface_1get_1display", "_1gdk_1surface_1get_1frame_1extents", + "_1gdk_1surface_1get_1origin", + "_1gdk_1surface_1get_1user_1data", + "_1gdk_1surface_1invalidate_1rect", + "_1gdk_1surface_1lower", + "_1gdk_1surface_1new_1child", + "_1gdk_1surface_1raise", + "_1gdk_1surface_1restack", + "_1gdk_1surface_1set_1cursor", + "_1gdk_1surface_1set_1user_1data", + "_1gdk_1surface_1show", + "_1gdk_1surface_1show_1unraised", "_1gdk_1text_1property_1to_1utf8_1list_1for_1display", "_1gdk_1unicode_1to_1keyval", "_1gdk_1utf8_1to_1string_1target", "_1gdk_1visual_1get_1depth", - "_1gdk_1window_1add_1filter", "_1gdk_1window_1begin_1draw_1frame", "_1gdk_1window_1create_1similar_1surface", "_1gdk_1window_1destroy", 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 b87a5aa80c..c465448940 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 @@ -179,12 +179,25 @@ typedef enum { _1gdk_1surface_1create_1similar_1surface_FUNC, _1gdk_1surface_1destroy_FUNC, _1gdk_1surface_1focus_FUNC, + _1gdk_1surface_1get_1children_FUNC, + _1gdk_1surface_1get_1device_1position_FUNC, + _1gdk_1surface_1get_1display_FUNC, _1gdk_1surface_1get_1frame_1extents_FUNC, + _1gdk_1surface_1get_1origin_FUNC, + _1gdk_1surface_1get_1user_1data_FUNC, + _1gdk_1surface_1invalidate_1rect_FUNC, + _1gdk_1surface_1lower_FUNC, + _1gdk_1surface_1new_1child_FUNC, + _1gdk_1surface_1raise_FUNC, + _1gdk_1surface_1restack_FUNC, + _1gdk_1surface_1set_1cursor_FUNC, + _1gdk_1surface_1set_1user_1data_FUNC, + _1gdk_1surface_1show_FUNC, + _1gdk_1surface_1show_1unraised_FUNC, _1gdk_1text_1property_1to_1utf8_1list_1for_1display_FUNC, _1gdk_1unicode_1to_1keyval_FUNC, _1gdk_1utf8_1to_1string_1target_FUNC, _1gdk_1visual_1get_1depth_FUNC, - _1gdk_1window_1add_1filter_FUNC, _1gdk_1window_1begin_1draw_1frame_FUNC, _1gdk_1window_1create_1similar_1surface_FUNC, _1gdk_1window_1destroy_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 4ff456def2..a384d5ead8 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 @@ -419,21 +419,6 @@ public class GDK extends OS { } /** * @param window cast=(GdkWindow *) - * @param function cast=(GdkFilterFunc) - * @param data cast=(gpointer) - */ - public static final native void _gdk_window_add_filter(long /*int*/ window, long /*int*/ function, long /*int*/ data); - /** [GTK3 only, if-def'd in os.h] */ - public static final void gdk_window_add_filter(long /*int*/ window, long /*int*/ function, long /*int*/ data) { - lock.lock(); - try { - _gdk_window_add_filter(window, function, data); - } finally { - lock.unlock(); - } - } - /** - * @param window cast=(GdkWindow *) * @param region cast=(cairo_region_t *) * @method flags=dynamic */ @@ -772,6 +757,19 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + */ + public static final native long /*int*/ _gdk_surface_get_display(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final long /*int*/ gdk_surface_get_display(long /*int*/ surface) { + lock.lock(); + try { + return _gdk_surface_get_display(surface); + } finally { + lock.unlock(); + } + } + /** * @method flags=dynamic * @param display cast=(GdkDisplay *) */ @@ -2068,6 +2066,17 @@ public class GDK extends OS { lock.unlock(); } } + /** @param surface cast=(GdkSurface *) */ + public static final native long /*int*/ _gdk_surface_get_children(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final long /*int*/ gdk_surface_get_children(long /*int*/ surface) { + lock.lock(); + try { + return _gdk_surface_get_children(surface); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native int _gdk_window_get_events(long /*int*/ window); /** [GTK3 only, if-def'd in os.h] */ @@ -2145,6 +2154,21 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + * @param x cast=(gint *) + * @param y cast=(gint *) + */ + public static final native int _gdk_surface_get_origin(long /*int*/ surface, int[] x, int[] y); + /** [GTK4 only, if-def'd in os.h] */ + public static final int gdk_surface_get_origin(long /*int*/ surface, int[] x, int[] y) { + lock.lock(); + try { + return _gdk_surface_get_origin(surface, x, y); + } finally { + lock.unlock(); + } + } + /** * @param window cast=(GdkWindow *) * @param device cast=(GdkDevice *) * @param x cast=(gint *) @@ -2161,6 +2185,23 @@ public class GDK extends OS { lock.unlock(); } } + /** + * @param surface cast=(GdkSurface *) + * @param device cast=(GdkDevice *) + * @param x cast=(gint *) + * @param y cast=(gint *) + * @param mask cast=(GdkModifierType *) + */ + public static final native long /*int*/ _gdk_surface_get_device_position(long /*int*/ surface, long /*int*/ device, int[] x, int[] y, int[] mask); + /** [GTK4 only, if-def'd in os.h] */ + public static final long /*int*/ gdk_surface_get_device_position(long /*int*/ surface, long /*int*/ device, int[] x, int[] y, int[] mask) { + lock.lock(); + try { + return _gdk_surface_get_device_position(surface, device, x, y, mask); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native long /*int*/ _gdk_window_get_parent(long /*int*/ window); /** [GTK3 only, if-def'd in os.h] */ @@ -2216,6 +2257,20 @@ public class GDK extends OS { lock.unlock(); } } + /** + * @param surface cast=(GdkSurface *) + * @param data cast=(gpointer *) + */ + public static final native void _gdk_surface_get_user_data(long /*int*/ surface, long /*int*/[] data); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_get_user_data(long /*int*/ surface, long /*int*/[] data) { + lock.lock(); + try { + _gdk_surface_get_user_data(surface, data); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native void _gdk_window_hide(long /*int*/ window); /** [GTK3 only, if-def'd in os.h] */ @@ -2243,6 +2298,20 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + * @param rectangle cast=(GdkRectangle *),flags=no_out + */ + public static final native void _gdk_surface_invalidate_rect(long /*int*/ surface, GdkRectangle rectangle); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_invalidate_rect(long /*int*/ surface, GdkRectangle rectangle) { + lock.lock(); + try { + _gdk_surface_invalidate_rect(surface, rectangle); + } finally { + lock.unlock(); + } + } + /** * @param window cast=(GdkWindow *) * @param region cast=(const cairo_region_t *) * @param invalidate_children cast=(gboolean) @@ -2304,6 +2373,20 @@ public class GDK extends OS { lock.unlock(); } } + /** + * @param surface cast=(GdkSurface *) + * @param rect flags=no_out + */ + public static final native long /*int*/ _gdk_surface_new_child(long /*int*/ surface, GdkRectangle rect); + /** [GTK4 only, if-def'd in os.h] */ + public static final long /*int*/ gdk_surface_new_child(long /*int*/ surface, GdkRectangle rect) { + lock.lock(); + try { + return _gdk_surface_new_child(surface, rect); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native void _gdk_window_lower(long /*int*/ window); /** [GTK3 only, if-def'd in os.h] */ @@ -2315,6 +2398,17 @@ public class GDK extends OS { lock.unlock(); } } + /** @param surface cast=(GdkSurface *) */ + public static final native void _gdk_surface_lower(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_lower(long /*int*/ surface) { + lock.lock(); + try { + _gdk_surface_lower(surface); + } finally { + lock.unlock(); + } + } /** * @method flags=dynamic */ @@ -2354,6 +2448,17 @@ public class GDK extends OS { lock.unlock(); } } + /** @param surface cast=(GdkSurface *) */ + public static final native void _gdk_surface_raise(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_raise(long /*int*/ surface) { + lock.lock(); + try { + _gdk_surface_raise(surface); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native void _gdk_window_resize(long /*int*/ window, int width, int height); /** [GTK3 only, if-def'd in os.h] */ @@ -2380,9 +2485,27 @@ public class GDK extends OS { lock.unlock(); } } - /** @method flags=dynamic */ + /** + * @param surface cast=(GdkSurface *) + * @param sibling cast=(GdkSurface *) + * @param above cast=(gboolean) + */ + public static final native void _gdk_surface_restack(long /*int*/ surface, long /*int*/ sibling, boolean above); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_restack(long /*int*/ surface, long /*int*/ sibling, boolean above) { + lock.lock(); + try { + _gdk_surface_restack(surface, sibling, above); + } finally { + lock.unlock(); + } + } + /** + * @param window cast=(GdkWindow *) + * @param pattern cast=(cairo_pattern_t *) + */ public static final native void _gdk_window_set_background_pattern(long /*int*/ window, long /*int*/ pattern); - /** [GTK3; 3.22 deprecated] */ + /** [GTK3 only; 3.22 deprecated] */ public static final void gdk_window_set_background_pattern(long /*int*/ window, long /*int*/ pattern) { lock.lock(); try { @@ -2406,6 +2529,20 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + * @param cursor cast=(GdkCursor *) + */ + public static final native void _gdk_surface_set_cursor(long /*int*/ surface, long /*int*/ cursor); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_set_cursor(long /*int*/ surface, long /*int*/ cursor) { + lock.lock(); + try { + _gdk_surface_set_cursor(surface, cursor); + } finally { + lock.unlock(); + } + } + /** * @param window cast=(GdkWindow *) * @param decorations cast=(GdkWMDecoration) */ @@ -2473,6 +2610,20 @@ public class GDK extends OS { } } /** + * @param surface cast=(GdkSurface *) + * @param user_data cast=(gpointer) + */ + public static final native void _gdk_surface_set_user_data(long /*int*/ surface, long /*int*/ user_data); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_set_user_data(long /*int*/ surface, long /*int*/ user_data) { + lock.lock(); + try { + _gdk_surface_set_user_data(surface, user_data); + } finally { + lock.unlock(); + } + } + /** * @param window cast=(GdkWindow *) * @param shape_region cast=(const cairo_region_t *) * @param offset_x cast=(gint) @@ -2499,6 +2650,17 @@ public class GDK extends OS { lock.unlock(); } } + /** @param surface cast=(GdkSurface *) */ + public static final native void _gdk_surface_show(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_show(long /*int*/ surface) { + lock.lock(); + try { + _gdk_surface_show(surface); + } finally { + lock.unlock(); + } + } /** @param window cast=(GdkWindow *) */ public static final native void _gdk_window_show_unraised(long /*int*/ window); /** [GTK3 only, if-def'd in os.h] */ @@ -2511,6 +2673,18 @@ public class GDK extends OS { } } + /** @param surface cast=(GdkSurface *) */ + public static final native void _gdk_surface_show_unraised(long /*int*/ surface); + /** [GTK4 only, if-def'd in os.h] */ + public static final void gdk_surface_show_unraised(long /*int*/ surface) { + lock.lock(); + try { + _gdk_surface_show_unraised(surface); + } finally { + lock.unlock(); + } + } + public static long /*int*/ gdk_get_pointer (long /*int*/ display) { if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { long /*int*/ default_seat = GDK.gdk_display_get_default_seat(display); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java index e600273b4e..d8ef8fed3f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java @@ -272,7 +272,7 @@ void createHandle (int index) { int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); switch (style & bits) { case SWT.ARROW: byte arrowType [] = GTK.GTK_NAMED_ICON_GO_UP; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java index bc40a2e64a..fca53d6826 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java @@ -491,7 +491,7 @@ void createHandle (int index) { state |= HANDLE | MENU; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); long /*int*/ oldList = GTK.gtk_window_list_toplevels (); if ((style & SWT.READ_ONLY) != 0) { handle = GTK.gtk_combo_box_text_new (); @@ -937,6 +937,11 @@ long /*int*/ eventWindow () { return paintWindow (); } +@Override +long /*int*/ eventSurface () { + return paintSurface (); +} + /** * Returns a point describing the location of the caret relative * to the receiver. @@ -1758,6 +1763,31 @@ long /*int*/ paintWindow () { return window; } +@Override +long /*int*/ paintSurface () { + long /*int*/ childHandle = entryHandle != 0 ? entryHandle : handle; + GTK.gtk_widget_realize (childHandle); + long /*int*/ surface = gtk_widget_get_surface (childHandle); + if ((style & SWT.READ_ONLY) != 0) return surface; + long /*int*/ children = GDK.gdk_surface_get_children (surface); + if (children != 0) { + /* + * The only direct child of GtkComboBox since 3.20 is GtkBox thus the children + * have to be traversed to get to the entry one. + */ + if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { + do { + surface = OS.g_list_data (children); + } while ((children = OS.g_list_next (children)) != 0); + } else { + surface = OS.g_list_data (children); + } + } + OS.g_list_free (children); + + return surface; +} + /** * Pastes text from clipboard. * <p> diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index e1d1e314a9..8b2f346c76 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -286,7 +286,7 @@ void createHandle (int index, boolean fixed, boolean scrolled) { if (fixed) { fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); } long /*int*/ vadj = GTK.gtk_adjustment_new (0, 0, 100, 1, 10, 10); if (vadj == 0) error (SWT.ERROR_NO_HANDLES); @@ -616,23 +616,44 @@ void fixTabList (Control control) { void fixZOrder () { if ((state & CANVAS) != 0) return; long /*int*/ parentHandle = parentingHandle (); - long /*int*/ parentWindow = gtk_widget_get_window (parentHandle); - if (parentWindow == 0) return; - long /*int*/ [] userData = new long /*int*/ [1]; - long /*int*/ windowList = GDK.gdk_window_get_children (parentWindow); - if (windowList != 0) { - long /*int*/ windows = windowList; - while (windows != 0) { - long /*int*/ window = OS.g_list_data (windows); - if (window != redrawWindow) { - GDK.gdk_window_get_user_data (window, userData); - if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) { - GDK.gdk_window_lower (window); + if (GTK.GTK4) { + long /*int*/ parentSurface = gtk_widget_get_surface (parentHandle); + if (parentSurface == 0) return; + long /*int*/ [] userData = new long /*int*/ [1]; + long /*int*/ surfaceList = GDK.gdk_surface_get_children (parentSurface); + if (surfaceList != 0) { + long /*int*/ surfaces = surfaceList; + while (surfaces != 0) { + long /*int*/ surface = OS.g_list_data (surfaces); + if (surface != redrawSurface) { + GDK.gdk_surface_get_user_data (surface, userData); + if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) { + GDK.gdk_surface_lower (surface); + } } + surfaces = OS.g_list_next (surfaces); } - windows = OS.g_list_next (windows); + OS.g_list_free (surfaceList); + } + } else { + long /*int*/ parentWindow = gtk_widget_get_window (parentHandle); + if (parentWindow == 0) return; + long /*int*/ [] userData = new long /*int*/ [1]; + long /*int*/ windowList = GDK.gdk_window_get_children (parentWindow); + if (windowList != 0) { + long /*int*/ windows = windowList; + while (windows != 0) { + long /*int*/ window = OS.g_list_data (windows); + if (window != redrawWindow) { + GDK.gdk_window_get_user_data (window, userData); + if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) { + GDK.gdk_window_lower (window); + } + } + windows = OS.g_list_next (windows); + } + OS.g_list_free (windowList); } - OS.g_list_free (windowList); } } @@ -864,9 +885,13 @@ long /*int*/ gtk_map (long /*int*/ widget) { long /*int*/ gtk_realize (long /*int*/ widget) { long /*int*/ result = super.gtk_realize (widget); if ((style & SWT.NO_BACKGROUND) != 0) { - long /*int*/ window = gtk_widget_get_window (paintHandle ()); - if (window != 0) { - GDK.gdk_window_set_background_pattern(window, 0); + if (GTK.GTK4) { + // TODO: no gdk_surface_set_background_pattern() on GTK4. + } else { + long /*int*/ window = gtk_widget_get_window (paintHandle ()); + if (window != 0) { + GDK.gdk_window_set_background_pattern(window, 0); + } } } if (socketHandle != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index e17656bcf8..7676f8e648 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -53,6 +53,7 @@ import org.eclipse.swt.internal.gtk.*; public abstract class Control extends Widget implements Drawable { long /*int*/ fixedHandle; long /*int*/ redrawWindow, enableWindow, provider; + long /*int*/ redrawSurface, enableSurface; int drawCount, backgroundAlpha = 255; long /*int*/ enterNotifyEventId; long /*int*/ dragGesture, zoomGesture, rotateGesture, panGesture; @@ -242,8 +243,8 @@ void drawBackground (Control control, long /*int*/ window, long /*int*/ cr, long boolean drawGripper (GC gc, int x, int y, int width, int height, boolean vertical) { long /*int*/ paintHandle = paintHandle (); - long /*int*/ window = gtk_widget_get_window (paintHandle); - if (window == 0) return false; + long /*int*/ gdkResource = GTK.GTK4? gtk_widget_get_surface(paintHandle) : gtk_widget_get_window (paintHandle); + if (gdkResource == 0) return false; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x; long /*int*/ context = GTK.gtk_widget_get_style_context (paintHandle); GTK.gtk_style_context_save (context); @@ -275,6 +276,12 @@ long /*int*/ eventWindow () { return gtk_widget_get_window (eventHandle); } +long /*int*/ eventSurface () { + long /*int*/ eventHandle = eventHandle (); + GTK.gtk_widget_realize (eventHandle); + return gtk_widget_get_surface (eventHandle); +} + void fixFocus (Control focusControl) { Shell shell = getShell (); Control control = this; @@ -490,6 +497,13 @@ long /*int*/ paintWindow () { } } +@Override +long /*int*/ paintSurface () { + long /*int*/ paintHandle = paintHandle (); + GTK.gtk_widget_realize (paintHandle); + return gtk_widget_get_surface (paintHandle); +} + /** * Prints the receiver and all children. * @@ -534,8 +548,8 @@ void printWidget (GC gc, long /*int*/ drawable, int depth, int x, int y) { boolean obscured = (state & OBSCURED) != 0; state &= ~OBSCURED; long /*int*/ topHandle = topHandle (); - long /*int*/ window = gtk_widget_get_window (topHandle); - printWindow (true, this, gc, drawable, depth, window, x, y); + long /*int*/ gdkResource = GTK.GTK4 ? gtk_widget_get_surface(topHandle) : gtk_widget_get_window (topHandle); + printWindow (true, this, gc, drawable, depth, gdkResource, x, y); if (obscured) state |= OBSCURED; } @@ -1514,9 +1528,14 @@ public void setLayoutData (Object layoutData) { */ public Point toControl (int x, int y) { checkWidget (); - long /*int*/ window = eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - GDK.gdk_window_get_origin (window, origin_x, origin_y); + if (GTK.GTK4) { + long /*int*/ surface = eventSurface (); + GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + } else { + long /*int*/ window = eventWindow (); + GDK.gdk_window_get_origin (window, origin_x, origin_y); + } x -= DPIUtil.autoScaleDown (origin_x [0]); y -= DPIUtil.autoScaleDown (origin_y [0]); if ((style & SWT.MIRRORED) != 0) x = DPIUtil.autoScaleDown (getClientWidth ()) - x; @@ -1571,9 +1590,14 @@ public Point toControl (Point point) { */ public Point toDisplay (int x, int y) { checkWidget(); - long /*int*/ window = eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - GDK.gdk_window_get_origin (window, origin_x, origin_y); + if (GTK.GTK4) { + long /*int*/ surface = eventSurface (); + GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + } else { + long /*int*/ window = eventWindow (); + GDK.gdk_window_get_origin (window, origin_x, origin_y); + } if ((style & SWT.MIRRORED) != 0) x = DPIUtil.autoScaleDown (getClientWidth ()) - x; x += DPIUtil.autoScaleDown (origin_x [0]); y += DPIUtil.autoScaleDown (origin_y [0]); @@ -1582,9 +1606,14 @@ public Point toDisplay (int x, int y) { Point toDisplayInPixels (int x, int y) { checkWidget(); - long /*int*/ window = eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - GDK.gdk_window_get_origin (window, origin_x, origin_y); + if (GTK.GTK4) { + long /*int*/ surface = eventSurface (); + GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + } else { + long /*int*/ window = eventWindow (); + GDK.gdk_window_get_origin (window, origin_x, origin_y); + } if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; x += origin_x [0]; y += origin_y [0]; @@ -4183,10 +4212,28 @@ void releaseWidget () { region = null; } +/** + * GTK3 only, do not call on GTK4. + * @param window a GdkWindow + * @param sibling the sibling thereof, or 0 + * @param above a boolean setting for whether the window + * should be raised or lowered + */ void restackWindow (long /*int*/ window, long /*int*/ sibling, boolean above) { GDK.gdk_window_restack (window, sibling, above); } +/** + * GTK4 only, do not call on GTK3. + * @param window a GdkSurface + * @param sibling the sibling thereof, or 0 + * @param above a boolean setting for whether the surface + * should be raised or lowered + */ +void restackSurface (long /*int*/ surface, long /*int*/ sibling, boolean above) { + GDK.gdk_surface_restack (surface, sibling, above); +} + boolean sendDragEvent (int button, int stateMask, int x, int y, boolean isStateMask) { Event event = new Event (); event.button = button; @@ -4635,6 +4682,7 @@ void setBackgroundSurface (Image image) { long /*int*/ pattern = Cairo.cairo_pattern_create_for_surface(image.surface); if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REPEAT); + // TODO: no gdk_surface_set_background_pattern() on GTK4. GDK.gdk_window_set_background_pattern(window, pattern); Cairo.cairo_pattern_destroy(pattern); } @@ -4692,10 +4740,15 @@ public void setCursor (Cursor cursor) { } void setCursor (long /*int*/ cursor) { - long /*int*/ window = eventWindow (); - if (window != 0) { - GDK.gdk_window_set_cursor (window, cursor); - GDK.gdk_flush (); + if (GTK.GTK4) { + long /*int*/ surface = eventSurface (); + GDK.gdk_surface_set_cursor(surface, cursor); + } else { + long /*int*/ window = eventWindow (); + if (window != 0) { + GDK.gdk_window_set_cursor (window, cursor); + GDK.gdk_flush (); + } } } @@ -4776,37 +4829,63 @@ public void setEnabled (boolean enabled) { } enableWidget (enabled); if (isDisposed ()) return; - if (enabled) { - if (enableWindow != 0) { - cleanupEnableWindow(); + if (GTK.GTK4) { + if (enabled) { + if (enableSurface != 0) { + cleanupEnableSurface(); + } + } else { + GTK.gtk_widget_realize (handle); + long /*int*/ parentHandle = parent.eventHandle (); + long /*int*/ surface = parent.eventSurface (); + long /*int*/ topHandle = topHandle (); + GtkAllocation allocation = new GtkAllocation (); + GTK.gtk_widget_get_allocation (topHandle, allocation); + GdkRectangle rect = new GdkRectangle (); + rect.x = allocation.x; + rect.y = allocation.y; + rect.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; + rect.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; + enableSurface = GDK.gdk_surface_new_child (surface, rect); + if (enableSurface != 0) { + GDK.gdk_surface_set_user_data (enableSurface, parentHandle); + restackSurface (enableSurface, gtk_widget_get_surface (topHandle), true); + if (GTK.gtk_widget_get_visible (topHandle)) GDK.gdk_surface_show_unraised (enableSurface); + } } } else { - GTK.gtk_widget_realize (handle); - long /*int*/ parentHandle = parent.eventHandle (); - long /*int*/ window = parent.eventWindow (); - long /*int*/ topHandle = topHandle (); - GdkWindowAttr attributes = new GdkWindowAttr (); - GtkAllocation allocation = new GtkAllocation (); - GTK.gtk_widget_get_allocation (topHandle, allocation); - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; - attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; - attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); - attributes.wclass = GDK.GDK_INPUT_ONLY; - attributes.window_type = GDK.GDK_WINDOW_CHILD; - enableWindow = GDK.gdk_window_new (window, attributes, GDK.GDK_WA_X | GDK.GDK_WA_Y); - if (enableWindow != 0) { - /* 427776: we need to listen to all enter-notify-event signals to - * see if this new GdkWindow has been added to a widget's internal - * hash table, so when the GdkWindow is destroyed we can also remove - * that reference. */ - if (enterNotifyEventFunc != null) - enterNotifyEventId = OS.g_signal_add_emission_hook (enterNotifyEventSignalId, 0, enterNotifyEventFunc.getAddress (), enableWindow, 0); - - GDK.gdk_window_set_user_data (enableWindow, parentHandle); - restackWindow (enableWindow, gtk_widget_get_window (topHandle), true); - if (GTK.gtk_widget_get_visible (topHandle)) GDK.gdk_window_show_unraised (enableWindow); + if (enabled) { + if (enableWindow != 0) { + cleanupEnableWindow(); + } + } else { + GTK.gtk_widget_realize (handle); + long /*int*/ parentHandle = parent.eventHandle (); + long /*int*/ window = parent.eventWindow (); + long /*int*/ topHandle = topHandle (); + GdkWindowAttr attributes = new GdkWindowAttr (); + GtkAllocation allocation = new GtkAllocation (); + GTK.gtk_widget_get_allocation (topHandle, allocation); + attributes.x = allocation.x; + attributes.y = allocation.y; + attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; + attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; + attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); + attributes.wclass = GDK.GDK_INPUT_ONLY; + attributes.window_type = GDK.GDK_WINDOW_CHILD; + enableWindow = GDK.gdk_window_new (window, attributes, GDK.GDK_WA_X | GDK.GDK_WA_Y); + if (enableWindow != 0) { + /* 427776: we need to listen to all enter-notify-event signals to + * see if this new GdkWindow has been added to a widget's internal + * hash table, so when the GdkWindow is destroyed we can also remove + * that reference. */ + if (enterNotifyEventFunc != null) + enterNotifyEventId = OS.g_signal_add_emission_hook (enterNotifyEventSignalId, 0, enterNotifyEventFunc.getAddress (), enableWindow, 0); + + GDK.gdk_window_set_user_data (enableWindow, parentHandle); + restackWindow (enableWindow, gtk_widget_get_window (topHandle), true); + if (GTK.gtk_widget_get_visible (topHandle)) GDK.gdk_window_show_unraised (enableWindow); + } } } if (fixFocus) fixFocus (control); @@ -4836,6 +4915,12 @@ void cleanupEnableWindow() { enableWindow = 0; } +void cleanupEnableSurface() { + GDK.gdk_surface_set_user_data (enableSurface, 0); + GDK.gdk_surface_destroy (enableSurface); + enableSurface = 0; +} + /** * Causes the receiver to have the <em>keyboard focus</em>, * such that all keyboard events will be delivered to it. Focus @@ -5346,6 +5431,7 @@ public void setRedraw (boolean redraw) { GDK.GDK_BUTTON_MOTION_MASK | GDK.GDK_BUTTON1_MOTION_MASK | GDK.GDK_BUTTON2_MOTION_MASK | GDK.GDK_BUTTON3_MOTION_MASK; GDK.gdk_window_set_events (window, GDK.gdk_window_get_events (window) & ~mouseMask); + // TODO: no gdk_surface_set_background_pattern() on GTK4. GDK.gdk_window_set_background_pattern(redrawWindow, 0); GDK.gdk_window_show (redrawWindow); } @@ -5562,33 +5648,66 @@ void setZOrder (Control sibling, boolean above, boolean fixRelations, boolean fi long /*int*/ topHandle = topHandle (); long /*int*/ siblingHandle = sibling != null ? sibling.topHandle () : 0; - long /*int*/ window = gtk_widget_get_window (topHandle); - if (window != 0) { - long /*int*/ siblingWindow = 0; - if (sibling != null) { - if (above && sibling.enableWindow != 0) { - siblingWindow = enableWindow; + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (topHandle); + if (surface != 0) { + long /*int*/ siblingSurface = 0; + if (sibling != null) { + if (above && sibling.enableSurface != 0) { + siblingSurface = enableSurface; + } else { + siblingSurface = GTK.gtk_widget_get_surface (siblingHandle); + } + } + long /*int*/ redrawSurface = fixChildren ? parent.redrawSurface : 0; + if (!OS.isX11 () || (siblingSurface == 0 && (!above || redrawSurface == 0))) { + if (above) { + GDK.gdk_surface_raise (surface); + if (redrawSurface != 0) GDK.gdk_surface_raise (redrawSurface); + if (enableSurface != 0) GDK.gdk_surface_raise (enableSurface); + } else { + if (enableSurface != 0) GDK.gdk_surface_lower (enableSurface); + GDK.gdk_surface_lower (surface); + } } else { - siblingWindow = GTK.gtk_widget_get_window (siblingHandle); + long /*int*/ siblingS = siblingSurface != 0 ? siblingSurface : redrawSurface; + boolean stack_mode = above; + if (redrawSurface != 0 && siblingSurface == 0) stack_mode = false; + restackSurface (surface, siblingS, stack_mode); + if (enableSurface != 0) { + restackSurface (enableSurface, surface, true); + } } } - long /*int*/ redrawWindow = fixChildren ? parent.redrawWindow : 0; - if (!OS.GDK_WINDOWING_X11 () || (siblingWindow == 0 && (!above || redrawWindow == 0))) { - if (above) { - GDK.gdk_window_raise (window); - if (redrawWindow != 0) GDK.gdk_window_raise (redrawWindow); - if (enableWindow != 0) GDK.gdk_window_raise (enableWindow); - } else { - if (enableWindow != 0) GDK.gdk_window_lower (enableWindow); - GDK.gdk_window_lower (window); + } else { + long /*int*/ window = gtk_widget_get_window (topHandle); + if (window != 0) { + long /*int*/ siblingWindow = 0; + if (sibling != null) { + if (above && sibling.enableWindow != 0) { + siblingWindow = enableWindow; + } else { + siblingWindow = GTK.gtk_widget_get_window (siblingHandle); + } } - } else { - long /*int*/ siblingW = siblingWindow != 0 ? siblingWindow : redrawWindow; - boolean stack_mode = above; - if (redrawWindow != 0 && siblingWindow == 0) stack_mode = false; - restackWindow (window, siblingW, stack_mode); - if (enableWindow != 0) { - restackWindow (enableWindow, window, true); + long /*int*/ redrawWindow = fixChildren ? parent.redrawWindow : 0; + if (!OS.isX11 () || (siblingWindow == 0 && (!above || redrawWindow == 0))) { + if (above) { + GDK.gdk_window_raise (window); + if (redrawWindow != 0) GDK.gdk_window_raise (redrawWindow); + if (enableWindow != 0) GDK.gdk_window_raise (enableWindow); + } else { + if (enableWindow != 0) GDK.gdk_window_lower (enableWindow); + GDK.gdk_window_lower (window); + } + } else { + long /*int*/ siblingW = siblingWindow != 0 ? siblingWindow : redrawWindow; + boolean stack_mode = above; + if (redrawWindow != 0 && siblingWindow == 0) stack_mode = false; + restackWindow (window, siblingW, stack_mode); + if (enableWindow != 0) { + restackWindow (enableWindow, window, true); + } } } } @@ -6181,6 +6300,7 @@ long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ us /** * Gets the position of the top left corner of the control in root window (display) coordinates. + * GTK3 only, do not call on GTK4. * * @return the origin */ @@ -6193,4 +6313,20 @@ Point getWindowOrigin () { return new Point (x [0], y [0]); } + +/** + * Gets the position of the top left corner of the control in root window (display) coordinates. + * GTK4 only, do not call on GTK3. + * + * @return the origin + */ +Point getSurfaceOrigin () { + int [] x = new int [1]; + int [] y = new int [1]; + + long /*int*/ surface = eventSurface (); + GDK.gdk_surface_get_origin (surface, x, y); + + return new Point (x [0], y [0]); +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java index f87355b086..4e583b5d0b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java @@ -425,7 +425,7 @@ void createHandle () { private void createHandleForFixed () { fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); } private void createHandleForCalendar () { 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 8768428801..c4bcb95a76 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 @@ -3982,13 +3982,13 @@ public Point map (Control from, Control to, int x, int y) { Point point = new Point (x, y); if (from == to) return point; if (from != null) { - Point origin = DPIUtil.autoScaleDown (from.getWindowOrigin ()); + Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? from.getSurfaceOrigin() : from.getWindowOrigin ()); if ((from.style & SWT.MIRRORED) != 0) point.x = DPIUtil.autoScaleDown (from.getClientWidth ()) - point.x; point.x += origin.x; point.y += origin.y; } if (to != null) { - Point origin = DPIUtil.autoScaleDown (to.getWindowOrigin ()); + Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin ()); point.x -= origin.x; point.y -= origin.y; if ((to.style & SWT.MIRRORED) != 0) point.x = DPIUtil.autoScaleDown (to.getClientWidth ()) - point.x; @@ -4003,13 +4003,13 @@ Point mapInPixels (Control from, Control to, int x, int y) { Point point = new Point (x, y); if (from == to) return point; if (from != null) { - Point origin = from.getWindowOrigin (); + Point origin = GTK.GTK4 ? from.getSurfaceOrigin() : from.getWindowOrigin (); if ((from.style & SWT.MIRRORED) != 0) point.x = from.getClientWidth () - point.x; point.x += origin.x; point.y += origin.y; } if (to != null) { - Point origin = to.getWindowOrigin (); + Point origin = GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin (); point.x -= origin.x; point.y -= origin.y; if ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x; @@ -4111,13 +4111,13 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei if (from == to) return rect; boolean fromRTL = false, toRTL = false; if (from != null) { - Point origin = DPIUtil.autoScaleDown (from.getWindowOrigin ()); + Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? from.getSurfaceOrigin () : from.getWindowOrigin ()); if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = DPIUtil.autoScaleDown (from.getClientWidth ()) - rect.x; rect.x += origin.x; rect.y += origin.y; } if (to != null) { - Point origin = DPIUtil.autoScaleDown (to.getWindowOrigin ()); + Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin ()); rect.x -= origin.x; rect.y -= origin.y; if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = DPIUtil.autoScaleDown (to.getClientWidth ()) - rect.x; @@ -4135,13 +4135,13 @@ Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int he if (from == to) return rect; boolean fromRTL = false, toRTL = false; if (from != null) { - Point origin = from.getWindowOrigin (); + Point origin = GTK.GTK4 ? from.getSurfaceOrigin() : from.getWindowOrigin (); if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth () - rect.x; rect.x += origin.x; rect.y += origin.y; } if (to != null) { - Point origin = to.getWindowOrigin (); + Point origin = GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin (); rect.x -= origin.x; rect.y -= origin.y; if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java index 584208938a..a468cd069a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java @@ -136,7 +136,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); handle = gtk_box_new (GTK.GTK_ORIENTATION_VERTICAL, false, 0); if (handle == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.V_SCROLL) != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java index b70fa33752..b36c2b1d24 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java @@ -184,7 +184,7 @@ void createHandle(int index) { fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); handle = GTK.gtk_frame_new (null); if (handle == 0) error (SWT.ERROR_NO_HANDLES); @@ -201,7 +201,7 @@ void createHandle(int index) { * it can listen to events (clicking/tooltip etc.) and so that * background can be drawn on it. */ - GTK.gtk_widget_set_has_window (clientHandle, true); + gtk_widget_set_has_surface_or_window (clientHandle, true); GTK.gtk_container_add (fixedHandle, handle); GTK.gtk_container_add (handle, clientHandle); @@ -470,4 +470,11 @@ long /*int*/ paintWindow () { return gtk_widget_get_window (paintHandle); } +@Override +long /*int*/ paintSurface () { + long /*int*/ paintHandle = clientHandle; + GTK.gtk_widget_realize (paintHandle); + return gtk_widget_get_surface (paintHandle); +} + }
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java index a65d5b1136..c6617193f3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java @@ -230,7 +230,7 @@ void createHandle (int index) { state |= HANDLE | THEME_BACKGROUND; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); if ((style & SWT.SEPARATOR) != 0) { if ((style & SWT.HORIZONTAL)!= 0) { handle = GTK.gtk_separator_new (GTK.GTK_ORIENTATION_HORIZONTAL); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java index 1b028a8042..8f98c9ab22 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java @@ -151,7 +151,7 @@ void createHandle(int index) { state |= HANDLE | THEME_BACKGROUND; handle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (handle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (handle, true); + gtk_widget_set_has_surface_or_window (handle, true); GTK.gtk_widget_set_can_focus (handle, true); layout = new TextLayout (display); disabledColor = new Color (display, LINK_DISABLED_FOREGROUND); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java index 622bf3b41f..095f4e5e23 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java @@ -203,7 +203,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); scrolledHandle = GTK.gtk_scrolled_window_new (0, 0); if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES); /* @@ -1056,6 +1056,7 @@ public boolean isSelected (int index) { @Override long /*int*/ paintWindow () { GTK.gtk_widget_realize (handle); + // TODO: this function has been removed on GTK4 return GTK.gtk_tree_view_get_bin_window (handle); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java index 631eb905d6..155fa96f86 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java @@ -476,9 +476,14 @@ void fixMenus (Decorations newParent) { if (!GTK.gtk_widget_get_mapped (handle)) { return new Rectangle (0, 0, 0, 0); } - long /*int*/ window = gtk_widget_get_window (handle); int [] origin_x = new int [1], origin_y = new int [1]; - GDK.gdk_window_get_origin (window, origin_x, origin_y); + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (handle); + GDK.gdk_surface_get_origin(surface, origin_x, origin_y); + } else { + long /*int*/ window = gtk_widget_get_window (handle); + GDK.gdk_window_get_origin (window, origin_x, origin_y); + } GtkAllocation allocation = new GtkAllocation (); GTK.gtk_widget_get_allocation (handle, allocation); int x = origin_x [0] + allocation.x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java index b6b6ff2662..974bef47a1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java @@ -88,7 +88,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); handle = GTK.gtk_progress_bar_new (); if (handle == 0) error (SWT.ERROR_NO_HANDLES); GTK.gtk_container_add (fixedHandle, handle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java index 58c666de34..a188de1811 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java @@ -143,7 +143,7 @@ void createHandle (int index) { state |= HANDLE | THEME_BACKGROUND; handle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (handle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (handle, true); + gtk_widget_set_has_surface_or_window (handle, true); GTK.gtk_widget_set_can_focus (handle, true); int type = (style & SWT.VERTICAL) != 0 ? GDK.GDK_SB_H_DOUBLE_ARROW : GDK.GDK_SB_V_DOUBLE_ARROW; defaultCursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), type); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java index 4dff30c213..012a99f5e9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java @@ -130,7 +130,7 @@ void createHandle (int index) { state |= HANDLE | THEME_BACKGROUND; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); long /*int*/ hAdjustment = GTK.gtk_adjustment_new (0, 0, 100, 1, 10, 0); if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.HORIZONTAL) != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java index 4340b4e544..76ffd0d193 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java @@ -362,14 +362,25 @@ Rectangle getThumbBoundsInPixels () { } Rectangle rect = new Rectangle(x, y, width, height); int [] origin_x = new int [1], origin_y = new int [1]; - long /*int*/ window = gtk_widget_get_window (parent.scrolledHandle); - if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); - rect.x += origin_x [0]; - rect.y += origin_y [0]; - window = gtk_widget_get_window (parent.handle); - if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); - rect.x -= origin_x [0]; - rect.y -= origin_y [0]; + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (parent.scrolledHandle); + if (surface != 0) GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + rect.x += origin_x [0]; + rect.y += origin_y [0]; + surface = gtk_widget_get_surface (parent.handle); + if (surface != 0) GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + rect.x -= origin_x [0]; + rect.y -= origin_y [0]; + } else { + long /*int*/ window = gtk_widget_get_window (parent.scrolledHandle); + if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); + rect.x += origin_x [0]; + rect.y += origin_y [0]; + window = gtk_widget_get_window (parent.handle); + if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); + rect.x -= origin_x [0]; + rect.y -= origin_y [0]; + } return rect; } @@ -439,14 +450,25 @@ Rectangle getThumbTrackBoundsInPixels () { } Rectangle rect = new Rectangle(x, y, width, height); int [] origin_x = new int [1], origin_y = new int [1]; - long /*int*/ window = gtk_widget_get_window (parent.scrolledHandle); - if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); - rect.x += origin_x [0]; - rect.y += origin_y [0]; - window = gtk_widget_get_window (parent.handle); - if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); - rect.x -= origin_x [0]; - rect.y -= origin_y [0]; + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (parent.scrolledHandle); + if (surface != 0) GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + rect.x += origin_x [0]; + rect.y += origin_y [0]; + surface = gtk_widget_get_surface (parent.handle); + if (surface != 0) GDK.gdk_surface_get_origin (surface, origin_x, origin_y); + rect.x -= origin_x [0]; + rect.y -= origin_y [0]; + } else { + long /*int*/ window = gtk_widget_get_window (parent.scrolledHandle); + if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); + rect.x += origin_x [0]; + rect.y += origin_y [0]; + window = gtk_widget_get_window (parent.handle); + if (window != 0) GDK.gdk_window_get_origin (window, origin_x, origin_y); + rect.x -= origin_x [0]; + rect.y -= origin_y [0]; + } return rect; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java index 885ebf9d07..f9345b0f70 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java @@ -424,7 +424,6 @@ void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boole if (!trim) return; long /*int*/ topHandle = topHandle (), paintHandle = paintHandle (); if (topHandle == paintHandle) return; - long /*int*/ window = gtk_widget_get_window (topHandle); GdkRectangle rect = new GdkRectangle (); if (redrawAll) { GtkAllocation allocation = new GtkAllocation (); @@ -439,7 +438,13 @@ void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boole rect.width = Math.max (0, width); rect.height = Math.max (0, height); } - GDK.gdk_window_invalidate_rect (window, rect, all); + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (topHandle); + GDK.gdk_surface_invalidate_rect (surface, rect); + } else { + long /*int*/ window = gtk_widget_get_window (topHandle); + GDK.gdk_window_invalidate_rect (window, rect, all); + } } @Override 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 cf1a1b7205..7ea1c5fdbd 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 @@ -2075,36 +2075,61 @@ public void setEnabled (boolean enabled) { } enableWidget (enabled); if (isDisposed ()) return; - if (enabled) { - if (enableWindow != 0) { - cleanupEnableWindow(); + if (GTK.GTK4) { + if (enabled) { + if (enableSurface != 0) { + cleanupEnableSurface(); + } + } else { + long /*int*/ parentHandle = shellHandle; + GTK.gtk_widget_realize (parentHandle); + long /*int*/ surface = gtk_widget_get_surface (parentHandle); + Rectangle rect = getBoundsInPixels (); + GdkRectangle gdkRectangle = new GdkRectangle (); + GdkWindowAttr attributes = new GdkWindowAttr (); + gdkRectangle.width = rect.width; + gdkRectangle.height = rect.height; + enableSurface = GDK.gdk_surface_new_child (surface, gdkRectangle); + if (enableSurface != 0) { + if (cursor != null) { + GDK.gdk_surface_set_cursor (enableSurface, cursor.handle); + } + GDK.gdk_surface_set_user_data (enableSurface, parentHandle); + GDK.gdk_surface_show (enableSurface); + } } } else { - long /*int*/ parentHandle = shellHandle; - GTK.gtk_widget_realize (parentHandle); - long /*int*/ window = gtk_widget_get_window (parentHandle); - Rectangle rect = getBoundsInPixels (); - GdkWindowAttr attributes = new GdkWindowAttr (); - attributes.width = rect.width; - attributes.height = rect.height; - attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); - attributes.wclass = GDK.GDK_INPUT_ONLY; - attributes.window_type = GDK.GDK_WINDOW_CHILD; - enableWindow = GDK.gdk_window_new (window, attributes, 0); - if (enableWindow != 0) { - if (cursor != null) { - GDK.gdk_window_set_cursor (enableWindow, cursor.handle); - GDK.gdk_flush (); + if (enabled) { + if (enableWindow != 0) { + cleanupEnableWindow(); + } + } else { + long /*int*/ parentHandle = shellHandle; + GTK.gtk_widget_realize (parentHandle); + long /*int*/ window = gtk_widget_get_window (parentHandle); + Rectangle rect = getBoundsInPixels (); + GdkWindowAttr attributes = new GdkWindowAttr (); + attributes.width = rect.width; + attributes.height = rect.height; + attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask); + attributes.wclass = GDK.GDK_INPUT_ONLY; + attributes.window_type = GDK.GDK_WINDOW_CHILD; + enableWindow = GDK.gdk_window_new (window, attributes, 0); + if (enableWindow != 0) { + if (cursor != null) { + GDK.gdk_window_set_cursor (enableWindow, cursor.handle); + GDK.gdk_flush (); + } + /* 427776: we need to listen to all enter-notify-event signals to + * see if this new GdkWindow has been added to a widget's internal + * hash table, so when the GdkWindow is destroyed we can also remove + * that reference. */ + if (enterNotifyEventFunc != null) + enterNotifyEventId = OS.g_signal_add_emission_hook (enterNotifyEventSignalId, 0, enterNotifyEventFunc.getAddress (), enableWindow, 0); + + GDK.gdk_window_set_user_data (enableWindow, parentHandle); + GDK.gdk_window_show (enableWindow); } - /* 427776: we need to listen to all enter-notify-event signals to - * see if this new GdkWindow has been added to a widget's internal - * hash table, so when the GdkWindow is destroyed we can also remove - * that reference. */ - if (enterNotifyEventFunc != null) - enterNotifyEventId = OS.g_signal_add_emission_hook (enterNotifyEventSignalId, 0, enterNotifyEventFunc.getAddress (), enableWindow, 0); - - GDK.gdk_window_set_user_data (enableWindow, parentHandle); - GDK.gdk_window_show (enableWindow); } } if (fixFocus) fixFocus (control); @@ -2586,8 +2611,14 @@ public void setVisible (boolean visible) { // the hidden widget and can never be returned. if (!OS.isX11() && GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) { if ((style & SWT.ON_TOP) != 0 && (style & SWT.NO_FOCUS) == 0) { - long /*int*/ window = gtk_widget_get_window (shellHandle); - long /*int*/ seat = GDK.gdk_display_get_default_seat(GDK.gdk_window_get_display(window)); + long /*int*/ seat; + if (GTK.GTK4) { + long /*int*/ surface = gtk_widget_get_surface (shellHandle); + seat = GDK.gdk_display_get_default_seat(GDK.gdk_surface_get_display(surface)); + } else { + long /*int*/ window = gtk_widget_get_window (shellHandle); + seat = GDK.gdk_display_get_default_seat(GDK.gdk_window_get_display(window)); + } GDK.gdk_seat_ungrab(seat); GTK.gtk_grab_remove(shellHandle); } @@ -2982,6 +3013,14 @@ Point getWindowOrigin () { return super.getWindowOrigin( ); } +@Override +Point getSurfaceOrigin () { + if (!mapped) { + return getLocationInPixels (); + } + return super.getSurfaceOrigin( ); +} + static long /*int*/ ParentDestroyedCallbackFunc (long /*int*/ parent, long /*int*/ child) { if (child != 0 && GTK.GTK_IS_WINDOW(child)) { GTK.gtk_widget_destroy(child); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java index 9078b7414f..880b48a143 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java @@ -156,7 +156,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); long /*int*/ hAdjustment = GTK.gtk_adjustment_new (0, 0, 100, 1, 10, 10); if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.HORIZONTAL) != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java index 00dd78cebc..668a15c54f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java @@ -305,7 +305,7 @@ void createHandle (int index) { state |= HANDLE | MENU; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); long /*int*/ adjustment = GTK.gtk_adjustment_new (0, 0, 100, 1, 10, 0); if (adjustment == 0) error (SWT.ERROR_NO_HANDLES); handle = GTK.gtk_spin_button_new (adjustment, climbRate, 0); @@ -357,6 +357,11 @@ long /*int*/ eventWindow () { } @Override +long /*int*/ eventSurface () { + return paintSurface (); +} + +@Override long /*int*/ enterExitHandle () { return fixedHandle; } @@ -796,6 +801,15 @@ long /*int*/ paintWindow () { return window; } +@Override +long /*int*/ paintSurface () { + long /*int*/ surface = super.paintSurface (); + long /*int*/ children = GDK.gdk_surface_get_children (surface); + if (children != 0) surface = OS.g_list_data (children); + OS.g_list_free (children); + return surface; +} + /** * Pastes text from clipboard. * <p> diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java index 69853fc578..3bbf10d6d3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java @@ -254,7 +254,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); handle = GTK.gtk_notebook_new (); if (handle == 0) error (SWT.ERROR_NO_HANDLES); GTK.gtk_container_add (fixedHandle, handle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index e2cb45d128..648eca932e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -613,7 +613,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); scrolledHandle = GTK.gtk_scrolled_window_new (0, 0); if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ [] types = getColumnTypes (1); @@ -1137,6 +1137,11 @@ long /*int*/ eventWindow () { return paintWindow (); } +@Override +long /*int*/ eventSurface () { + return paintSurface (); +} + boolean fixAccessibility () { /* * Bug in GTK. With GTK 2.12, when assistive technologies is on, the time @@ -2417,6 +2422,7 @@ boolean mnemonicMatch (char key) { @Override long /*int*/ paintWindow () { GTK.gtk_widget_realize (handle); + // TODO: this function has been removed on GTK4 return GTK.gtk_tree_view_get_bin_window (handle); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index baccd88761..86dd953e41 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -203,7 +203,7 @@ void createHandle (int index) { } fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); if ((style & SWT.SINGLE) != 0) { handle = GTK.gtk_entry_new (); if (handle == 0) error (SWT.ERROR_NO_HANDLES); @@ -2006,9 +2006,32 @@ long /*int*/ paintWindow () { return window; } GTK.gtk_widget_realize (handle); + // TODO: this function has been removed on GTK4 return GTK.gtk_text_view_get_window (handle, GTK.GTK_TEXT_WINDOW_TEXT); } +@Override +long /*int*/ paintSurface () { + if ((style & SWT.SINGLE) != 0) { + long /*int*/ surface = super.paintSurface (); + long /*int*/ children = GDK.gdk_surface_get_children (surface); + if (children != 0) { + /* + * When search or cancel icons are added to Text, those + * icon window(s) are added to the beginning of the list. + * In order to always return the correct window for Text, + * browse to the end of the list. + */ + do { + surface = OS.g_list_data (children); + } while ((children = OS.g_list_next (children)) != 0); + } + OS.g_list_free (children); + return surface; + } + return 0; +} + /** * Pastes text from clipboard. * <p> diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java index 4eb52ce7e0..49ffd26f88 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java @@ -132,7 +132,7 @@ void createHandle (int index) { state |= HANDLE | THEME_BACKGROUND; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); handle = GTK.gtk_toolbar_new (); if (handle == 0) error (SWT.ERROR_NO_HANDLES); GTK.gtk_container_add (fixedHandle, handle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java index 4748d7ad9e..0e80db6dfd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java @@ -480,21 +480,21 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { } void drawTooltip (long /*int*/ cr) { - long /*int*/ window = gtk_widget_get_window (handle); + long /*int*/ gdkResource = GTK.GTK4 ? gtk_widget_get_surface(handle) : gtk_widget_get_window (handle); int x = BORDER + PADDING; int y = BORDER + PADDING; long /*int*/ cairo = 0; long /*int*/ context = 0; if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { if (cr == 0) { - long /*int*/ cairo_region = GDK.gdk_window_get_visible_region(window); - context = GDK.gdk_window_begin_draw_frame(window, cairo_region); + long /*int*/ cairo_region = GDK.gdk_window_get_visible_region(gdkResource); + context = GDK.gdk_window_begin_draw_frame(gdkResource, cairo_region); cairo = GDK.gdk_drawing_context_get_cairo_context(context); } else { cairo = cr; } } else { - cairo = cr != 0 ? cr : GDK.gdk_cairo_create(window); + cairo = cr != 0 ? cr : GDK.gdk_cairo_create(gdkResource); } if (cairo == 0) error (SWT.ERROR_NO_HANDLES); int count = borderPolygon.length / 2; @@ -540,7 +540,7 @@ void drawTooltip (long /*int*/ cr) { OS.pango_cairo_show_layout(cairo, layoutMessage); } if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { - if (cairo != cr && context != 0) GDK.gdk_window_end_draw_frame(window, context); + if (cairo != cr && context != 0) GDK.gdk_window_end_draw_frame(gdkResource, context); } else { if (cairo != cr) Cairo.cairo_destroy(cairo); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java index fcd6511136..768a1ed31f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java @@ -325,11 +325,12 @@ Rectangle [] computeProportions (Rectangle [] rects) { * @param rects */ void drawRectangles (Rectangle [] rects) { - long /*int*/ window = GDK.gdk_get_default_root_window(); + long /*int*/ gdkResource = GDK.gdk_get_default_root_window(); if (parent != null) { - window = gtk_widget_get_window (parent.paintHandle()); + long /*int*/ paintHandle = parent.paintHandle(); + gdkResource = GTK.GTK4 ? gtk_widget_get_surface(paintHandle) : gtk_widget_get_window (paintHandle); } - if (window == 0) return; + if (gdkResource == 0) return; if (overlay == 0) return; GTK.gtk_widget_shape_combine_region (overlay, 0); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index 2628d3b63d..e18408debd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -751,7 +751,7 @@ void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); - GTK.gtk_widget_set_has_window (fixedHandle, true); + gtk_widget_set_has_surface_or_window (fixedHandle, true); scrolledHandle = GTK.gtk_scrolled_window_new (0, 0); if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ [] types = getColumnTypes (1); @@ -2595,6 +2595,7 @@ boolean mnemonicMatch (char key) { @Override long /*int*/ paintWindow () { GTK.gtk_widget_realize (handle); + // TODO: this function has been removed on GTK4 return GTK.gtk_tree_view_get_bin_window (handle); } 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 393c8c7ec1..92e0d5dfae 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 @@ -345,6 +345,10 @@ long /*int*/ paintWindow () { return 0; } +long /*int*/ paintSurface () { + return 0; +} + long /*int*/ cssHandle() { return handle; } @@ -2022,6 +2026,15 @@ long /*int*/ gdk_window_get_device_position (long /*int*/ window, int[] x, int[] return GDK.gdk_window_get_device_position(window, pointer, x, y, mask); } +long /*int*/ gdk_surface_get_device_position (long /*int*/ surface, int[] x, int[] y, int[] mask) { + long /*int*/ display = 0; + if (surface != 0) { + display = GDK.gdk_surface_get_display (surface); + } + long /*int*/ pointer = GDK.gdk_get_pointer(display); + return GDK.gdk_surface_get_device_position(surface, pointer, x, y, mask); +} + void gtk_cell_renderer_get_preferred_size (long /*int*/ cell, long /*int*/ widget, int[] width, int[] height) { GtkRequisition minimum_size = new GtkRequisition (); GTK.gtk_cell_renderer_get_preferred_size (cell, widget, minimum_size, null); |