Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-11-26 20:50:46 +0000
committerEric Williams2018-12-11 19:18:42 +0000
commitcdd59fc81ef10b80938fb427fbc78836e5da3251 (patch)
tree2b00ee7086a0d2d2789230f640d0211a1103764c
parent285c866c3270b67bc5c6c408538cb861a7476c15 (diff)
downloadeclipse.platform.swt-cdd59fc81ef10b80938fb427fbc78836e5da3251.tar.gz
eclipse.platform.swt-cdd59fc81ef10b80938fb427fbc78836e5da3251.tar.xz
eclipse.platform.swt-cdd59fc81ef10b80938fb427fbc78836e5da3251.zip
Bug 540841: [GTK4] Rename GdkWindow to GdkSurface
Rename GdkWindow to GdkSurface, part 2 (4.11). Change-Id: I7bcb17d4c88b9f22cf75fc2faa4f0de7a6129386 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c164
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java132
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java246
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java118
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java80
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java84
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java65
28 files changed, 956 insertions, 344 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
index f0c77b70e5..71ab8aa02b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java
@@ -4626,8 +4626,13 @@ class AccessibleObject {
}
if (widget == 0) return;
long /*int*/ topLevel = GTK.gtk_widget_get_toplevel (widget);
- long /*int*/ window = GTK.gtk_widget_get_window (topLevel);
- GDK.gdk_window_get_origin (window, x, y);
+ if (GTK.GTK4) {
+ long /*int*/ surface = GTK.gtk_widget_get_surface (topLevel);
+ GDK.gdk_surface_get_origin (surface, x, y);
+ } else {
+ long /*int*/ window = GTK.gtk_widget_get_window (topLevel);
+ GDK.gdk_window_get_origin (window, x, y);
+ }
}
static int nextIndexOfChar (String string, String searchChars, int startIndex) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
index 98d7b4f905..7f6eefe262 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -353,7 +353,12 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
* NOTE: We believe that it is never an error to ungrab when
* a drag is finished.
*/
- long /*int*/ display = GDK.gdk_window_get_display(GTK.gtk_widget_get_window(widget));
+ long /*int*/ display;
+ if (GTK.GTK4) {
+ display = GDK.gdk_surface_get_display(GTK.gtk_widget_get_surface(widget));
+ } else {
+ display = GDK.gdk_window_get_display(GTK.gtk_widget_get_window(widget));
+ }
long /*int*/ pointer = GDK.gdk_get_pointer(display);
long /*int*/ keyboard = GDK.gdk_device_get_associated_device(pointer);
if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
index 816748b5ca..8ec97e05a3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
@@ -569,7 +569,14 @@ int getOperationFromKeyState() {
int[] state = new int[1];
long /*int*/ root = GDK.gdk_get_default_root_window ();
long /*int*/ pointer = GDK.gdk_get_pointer (GDK.gdk_window_get_display (root));
- GDK.gdk_window_get_device_position(root, pointer, null, null, state);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() here
+ * uses gdk_get_default_root_window(), which doesn't exist on GTK4.
+ */
+ } else {
+ GDK.gdk_window_get_device_position(root, pointer, null, null, state);
+ }
boolean ctrl = (state[0] & GDK.GDK_CONTROL_MASK) != 0;
boolean shift = (state[0] & GDK.GDK_SHIFT_MASK) != 0;
if (ctrl && shift) return DND.DROP_LINK;
@@ -769,9 +776,14 @@ boolean setEventData(long /*int*/ context, int x, int y, int time, DNDEvent even
targets = OS.g_list_next (targets);
}
if (dataTypes.length == 0) return false;
- long /*int*/ window = GTK.gtk_widget_get_window (control.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.gtk_widget_get_surface (control.handle);
+ GDK.gdk_surface_get_origin(surface, origin_x, origin_y);
+ } else {
+ long /*int*/ window = GTK.gtk_widget_get_window (control.handle);
+ GDK.gdk_window_get_origin(window, origin_x, origin_y);
+ }
Point coordinates = DPIUtil.autoScaleDown(new Point(origin_x[0] + x, origin_y[0] + y));
event.widget = this;
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 259b232364..6c255b2337 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
@@ -2102,6 +2102,18 @@ fail:
}
#endif
+#ifndef NO__1gdk_1surface_1get_1height
+JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1surface_1get_1height)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1height_FUNC);
+ rc = (jint)gdk_surface_get_height((GdkSurface *)arg0);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1height_FUNC);
+ return rc;
+}
+#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)
@@ -2121,6 +2133,23 @@ fail:
}
#endif
+#ifndef NO__1gdk_1surface_1get_1root_1origin
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1get_1root_1origin)
+ (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2)
+{
+ jint *lparg1=NULL;
+ jint *lparg2=NULL;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1root_1origin_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ gdk_surface_get_root_origin((GdSurface *)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_1root_1origin_FUNC);
+}
+#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)
@@ -2135,6 +2164,28 @@ fail:
}
#endif
+#ifndef NO__1gdk_1surface_1get_1width
+JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1surface_1get_1width)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1get_1width_FUNC);
+ rc = (jint)gdk_surface_get_width((GdkSurface *)arg0);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1get_1width_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1surface_1hide
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1hide)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1hide_FUNC);
+ gdk_surface_hide((GdkSurface *)arg0);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1hide_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)
@@ -2148,6 +2199,16 @@ fail:
}
#endif
+#ifndef NO__1gdk_1surface_1invalidate_1region
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1invalidate_1region)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1invalidate_1region_FUNC);
+ gdk_surface_invalidate_region((Gdksurface *)arg0, (const cairo_region_t *)arg1);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1invalidate_1region_FUNC);
+}
+#endif
+
#ifndef NO__1gdk_1surface_1lower
JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1lower)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -2158,6 +2219,16 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1lower)
}
#endif
+#ifndef NO__1gdk_1surface_1move
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1move)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1move_FUNC);
+ gdk_surface_move((GdkSurface *)arg0, arg1, arg2);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1move_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)
@@ -2183,6 +2254,16 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1raise)
}
#endif
+#ifndef NO__1gdk_1surface_1resize
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1resize)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jint arg2)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1resize_FUNC);
+ gdk_surface_resize((GdkSurface *)arg0, arg1, arg2);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1resize_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)
@@ -2203,6 +2284,26 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1set_1cursor)
}
#endif
+#ifndef NO__1gdk_1surface_1set_1decorations
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1set_1decorations)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1set_1decorations_FUNC);
+ gdk_surface_set_decorations((GdkSurface *)arg0, (GdkWMDecoration)arg1);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1set_1decorations_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1surface_1set_1functions
+JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1surface_1set_1functions)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1)
+{
+ GDK_NATIVE_ENTER(env, that, _1gdk_1surface_1set_1functions_FUNC);
+ gdk_surface_set_functions((GdkSurface *)arg0, (GdkWMFunction)arg1);
+ GDK_NATIVE_EXIT(env, that, _1gdk_1surface_1set_1functions_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)
@@ -2476,23 +2577,6 @@ JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1window_1get_1parent)
}
#endif
-#ifndef NO__1gdk_1window_1get_1position
-JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1get_1position)
- (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2)
-{
- jint *lparg1=NULL;
- jint *lparg2=NULL;
- GDK_NATIVE_ENTER(env, that, _1gdk_1window_1get_1position_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
- if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
- gdk_window_get_position((GdkWindow *)arg0, (gint *)lparg1, (gint *)lparg2);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- GDK_NATIVE_EXIT(env, that, _1gdk_1window_1get_1position_FUNC);
-}
-#endif
-
#ifndef NO__1gdk_1window_1get_1root_1origin
JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1get_1root_1origin)
(JNIEnv *env, jclass that, jintLong arg0, jintArray arg1, jintArray arg2)
@@ -2593,18 +2677,6 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1invalidate_1region)
}
#endif
-#ifndef NO__1gdk_1window_1is_1visible
-JNIEXPORT jboolean JNICALL GDK_NATIVE(_1gdk_1window_1is_1visible)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jboolean rc = 0;
- GDK_NATIVE_ENTER(env, that, _1gdk_1window_1is_1visible_FUNC);
- rc = (jboolean)gdk_window_is_visible((GdkWindow *)arg0);
- GDK_NATIVE_EXIT(env, that, _1gdk_1window_1is_1visible_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gdk_1window_1lower
JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1lower)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -2786,16 +2858,6 @@ JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1set_1user_1data)
}
#endif
-#ifndef NO__1gdk_1window_1shape_1combine_1region
-JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1shape_1combine_1region)
- (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jint arg3)
-{
- GDK_NATIVE_ENTER(env, that, _1gdk_1window_1shape_1combine_1region_FUNC);
- gdk_window_shape_combine_region((GdkWindow *)arg0, (const cairo_region_t *)arg1, (gint)arg2, (gint)arg3);
- GDK_NATIVE_EXIT(env, that, _1gdk_1window_1shape_1combine_1region_FUNC);
-}
-#endif
-
#ifndef NO__1gdk_1window_1show
JNIEXPORT void JNICALL GDK_NATIVE(_1gdk_1window_1show)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -16657,6 +16719,18 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1pango_1cairo_1create_1layout)
}
#endif
+#ifndef NO__1pango_1cairo_1font_1map_1get_1default
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1get_1default)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+ rc = (jintLong)pango_cairo_font_map_get_default();
+ OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1pango_1cairo_1layout_1path
JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1layout_1path)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
@@ -17001,6 +17075,18 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1pango_1font_1get_1metrics)
}
#endif
+#ifndef NO__1pango_1font_1map_1create_1context
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1pango_1font_1map_1create_1context)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1pango_1font_1map_1create_1context_FUNC);
+ rc = (jintLong)pango_font_map_create_context((PangoFontMap *)arg0);
+ OS_NATIVE_EXIT(env, that, _1pango_1font_1map_1create_1context_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1pango_1font_1metrics_1get_1approximate_1char_1width
JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1approximate_1char_1width)
(JNIEnv *env, jclass that, jintLong arg0)
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 19ac102cbd..2676362c5c 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
@@ -319,7 +319,6 @@
#define NO__1gdk_1display_1get_1monitor_1at_1window
#define NO__1gdk_1get_1default_1root_1window
#define NO__1gdk_1property_1get
-#define NO__1gdk_1window_1add_1filter
#define NO__1gdk_1window_1begin_1draw_1frame
#define NO__1gdk_1window_1create_1similar_1surface
#define NO__1gdk_1window_1destroy
@@ -335,7 +334,6 @@
#define NO__1gdk_1window_1get_1width
#define NO__1gdk_1window_1get_1origin
#define NO__1gdk_1window_1get_1parent
-#define NO__1gdk_1window_1get_1position
#define NO__1gdk_1window_1get_1root_1origin
#define NO__1gdk_1window_1get_1state
#define NO__1gdk_1window_1get_1user_1data
@@ -344,7 +342,6 @@
#define NO__1gdk_1window_1hide
#define NO__1gdk_1window_1invalidate_1rect
#define NO__1gdk_1window_1invalidate_1region
-#define NO__1gdk_1window_1is_1visible
#define NO__1gdk_1window_1raise
#define NO__1gdk_1window_1lower
#define NO__1gdk_1window_1move
@@ -355,11 +352,9 @@
#define NO__1gdk_1window_1restack
#define NO__1gdk_1window_1set_1cursor
#define NO__1gdk_1window_1set_1decorations
-#define NO__1gdk_1window_1set_1events
#define NO__1gdk_1window_1set_1functions
#define NO__1gdk_1window_1set_1override_1redirect
#define NO__1gdk_1window_1set_1user_1data
-#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
@@ -424,6 +419,15 @@
#define NO__1gdk_1surface_1get_1device_1position
#define NO__1gdk_1display_1get_1monitor_1at_1surface
#define NO__1gdk_1surface_1get_1frame_1extents
+#define NO__1gdk_1surface_1get_1width
+#define NO__1gdk_1surface_1get_1height
+#define NO__1gdk_1surface_1resize
+#define NO__1gdk_1surface_1move
+#define NO__1gdk_1surface_1hide
+#define NO__1gdk_1surface_1set_1decorations
+#define NO__1gdk_1surface_1set_1functions
+#define NO__1gdk_1surface_1get_1root_1origin
+#define NO__1gdk_1surface_1invalidate_1region
// Miscellaneous functions not present on GTK3
#define NO__1gdk_1device_1warp__III
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 bfa51e1a99..861bff696b 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
@@ -173,14 +173,23 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1surface_1get_1device_1position",
"_1gdk_1surface_1get_1display",
"_1gdk_1surface_1get_1frame_1extents",
+ "_1gdk_1surface_1get_1height",
"_1gdk_1surface_1get_1origin",
+ "_1gdk_1surface_1get_1root_1origin",
"_1gdk_1surface_1get_1user_1data",
+ "_1gdk_1surface_1get_1width",
+ "_1gdk_1surface_1hide",
"_1gdk_1surface_1invalidate_1rect",
+ "_1gdk_1surface_1invalidate_1region",
"_1gdk_1surface_1lower",
+ "_1gdk_1surface_1move",
"_1gdk_1surface_1new_1child",
"_1gdk_1surface_1raise",
+ "_1gdk_1surface_1resize",
"_1gdk_1surface_1restack",
"_1gdk_1surface_1set_1cursor",
+ "_1gdk_1surface_1set_1decorations",
+ "_1gdk_1surface_1set_1functions",
"_1gdk_1surface_1set_1user_1data",
"_1gdk_1surface_1show",
"_1gdk_1surface_1show_1unraised",
@@ -201,7 +210,6 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1window_1get_1height",
"_1gdk_1window_1get_1origin",
"_1gdk_1window_1get_1parent",
- "_1gdk_1window_1get_1position",
"_1gdk_1window_1get_1root_1origin",
"_1gdk_1window_1get_1state",
"_1gdk_1window_1get_1user_1data",
@@ -210,7 +218,6 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1window_1hide",
"_1gdk_1window_1invalidate_1rect",
"_1gdk_1window_1invalidate_1region",
- "_1gdk_1window_1is_1visible",
"_1gdk_1window_1lower",
"_1gdk_1window_1move",
"_1gdk_1window_1move_1resize",
@@ -227,7 +234,6 @@ char * GDK_nativeFunctionNames[] = {
"_1gdk_1window_1set_1functions",
"_1gdk_1window_1set_1override_1redirect",
"_1gdk_1window_1set_1user_1data",
- "_1gdk_1window_1shape_1combine_1region",
"_1gdk_1window_1show",
"_1gdk_1window_1show_1unraised",
"_1gdk_1x11_1display_1error_1trap_1pop_1ignored",
@@ -1540,6 +1546,7 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1cairo_1context_1get_1font_1options",
"_1pango_1cairo_1context_1set_1font_1options",
"_1pango_1cairo_1create_1layout",
+ "_1pango_1cairo_1font_1map_1get_1default",
"_1pango_1cairo_1layout_1path",
"_1pango_1cairo_1show_1layout",
"_1pango_1context_1get_1base_1dir",
@@ -1569,6 +1576,7 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1font_1family_1get_1name",
"_1pango_1font_1family_1list_1faces",
"_1pango_1font_1get_1metrics",
+ "_1pango_1font_1map_1create_1context",
"_1pango_1font_1metrics_1get_1approximate_1char_1width",
"_1pango_1font_1metrics_1get_1ascent",
"_1pango_1font_1metrics_1get_1descent",
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 ab820ffef4..c83011da67 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
@@ -183,14 +183,23 @@ typedef enum {
_1gdk_1surface_1get_1device_1position_FUNC,
_1gdk_1surface_1get_1display_FUNC,
_1gdk_1surface_1get_1frame_1extents_FUNC,
+ _1gdk_1surface_1get_1height_FUNC,
_1gdk_1surface_1get_1origin_FUNC,
+ _1gdk_1surface_1get_1root_1origin_FUNC,
_1gdk_1surface_1get_1user_1data_FUNC,
+ _1gdk_1surface_1get_1width_FUNC,
+ _1gdk_1surface_1hide_FUNC,
_1gdk_1surface_1invalidate_1rect_FUNC,
+ _1gdk_1surface_1invalidate_1region_FUNC,
_1gdk_1surface_1lower_FUNC,
+ _1gdk_1surface_1move_FUNC,
_1gdk_1surface_1new_1child_FUNC,
_1gdk_1surface_1raise_FUNC,
+ _1gdk_1surface_1resize_FUNC,
_1gdk_1surface_1restack_FUNC,
_1gdk_1surface_1set_1cursor_FUNC,
+ _1gdk_1surface_1set_1decorations_FUNC,
+ _1gdk_1surface_1set_1functions_FUNC,
_1gdk_1surface_1set_1user_1data_FUNC,
_1gdk_1surface_1show_FUNC,
_1gdk_1surface_1show_1unraised_FUNC,
@@ -211,7 +220,6 @@ typedef enum {
_1gdk_1window_1get_1height_FUNC,
_1gdk_1window_1get_1origin_FUNC,
_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,
@@ -220,7 +228,6 @@ typedef enum {
_1gdk_1window_1hide_FUNC,
_1gdk_1window_1invalidate_1rect_FUNC,
_1gdk_1window_1invalidate_1region_FUNC,
- _1gdk_1window_1is_1visible_FUNC,
_1gdk_1window_1lower_FUNC,
_1gdk_1window_1move_FUNC,
_1gdk_1window_1move_1resize_FUNC,
@@ -237,7 +244,6 @@ typedef enum {
_1gdk_1window_1set_1functions_FUNC,
_1gdk_1window_1set_1override_1redirect_FUNC,
_1gdk_1window_1set_1user_1data_FUNC,
- _1gdk_1window_1shape_1combine_1region_FUNC,
_1gdk_1window_1show_FUNC,
_1gdk_1window_1show_1unraised_FUNC,
_1gdk_1x11_1display_1error_1trap_1pop_1ignored_FUNC,
@@ -1526,6 +1532,7 @@ typedef enum {
_1pango_1cairo_1context_1get_1font_1options_FUNC,
_1pango_1cairo_1context_1set_1font_1options_FUNC,
_1pango_1cairo_1create_1layout_FUNC,
+ _1pango_1cairo_1font_1map_1get_1default_FUNC,
_1pango_1cairo_1layout_1path_FUNC,
_1pango_1cairo_1show_1layout_FUNC,
_1pango_1context_1get_1base_1dir_FUNC,
@@ -1555,6 +1562,7 @@ typedef enum {
_1pango_1font_1family_1get_1name_FUNC,
_1pango_1font_1family_1list_1faces_FUNC,
_1pango_1font_1get_1metrics_FUNC,
+ _1pango_1font_1map_1create_1context_FUNC,
_1pango_1font_1metrics_1get_1approximate_1char_1width_FUNC,
_1pango_1font_1metrics_1get_1ascent_FUNC,
_1pango_1font_1metrics_1get_1descent_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 a384d5ead8..9037953907 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
@@ -564,6 +564,19 @@ public class GDK extends OS {
}
}
/**
+ * @param surface cast=(GdkSurface *)
+ */
+ public static final native int _gdk_surface_get_width(long /*int*/ surface);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final int gdk_surface_get_width(long /*int*/ surface) {
+ lock.lock();
+ try {
+ return _gdk_surface_get_width(surface);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
* @param window cast=(GdkWindow *)
*/
public static final native long /*int*/ _gdk_window_get_visible_region(long /*int*/ window);
@@ -590,6 +603,19 @@ public class GDK extends OS {
}
}
/**
+ * @param surface cast=(GdkSurface *)
+ */
+ public static final native int _gdk_surface_get_height(long /*int*/ surface);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final int gdk_surface_get_height(long /*int*/ surface) {
+ lock.lock();
+ try {
+ return _gdk_surface_get_height(surface);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
* @param cairo cast=(cairo_t *)
* @param pixbuf cast=(const GdkPixbuf *)
* @param pixbuf_x cast=(gdouble)
@@ -2218,27 +2244,27 @@ public class GDK extends OS {
* @param x cast=(gint *)
* @param y cast=(gint *)
*/
- public static final native void _gdk_window_get_position(long /*int*/ window, int[] x, int[] y);
+ public static final native void _gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y);
/** [GTK3 only, if-def'd in os.h] */
- public static final void gdk_window_get_position(long /*int*/ window, int[] x, int[] y) {
+ public static final void gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y) {
lock.lock();
try {
- _gdk_window_get_position(window, x, y);
+ _gdk_window_get_root_origin(window, x, y);
} finally {
lock.unlock();
}
}
/**
- * @param window cast=(GdkWindow *)
+ * @param surface cast=(GdSurface *)
* @param x cast=(gint *)
* @param y cast=(gint *)
*/
- public static final native void _gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y);
- /** [GTK3 only, if-def'd in os.h] */
- public static final void gdk_window_get_root_origin(long /*int*/ window, int[] x, int[] y) {
+ public static final native void _gdk_surface_get_root_origin(long /*int*/ surface, int[] x, int[] y);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_get_root_origin(long /*int*/ surface, int[] x, int[] y) {
lock.lock();
try {
- _gdk_window_get_root_origin(window, x, y);
+ _gdk_surface_get_root_origin(surface, x, y);
} finally {
lock.unlock();
}
@@ -2282,6 +2308,17 @@ public class GDK extends OS {
lock.unlock();
}
}
+ /** @param surface cast=(GdkSurface *) */
+ public static final native void _gdk_surface_hide(long /*int*/ surface);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_hide(long /*int*/ surface) {
+ lock.lock();
+ try {
+ _gdk_surface_hide(surface);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param window cast=(GdkWindow *)
* @param rectangle cast=(GdkRectangle *),flags=no_out
@@ -2326,13 +2363,16 @@ public class GDK extends OS {
lock.unlock();
}
}
- /** @param window cast=(GdkWindow *) */
- public static final native boolean _gdk_window_is_visible(long /*int*/ window);
- /** [GTK3 only, if-def'd in os.h] */
- public static final boolean gdk_window_is_visible(long /*int*/ window) {
+ /**
+ * @param surface cast=(Gdksurface *)
+ * @param region cast=(const cairo_region_t *)
+ */
+ public static final native void _gdk_surface_invalidate_region(long /*int*/ surface, long /*int*/ region);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_invalidate_region(long /*int*/ surface, long /*int*/ region) {
lock.lock();
try {
- return _gdk_window_is_visible(window);
+ _gdk_surface_invalidate_region(surface, region);
} finally {
lock.unlock();
}
@@ -2348,6 +2388,17 @@ public class GDK extends OS {
lock.unlock();
}
}
+ /** @param surface cast=(GdkSurface *) */
+ public static final native void _gdk_surface_move(long /*int*/ surface, int x, int y);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_move(long /*int*/ surface, int x, int y) {
+ lock.lock();
+ try {
+ _gdk_surface_move(surface, x, y);
+ } finally {
+ lock.unlock();
+ }
+ }
/** @param window cast=(GdkWindow *) */
public static final native void _gdk_window_move_resize(long /*int*/ window, int x, int y, int width, int height);
/** [GTK3 only, if-def'd in os.h] */
@@ -2470,6 +2521,17 @@ public class GDK extends OS {
lock.unlock();
}
}
+ /** @param surface cast=(GdkSurface *) */
+ public static final native void _gdk_surface_resize(long /*int*/ surface, int width, int height);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_resize(long /*int*/ surface, int width, int height) {
+ lock.lock();
+ try {
+ _gdk_surface_resize(surface, width, height);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param window cast=(GdkWindow *)
* @param sibling cast=(GdkWindow *)
@@ -2557,6 +2619,20 @@ public class GDK extends OS {
}
}
/**
+ * @param surface cast=(GdkSurface *)
+ * @param decorations cast=(GdkWMDecoration)
+ */
+ public static final native void _gdk_surface_set_decorations(long /*int*/ surface, int decorations);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_set_decorations(long /*int*/ surface, int decorations) {
+ lock.lock();
+ try {
+ _gdk_surface_set_decorations(surface, decorations);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
* @param window cast=(GdkWindow *)
* @param functions cast=(GdkWMFunction)
*/
@@ -2570,6 +2646,20 @@ public class GDK extends OS {
lock.unlock();
}
}
+ /**
+ * @param surface cast=(GdkSurface *)
+ * @param functions cast=(GdkWMFunction)
+ */
+ public static final native void _gdk_surface_set_functions(long /*int*/ surface, int functions);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gdk_surface_set_functions(long /*int*/ surface, int functions) {
+ lock.lock();
+ try {
+ _gdk_surface_set_functions(surface, functions);
+ } finally {
+ lock.unlock();
+ }
+ }
/** @param window cast=(GdkWindow *) */
public static final native void _gdk_window_set_events(long /*int*/ window, int event_mask);
/** [GTK3 only, if-def'd in os.h] */
@@ -2623,22 +2713,6 @@ public class GDK extends OS {
lock.unlock();
}
}
- /**
- * @param window cast=(GdkWindow *)
- * @param shape_region cast=(const cairo_region_t *)
- * @param offset_x cast=(gint)
- * @param offset_y cast=(gint)
- */
- public static final native void _gdk_window_shape_combine_region (long /*int*/ window, long /*int*/ shape_region, int offset_x, int offset_y);
- /** [GTK3 only, if-def'd in os.h] */
- public static final void gdk_window_shape_combine_region (long /*int*/ window, long /*int*/ shape_region, int offset_x, int offset_y) {
- lock.lock();
- try {
- _gdk_window_shape_combine_region(window, shape_region, offset_x, offset_y);
- } finally {
- lock.unlock();
- }
- }
/** @param window cast=(GdkWindow *) */
public static final native void _gdk_window_show(long /*int*/ window);
/** [GTK3 only, if-def'd in os.h] */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index a711204484..1d866c5f0f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -1690,7 +1690,7 @@ public class GTK extends OS {
* @param target_list cast=(GtkTargetList *)
*/
public static final native long /*int*/ _gtk_drag_dest_find_target(long /*int*/ widget, long /*int*/ context, long /*int*/ target_list);
- /** [GTK3/GTK4: TODO_ericwill both have identical signatures but accept differing parameters at the native level] */
+ /** [GTK3/GTK4: both have identical signatures but accept differing parameters at the native level] */
public static final long /*int*/ gtk_drag_dest_find_target(long /*int*/ widget, long /*int*/ context, long /*int*/ target_list) {
lock.lock();
try {
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 0de4db4ace..2beb91700a 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
@@ -3244,6 +3244,15 @@ public static final long /*int*/ pango_cairo_create_layout(long /*int*/ cairo) {
lock.unlock();
}
}
+public static final native long /*int*/ _pango_cairo_font_map_get_default();
+public static final long /*int*/ pango_cairo_font_map_get_default() {
+ lock.lock();
+ try {
+ return _pango_cairo_font_map_get_default();
+ } finally {
+ lock.unlock();
+ }
+}
/**
* @param context cast=(PangoContext *)
*/
@@ -3600,6 +3609,18 @@ public static final long /*int*/ pango_font_get_metrics(long /*int*/ font, long
lock.unlock();
}
}
+/**
+ * @param fontMap cast=(PangoFontMap *)
+ */
+public static final native long /*int*/ _pango_font_map_create_context(long /*int*/ fontMap);
+public static final long /*int*/ pango_font_map_create_context(long /*int*/ fontMap) {
+ lock.lock();
+ try {
+ return _pango_font_map_create_context(fontMap);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param metrics cast=(PangoFontMetrics *) */
public static final native int _pango_font_metrics_get_approximate_char_width(long /*int*/ metrics);
public static final int pango_font_metrics_get_approximate_char_width(long /*int*/ metrics) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index a71d1eb3ca..42920e0b03 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -424,7 +424,13 @@ public FontData[] getFontList (String faceName, boolean scalable) {
int[] n_families = new int[1];
long /*int*/[] faces = new long /*int*/[1];
int[] n_faces = new int[1];
- long /*int*/ context = GDK.gdk_pango_context_get();
+ long /*int*/ context;
+ if (GTK.GTK4) {
+ long /*int*/ fontMap = OS.pango_cairo_font_map_get_default ();
+ context = OS.pango_font_map_create_context (fontMap);
+ } else {
+ context = GDK.gdk_pango_context_get();
+ }
OS.pango_context_list_families(context, families, n_families);
int nFds = 0;
FontData[] fds = new FontData[faceName != null ? 4 : n_families[0]];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 1c300e6431..76b912103d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -562,7 +562,11 @@ void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int
long /*int*/ invalidateRegion = Cairo.cairo_region_create_rectangle (srcRect);
Cairo.cairo_region_subtract (invalidateRegion, visibleRegion);
Cairo.cairo_region_translate (invalidateRegion, deltaX, deltaY);
- GDK.gdk_window_invalidate_region(drawable, invalidateRegion, false);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_invalidate_region(drawable, invalidateRegion);
+ } else {
+ GDK.gdk_window_invalidate_region(drawable, invalidateRegion, false);
+ }
Cairo.cairo_region_destroy (visibleRegion);
Cairo.cairo_region_destroy (copyRegion);
Cairo.cairo_region_destroy (invalidateRegion);
@@ -604,7 +608,13 @@ void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int
}
void createLayout() {
- long /*int*/ context = GDK.gdk_pango_context_get();
+ long /*int*/ context;
+ if (GTK.GTK4) {
+ long /*int*/ fontMap = OS.pango_cairo_font_map_get_default ();
+ context = OS.pango_font_map_create_context (fontMap);
+ } else {
+ context = GDK.gdk_pango_context_get();
+ }
if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
data.context = context;
long /*int*/ layout = OS.pango_layout_new(context);
@@ -2410,8 +2420,13 @@ void getSize(int[] width, int[] height) {
return;
}
if (data.drawable != 0) {
- width[0] = GDK.gdk_window_get_width(data.drawable);
- height[0] = GDK.gdk_window_get_height(data.drawable);
+ if (GTK.GTK4) {
+ width[0] = GDK.gdk_surface_get_width(data.drawable);
+ height[0] = GDK.gdk_surface_get_height(data.drawable);
+ } else {
+ width[0] = GDK.gdk_window_get_width(data.drawable);
+ height[0] = GDK.gdk_window_get_height(data.drawable);
+ }
return;
}
long /*int*/ surface = Cairo.cairo_get_target(handle);
@@ -2601,7 +2616,12 @@ void initCairo() {
long /*int*/ cairo = data.cairo;
if (cairo != 0) return;
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long /*int*/ surface = GDK.gdk_window_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ long /*int*/ surface;
+ if (GTK.GTK4) {
+ surface = GDK.gdk_surface_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ } else {
+ surface = GDK.gdk_window_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ }
data.cairo = cairo = Cairo.cairo_create(surface);
} else {
data.cairo = cairo = GDK.gdk_cairo_create(data.drawable);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
index ba044ea83c..157003f43f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
@@ -60,7 +60,9 @@ public final class GCData {
public int interpolation = SWT.DEFAULT;
public Image image;
- public long /*int*/ clipRgn, context, layout, damageRgn, drawable, cairo, regionSet;
+ public long /*int*/ clipRgn, context, layout, damageRgn, cairo, regionSet;
+ /** Usually a GdkWindow on GTK3, or a GdkSurface on GTK4 */
+ public long /*int*/ drawable;
public double cairoXoffset, cairoYoffset;
public boolean disposeCairo;
public double[] identity, clippingTransform;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
index 3f42472bee..d3bca490c7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java
@@ -82,7 +82,12 @@ public final class TextLayout extends Resource {
public TextLayout (Device device) {
super(device);
device = this.device;
- context = GDK.gdk_pango_context_get();
+ if (GTK.GTK4) {
+ long /*int*/ fontMap = OS.pango_cairo_font_map_get_default ();
+ context = OS.pango_font_map_create_context (fontMap);
+ } else {
+ context = GDK.gdk_pango_context_get();
+ }
if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.pango_context_set_language(context, GTK.gtk_get_default_language());
OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
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 64bd9228a6..71c2163023 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
@@ -568,11 +568,11 @@ void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, De
}
@Override
-void fixParentGdkWindow() {
+void fixParentGdkResource() {
// Changes to this method should be verified via
// org.eclipse.swt.tests.gtk/*/Bug510803_TabFolder_TreeEditor_Regression.java (part two)
for (Control child : _getChildren()) {
- child.fixParentGdkWindow();
+ child.fixParentGdkResource();
}
}
@@ -1299,8 +1299,14 @@ void moveChildren(int oldWidth) {
if (oldWidth > 0) x = oldWidth - controlWidth - x;
int clientWidth = getClientWidth ();
x = clientWidth - controlWidth - x;
- if (child.enableWindow != 0) {
- GDK.gdk_window_move (child.enableWindow, x, y);
+ if (GTK.GTK4) {
+ if (child.enableSurface != 0) {
+ GDK.gdk_surface_move (child.enableSurface, x, y);
+ }
+ } else {
+ if (child.enableWindow != 0) {
+ GDK.gdk_window_move (child.enableWindow, x, y);
+ }
}
child.moveHandle (x, y);
/*
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 452267192e..8e2b8049d5 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
@@ -463,7 +463,15 @@ boolean hooksPaint () {
@Override
long /*int*/ hoverProc (long /*int*/ widget) {
int [] x = new int [1], y = new int [1], mask = new int [1];
- gdk_window_get_device_position (0, x, y, mask);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() with a 0
+ * for the GdkWindow uses gdk_get_default_root_window(),
+ * which doesn't exist on GTK4.
+ */
+ } else {
+ display.gdk_window_get_device_position (0, x, y, mask);
+ }
if (containedInRegion(x[0], y[0])) return 0;
sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x [0], y [0], false, mask [0]);
/* Always return zero in order to cancel the hover timer */
@@ -1005,8 +1013,14 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
int oldY = allocation.y;
sameOrigin = x == oldX && y == oldY;
if (!sameOrigin) {
- if (enableWindow != 0) {
- GDK.gdk_window_move (enableWindow, x, y);
+ if (GTK.GTK4) {
+ if (enableSurface != 0) {
+ GDK.gdk_surface_move (enableSurface, x, y);
+ }
+ } else {
+ if (enableWindow != 0) {
+ GDK.gdk_window_move (enableWindow, x, y);
+ }
}
moveHandle (x, y);
}
@@ -1020,11 +1034,20 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
if (!sameExtent && !(width == 0 && height == 0)) {
int newWidth = Math.max (1, width);
int newHeight = Math.max (1, height);
- if (redrawWindow != 0) {
- GDK.gdk_window_resize (redrawWindow, newWidth, newHeight);
- }
- if (enableWindow != 0) {
- GDK.gdk_window_resize (enableWindow, newWidth, newHeight);
+ if (GTK.GTK4) {
+ if (redrawSurface != 0) {
+ GDK.gdk_surface_resize (redrawSurface, newWidth, newHeight);
+ }
+ if (enableSurface != 0) {
+ GDK.gdk_surface_resize (enableSurface, newWidth, newHeight);
+ }
+ } else {
+ if (redrawWindow != 0) {
+ GDK.gdk_window_resize (redrawWindow, newWidth, newHeight);
+ }
+ if (enableWindow != 0) {
+ GDK.gdk_window_resize (enableWindow, newWidth, newHeight);
+ }
}
resizeHandle (newWidth, newHeight);
}
@@ -1085,17 +1108,33 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
if (!sameExtent) {
state = (width == 0) ? state | ZERO_WIDTH : state & ~ZERO_WIDTH;
state = (height == 0) ? state | ZERO_HEIGHT : state & ~ZERO_HEIGHT;
- if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) != 0) {
- if (enableWindow != 0) {
- GDK.gdk_window_hide (enableWindow);
+ if (GTK.GTK4) {
+ if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) != 0) {
+ if (enableSurface != 0) {
+ GDK.gdk_surface_hide (enableSurface);
+ }
+ GTK.gtk_widget_hide (topHandle);
+ } else {
+ if ((state & HIDDEN) == 0) {
+ if (enableSurface != 0) {
+ GDK.gdk_surface_show_unraised (enableSurface);
+ }
+ GTK.gtk_widget_show (topHandle);
+ }
}
- GTK.gtk_widget_hide (topHandle);
} else {
- if ((state & HIDDEN) == 0) {
+ if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) != 0) {
if (enableWindow != 0) {
- GDK.gdk_window_show_unraised (enableWindow);
+ GDK.gdk_window_hide (enableWindow);
+ }
+ GTK.gtk_widget_hide (topHandle);
+ } else {
+ if ((state & HIDDEN) == 0) {
+ if (enableWindow != 0) {
+ GDK.gdk_window_show_unraised (enableWindow);
+ }
+ GTK.gtk_widget_show (topHandle);
}
- GTK.gtk_widget_show (topHandle);
}
}
if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth);
@@ -2595,7 +2634,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
quit = true;
}
int [] newX = new int [1], newY = new int [1];
- gdk_window_get_device_position (gdkMotionEvent.window, newX, newY, null);
+ display.gdk_window_get_device_position (gdkMotionEvent.window, newX, newY, null);
break;
}
case GDK.GDK_KEY_PRESS:
@@ -2651,10 +2690,10 @@ void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, De
*
* Note, composites should treat this differently and take child controls into consideration.
*/
-void fixParentGdkWindow() {
+void fixParentGdkResource() {
// Changes to this method should be verified via
// org.eclipse.swt.tests.gtk/*/Bug510803_TabFolder_TreeEditor_Regression.java (part one)
- parent.setParentGdkWindow(this);
+ parent.setParentGdkResource(this);
}
/**
@@ -2696,7 +2735,7 @@ static void gtk_widget_reparent (Control control, long /*int*/ newParentHandle)
// GTK.gtk_container_add (newParentHandle, widget);
// OS.g_object_unref (widget);
- control.fixParentGdkWindow();
+ control.fixParentGdkResource();
}
}
@@ -3035,7 +3074,12 @@ public Monitor getMonitor () {
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
long /*int*/ display = GDK.gdk_display_get_default ();
if (display != 0) {
- long /*int*/ monitor = GDK.gdk_display_get_monitor_at_window(display, paintWindow ());
+ long /*int*/ monitor;
+ if (GTK.GTK4) {
+ monitor = GDK.gdk_display_get_monitor_at_surface(display, paintSurface ());
+ } else {
+ monitor = GDK.gdk_display_get_monitor_at_window(display, paintWindow ());
+ }
long /*int*/ toCompare;
for (int i = 0; i < monitors.length; i++) {
toCompare = GDK.gdk_display_get_monitor(display, i);
@@ -3693,7 +3737,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
if (gdkEvent.is_hint != 0) {
int [] pointer_x = new int [1], pointer_y = new int [1], mask = new int [1];
long /*int*/ window = eventWindow ();
- gdk_window_get_device_position (window, pointer_x, pointer_y, mask);
+ display.gdk_window_get_device_position (window, pointer_x, pointer_y, mask);
x = pointer_x [0];
y = pointer_y [0];
state = mask [0];
@@ -3717,7 +3761,15 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
long /*int*/ gtk_popup_menu (long /*int*/ widget) {
if (!hasFocus()) return 0;
int [] x = new int [1], y = new int [1];
- gdk_window_get_device_position (0, x, y, null);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() with a 0
+ * for the GdkWindow uses gdk_get_default_root_window(),
+ * which doesn't exist on GTK4.
+ */
+ } else {
+ display.gdk_window_get_device_position (0, x, y, null);
+ }
return showMenu (x [0], y [0], SWT.MENU_KEYBOARD) ? 1 : 0;
}
@@ -3815,17 +3867,22 @@ long /*int*/ gtk_unrealize (long /*int*/ widget) {
@Override
public long /*int*/ internal_new_GC (GCData data) {
checkWidget ();
- long /*int*/ window = paintWindow ();
- if (window == 0) error (SWT.ERROR_NO_HANDLES);
+ long /*int*/ gdkResource = GTK.GTK4 ? paintSurface () : paintWindow ();
+ if (gdkResource == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ gc = data.cairo;
if (gc != 0) {
Cairo.cairo_reference (gc);
} else {
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long /*int*/ surface = GDK.gdk_window_create_similar_surface(window, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ long /*int*/ surface;
+ if (GTK.GTK4) {
+ surface = GDK.gdk_surface_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ } else {
+ surface = GDK.gdk_window_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ }
gc = Cairo.cairo_create(surface);
} else {
- gc = GDK.gdk_cairo_create (window);
+ gc = GDK.gdk_cairo_create (gdkResource);
}
}
if (gc == 0) error (SWT.ERROR_NO_HANDLES);
@@ -3838,7 +3895,7 @@ public long /*int*/ internal_new_GC (GCData data) {
data.style |= SWT.MIRRORED;
}
}
- data.drawable = window;
+ data.drawable = gdkResource;
data.device = display;
Control control = findBackgroundControl ();
@@ -4126,20 +4183,36 @@ void redrawChildren () {
void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) {
if (!GTK.gtk_widget_get_realized(handle)) return;
- long /*int*/ window = paintWindow ();
GdkRectangle rect = new GdkRectangle ();
- if (redrawAll) {
- int [] w = new int [1], h = new int [1];
- gdk_window_get_size (window, w, h);
- rect.width = w [0];
- rect.height = h [0];
+ if (GTK.GTK4) {
+ long /*int*/ surface = paintSurface ();
+ if (redrawAll) {
+ int [] w = new int [1], h = new int [1];
+ gdk_surface_get_size (surface, w, h);
+ rect.width = w [0];
+ rect.height = h [0];
+ } else {
+ rect.x = x;
+ rect.y = y;
+ rect.width = Math.max (0, width);
+ rect.height = Math.max (0, height);
+ }
+ GDK.gdk_surface_invalidate_rect(surface, rect);
} else {
- rect.x = x;
- rect.y = y;
- rect.width = Math.max (0, width);
- rect.height = Math.max (0, height);
+ long /*int*/ window = paintWindow ();
+ if (redrawAll) {
+ int [] w = new int [1], h = new int [1];
+ gdk_window_get_size (window, w, h);
+ rect.width = w [0];
+ rect.height = h [0];
+ } else {
+ rect.x = x;
+ rect.y = y;
+ rect.width = Math.max (0, width);
+ rect.height = Math.max (0, height);
+ }
+ GDK.gdk_window_invalidate_rect (window, rect, all);
}
- GDK.gdk_window_invalidate_rect (window, rect, all);
}
@Override
@@ -4412,11 +4485,19 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0);
event.setBounds (DPIUtil.autoScaleDown (eventRect));
} else {
- 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);
- Rectangle eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
- event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ Rectangle eventRect;
+ if (GTK.GTK4) {
+ long /*int*/ surface = eventSurface ();
+ GDK.gdk_surface_get_origin (surface, origin_x, origin_y);
+ eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ } else {
+ long /*int*/ window = eventWindow ();
+ GDK.gdk_window_get_origin (window, origin_x, origin_y);
+ eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
+ event.setBounds (DPIUtil.autoScaleDown (eventRect));
+ }
}
if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x;
setInputState (event, state);
@@ -5379,7 +5460,7 @@ void setParentBackground () {
if (fixedHandle != 0) setBackgroundGdkRGBA (fixedHandle, null);
}
-void setParentGdkWindow (Control child) {
+void setParentGdkResource (Control child) {
}
boolean setRadioSelection (boolean value) {
@@ -5413,36 +5494,53 @@ public void setRedraw (boolean redraw) {
checkWidget();
if (redraw) {
if (--drawCount == 0) {
- if (redrawWindow != 0) {
- long /*int*/ window = paintWindow ();
- /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */
- GDK.gdk_window_hide (redrawWindow);
- GDK.gdk_window_destroy (redrawWindow);
- GDK.gdk_window_set_events (window, GTK.gtk_widget_get_events (paintHandle ()));
- redrawWindow = 0;
+ if (GTK.GTK4) {
+ if (redrawSurface != 0) {
+ GDK.gdk_surface_hide (redrawSurface);
+ GDK.gdk_surface_destroy (redrawSurface);
+ redrawSurface = 0;
+ }
+ } else {
+ if (redrawWindow != 0) {
+ long /*int*/ window = paintWindow ();
+ /* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */
+ GDK.gdk_window_hide (redrawWindow);
+ GDK.gdk_window_destroy (redrawWindow);
+ GDK.gdk_window_set_events (window, GTK.gtk_widget_get_events (paintHandle ()));
+ redrawWindow = 0;
+ }
}
}
} else {
if (drawCount++ == 0) {
if (GTK.gtk_widget_get_realized (handle)) {
- long /*int*/ window = paintWindow ();
Rectangle rect = getBoundsInPixels ();
- GdkWindowAttr attributes = new GdkWindowAttr ();
- attributes.width = rect.width;
- attributes.height = rect.height;
- attributes.event_mask = GDK.GDK_EXPOSURE_MASK;
- attributes.window_type = GDK.GDK_WINDOW_CHILD;
- redrawWindow = GDK.gdk_window_new (window, attributes, 0);
- if (redrawWindow != 0) {
- int mouseMask = GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_BUTTON_RELEASE_MASK |
- GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK |
- GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_POINTER_MOTION_HINT_MASK |
- 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);
+ if (GTK.GTK4) {
+ long /*int*/ surface = paintSurface();
+ GdkRectangle gdkRectangle = new GdkRectangle ();
+ gdkRectangle.width = rect.width;
+ gdkRectangle.height = rect.height;
+ redrawSurface = GDK.gdk_surface_new_child(surface, gdkRectangle);
+ GDK.gdk_surface_show(redrawSurface);
+ } else {
+ long /*int*/ window = paintWindow ();
+ GdkWindowAttr attributes = new GdkWindowAttr ();
+ attributes.width = rect.width;
+ attributes.height = rect.height;
+ attributes.event_mask = GDK.GDK_EXPOSURE_MASK;
+ attributes.window_type = GDK.GDK_WINDOW_CHILD;
+ redrawWindow = GDK.gdk_window_new (window, attributes, 0);
+ if (redrawWindow != 0) {
+ int mouseMask = GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_BUTTON_RELEASE_MASK |
+ GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK |
+ GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_POINTER_MOTION_HINT_MASK |
+ 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);
+ }
}
}
}
@@ -5585,7 +5683,11 @@ public void setVisible (boolean visible) {
if (isDisposed ()) return;
state &= ~HIDDEN;
if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) == 0) {
- if (enableWindow != 0) GDK.gdk_window_show_unraised (enableWindow);
+ if (GTK.GTK4) {
+ if (enableSurface != 0) GDK.gdk_surface_show_unraised (enableSurface);
+ } else {
+ if (enableWindow != 0) GDK.gdk_window_show_unraised (enableWindow);
+ }
GTK.gtk_widget_show (topHandle);
}
} else {
@@ -5613,7 +5715,11 @@ public void setVisible (boolean visible) {
}
GTK.gtk_widget_hide (topHandle);
if (isDisposed ()) return;
- if (enableWindow != 0) GDK.gdk_window_hide (enableWindow);
+ if (GTK.GTK4) {
+ if (enableSurface != 0) GDK.gdk_surface_hide (enableSurface);
+ } else {
+ if (enableWindow != 0) GDK.gdk_window_hide (enableWindow);
+ }
sendEvent (SWT.Hide);
}
}
@@ -5802,7 +5908,7 @@ void showWidget () {
state |= ZERO_WIDTH | ZERO_HEIGHT;
long /*int*/ topHandle = topHandle ();
long /*int*/ parentHandle = parent.parentingHandle ();
- parent.setParentGdkWindow (this);
+ parent.setParentGdkResource (this);
GTK.gtk_container_add (parentHandle, topHandle);
if (handle != 0 && handle != topHandle) GTK.gtk_widget_show (handle);
if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) == 0) {
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 1b29df490f..41ac77c3fa 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
@@ -1671,9 +1671,18 @@ public Control getCursorControl () {
int[] x = new int[1], y = new int[1];
long /*int*/ handle = 0;
long /*int*/ [] user_data = new long /*int*/ [1];
- long /*int*/ window = gdk_device_get_window_at_position (x,y);
- if (window != 0) {
- GDK.gdk_window_get_user_data (window, user_data);
+ long /*int*/ gdkResource;
+ if (GTK.GTK4) {
+ gdkResource = gdk_device_get_surface_at_position (x,y);
+ } else {
+ gdkResource = gdk_device_get_window_at_position (x,y);
+ }
+ if (gdkResource != 0) {
+ if (GTK.GTK4) {
+ GDK.gdk_surface_get_user_data (gdkResource, user_data);
+ } else {
+ GDK.gdk_window_get_user_data (gdkResource, user_data);
+ }
handle = user_data [0];
} else {
/*
@@ -1754,7 +1763,15 @@ public Point getCursorLocation () {
Point getCursorLocationInPixels () {
checkDevice ();
int [] x = new int [1], y = new int [1];
- gdk_window_get_device_position (0, x, y, null);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() with a 0
+ * for the GdkWindow uses gdk_get_default_root_window(),
+ * which doesn't exist on GTK4.
+ */
+ } else {
+ gdk_window_get_device_position (0, x, y, null);
+ }
/*
* Wayland feature: There is no global x/y coordinates in Wayland for security measures, so they
* all return relative coordinates dependant to the root window. If there is a popup window (type SWT.ON_TOP),
@@ -5917,12 +5934,27 @@ 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);
+}
+
long /*int*/ gdk_device_get_window_at_position (int[] win_x, int[] win_y) {
long /*int*/ display = GDK.gdk_display_get_default ();
long /*int*/ device = GDK.gdk_get_pointer(display);
return GDK.gdk_device_get_window_at_position (device, win_x, win_y);
}
+long /*int*/ gdk_device_get_surface_at_position (int[] win_x, int[] win_y) {
+ long /*int*/ display = GDK.gdk_display_get_default ();
+ long /*int*/ device = GDK.gdk_get_pointer(display);
+ return GDK.gdk_device_get_surface_at_position (device, win_x, win_y);
+}
+
/**
* @noreference This method is not intended to be referenced by clients.
* @nooverride This method is not intended to be re-implemented or extended by clients.
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 b36c2b1d24..78818cf2d7 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
@@ -456,7 +456,7 @@ long /*int*/ paintHandle() {
/* we draw all our children on the clientHandle*/
long /*int*/ paintHandle = clientHandle;
while (paintHandle != topHandle) {
- if (GTK.gtk_widget_get_has_window (paintHandle)) break;
+ if (gtk_widget_get_has_surface_or_window (paintHandle)) break;
paintHandle = GTK.gtk_widget_get_parent (paintHandle);
}
return paintHandle;
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 cf917d7797..b66eef34de 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
@@ -265,22 +265,32 @@ void _setVisible (boolean visible) {
// Create the rectangle relative to the parent (in this case, global) GdkWindow
GdkRectangle rect = new GdkRectangle();
if (OS.isX11()) {
- // Get and (add reference to) the global GdkWindow
+ // Get and (add reference to) the global GdkWindow/GdkSurface
event.window = GDK.gdk_display_get_default_group(GDK.gdk_display_get_default());
OS.g_object_ref(event.window);
OS.memmove (eventPtr, event, GdkEventButton.sizeof);
/*
- * Get the origin of the global GdkWindow to calculate the size of any offsets
+ * Get the origin of the global GdkWindow/GdkSurface to calculate the size of any offsets
* such as client side decorations, or the system tray.
*/
int [] globalWindowOriginY = new int [1];
int [] globalWindowOriginX = new int [1];
- GDK.gdk_window_get_origin (event.window, globalWindowOriginX, globalWindowOriginY);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_get_origin (event.window, globalWindowOriginX, globalWindowOriginY);
+ } else {
+ GDK.gdk_window_get_origin (event.window, globalWindowOriginX, globalWindowOriginY);
+ }
rect.x = this.x - globalWindowOriginX[0];
rect.y = this.y - globalWindowOriginY[0];
} else {
- // On Wayland, get the relative GdkWindow from the parent shell
- event.window = OS.g_object_ref(GTK.gtk_widget_get_window (getShell().topHandle()));
+ // On Wayland, get the relative GdkWindow from the parent shell.
+ long /*int*/ gdkResource;
+ if (GTK.GTK4) {
+ gdkResource = GTK.gtk_widget_get_surface (getShell().topHandle());
+ } else {
+ gdkResource = GTK.gtk_widget_get_window (getShell().topHandle());
+ }
+ event.window = OS.g_object_ref(gdkResource);
OS.memmove (eventPtr, event, GdkEventButton.sizeof);
// Bug in GTK?: testing with SWT_MENU_LOCATION_DEBUGGING=1 shows final_rect.x and
// final_rect.y popup menu position is off by 1 compared to this.x and this.y
@@ -1197,20 +1207,25 @@ void adjustParentWindowWayland (long /*int*/ eventPtr) {
if (!OS.isX11()) {
long /*int*/ display = GDK.gdk_display_get_default ();
long /*int*/ pointer = GDK.gdk_get_pointer(display);
- long /*int*/ deviceWindow = GDK.gdk_device_get_window_at_position(pointer, null, null);
- OS.g_object_ref(deviceWindow);
+ long /*int*/ deviceResource;
+ if (GTK.GTK4) {
+ deviceResource = GDK.gdk_device_get_surface_at_position(pointer, null, null);
+ } else {
+ deviceResource = GDK.gdk_device_get_window_at_position(pointer, null, null);
+ }
+ OS.g_object_ref(deviceResource);
int eventType = GDK.gdk_event_get_event_type(eventPtr);
switch (eventType) {
case GDK.GDK_BUTTON_PRESS:
GdkEventButton eventButton = new GdkEventButton();
OS.memmove (eventButton, eventPtr, GdkEventButton.sizeof);
- eventButton.window = deviceWindow;
+ eventButton.window = deviceResource;
OS.memmove(eventPtr, eventButton, GdkEventButton.sizeof);
break;
case GDK.GDK_KEY_PRESS:
GdkEventKey eventKey = new GdkEventKey();
OS.memmove (eventKey, eventPtr, GdkEventKey.sizeof);
- eventKey.window = deviceWindow;
+ eventKey.window = deviceResource;
OS.memmove(eventPtr, eventKey, GdkEventKey.sizeof);
break;
}
@@ -1252,9 +1267,16 @@ void verifyMenuPosition (int itemCount) {
GTK.gtk_widget_get_preferred_height(handle, null, naturalHeight);
if (naturalHeight[0] > 0) {
long /*int*/ topLevelWidget = GTK.gtk_widget_get_toplevel(handle);
- long /*int*/ topLevelWindow = GTK.gtk_widget_get_window(topLevelWidget);
- int width = GDK.gdk_window_get_width(topLevelWindow);
- GDK.gdk_window_resize(topLevelWindow, width, naturalHeight[0]);
+ int width;
+ if (GTK.GTK4) {
+ long /*int*/ topLevelSurface = GTK.gtk_widget_get_surface(topLevelWidget);
+ width = GDK.gdk_surface_get_width(topLevelSurface);
+ GDK.gdk_surface_resize(topLevelSurface, width, naturalHeight[0]);
+ } else {
+ long /*int*/ topLevelWindow = GTK.gtk_widget_get_window(topLevelWidget);
+ width = GDK.gdk_window_get_width(topLevelWindow);
+ GDK.gdk_window_resize(topLevelWindow, width, naturalHeight[0]);
+ }
}
}
}
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 a188de1811..d37b060359 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
@@ -302,10 +302,10 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
if (newX == lastX && newY == lastY) return result;
/* Ensure that the pointer image does not change */
- long /*int*/ window = gtk_widget_get_window (handle);
+ long /*int*/ gdkResource = GTK.GTK4? gtk_widget_get_surface (handle) : gtk_widget_get_window (handle);
int grabMask = GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_RELEASE_MASK;
long /*int*/ gdkCursor = cursor != null ? cursor.handle : defaultCursor;
- int ptrGrabResult = gdk_pointer_grab (window, GDK.GDK_OWNERSHIP_NONE, false, grabMask, window, gdkCursor, GDK.GDK_CURRENT_TIME);
+ int ptrGrabResult = gdk_pointer_grab (gdkResource, GDK.GDK_OWNERSHIP_NONE, false, grabMask, gdkResource, gdkCursor, GDK.GDK_CURRENT_TIME);
/* The event must be sent because its doit flag is used. */
Event event = new Event ();
@@ -314,7 +314,7 @@ long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
event.setBounds (DPIUtil.autoScaleDown (eventRect));
if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth () - width) - event.x;
sendSelectionEvent (SWT.Selection, event, true);
- if (ptrGrabResult == GDK.GDK_GRAB_SUCCESS) gdk_pointer_ungrab (window, GDK.GDK_CURRENT_TIME);
+ if (ptrGrabResult == GDK.GDK_GRAB_SUCCESS) gdk_pointer_ungrab (gdkResource, GDK.GDK_CURRENT_TIME);
if (isDisposed ()) break;
if (event.doit) {
@@ -350,7 +350,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ eventPtr
int eventX, eventY, eventState;
if (gdkEvent.is_hint != 0) {
int [] pointer_x = new int [1], pointer_y = new int [1], mask = new int [1];
- gdk_window_get_device_position (gdkEvent.window, pointer_x, pointer_y, mask);
+ display.gdk_window_get_device_position (gdkEvent.window, pointer_x, pointer_y, mask);
eventX = pointer_x [0];
eventY = pointer_y [0];
eventState = mask [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 52430a46d9..d4aa51e429 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
@@ -580,12 +580,17 @@ void bringToTop (boolean force) {
* window. The fix is to use XSetInputFocus() to force
* the focus, or gtk_grab_add() for GTK > 3.20.
*/
- long /*int*/ window = gtk_widget_get_window (shellHandle);
+ long /*int*/ gdkResource;
+ if (GTK.GTK4) {
+ gdkResource = gtk_widget_get_surface (shellHandle);
+ } else {
+ gdkResource = gtk_widget_get_window (shellHandle);
+ }
if ((xFocus || (style & SWT.ON_TOP) != 0)) {
if (OS.isX11()) {
- long /*int*/ gdkDisplay = GDK.gdk_window_get_display(window);
+ long /*int*/ gdkDisplay = GDK.gdk_window_get_display(gdkResource);
long /*int*/ xDisplay = GDK.gdk_x11_display_get_xdisplay(gdkDisplay);
- long /*int*/ xWindow = GDK.gdk_x11_window_get_xid (window);
+ long /*int*/ xWindow = GDK.gdk_x11_window_get_xid (gdkResource);
GDK.gdk_x11_display_error_trap_push(gdkDisplay);
/* Use CurrentTime instead of the last event time to ensure that the shell becomes active */
OS.XSetInputFocus (xDisplay, xWindow, OS.RevertToParent, OS.CurrentTime);
@@ -593,9 +598,19 @@ void bringToTop (boolean force) {
} else {
if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
GTK.gtk_grab_add(shellHandle);
- long /*int*/ seat = GDK.gdk_display_get_default_seat(GDK.gdk_window_get_display(window));
- GDK.gdk_window_show(window);
- GDK.gdk_seat_grab(seat, window, GDK.GDK_SEAT_CAPABILITY_ALL, true, 0, 0, 0, 0);
+ long /*int*/ gdkDisplay;
+ if (GTK.GTK4) {
+ gdkDisplay = GDK.gdk_surface_get_display(gdkResource);
+ } else {
+ gdkDisplay = GDK.gdk_window_get_display(gdkResource);
+ }
+ long /*int*/ seat = GDK.gdk_display_get_default_seat(gdkDisplay);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_show(gdkResource);
+ } else {
+ GDK.gdk_window_show(gdkResource);
+ }
+ GDK.gdk_seat_grab(seat, gdkResource, GDK.GDK_SEAT_CAPABILITY_ALL, true, 0, 0, 0, 0);
/*
* Bug 541185: Hover over to open Javadoc popup will make the popup
* close instead of gaining focus due to an extra focus out signal sent
@@ -607,7 +622,11 @@ void bringToTop (boolean force) {
}
}
} else {
- GDK.gdk_window_focus (window, GDK.GDK_CURRENT_TIME);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_focus (gdkResource, GDK.GDK_CURRENT_TIME);
+ } else {
+ GDK.gdk_window_focus (gdkResource, GDK.GDK_CURRENT_TIME);
+ }
}
display.activeShell = this;
display.activePending = true;
@@ -1686,19 +1705,27 @@ long /*int*/ gtk_realize (long /*int*/ widget) {
if ((style & SWT.RESIZE) != 0) decorations |= GDK.GDK_DECOR_BORDER;
if ((style & SWT.NO_MOVE) == 0) functions |= GDK.GDK_FUNC_MOVE;
}
- GDK.gdk_window_set_decorations (gdkResource, decorations);
-
- /*
- * For systems running Metacity, this call forces the style hints to
- * be displayed in a window's titlebar. Otherwise, the decorations
- * set by the function gdk_window_set_decorations (window,
- * decorations) are ignored by the window manager.
- */
- GDK.gdk_window_set_functions(gdkResource, functions);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_set_decorations (gdkResource, decorations);
+ GDK.gdk_surface_set_functions(gdkResource, functions);
+ } else {
+ GDK.gdk_window_set_decorations (gdkResource, decorations);
+ /*
+ * For systems running Metacity, this call forces the style hints to
+ * be displayed in a window's titlebar. Otherwise, the decorations
+ * set by the function gdk_window_set_decorations (window,
+ * decorations) are ignored by the window manager.
+ */
+ GDK.gdk_window_set_functions(gdkResource, functions);
+ }
} else if ((style & SWT.NO_MOVE) != 0) {
// if the GDK_FUNC_ALL bit is present, all the other style
// bits specified as a parameter will be removed from the window
- GDK.gdk_window_set_functions (gdkResource, GDK.GDK_FUNC_ALL | GDK.GDK_FUNC_MOVE);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_set_functions (gdkResource, GDK.GDK_FUNC_ALL | GDK.GDK_FUNC_MOVE);
+ } else {
+ GDK.gdk_window_set_functions (gdkResource, GDK.GDK_FUNC_ALL | GDK.GDK_FUNC_MOVE);
+ }
}
if ((style & SWT.ON_TOP) != 0) GTK.gtk_window_set_keep_above(shellHandle, true);
@@ -1940,14 +1967,23 @@ public void setAlpha (int alpha) {
}
void resizeBounds (int width, int height, boolean notify) {
- if (redrawWindow != 0) {
- GDK.gdk_window_resize (redrawWindow, width, height);
- }
- if (enableWindow != 0) {
- GDK.gdk_window_resize (enableWindow, width, height);
- }
int border = 0;
- if (!GTK.GTK4) border = GTK.gtk_container_get_border_width (shellHandle);
+ if (GTK.GTK4) {
+ if (redrawSurface != 0) {
+ GDK.gdk_surface_resize (redrawSurface, width, height);
+ }
+ if (redrawSurface != 0) {
+ GDK.gdk_surface_resize (redrawSurface, width, height);
+ }
+ } else {
+ if (redrawWindow != 0) {
+ GDK.gdk_window_resize (redrawWindow, width, height);
+ }
+ if (enableWindow != 0) {
+ GDK.gdk_window_resize (enableWindow, width, height);
+ }
+ border = GTK.gtk_container_get_border_width (shellHandle);
+ }
int boxWidth = width - 2*border;
int boxHeight = height - 2*border;
if ((style & SWT.RESIZE) == 0) {
@@ -2036,9 +2072,15 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
@Override
void setCursor (long /*int*/ cursor) {
- if (enableWindow != 0) {
- GDK.gdk_window_set_cursor (enableWindow, cursor);
- GDK.gdk_flush ();
+ if (GTK.GTK4) {
+ if (enableSurface != 0) {
+ GDK.gdk_surface_set_cursor (enableSurface, cursor);
+ }
+ } else {
+ if (enableWindow != 0) {
+ GDK.gdk_window_set_cursor (enableWindow, cursor);
+ GDK.gdk_flush ();
+ }
}
super.setCursor (cursor);
}
@@ -2530,7 +2572,11 @@ public void setVisible (boolean visible) {
* Feature in GTK: This handles grabbing the keyboard focus from a SWT.ON_TOP window
* if it has editable fields and is running Wayland. Refer to bug 515773.
*/
- if (enableWindow != 0) GDK.gdk_window_raise (enableWindow);
+ if (GTK.GTK4) {
+ if (enableSurface != 0) GDK.gdk_surface_raise (enableSurface);
+ } else {
+ if (enableWindow != 0) GDK.gdk_window_raise (enableWindow);
+ }
if (isDisposed ()) return;
if (!(OS.isX11() && GTK.GTK_IS_PLUG (shellHandle))) {
display.dispatchEvents = new int [] {
@@ -2649,7 +2695,15 @@ void showWidget () {
long /*int*/ sizeAllocateProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ user_data) {
int offset = 16;
int [] x = new int [1], y = new int [1];
- gdk_window_get_device_position (0, x, y, null);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() with a 0
+ * for the GdkWindow uses gdk_get_default_root_window(),
+ * which doesn't exist on GTK4.
+ */
+ } else {
+ display.gdk_window_get_device_position (0, x, y, null);
+ }
y [0] += offset;
GdkRectangle dest = new GdkRectangle ();
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
@@ -2924,7 +2978,11 @@ Rectangle getBoundsInPixels () {
if ((state & Widget.DISPOSE_SENT) == 0) {
GTK.gtk_window_get_position (shellHandle, x, y);
} else {
- GDK.gdk_window_get_root_origin(GTK.gtk_widget_get_window(shellHandle), x, y);
+ if (GTK.GTK4) {
+ GDK.gdk_surface_get_root_origin(GTK.gtk_widget_get_surface(shellHandle), x, y);
+ } else {
+ GDK.gdk_window_get_root_origin(GTK.gtk_widget_get_window(shellHandle), x, y);
+ }
}
GtkAllocation allocation = new GtkAllocation ();
GTK.gtk_widget_get_allocation (vboxHandle, allocation);
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 f6699f3322..2998b56a5f 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
@@ -1173,27 +1173,43 @@ void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, De
Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
- GTK.gtk_widget_realize (handle);
- long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
- long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
- int [] binX = new int [1], binY = new int [1];
- GDK.gdk_window_get_origin (binWindow, binX, binY);
- int [] fixedX = new int [1], fixedY = new int [1];
- GDK.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
long /*int*/ clientHandle = clientHandle ();
GtkAllocation allocation = new GtkAllocation ();
GTK.gtk_widget_get_allocation (clientHandle, allocation);
int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+ Rectangle rect;
+ if (GTK.GTK4) {
+ long /*int*/ fixedSurface = gtk_widget_get_surface (fixedHandle);
+ long /*int*/ surface = gtk_widget_get_surface (clientHandle);
+ int [] surfaceX = new int [1], surfaceY = new int [1];
+ GDK.gdk_surface_get_origin (surface, surfaceX, surfaceY);
+ int [] fixedX = new int [1], fixedY = new int [1];
+ GDK.gdk_surface_get_origin (fixedSurface, fixedX, fixedY);
+ rect = new Rectangle (fixedX [0] - surfaceX [0], fixedY [0] - surfaceY [0], width, height);
+ } else {
+ GTK.gtk_widget_realize (handle);
+ long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
+ long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
+ int [] binX = new int [1], binY = new int [1];
+ GDK.gdk_window_get_origin (binWindow, binX, binY);
+ int [] fixedX = new int [1], fixedY = new int [1];
+ GDK.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
+ rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+ }
return rect;
}
@Override
int getClientWidth () {
int [] w = new int [1], h = new int [1];
- GTK.gtk_widget_realize (handle);
- gdk_window_get_size(GTK.gtk_tree_view_get_bin_window(handle), w, h);
+ if (GTK.GTK4) {
+ long /*int*/ surface = gtk_widget_get_surface(handle);
+ gdk_surface_get_size(surface, w, h);
+ } else {
+ GTK.gtk_widget_realize (handle);
+ gdk_window_get_size(GTK.gtk_tree_view_get_bin_window(handle), w, h);
+ }
return w[0];
}
@@ -1483,14 +1499,24 @@ int getHeaderHeightInPixels () {
}
return height;
}
- GTK.gtk_widget_realize (handle);
- long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
- long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
- int [] binY = new int [1];
- GDK.gdk_window_get_origin (binWindow, null, binY);
- int [] fixedY = new int [1];
- GDK.gdk_window_get_origin (fixedWindow, null, fixedY);
- return binY [0] - fixedY [0];
+ if (GTK.GTK4) {
+ long /*int*/ fixedSurface = gtk_widget_get_surface (fixedHandle);
+ long /*int*/ surface = gtk_widget_get_surface (handle);
+ int [] surfaceY = new int [1];
+ GDK.gdk_surface_get_origin (surface, null, surfaceY);
+ int [] fixedY = new int [1];
+ GDK.gdk_surface_get_origin (fixedSurface, null, fixedY);
+ return surfaceY [0] - fixedY [0];
+ } else {
+ GTK.gtk_widget_realize (handle);
+ long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
+ long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
+ int [] binY = new int [1];
+ GDK.gdk_window_get_origin (binWindow, null, binY);
+ int [] fixedY = new int [1];
+ GDK.gdk_window_get_origin (fixedWindow, null, fixedY);
+ return binY [0] - fixedY [0];
+ }
}
/**
@@ -3587,9 +3613,7 @@ void setParentBackground () {
}
@Override
-void setParentGdkWindow (Control child) {
- long /*int*/ parentGdkWindow = eventWindow ();
- GTK.gtk_widget_set_parent_window (child.topHandle(), parentGdkWindow);
+void setParentGdkResource (Control child) {
/*
* Feature in GTK3: non-native GdkWindows are not drawn implicitly
* as of GTK3.10+. It is the client's responsibility to propagate draw
@@ -3600,8 +3624,18 @@ void setParentGdkWindow (Control child) {
* Table's fixedHandle to the draw signal, and propagate the draw
* signal using gtk_container_propagate_draw(). See bug 531928.
*/
- hasChildren = true;
- connectFixedHandleDraw();
+ if (GTK.GTK4) {
+ long /*int*/ parentGdkSurface = eventSurface ();
+ GTK.gtk_widget_set_parent_surface (child.topHandle(), parentGdkSurface);
+ // TODO: implement connectFixedHandleDraw with the "snapshot" signal
+ } else {
+ long /*int*/ parentGdkWindow = eventWindow ();
+ GTK.gtk_widget_set_parent_window (child.topHandle(), parentGdkWindow);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 10, 0)) {
+ hasChildren = true;
+ connectFixedHandleDraw();
+ }
+ }
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index af97760002..e05dd7d720 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -760,22 +760,43 @@ void setWidthInPixels (int width) {
*/
if (width != 0) {
if (buttonHandle != 0) {
- long /*int*/ window = GTK.gtk_widget_get_parent_window (buttonHandle);
- if (window != 0) {
- long /*int*/ windowList = GDK.gdk_window_get_children (window);
- if (windowList != 0) {
- long /*int*/ windows = windowList;
- long /*int*/ [] userData = new long /*int*/ [1];
- while (windows != 0) {
- long /*int*/ child = OS.g_list_data (windows);
- GDK.gdk_window_get_user_data (child, userData);
- if (userData[0] == buttonHandle) {
- GDK.gdk_window_lower (child);
- break;
+ if (GTK.GTK4) {
+ long /*int*/ surface = GTK.gtk_widget_get_parent_surface (buttonHandle);
+ if (surface != 0) {
+ long /*int*/ surfaceList = GDK.gdk_surface_get_children (surface);
+ if (surfaceList != 0) {
+ long /*int*/ surfaces = surfaceList;
+ long /*int*/ [] userData = new long /*int*/ [1];
+ while (surfaces != 0) {
+ long /*int*/ child = OS.g_list_data (surfaces);
+ GDK.gdk_surface_get_user_data (child, userData);
+ if (userData[0] == buttonHandle) {
+ GDK.gdk_surface_lower (child);
+ break;
+ }
+ surfaces = OS.g_list_next (surfaces);
}
- windows = OS.g_list_next (windows);
+ OS.g_list_free (surfaceList);
+ }
+ }
+ } else {
+ long /*int*/ window = GTK.gtk_widget_get_parent_window (buttonHandle);
+ if (window != 0) {
+ long /*int*/ windowList = GDK.gdk_window_get_children (window);
+ if (windowList != 0) {
+ long /*int*/ windows = windowList;
+ long /*int*/ [] userData = new long /*int*/ [1];
+ while (windows != 0) {
+ long /*int*/ child = OS.g_list_data (windows);
+ GDK.gdk_window_get_user_data (child, userData);
+ if (userData[0] == buttonHandle) {
+ GDK.gdk_window_lower (child);
+ break;
+ }
+ windows = OS.g_list_next (windows);
+ }
+ OS.g_list_free (windowList);
}
- OS.g_list_free (windowList);
}
}
}
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 5b325836fc..66dbc0f552 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
@@ -357,7 +357,15 @@ Point getLocation () {
}
if (x == -1 || y == -1) {
int [] px = new int [1], py = new int [1];
- gdk_window_get_device_position (0, px, py, null);
+ if (GTK.GTK4) {
+ /*
+ * TODO: calling gdk_window_get_device_position() with a 0
+ * for the GdkWindow uses gdk_get_default_root_window(),
+ * which doesn't exist on GTK4.
+ */
+ } else {
+ display.gdk_window_get_device_position (0, px, py, null);
+ }
x = px [0];
y = py [0];
}
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 768a1ed31f..b8ae6c7bac 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
@@ -48,6 +48,7 @@ public class Tracker extends Widget {
Composite parent;
Cursor cursor;
long /*int*/ lastCursor, window, overlay;
+ long /*int*/ surface;
boolean tracking, cancelled, grabbed, stippled;
Rectangle [] rectangles = new Rectangle [0], proportions = rectangles;
Rectangle bounds;
@@ -208,13 +209,12 @@ Point adjustMoveCursor () {
Point point = display.mapInPixels (parent, null, newX, newY);
display.setCursorLocation (point);
- /*
- * The call to XWarpPointer does not always place the pointer on the
- * exact location that is specified, so do a query (below) to get the
- * actual location of the pointer after it has been moved.
- */
int [] actualX = new int [1], actualY = new int [1], state = new int [1];
- gdk_window_get_device_position (window, actualX, actualY, state);
+ if (GTK.GTK4) {
+ display.gdk_surface_get_device_position (surface, actualX, actualY, state);
+ } else {
+ display.gdk_window_get_device_position (window, actualX, actualY, state);
+ }
return new Point (actualX [0], actualY [0]);
}
@@ -247,7 +247,11 @@ Point adjustResizeCursor () {
* actual location of the pointer after it has been moved.
*/
int [] actualX = new int [1], actualY = new int [1], state = new int [1];
- gdk_window_get_device_position (window, actualX, actualY, state);
+ if (GTK.GTK4) {
+ display.gdk_surface_get_device_position (surface, actualX, actualY, state);
+ } else {
+ display.gdk_window_get_device_position (window, actualX, actualY, state);
+ }
return new Point (actualX [0], actualY [0]);
}
@@ -401,9 +405,15 @@ void drawRectangles (Rectangle [] rects) {
GTK.gtk_widget_shape_combine_region (overlay, region);
Cairo.cairo_region_destroy (region);
- long /*int*/ overlayWindow = GTK.gtk_widget_get_window (overlay);
- GDK.gdk_window_hide (overlayWindow);
- GDK.gdk_window_show (overlayWindow);
+ if (GTK.GTK4) {
+ long /*int*/ overlaySurface = GTK.gtk_widget_get_surface (overlay);
+ GDK.gdk_surface_hide (overlaySurface);
+ GDK.gdk_surface_show (overlaySurface);
+ } else {
+ long /*int*/ overlayWindow = GTK.gtk_widget_get_window (overlay);
+ GDK.gdk_window_hide (overlayWindow);
+ GDK.gdk_window_show (overlayWindow);
+ }
}
/**
@@ -455,7 +465,8 @@ public boolean getStippled () {
boolean grab () {
long /*int*/ cursor = this.cursor != null ? this.cursor.handle : 0;
- int result = gdk_pointer_grab (window, GDK.GDK_OWNERSHIP_NONE, false, GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_RELEASE_MASK, 0, cursor, GDK.GDK_CURRENT_TIME);
+ int result = gdk_pointer_grab (GTK.GTK4 ? surface : window, GDK.GDK_OWNERSHIP_NONE, false,
+ GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_RELEASE_MASK, 0, cursor, GDK.GDK_CURRENT_TIME);
return result == GDK.GDK_GRAB_SUCCESS;
}
@@ -611,7 +622,11 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ eventPtr
long /*int*/ gtk_mouse (int eventType, long /*int*/ widget, long /*int*/ eventPtr) {
int [] newX = new int [1], newY = new int [1];
- gdk_window_get_device_position (window, newX, newY, null);
+ if (GTK.GTK4) {
+ display.gdk_surface_get_device_position (surface, newX, newY, null);
+ } else {
+ display.gdk_window_get_device_position (window, newX, newY, null);
+ }
if (oldX != newX [0] || oldY != newY [0]) {
Rectangle [] oldRectangles = rectangles;
Rectangle [] rectsToErase = new Rectangle [rectangles.length];
@@ -754,7 +769,11 @@ public boolean open () {
cancelled = false;
tracking = true;
int [] oldX = new int [1], oldY = new int [1], state = new int [1];
- gdk_window_get_device_position (window, oldX, oldY, state);
+ if (GTK.GTK4) {
+ display.gdk_surface_get_device_position (surface, oldX, oldY, state);
+ } else {
+ display.gdk_window_get_device_position (window, oldX, oldY, state);
+ }
/*
* if exactly one of UP/DOWN is specified as a style then set the cursor
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 e4693db1ea..c0d8fe0fe8 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
@@ -1203,27 +1203,43 @@ void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, De
Rectangle getClientAreaInPixels () {
checkWidget ();
forceResize ();
- GTK.gtk_widget_realize (handle);
- long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
- long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
- int [] binX = new int [1], binY = new int [1];
- GDK.gdk_window_get_origin (binWindow, binX, binY);
- int [] fixedX = new int [1], fixedY = new int [1];
- GDK.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
long /*int*/ clientHandle = clientHandle ();
GtkAllocation allocation = new GtkAllocation ();
GTK.gtk_widget_get_allocation (clientHandle, allocation);
int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
- Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+ Rectangle rect;
+ if (GTK.GTK4) {
+ long /*int*/ fixedSurface = gtk_widget_get_surface (fixedHandle);
+ long /*int*/ surface = gtk_widget_get_surface (clientHandle);
+ int [] surfaceX = new int [1], surfaceY = new int [1];
+ GDK.gdk_surface_get_origin (surface, surfaceX, surfaceY);
+ int [] fixedX = new int [1], fixedY = new int [1];
+ GDK.gdk_surface_get_origin (fixedSurface, fixedX, fixedY);
+ rect = new Rectangle (fixedX [0] - surfaceX [0], fixedY [0] - surfaceY [0], width, height);
+ } else {
+ GTK.gtk_widget_realize (handle);
+ long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
+ long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
+ int [] binX = new int [1], binY = new int [1];
+ GDK.gdk_window_get_origin (binWindow, binX, binY);
+ int [] fixedX = new int [1], fixedY = new int [1];
+ GDK.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
+ rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+ }
return rect;
}
@Override
int getClientWidth () {
int [] w = new int [1], h = new int [1];
- GTK.gtk_widget_realize (handle);
- gdk_window_get_size(GTK.gtk_tree_view_get_bin_window(handle), w, h);
+ if (GTK.GTK4) {
+ long /*int*/ surface = gtk_widget_get_surface(handle);
+ gdk_surface_get_size(surface, w, h);
+ } else {
+ GTK.gtk_widget_realize (handle);
+ gdk_window_get_size(GTK.gtk_tree_view_get_bin_window(handle), w, h);
+ }
return w[0];
}
@@ -1517,14 +1533,24 @@ int getHeaderHeightInPixels () {
}
return height;
}
- GTK.gtk_widget_realize (handle);
- long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
- long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
- int [] binY = new int [1];
- GDK.gdk_window_get_origin (binWindow, null, binY);
- int [] fixedY = new int [1];
- GDK.gdk_window_get_origin (fixedWindow, null, fixedY);
- return binY [0] - fixedY [0];
+ if (GTK.GTK4) {
+ long /*int*/ fixedSurface = gtk_widget_get_surface (fixedHandle);
+ long /*int*/ surface = gtk_widget_get_surface (handle);
+ int [] surfaceY = new int [1];
+ GDK.gdk_surface_get_origin (surface, null, surfaceY);
+ int [] fixedY = new int [1];
+ GDK.gdk_surface_get_origin (fixedSurface, null, fixedY);
+ return surfaceY [0] - fixedY [0];
+ } else {
+ GTK.gtk_widget_realize (handle);
+ long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
+ long /*int*/ binWindow = GTK.gtk_tree_view_get_bin_window (handle);
+ int [] binY = new int [1];
+ GDK.gdk_window_get_origin (binWindow, null, binY);
+ int [] fixedY = new int [1];
+ GDK.gdk_window_get_origin (fixedWindow, null, fixedY);
+ return binY [0] - fixedY [0];
+ }
}
/**
@@ -3611,21 +3637,29 @@ void setParentBackground () {
}
@Override
-void setParentGdkWindow (Control child) {
- long /*int*/ parentGdkWindow = eventWindow ();
- GTK.gtk_widget_set_parent_window (child.topHandle(), parentGdkWindow);
+void setParentGdkResource (Control child) {
/*
* Feature in GTK3: non-native GdkWindows are not drawn implicitly
* as of GTK3.10+. It is the client's responsibility to propagate draw
* events to these windows in the "draw" signal handler.
*
- * This change breaks tree editing on GTK3.10+, as the tree editor
+ * This change breaks table editing on GTK3.10+, as the table editor
* widgets no longer receive draw signals. The fix is to connect the
- * Tree's fixedHandle to the draw signal, and propagate the draw
+ * Table's fixedHandle to the draw signal, and propagate the draw
* signal using gtk_container_propagate_draw(). See bug 531928.
*/
- hasChildren = true;
- connectFixedHandleDraw();
+ if (GTK.GTK4) {
+ long /*int*/ parentGdkSurface = eventSurface ();
+ GTK.gtk_widget_set_parent_surface (child.topHandle(), parentGdkSurface);
+ // TODO: implement connectFixedHandleDraw with the "snapshot" signal
+ } else {
+ long /*int*/ parentGdkWindow = eventWindow ();
+ GTK.gtk_widget_set_parent_window (child.topHandle(), parentGdkWindow);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 10, 0)) {
+ hasChildren = true;
+ connectFixedHandleDraw();
+ }
+ }
}
void setScrollWidth (long /*int*/ column, TreeItem item) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 22d4c5a6b8..c1fb6879fa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -731,22 +731,43 @@ void setWidthInPixels (int width) {
*/
if (width != 0) {
if (buttonHandle != 0) {
- long /*int*/ window = GTK.gtk_widget_get_parent_window (buttonHandle);
- if (window != 0) {
- long /*int*/ windowList = GDK.gdk_window_get_children (window);
- if (windowList != 0) {
- long /*int*/ windows = windowList;
- long /*int*/ [] userData = new long /*int*/ [1];
- while (windows != 0) {
- long /*int*/ child = OS.g_list_data (windows);
- GDK.gdk_window_get_user_data (child, userData);
- if (userData[0] == buttonHandle) {
- GDK.gdk_window_lower (child);
- break;
+ if (GTK.GTK4) {
+ long /*int*/ surface = GTK.gtk_widget_get_parent_surface (buttonHandle);
+ if (surface != 0) {
+ long /*int*/ surfaceList = GDK.gdk_surface_get_children (surface);
+ if (surfaceList != 0) {
+ long /*int*/ surfaces = surfaceList;
+ long /*int*/ [] userData = new long /*int*/ [1];
+ while (surfaces != 0) {
+ long /*int*/ child = OS.g_list_data (surfaces);
+ GDK.gdk_surface_get_user_data (child, userData);
+ if (userData[0] == buttonHandle) {
+ GDK.gdk_surface_lower (child);
+ break;
+ }
+ surfaces = OS.g_list_next (surfaces);
}
- windows = OS.g_list_next (windows);
+ OS.g_list_free (surfaceList);
+ }
+ }
+ } else {
+ long /*int*/ window = GTK.gtk_widget_get_parent_window (buttonHandle);
+ if (window != 0) {
+ long /*int*/ windowList = GDK.gdk_window_get_children (window);
+ if (windowList != 0) {
+ long /*int*/ windows = windowList;
+ long /*int*/ [] userData = new long /*int*/ [1];
+ while (windows != 0) {
+ long /*int*/ child = OS.g_list_data (windows);
+ GDK.gdk_window_get_user_data (child, userData);
+ if (userData[0] == buttonHandle) {
+ GDK.gdk_window_lower (child);
+ break;
+ }
+ windows = OS.g_list_next (windows);
+ }
+ OS.g_list_free (windowList);
}
- OS.g_list_free (windowList);
}
}
}
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 f9d175f67a..5e0ed43028 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
@@ -1816,10 +1816,16 @@ void gtk_widget_set_visible (long /*int*/ widget, boolean visible) {
}
void gdk_window_get_size (long /*int*/ drawable, int[] width, int[] height) {
- width[0] = GDK.gdk_window_get_width (drawable);
- height[0] = GDK.gdk_window_get_height (drawable);
+ width[0] = GDK.gdk_window_get_width (drawable);
+ height[0] = GDK.gdk_window_get_height (drawable);
}
+void gdk_surface_get_size (long /*int*/ surface, int[] width, int[] height) {
+ width[0] = GDK.gdk_surface_get_width (surface);
+ height[0] = GDK.gdk_surface_get_height (surface);
+}
+
+
/**
* Wrapper function for gdk_event_get_state()
* @param event pointer to the GdkEvent.
@@ -1839,13 +1845,19 @@ long /*int*/ gtk_box_new (int orientation, boolean homogeneous, int spacing) {
return box;
}
-int gdk_pointer_grab (long /*int*/ window, int grab_ownership, boolean owner_events, int event_mask, long /*int*/ confine_to, long /*int*/ cursor, int time_) {
+int gdk_pointer_grab (long /*int*/ gdkResource, int grab_ownership, boolean owner_events, int event_mask, long /*int*/ confine_to, long /*int*/ cursor, int time_) {
long /*int*/ display = 0;
- if( window != 0) {
- display = GDK.gdk_window_get_display (window);
+ if (GTK.GTK4) {
+ if( gdkResource != 0) {
+ display = GDK.gdk_surface_get_display (gdkResource);
+ }
} else {
- window = GDK.gdk_get_default_root_window ();
- display = GDK.gdk_window_get_display (window);
+ if( gdkResource != 0) {
+ display = GDK.gdk_window_get_display (gdkResource);
+ } else {
+ gdkResource = GDK.gdk_get_default_root_window ();
+ display = GDK.gdk_window_get_display (gdkResource);
+ }
}
if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
long /*int*/ seat = GDK.gdk_display_get_default_seat(display);
@@ -1854,15 +1866,15 @@ int gdk_pointer_grab (long /*int*/ window, int grab_ownership, boolean owner_eve
}
long /*int*/ gdkSeatGrabPrepareFuncAddress = gdkSeatGrabPrepareFunc.getAddress();
if (gdkSeatGrabPrepareFuncAddress == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
- return GDK.gdk_seat_grab(seat, window, GDK.GDK_SEAT_CAPABILITY_ALL_POINTING, owner_events, cursor, 0, gdkSeatGrabPrepareFuncAddress, window);
+ return GDK.gdk_seat_grab(seat, gdkResource, GDK.GDK_SEAT_CAPABILITY_ALL_POINTING, owner_events, cursor, 0, gdkSeatGrabPrepareFuncAddress, gdkResource);
} else {
long /*int*/ pointer = GDK.gdk_get_pointer(display);
- return GDK.gdk_device_grab (pointer, window, grab_ownership, owner_events, event_mask, cursor, time_);
+ return GDK.gdk_device_grab (pointer, gdkResource, grab_ownership, owner_events, event_mask, cursor, time_);
}
}
-void gdk_pointer_ungrab (long /*int*/ window, int time_) {
- long /*int*/ display = GDK.gdk_window_get_display (window);
+void gdk_pointer_ungrab (long /*int*/ gdkResource, int time_) {
+ long /*int*/ display = GTK.GTK4? GDK.gdk_surface_get_display(gdkResource) : GDK.gdk_window_get_display (gdkResource);
if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
long /*int*/ seat = GDK.gdk_display_get_default_seat(display);
GDK.gdk_seat_ungrab(seat);
@@ -1872,9 +1884,13 @@ void gdk_pointer_ungrab (long /*int*/ window, int time_) {
}
}
-static long /*int*/ GdkSeatGrabPrepareFunc (long /*int*/ gdkSeat, long /*int*/ gdkWindow, long /*int*/ userData_gdkWindow) {
- if (userData_gdkWindow != 0) {
- GDK.gdk_window_show(userData_gdkWindow);
+static long /*int*/ GdkSeatGrabPrepareFunc (long /*int*/ gdkSeat, long /*int*/ gdkResource, long /*int*/ userData_gdkResource) {
+ if (userData_gdkResource != 0) {
+ if (GTK.GTK4) {
+ GDK.gdk_surface_show(userData_gdkResource);
+ } else {
+ GDK.gdk_window_show(userData_gdkResource);
+ }
}
return 0;
}
@@ -2020,27 +2036,6 @@ long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ ar
}
}
-long /*int*/ gdk_window_get_device_position (long /*int*/ window, int[] x, int[] y, int[] mask) {
- long /*int*/ display = 0;
- if( window != 0) {
- display = GDK.gdk_window_get_display (window);
- } else {
- window = GDK.gdk_get_default_root_window ();
- display = GDK.gdk_window_get_display (window);
- }
- long /*int*/ pointer = GDK.gdk_get_pointer(display);
- 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);

Back to the top