Skip to content

Commit 0bbc770

Browse files
committed
Changes to build SWT with GTK4 on Windows Successfully
1 parent 5c103aa commit 0bbc770

15 files changed

Lines changed: 186 additions & 128 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AccessibleObject {
5555
} else {
5656
// Lightweight widgets map to no "real" GTK widget, so we
5757
// just instantiate a new SwtFixedAccessible
58-
atkHandle = OS.g_object_new (OS.swt_fixed_accessible_get_type(), 0);
58+
atkHandle = OS.g_object_new (GTK3.swt_fixed_accessible_get_type(), 0);
5959
}
6060
OS.swt_fixed_accessible_register_accessible(atkHandle, false, widget);
6161
} else {
@@ -89,7 +89,7 @@ static int size(Collection<?> listeners) {
8989
* parent
9090
*/
9191
static AtkActionIface getParentActionIface (long atkObject) {
92-
long type = OS.swt_fixed_accessible_get_type();
92+
long type = GTK3.swt_fixed_accessible_get_type();
9393
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_ACTION())) {
9494
AtkActionIface iface = new AtkActionIface ();
9595
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_ACTION_GET_IFACE (atkObject)));
@@ -336,7 +336,7 @@ static long atkAction_get_name (long atkObject, long index) {
336336
* parent
337337
*/
338338
static AtkComponentIface getParentComponentIface (long atkObject) {
339-
long type = OS.swt_fixed_accessible_get_type();
339+
long type = GTK3.swt_fixed_accessible_get_type();
340340
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_COMPONENT())) {
341341
AtkComponentIface iface = new AtkComponentIface ();
342342
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_COMPONENT_GET_IFACE (atkObject)));
@@ -478,7 +478,7 @@ static long atkComponent_ref_accessible_at_point (long atkObject, long x,
478478
* parent
479479
*/
480480
static AtkEditableTextIface getParentEditableTextIface (long atkObject) {
481-
long type = OS.swt_fixed_accessible_get_type();
481+
long type = GTK3.swt_fixed_accessible_get_type();
482482
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_EDITABLE_TEXT())) {
483483
AtkEditableTextIface iface = new AtkEditableTextIface ();
484484
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_EDITABLE_TEXT_GET_IFACE (atkObject)));
@@ -912,7 +912,7 @@ static long atkEditableText_paste_text (long atkObject, long position) {
912912
* parent
913913
*/
914914
static AtkHypertextIface getParentHypertextIface (long atkObject) {
915-
long type = OS.swt_fixed_accessible_get_type();
915+
long type = GTK3.swt_fixed_accessible_get_type();
916916
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_HYPERTEXT())) {
917917
AtkHypertextIface iface = new AtkHypertextIface ();
918918
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_HYPERTEXT_GET_IFACE (atkObject)));
@@ -1047,7 +1047,7 @@ static long atkHypertext_get_link_index (long atkObject, long char_index) {
10471047
*/
10481048
static AtkObjectClass getParentAtkObjectClass () {
10491049
AtkObjectClass objectClass = new AtkObjectClass ();
1050-
long type = OS.swt_fixed_accessible_get_type();
1050+
long type = GTK3.swt_fixed_accessible_get_type();
10511051
if (type != 0) {
10521052
long parentType = OS.g_type_parent (type);
10531053
if (parentType != 0) ATK.memmove (objectClass, OS.g_type_class_peek (parentType));
@@ -1598,7 +1598,7 @@ static long atkObject_ref_state_set (long atkObject) {
15981598
* parent
15991599
*/
16001600
static AtkSelectionIface getParentSelectionIface (long atkObject) {
1601-
long type = OS.swt_fixed_accessible_get_type() ;
1601+
long type = GTK3.swt_fixed_accessible_get_type() ;
16021602
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_SELECTION())) {
16031603
AtkSelectionIface iface = new AtkSelectionIface ();
16041604
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_SELECTION_GET_IFACE (atkObject)));
@@ -1703,7 +1703,7 @@ static long atkSelection_ref_selection (long atkObject, long index) {
17031703
* parent
17041704
*/
17051705
static AtkTableIface getParentTableIface (long atkObject) {
1706-
long type = OS.swt_fixed_accessible_get_type();
1706+
long type = GTK3.swt_fixed_accessible_get_type();
17071707
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_TABLE())) {
17081708
AtkTableIface iface = new AtkTableIface ();
17091709
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_TABLE_GET_IFACE (atkObject)));
@@ -2674,7 +2674,7 @@ static long atkTable_remove_column_selection (long atkObject, long column) {
26742674
* parent
26752675
*/
26762676
static AtkTextIface getParentTextIface (long atkObject) {
2677-
long type = OS.swt_fixed_accessible_get_type();
2677+
long type = GTK3.swt_fixed_accessible_get_type();
26782678
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_TEXT())) {
26792679
AtkTextIface iface = new AtkTextIface ();
26802680
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_TEXT_GET_IFACE (atkObject)));
@@ -4261,7 +4261,7 @@ static Number getGValue (long value) {
42614261
* parent
42624262
*/
42634263
static AtkValueIface getParentValueIface (long atkObject) {
4264-
long type = OS.swt_fixed_accessible_get_type();
4264+
long type = GTK3.swt_fixed_accessible_get_type();
42654265
if (OS.g_type_is_a (OS.g_type_parent (type), ATK.ATK_TYPE_VALUE())) {
42664266
AtkValueIface iface = new AtkValueIface ();
42674267
ATK.memmove (iface, OS.g_type_interface_peek_parent (ATK.ATK_VALUE_GET_IFACE (atkObject)));

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/build.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ppc64le' -o ${MODEL} = 'aarch64' -o ${MO
165165
export SWT_PTR_CFLAGS
166166
fi
167167

168+
# Set PKG_CONFIG_PATH
169+
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
170+
168171
if [ x`pkg-config --exists cairo && echo YES` = "xYES" ]; then
169172
func_echo_plus "Cairo found, compiling SWT support for the cairo graphics library."
170173
MAKE_CAIRO=make_cairo
@@ -193,16 +196,16 @@ if [ -z "${AWT_LIB_PATH}" ]; then
193196
AWT_LIB_PATH=${SWT_JAVA_HOME}/lib
194197
export AWT_LIB_PATH
195198
else
196-
AWT_LIB_PATH=${SWT_JAVA_HOME}/jre/bin
199+
AWT_LIB_PATH=${SWT_JAVA_HOME}/bin
197200
export AWT_LIB_PATH
198201
fi
199202
fi
200203

201-
if [ -f ${AWT_LIB_PATH}/${AWT_LIB_EXPR} ]; then
202-
func_echo_plus "libjawt.so found, the SWT/AWT integration library will be compiled."
204+
if [ -f "${AWT_LIB_PATH}/${AWT_LIB_EXPR}" ]; then
205+
func_echo_plus "jawt.dll found, the SWT/AWT integration library will be compiled."
203206
MAKE_AWT=make_awt
204207
else
205-
func_echo_error "libjawt.so not found, the SWT/AWT integration library will not be compiled."
208+
func_echo_error "jawt.dll not found, the SWT/AWT integration library will not be compiled."
206209
fi
207210

208211
## Interaction(s) with makefile(s) below:

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2022 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -916,6 +916,42 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1frame_1set_1shadow_1type)
916916
}
917917
#endif
918918

919+
#ifndef NO_gtk_1gesture_1drag_1new
920+
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1gesture_1drag_1new)
921+
(JNIEnv *env, jclass that, jlong arg0)
922+
{
923+
jlong rc = 0;
924+
GTK3_NATIVE_ENTER(env, that, gtk_1gesture_1drag_1new_FUNC);
925+
rc = (jlong)gtk_gesture_drag_new((GtkWidget *)arg0);
926+
GTK3_NATIVE_EXIT(env, that, gtk_1gesture_1drag_1new_FUNC);
927+
return rc;
928+
}
929+
#endif
930+
931+
#ifndef NO_gtk_1gesture_1rotate_1new
932+
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1gesture_1rotate_1new)
933+
(JNIEnv *env, jclass that, jlong arg0)
934+
{
935+
jlong rc = 0;
936+
GTK3_NATIVE_ENTER(env, that, gtk_1gesture_1rotate_1new_FUNC);
937+
rc = (jlong)gtk_gesture_rotate_new((GtkWidget *)arg0);
938+
GTK3_NATIVE_EXIT(env, that, gtk_1gesture_1rotate_1new_FUNC);
939+
return rc;
940+
}
941+
#endif
942+
943+
#ifndef NO_gtk_1gesture_1zoom_1new
944+
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1gesture_1zoom_1new)
945+
(JNIEnv *env, jclass that, jlong arg0)
946+
{
947+
jlong rc = 0;
948+
GTK3_NATIVE_ENTER(env, that, gtk_1gesture_1zoom_1new_FUNC);
949+
rc = (jlong)gtk_gesture_zoom_new((GtkWidget *)arg0);
950+
GTK3_NATIVE_EXIT(env, that, gtk_1gesture_1zoom_1new_FUNC);
951+
return rc;
952+
}
953+
#endif
954+
919955
#ifndef NO_gtk_1get_1current_1event
920956
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1get_1current_1event)
921957
(JNIEnv *env, jclass that)
@@ -2776,3 +2812,35 @@ JNIEXPORT void JNICALL GTK3_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk3_GdkEv
27762812
}
27772813
#endif
27782814

2815+
#ifndef NO_swt_1debug_1on_1fatal_1warnings
2816+
JNIEXPORT void JNICALL GTK3_NATIVE(swt_1debug_1on_1fatal_1warnings)
2817+
(JNIEnv *env, jclass that)
2818+
{
2819+
GTK3_NATIVE_ENTER(env, that, swt_1debug_1on_1fatal_1warnings_FUNC);
2820+
swt_debug_on_fatal_warnings();
2821+
GTK3_NATIVE_EXIT(env, that, swt_1debug_1on_1fatal_1warnings_FUNC);
2822+
}
2823+
#endif
2824+
2825+
#ifndef NO_swt_1fixed_1accessible_1get_1type
2826+
JNIEXPORT jlong JNICALL GTK3_NATIVE(swt_1fixed_1accessible_1get_1type)
2827+
(JNIEnv *env, jclass that)
2828+
{
2829+
jlong rc = 0;
2830+
GTK3_NATIVE_ENTER(env, that, swt_1fixed_1accessible_1get_1type_FUNC);
2831+
rc = (jlong)swt_fixed_accessible_get_type();
2832+
GTK3_NATIVE_EXIT(env, that, swt_1fixed_1accessible_1get_1type_FUNC);
2833+
return rc;
2834+
}
2835+
#endif
2836+
2837+
#ifndef NO_swt_1set_1lock_1functions
2838+
JNIEXPORT void JNICALL GTK3_NATIVE(swt_1set_1lock_1functions)
2839+
(JNIEnv *env, jclass that)
2840+
{
2841+
GTK3_NATIVE_ENTER(env, that, swt_1set_1lock_1functions_FUNC);
2842+
swt_set_lock_functions();
2843+
GTK3_NATIVE_EXIT(env, that, swt_1set_1lock_1functions_FUNC);
2844+
}
2845+
#endif
2846+

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -100,6 +100,9 @@ typedef enum {
100100
gtk_1file_1chooser_1set_1local_1only_FUNC,
101101
gtk_1file_1chooser_1set_1uri_FUNC,
102102
gtk_1frame_1set_1shadow_1type_FUNC,
103+
gtk_1gesture_1drag_1new_FUNC,
104+
gtk_1gesture_1rotate_1new_FUNC,
105+
gtk_1gesture_1zoom_1new_FUNC,
103106
gtk_1get_1current_1event_FUNC,
104107
gtk_1get_1current_1event_1state_FUNC,
105108
gtk_1get_1event_1widget_FUNC,
@@ -250,4 +253,7 @@ typedef enum {
250253
memmove__Lorg_eclipse_swt_internal_gtk3_GdkEventKey_2JJ_FUNC,
251254
memmove__Lorg_eclipse_swt_internal_gtk3_GdkEventMotion_2JJ_FUNC,
252255
memmove__Lorg_eclipse_swt_internal_gtk3_GdkEventWindowState_2JJ_FUNC,
256+
swt_1debug_1on_1fatal_1warnings_FUNC,
257+
swt_1fixed_1accessible_1get_1type_FUNC,
258+
swt_1set_1lock_1functions_FUNC,
253259
} GTK3_FUNCS;

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -726,6 +726,42 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1gesture_1click_1new)
726726
}
727727
#endif
728728

729+
#ifndef NO_gtk_1gesture_1drag_1new
730+
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1gesture_1drag_1new)
731+
(JNIEnv *env, jclass that)
732+
{
733+
jlong rc = 0;
734+
GTK4_NATIVE_ENTER(env, that, gtk_1gesture_1drag_1new_FUNC);
735+
rc = (jlong)gtk_gesture_drag_new();
736+
GTK4_NATIVE_EXIT(env, that, gtk_1gesture_1drag_1new_FUNC);
737+
return rc;
738+
}
739+
#endif
740+
741+
#ifndef NO_gtk_1gesture_1rotate_1new
742+
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1gesture_1rotate_1new)
743+
(JNIEnv *env, jclass that)
744+
{
745+
jlong rc = 0;
746+
GTK4_NATIVE_ENTER(env, that, gtk_1gesture_1rotate_1new_FUNC);
747+
rc = (jlong)gtk_gesture_rotate_new();
748+
GTK4_NATIVE_EXIT(env, that, gtk_1gesture_1rotate_1new_FUNC);
749+
return rc;
750+
}
751+
#endif
752+
753+
#ifndef NO_gtk_1gesture_1zoom_1new
754+
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1gesture_1zoom_1new)
755+
(JNIEnv *env, jclass that)
756+
{
757+
jlong rc = 0;
758+
GTK4_NATIVE_ENTER(env, that, gtk_1gesture_1zoom_1new_FUNC);
759+
rc = (jlong)gtk_gesture_zoom_new();
760+
GTK4_NATIVE_EXIT(env, that, gtk_1gesture_1zoom_1new_FUNC);
761+
return rc;
762+
}
763+
#endif
764+
729765
#ifndef NO_gtk_1hsv_1to_1rgb
730766
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1hsv_1to_1rgb)
731767
(JNIEnv *env, jclass that, jfloat arg0, jfloat arg1, jfloat arg2, jfloatArray arg3, jfloatArray arg4, jfloatArray arg5)

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -83,6 +83,9 @@ typedef enum {
8383
gtk_1file_1chooser_1set_1file_FUNC,
8484
gtk_1frame_1set_1child_FUNC,
8585
gtk_1gesture_1click_1new_FUNC,
86+
gtk_1gesture_1drag_1new_FUNC,
87+
gtk_1gesture_1rotate_1new_FUNC,
88+
gtk_1gesture_1zoom_1new_FUNC,
8689
gtk_1hsv_1to_1rgb_FUNC,
8790
gtk_1icon_1paintable_1get_1file_FUNC,
8891
gtk_1icon_1theme_1get_1for_1display_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/make_win32.mak

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ endif
3636
include make_common.mak
3737

3838
SWT_VERSION=$(maj_ver)$(min_ver)r$(rev)
39-
GTK_VERSION?=3.0
39+
GTK_VERSION?=4.0
4040

4141
# Define the various shared libraries to be build.
4242
WS_PREFIX = gtk
@@ -108,8 +108,8 @@ CFLAGS := $(CFLAGS) \
108108
$(SWT_DEBUG) \
109109
$(SWT_WEBKIT_DEBUG) \
110110
-DWIN32 -DGTK \
111-
-I$(SWT_JAVA_HOME)/include \
112-
-I$(SWT_JAVA_HOME)/include/win32 \
111+
-I"$(SWT_JAVA_HOME)/include" \
112+
-I"$(SWT_JAVA_HOME)/include/win32" \
113113
-fPIC \
114114
${SWT_PTR_CFLAGS}
115115
LFLAGS = -shared -fPIC ${SWT_LFLAGS}

0 commit comments

Comments
 (0)