Skip to content

Commit 3177545

Browse files
ptzieglerakurtakov
authored andcommitted
[GTK4] Fix GtkWidget warning when updating shell bounds
This is a continuation of bd1cdd6 where a 'GTK_IS_WIDGET (widget)' warning is logged when measuring the height of a NULL titlebar. This issue appears when e.g. calling setBounds() on a Shell. To reproduce this warning, run e.g. Snippet16.
1 parent d7f6b38 commit 3177545

File tree

1 file changed

+8
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,9 +1856,11 @@ long gtk_size_allocate (long widget, long allocation) {
18561856
long display = GDK.gdk_display_get_default();
18571857
long monitor = GDK.gdk_display_get_monitor_at_surface(display, paintSurface());
18581858
GDK.gdk_monitor_get_geometry(monitor, monitorSize);
1859-
long header = GTK4.gtk_widget_get_next_sibling(GTK4.gtk_widget_get_first_child(shellHandle));
1859+
long header = GTK4.gtk_window_get_titlebar(shellHandle);
18601860
int[] headerNaturalHeight = new int[1];
1861-
GTK4.gtk_widget_measure(header, GTK.GTK_ORIENTATION_VERTICAL, -1, null, headerNaturalHeight, null, null);
1861+
if (header != 0) {
1862+
GTK4.gtk_widget_measure(header, GTK.GTK_ORIENTATION_VERTICAL, 0, null, headerNaturalHeight, null, null);
1863+
}
18621864
widthA[0] = monitorSize.width;
18631865
heightA[0] = monitorSize.height - headerNaturalHeight[0];
18641866
}
@@ -2371,9 +2373,11 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
23712373
* On GTK4, GtkWindow size includes the header bar. In order to keep window size allocation of the client area
23722374
* consistent with previous versions of SWT, we need to include the header bar height in addition to the given height value.
23732375
*/
2374-
long header = GTK4.gtk_widget_get_next_sibling(GTK4.gtk_widget_get_first_child(shellHandle));
2376+
long header = GTK4.gtk_window_get_titlebar(shellHandle);
23752377
int[] headerNaturalHeight = new int[1];
2376-
GTK4.gtk_widget_measure(header, GTK.GTK_ORIENTATION_VERTICAL, -1, null, headerNaturalHeight, null, null);
2378+
if (header != 0) {
2379+
GTK4.gtk_widget_measure(header, GTK.GTK_ORIENTATION_VERTICAL, 0, null, headerNaturalHeight, null, null);
2380+
}
23772381
GTK.gtk_window_set_default_size(shellHandle, width, height + headerNaturalHeight[0]);
23782382
} else {
23792383
GTK3.gtk_window_resize (shellHandle, width, height);

0 commit comments

Comments
 (0)