Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTK4] Implement correct moveAbove()/moveBelow() control behavior #1780

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,26 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1widget_1get_1root)
}
#endif

#ifndef NO_gtk_1widget_1insert_1after
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1widget_1insert_1after)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2)
{
GTK4_NATIVE_ENTER(env, that, gtk_1widget_1insert_1after_FUNC);
gtk_widget_insert_after((GtkWidget *)arg0, (GtkWidget *)arg1, (GtkWidget *)arg2);
GTK4_NATIVE_EXIT(env, that, gtk_1widget_1insert_1after_FUNC);
}
#endif

#ifndef NO_gtk_1widget_1insert_1before
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1widget_1insert_1before)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlong arg2)
{
GTK4_NATIVE_ENTER(env, that, gtk_1widget_1insert_1before_FUNC);
gtk_widget_insert_before((GtkWidget *)arg0, (GtkWidget *)arg1, (GtkWidget *)arg2);
GTK4_NATIVE_EXIT(env, that, gtk_1widget_1insert_1before_FUNC);
}
#endif

#ifndef NO_gtk_1widget_1measure
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1widget_1measure)
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ typedef enum {
gtk_1widget_1get_1prev_1sibling_FUNC,
gtk_1widget_1get_1receives_1default_FUNC,
gtk_1widget_1get_1root_FUNC,
gtk_1widget_1insert_1after_FUNC,
gtk_1widget_1insert_1before_FUNC,
gtk_1widget_1measure_FUNC,
gtk_1widget_1set_1cursor_FUNC,
gtk_1widget_1set_1focusable_FUNC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,18 @@ public class GTK4 {
* @param allocation cast=(GtkAllocation *),flags=no_out
*/
public static final native void gtk_widget_size_allocate(long widget, GtkAllocation allocation, int baseline);
/**
* @param widget cast=(GtkWidget *)
* @param parent cast=(GtkWidget *)
* @param previous_sibling cast=(GtkWidget *)
*/
public static final native void gtk_widget_insert_after(long widget, long parent, long previous_sibling);
/**
* @param widget cast=(GtkWidget *)
* @param parent cast=(GtkWidget *)
* @param next_sibling cast=(GtkWidget *)
*/
public static final native void gtk_widget_insert_before(long widget, long parent, long next_sibling);

/* GtkComboBox */
/** @param combo_box cast=(GtkComboBox *) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,15 @@ void markLayout (boolean changed, boolean all) {
void moveAbove (long child, long sibling) {
if (child == sibling) return;
long parentHandle = parentingHandle ();
OS.swt_fixed_restack (parentHandle, child, sibling, true);
if (GTK.GTK4) {
if (sibling == 0) {
GTK4.gtk_widget_insert_after(child, parentHandle, 0L);
} else {
GTK4.gtk_widget_insert_before(child, parentHandle, sibling);
}
} else {
OS.swt_fixed_restack (parentHandle, child, sibling, true);
}
return;
}

Expand All @@ -1364,7 +1372,15 @@ void moveBelow (long child, long sibling) {
moveAbove (child, scrolledHandle != 0 ? scrolledHandle : handle);
return;
}
OS.swt_fixed_restack (parentHandle, child, sibling, false);
if (GTK.GTK4) {
if (sibling == 0) {
GTK4.gtk_widget_insert_before(child, parentHandle, 0L);
} else {
GTK4.gtk_widget_insert_after(child, parentHandle, sibling);
}
} else {
OS.swt_fixed_restack (parentHandle, child, sibling, false);
}
return;
}

Expand Down
Loading