Skip to content

Commit a973632

Browse files
vogellaclaude
authored andcommitted
[GTK3] Remove gtk_toolbar_set_show_arrow workaround
Remove all gtk_toolbar_set_show_arrow usage from ToolBar: both the toggle in computeSizeInPixels (added in 2012 for Bug 46025) and the toggle in setBounds. WRAP is not supported on GTK and the show_arrow flag was being misused to work around a GTK3 sizing bug from the GTK 3.4 era that no longer applies on modern GTK 3.24. The workaround in computeSizeInPixels caused two GTK state transitions per measurement, each triggering gtk_widget_queue_resize -> gtk_widget_queue_draw -> gdk_window_invalidate_region. When a SWT.WRAP ToolBar sits inside a frequently-measured parent (e.g. CTabFolder.setTopRight), this created a self-sustaining ~60 Hz repaint loop that burns 10-25% CPU while idle. With no remaining callers, the gtk_toolbar_set_show_arrow native binding is removed from GTK3.java as well. Fixes #3236 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dbac219 commit a973632

4 files changed

Lines changed: 2 additions & 44 deletions

File tree

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,16 +1987,6 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1toolbar_1set_1icon_1size)
19871987
}
19881988
#endif
19891989

1990-
#ifndef NO_gtk_1toolbar_1set_1show_1arrow
1991-
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1toolbar_1set_1show_1arrow)
1992-
(JNIEnv *env, jclass that, jlong arg0, jboolean arg1)
1993-
{
1994-
GTK3_NATIVE_ENTER(env, that, gtk_1toolbar_1set_1show_1arrow_FUNC);
1995-
gtk_toolbar_set_show_arrow((GtkToolbar *)arg0, (gboolean)arg1);
1996-
GTK3_NATIVE_EXIT(env, that, gtk_1toolbar_1set_1show_1arrow_FUNC);
1997-
}
1998-
#endif
1999-
20001990
#ifndef NO_gtk_1toolbar_1set_1style
20011991
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1toolbar_1set_1style)
20021992
(JNIEnv *env, jclass that, jlong arg0, jint arg1)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 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
@@ -184,7 +184,6 @@ typedef enum {
184184
gtk_1toolbar_1insert_FUNC,
185185
gtk_1toolbar_1new_FUNC,
186186
gtk_1toolbar_1set_1icon_1size_FUNC,
187-
gtk_1toolbar_1set_1show_1arrow_FUNC,
188187
gtk_1toolbar_1set_1style_FUNC,
189188
gtk_1tree_1view_1column_1cell_1get_1size_FUNC,
190189
gtk_1tree_1view_1get_1bin_1window_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,6 @@ public class GTK3 {
702702
* @param item cast=(GtkToolItem *)
703703
*/
704704
public static final native void gtk_toolbar_insert(long toolbar, long item, int pos);
705-
/**
706-
* @param toolbar cast=(GtkToolbar *)
707-
* @param show_arrow cast=(gboolean)
708-
*/
709-
public static final native void gtk_toolbar_set_show_arrow(long toolbar, boolean show_arrow);
710705
/**
711706
* @param toolbar cast=(GtkToolbar *)
712707
* @param style cast=(GtkToolbarStyle)

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
177177
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
178178
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
179179

180-
Point size = null;
181-
182-
if (GTK.GTK4) {
183-
size = computeNativeSize (handle, wHint, hHint, changed);
184-
} else {
185-
/*
186-
* Feature in GTK. Size of toolbar is calculated incorrectly
187-
* and appears as just the overflow arrow, if the arrow is enabled
188-
* to display. The fix is to disable it before the computation of
189-
* size and enable it if WRAP style is set.
190-
*/
191-
GTK3.gtk_toolbar_set_show_arrow (handle, false);
192-
size = computeNativeSize (handle, wHint, hHint, changed);
193-
if ((style & SWT.WRAP) != 0) GTK3.gtk_toolbar_set_show_arrow (handle, true);
194-
}
195-
196-
return size;
180+
return computeNativeSize (handle, wHint, hHint, changed);
197181
}
198182

199183
@Override
@@ -609,18 +593,8 @@ void reskinChildren (int flags) {
609593

610594
@Override
611595
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
612-
if (!GTK.GTK4) GTK3.gtk_toolbar_set_show_arrow (handle, false);
613596
int result = super.setBounds (x, y, width, height, move, resize);
614597
if ((result & RESIZED) != 0) relayout ();
615-
if ((style & SWT.WRAP) != 0) {
616-
if (GTK.GTK4) {
617-
/* TODO: GTK4 will require us to implement our own
618-
* overflow menu. May require the use of the "toolbar" style class
619-
* applied to the widget. */
620-
} else {
621-
GTK3.gtk_toolbar_set_show_arrow (handle, true);
622-
}
623-
}
624598

625599
return result;
626600
}

0 commit comments

Comments
 (0)