Skip to content

Commit 5461c2e

Browse files
committed
[GTK4] Fix Shell.bringToTop
As the shellHandle is always GtkWindow under Gtk 4.x, gtk_window_present can be called directly.
1 parent a6cdf00 commit 5461c2e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,16 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1window_1new)
27762776
}
27772777
#endif
27782778

2779+
#ifndef NO_gtk_1window_1present
2780+
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1window_1present)
2781+
(JNIEnv *env, jclass that, jlong arg0)
2782+
{
2783+
GTK4_NATIVE_ENTER(env, that, gtk_1window_1present_FUNC);
2784+
gtk_window_present((GtkWindow *)arg0);
2785+
GTK4_NATIVE_EXIT(env, that, gtk_1window_1present_FUNC);
2786+
}
2787+
#endif
2788+
27792789
#ifndef NO_gtk_1window_1set_1child
27802790
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1window_1set_1child)
27812791
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ typedef enum {
226226
gtk_1window_1maximize_FUNC,
227227
gtk_1window_1minimize_FUNC,
228228
gtk_1window_1new_FUNC,
229+
gtk_1window_1present_FUNC,
229230
gtk_1window_1set_1child_FUNC,
230231
gtk_1window_1set_1default_1widget_FUNC,
231232
gtk_1window_1set_1icon_1name_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ public class GTK4 {
453453
public static final native void gtk_window_set_child(long window, long child);
454454
/** @param window cast=(GtkWindow *) */
455455
public static final native void gtk_window_destroy(long window);
456+
456457
/** @param window cast=(GtkWindow *) */
457458
public static final native long gtk_window_get_icon_name(long window);
458459
/**
@@ -463,6 +464,9 @@ public class GTK4 {
463464
/** @param window cast=(GtkWindow *) */
464465
public static final native long gtk_window_get_titlebar(long window);
465466

467+
/** @param window cast=(GtkWindow *) */
468+
public static final native void gtk_window_present(long window) ;
469+
466470
/* GtkShortcutController */
467471
public static final native long gtk_shortcut_controller_new();
468472
/**

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ void bringToTop (boolean force) {
637637
}
638638
long seat = GDK.gdk_display_get_default_seat(gdkDisplay);
639639
if (GTK.GTK4) {
640-
/* TODO: GTK does not provide a gdk_surface_show, probably will require use of the present api */
640+
GTK4.gtk_window_present(shellHandle);
641641
} else {
642642
GDK.gdk_window_show(gdkResource);
643643
}

0 commit comments

Comments
 (0)