Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c47
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java67
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java12
11 files changed, 153 insertions, 66 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 399ce37b4a..03478612a9 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
@@ -12413,6 +12413,18 @@ JNIEXPORT jboolean JNICALL GTK_NATIVE(gtk_1widget_1get_1realized)
}
#endif
+#ifndef NO_gtk_1widget_1get_1root
+JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1widget_1get_1root)
+ (JNIEnv *env, jclass that, jlong arg0)
+{
+ jlong rc = 0;
+ GTK_NATIVE_ENTER(env, that, gtk_1widget_1get_1root_FUNC);
+ rc = (jlong)gtk_widget_get_root((GtkWidget *)arg0);
+ GTK_NATIVE_EXIT(env, that, gtk_1widget_1get_1root_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_gtk_1widget_1get_1scale_1factor
JNIEXPORT jint JNICALL GTK_NATIVE(gtk_1widget_1get_1scale_1factor)
(JNIEnv *env, jclass that, jlong arg0)
@@ -13206,21 +13218,48 @@ fail:
}
#endif
-#ifndef NO_gtk_1widget_1translate_1coordinates
-JNIEXPORT jboolean JNICALL GTK_NATIVE(gtk_1widget_1translate_1coordinates)
+#ifndef NO_gtk_1widget_1translate_1coordinates__JJDD_3D_3D
+JNIEXPORT jboolean JNICALL GTK_NATIVE(gtk_1widget_1translate_1coordinates__JJDD_3D_3D)
+ (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jdouble arg2, jdouble arg3, jdoubleArray arg4, jdoubleArray arg5)
+{
+ jdouble *lparg4=NULL;
+ jdouble *lparg5=NULL;
+ jboolean rc = 0;
+ GTK_NATIVE_ENTER(env, that, gtk_1widget_1translate_1coordinates__JJDD_3D_3D_FUNC);
+ if (arg4) if ((lparg4 = (*env)->GetDoubleArrayElements(env, arg4, NULL)) == NULL) goto fail;
+ if (arg5) if ((lparg5 = (*env)->GetDoubleArrayElements(env, arg5, NULL)) == NULL) goto fail;
+/*
+ rc = (jboolean)gtk_widget_translate_coordinates((GtkWidget *)arg0, (GtkWidget *)arg1, arg2, arg3, (double *)lparg4, (double *)lparg5);
+*/
+ {
+ GTK_LOAD_FUNCTION(fp, gtk_widget_translate_coordinates)
+ if (fp) {
+ rc = (jboolean)((jboolean (CALLING_CONVENTION*)(GtkWidget *, GtkWidget *, jdouble, jdouble, double *, double *))fp)((GtkWidget *)arg0, (GtkWidget *)arg1, arg2, arg3, (double *)lparg4, (double *)lparg5);
+ }
+ }
+fail:
+ if (arg5 && lparg5) (*env)->ReleaseDoubleArrayElements(env, arg5, lparg5, 0);
+ if (arg4 && lparg4) (*env)->ReleaseDoubleArrayElements(env, arg4, lparg4, 0);
+ GTK_NATIVE_EXIT(env, that, gtk_1widget_1translate_1coordinates__JJDD_3D_3D_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_gtk_1widget_1translate_1coordinates__JJII_3I_3I
+JNIEXPORT jboolean JNICALL GTK_NATIVE(gtk_1widget_1translate_1coordinates__JJII_3I_3I)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5)
{
jint *lparg4=NULL;
jint *lparg5=NULL;
jboolean rc = 0;
- GTK_NATIVE_ENTER(env, that, gtk_1widget_1translate_1coordinates_FUNC);
+ GTK_NATIVE_ENTER(env, that, gtk_1widget_1translate_1coordinates__JJII_3I_3I_FUNC);
if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
rc = (jboolean)gtk_widget_translate_coordinates((GtkWidget *)arg0, (GtkWidget *)arg1, arg2, arg3, (gint *)lparg4, (gint *)lparg5);
fail:
if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
- GTK_NATIVE_EXIT(env, that, gtk_1widget_1translate_1coordinates_FUNC);
+ GTK_NATIVE_EXIT(env, that, gtk_1widget_1translate_1coordinates__JJII_3I_3I_FUNC);
return rc;
}
#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index 4513ebf592..19779d5ee8 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
@@ -550,6 +550,7 @@
#define NO_gdk_1device_1warp__JII
#define NO_gtk_1widget_1measure
#define NO_gtk_1style_1context_1add_1provider_1for_1display
+#define NO_gtk_1widget_1get_1root
#define NO_gtk_1css_1provider_1load_1from_1data__I_3BI
#define NO_gtk_1css_1provider_1load_1from_1data__J_3BJ
#define NO_gdk_1display_1is_1composited
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
index 12ecf32d86..23b5bd59c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
@@ -885,30 +885,17 @@ static void swt_fixed_map (GtkWidget *widget) {
return GTK_WIDGET_CLASS (swt_fixed_parent_class)->map (widget);
}
-static void swt_fixed_measure (GtkWidget *widget, GtkOrientation orientation, int for_size, int *minimum,
- int *natural, int *minimum_baseline, int *natural_baseline) {
- SwtFixed *fixed = SWT_FIXED (widget);
- SwtFixedPrivate *priv = fixed->priv;
- GList *list;
- int natural_size, child_nat;
-
- list = priv->children;
- natural_size = 0;
-
- while (list) {
- SwtFixedChild *child_data = list->data;
- GtkWidget *child = child_data->widget;
+static void swt_fixed_measure (GtkWidget *widget, GtkOrientation orientation, int for_size, int *minimum, int *natural, int *minimum_baseline, int *natural_baseline) {
+ for (GtkWidget* child = gtk_widget_get_first_child(widget); child != NULL; child = gtk_widget_get_next_sibling(child)) {
+ int child_nat = 0;
gtk_widget_measure(child, orientation, -1, NULL, &child_nat, NULL, NULL);
- if (child_nat > natural_size) natural_size = child_nat;
-
- list = list->next;
+ *natural = MAX(*natural, child_nat);
}
- if (natural) *natural = natural_size;
+
if (minimum) *minimum = 0;
if (minimum_baseline) *minimum_baseline = -1;
if (natural_baseline) *natural_baseline = -1;
- return;
}
static void swt_fixed_size_allocate (GtkWidget *widget, int width, int height, int baseline) {
@@ -999,17 +986,17 @@ void swt_fixed_resize (SwtFixed *fixed, GtkWidget *widget, gint width, gint heig
}
void swt_fixed_add (GtkWidget *container, GtkWidget *child) {
- SwtFixed *fixed = SWT_FIXED (container);
+ SwtFixed *fixed = SWT_FIXED(container);
SwtFixedPrivate *priv = fixed->priv;
- SwtFixedChild *child_data;
- child_data = g_new (SwtFixedChild, 1);
+ SwtFixedChild *child_data = g_new(SwtFixedChild, 1);
child_data->widget = child;
child_data->x = child_data->y = 0;
child_data->width = child_data->height = -1;
- priv->children = g_list_append (priv->children, child_data);
- gtk_widget_set_parent (child, container);
+ priv->children = g_list_append(priv->children, child_data);
+
+ gtk_widget_set_parent(child, container);
}
void swt_fixed_remove (GtkWidget *container, GtkWidget *widget) {
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 68b71bf2c9..706b1fccc0 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
@@ -971,6 +971,7 @@ char * GTK_nativeFunctionNames[] = {
"gtk_1widget_1get_1preferred_1width_1for_1height",
"gtk_1widget_1get_1prev_1sibling",
"gtk_1widget_1get_1realized",
+ "gtk_1widget_1get_1root",
"gtk_1widget_1get_1scale_1factor",
"gtk_1widget_1get_1screen",
"gtk_1widget_1get_1sensitive",
@@ -1029,7 +1030,8 @@ char * GTK_nativeFunctionNames[] = {
"gtk_1widget_1snapshot_1child",
"gtk_1widget_1style_1get__J_3B_3IJ",
"gtk_1widget_1style_1get__J_3B_3JJ",
- "gtk_1widget_1translate_1coordinates",
+ "gtk_1widget_1translate_1coordinates__JJDD_3D_3D",
+ "gtk_1widget_1translate_1coordinates__JJII_3I_3I",
"gtk_1widget_1unparent",
"gtk_1window_1activate_1default",
"gtk_1window_1add_1accel_1group",
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 e5a4136060..cb251c0096 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
@@ -969,6 +969,7 @@ typedef enum {
gtk_1widget_1get_1preferred_1width_1for_1height_FUNC,
gtk_1widget_1get_1prev_1sibling_FUNC,
gtk_1widget_1get_1realized_FUNC,
+ gtk_1widget_1get_1root_FUNC,
gtk_1widget_1get_1scale_1factor_FUNC,
gtk_1widget_1get_1screen_FUNC,
gtk_1widget_1get_1sensitive_FUNC,
@@ -1027,7 +1028,8 @@ typedef enum {
gtk_1widget_1snapshot_1child_FUNC,
gtk_1widget_1style_1get__J_3B_3IJ_FUNC,
gtk_1widget_1style_1get__J_3B_3JJ_FUNC,
- gtk_1widget_1translate_1coordinates_FUNC,
+ gtk_1widget_1translate_1coordinates__JJDD_3D_3D_FUNC,
+ gtk_1widget_1translate_1coordinates__JJII_3I_3I_FUNC,
gtk_1widget_1unparent_FUNC,
gtk_1window_1activate_1default_FUNC,
gtk_1window_1add_1accel_1group_FUNC,
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 3d05358992..e05a72a00b 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
@@ -305,6 +305,9 @@ public class GTK extends OS {
*/
public static final native long gtk_widget_class_get_css_name(long widget_class);
+ /** @param widget cast=(GtkWidget *) */
+ public static final native long gtk_widget_get_root(long widget);
+
public static final native long gtk_button_new();
/** @method flags=dynamic
@@ -3573,6 +3576,14 @@ public class GTK extends OS {
* @param dest_y cast=(gint *)
*/
public static final native boolean gtk_widget_translate_coordinates(long src_widget, long dest_widget, int src_x, int src_y, int[] dest_x, int[] dest_y);
+ /**
+ * @method flags=dynamic
+ * @param src_widget cast=(GtkWidget *)
+ * @param dest_widget cast=(GtkWidget *)
+ * @param dest_x cast=(double *)
+ * @param dest_y cast=(double *)
+ */
+ public static final native boolean gtk_widget_translate_coordinates(long src_widget, long dest_widget, double src_x, double src_y, double[] dest_x, double[] dest_y);
/** @param widget cast=(GtkWidget *) */
public static final native boolean gtk_widget_activate(long widget);
/**
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 e012e61938..fea3cbe312 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
@@ -3564,7 +3564,12 @@ long gtk_button_press_event (long widget, long event, boolean sendMouseDown) {
double [] eventRX = new double [1];
double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(event, eventRX, eventRY);
+ if (GTK.GTK4) {
+ long root = GTK.gtk_widget_get_root(widget);
+ GTK.gtk_widget_translate_coordinates(widget, root, eventX[0], eventY[0], eventRX, eventRY);
+ } else {
+ GDK.gdk_event_get_root_coords(event, eventRX, eventRY);
+ }
lastInput.x = (int) eventX[0];
lastInput.y = (int) eventY[0];
@@ -4279,7 +4284,7 @@ long gtk_scroll_event (long widget, long eventPtr) {
double [] eventY = new double [1];
int [] state = new int [1];
if (GTK.GTK4) {
- GDK.gdk_event_get_position(eventPtr, eventX, eventY);
+ // GTK4 Position returns NaN
state[0] = GDK.gdk_event_get_modifier_state(eventPtr);
} else {
GDK.gdk_event_get_coords(eventPtr, eventX, eventY);
@@ -4288,7 +4293,12 @@ long gtk_scroll_event (long widget, long eventPtr) {
double [] eventRX = new double[1];
double [] eventRY = new double[1];
- GDK.gdk_event_get_root_coords(eventPtr, eventRX, eventRY);
+ if (GTK.GTK4) {
+ long root = GTK.gtk_widget_get_root(widget);
+ GTK.gtk_widget_translate_coordinates(widget, root, eventX[0], eventY[0], eventRX, eventRY);
+ } else {
+ GDK.gdk_event_get_root_coords(eventPtr, eventRX, eventRY);
+ }
int time = GDK.gdk_event_get_time(eventPtr);
@@ -6327,7 +6337,11 @@ void showWidget () {
long topHandle = topHandle ();
long parentHandle = parent.parentingHandle ();
parent.setParentGdkResource (this);
- GTK.gtk_container_add (parentHandle, topHandle);
+ if (GTK.GTK4) {
+ OS.swt_fixed_add(parentHandle, topHandle);
+ } else {
+ GTK.gtk_container_add(parentHandle, topHandle);
+ }
if (handle != 0 && handle != topHandle) GTK.gtk_widget_show (handle);
if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) == 0) {
if (fixedHandle != 0) GTK.gtk_widget_show (fixedHandle);
@@ -6572,7 +6586,11 @@ boolean translateMnemonic (int keyval, long event) {
} else {
Shell shell = _getShell ();
int mask = GDK.GDK_CONTROL_MASK | GDK.GDK_SHIFT_MASK | GDK.GDK_MOD1_MASK;
- if ((state[0] & mask) != GTK.gtk_window_get_mnemonic_modifier (shell.shellHandle)) return false;
+ if (GTK.GTK4) {
+ if (state[0] != GDK.GDK_MOD1_MASK) return false;
+ } else {
+ if ((state[0] & mask) != GTK.gtk_window_get_mnemonic_modifier (shell.shellHandle)) return false;
+ }
}
Decorations shell = menuShell ();
if (shell.isVisible () && shell.isEnabled ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index b5620abc1e..c6ce5454ad 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -606,8 +606,7 @@ void hookEvents () {
super.hookEvents ();
OS.g_signal_connect_closure (adjustmentHandle, OS.value_changed, display.getClosure (VALUE_CHANGED), false);
if (GTK.GTK4) {
- // GTK4: event-after replaced with generic event
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ // GTK4: no event-after
// GTK4: change-value moved to gtk_scroll_child in Composite
} else {
OS.g_signal_connect_closure (handle, OS.change_value, display.getClosure (CHANGE_VALUE), false);
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 bb61b30a0f..7d0d68748a 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
@@ -658,8 +658,13 @@ void createHandle (int index) {
OS.g_object_ref (checkRenderer);
}
createColumn (null, 0);
- GTK.gtk_container_add (fixedHandle, scrolledHandle);
- GTK.gtk_container_add (scrolledHandle, handle);
+ if (GTK.GTK4) {
+ OS.swt_fixed_add(fixedHandle, scrolledHandle);
+ GTK.gtk_scrolled_window_set_child(scrolledHandle, handle);
+ } else {
+ GTK.gtk_container_add(fixedHandle, scrolledHandle);
+ GTK.gtk_container_add(scrolledHandle, handle);
+ }
int mode = (style & SWT.MULTI) != 0 ? GTK.GTK_SELECTION_MULTIPLE : GTK.GTK_SELECTION_BROWSE;
long selectionHandle = GTK.gtk_tree_view_get_selection (handle);
@@ -699,21 +704,34 @@ void createItem (TableColumn column, int index) {
} else {
createColumn (column, index);
}
- long boxHandle = gtk_box_new (GTK.GTK_ORIENTATION_HORIZONTAL, false, 3);
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
- long labelHandle = GTK.gtk_label_new_with_mnemonic (null);
- if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
- long imageHandle = GTK.gtk_image_new ();
- if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
- GTK.gtk_container_add (boxHandle, imageHandle);
- GTK.gtk_container_add (boxHandle, labelHandle);
- GTK.gtk_widget_show (boxHandle);
- GTK.gtk_widget_show (labelHandle);
+
+ long boxHandle = gtk_box_new(GTK.GTK_ORIENTATION_HORIZONTAL, false, 3);
+ if (boxHandle == 0) error(SWT.ERROR_NO_HANDLES);
+ GTK.gtk_tree_view_column_set_widget (column.handle, boxHandle);
+
+ long labelHandle = GTK.gtk_label_new_with_mnemonic(null);
+ if (labelHandle == 0) error(SWT.ERROR_NO_HANDLES);
+ long imageHandle = GTK.gtk_image_new();
+ if (imageHandle == 0) error(SWT.ERROR_NO_HANDLES);
+
+ if (GTK.GTK4) {
+ GTK.gtk_box_append(boxHandle, imageHandle);
+ GTK.gtk_box_append(boxHandle, labelHandle);
+
+ GTK.gtk_widget_hide(imageHandle);
+ } else {
+ GTK.gtk_container_add (boxHandle, imageHandle);
+ GTK.gtk_container_add (boxHandle, labelHandle);
+
+ GTK.gtk_widget_show (boxHandle);
+ GTK.gtk_widget_show (labelHandle);
+ }
+
column.labelHandle = labelHandle;
column.imageHandle = imageHandle;
- GTK.gtk_tree_view_column_set_widget (column.handle, boxHandle);
column.buttonHandle = GTK.gtk_tree_view_column_get_button(column.handle);
GTK.gtk_widget_set_focus_on_click(column.buttonHandle, false);
+
if (columnCount == columns.length) {
TableColumn [] newColumns = new TableColumn [columns.length + 4];
System.arraycopy (columns, 0, newColumns, 0, columns.length);
@@ -1539,13 +1557,9 @@ int getHeaderHeightInPixels () {
return height;
}
if (GTK.GTK4) {
- long fixedSurface = gtk_widget_get_surface (fixedHandle);
- long 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];
+ // TODO: GTK4 get header height before adding any columns
+
+ return 0;
} else {
GTK.gtk_widget_realize (handle);
long fixedWindow = gtk_widget_get_window (fixedHandle);
@@ -1713,7 +1727,11 @@ int getItemHeightInPixels () {
long column = GTK.gtk_tree_view_get_column (handle, i);
GTK.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
int [] w = new int [1], h = new int [1];
- GTK.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+ if (GTK.GTK4) {
+ GTK.gtk_tree_view_column_cell_get_size(column, null, null, w, h);
+ } else {
+ GTK.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+ }
long textRenderer = getTextRenderer (column);
int [] ypad = new int[1];
if (textRenderer != 0) GTK.gtk_cell_renderer_get_padding(textRenderer, null, ypad);
@@ -2057,7 +2075,12 @@ long gtk_button_press_event (long widget, long event) {
double [] eventRX = new double [1];
double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(event, eventRX, eventRY);
+ if (GTK.GTK4) {
+ long root = GTK.gtk_widget_get_root(widget);
+ GTK.gtk_widget_translate_coordinates(widget, root, eventX[0], eventY[0], eventRX, eventRY);
+ } else {
+ GDK.gdk_event_get_root_coords(event, eventRX, eventRY);
+ }
long eventGdkResource = gdk_event_get_surface_or_window(event);
if (GTK.GTK4) {
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 bbbf66b168..6ec17dc097 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
@@ -338,6 +338,11 @@ int getWidthInPixels () {
@Override
long gtk_clicked (long widget) {
+ if (GTK.GTK4) {
+ sendSelectionEvent(SWT.Selection);
+ return 0;
+ }
+
/*
* There is no API to get a double click on a table column. Normally, when
* the mouse is double clicked, this is indicated by GDK_2BUTTON_PRESS
@@ -442,10 +447,10 @@ void hookEvents () {
super.hookEvents ();
OS.g_signal_connect_closure (handle, OS.clicked, display.getClosure (CLICKED), false);
if (buttonHandle != 0) {
- OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.getClosure (SIZE_ALLOCATE), false);
if (GTK.GTK4) {
- OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ // TODO: GTK4 no EVENT_AFTER signal
} else {
+ OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.getClosure (SIZE_ALLOCATE), false);
OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
}
}
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 fb6a49c8f3..95e2af154e 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
@@ -1567,7 +1567,7 @@ void sendSelectionEvent (int eventType, Event event, boolean send) {
return;
}
if (event == null) event = new Event ();
- long ptr = GTK.gtk_get_current_event ();
+ long ptr = GTK.GTK4 ? 0 : GTK.gtk_get_current_event ();
if (ptr != 0) {
int currentEventType = GDK.gdk_event_get_event_type(ptr);
currentEventType = Control.fixGdkEventTypeValues(currentEventType);
@@ -1814,13 +1814,13 @@ boolean setKeyState (Event javaEvent, long event) {
short [] keyCode = new short [1];
if (GTK.GTK4) {
keyCode[0] = (short) GDK.gdk_key_event_get_keycode(event);
+ javaEvent.keyCode = keyCode[0];
} else {
GDK.gdk_event_get_keycode(event, keyCode);
- }
-
- if (GDK.gdk_keymap_translate_keyboard_state (keymap, keyCode[0],
- 0, group, keyval, effective_group, level, consumed_modifiers)) {
- javaEvent.keyCode = (int) GDK.gdk_keyval_to_unicode (keyval [0]);
+ if (GDK.gdk_keymap_translate_keyboard_state (keymap, keyCode[0],
+ 0, group, keyval, effective_group, level, consumed_modifiers)) {
+ javaEvent.keyCode = (int) GDK.gdk_keyval_to_unicode (keyval [0]);
+ }
}
}
int key = eventKeyval[0];

Back to the top