Skip to content

Gnome: pin code view scrollbars to LTR#135

Merged
JumpLink merged 3 commits into
mainfrom
fix/rtl-code-scrollbar-direction
Jun 12, 2026
Merged

Gnome: pin code view scrollbars to LTR#135
JumpLink merged 3 commits into
mainfrom
fix/rtl-code-scrollbar-direction

Conversation

@JumpLink

@JumpLink JumpLink commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Follow-up to #126, found while testing the RTL fixes under he_IL.UTF-8.

Problem

In RTL locales the horizontal scrollbar of code blocks mapped the scroll position mirrored: the thumb sat at the right end while the view showed the left edge of the LTR code, and dragging felt inverted.

Cause

gtk_widget_set_direction does not propagate to children — and each GtkScrollbar holds an internal GtkRange child (scrollbar > range > trough > slider) that does the actual value↔thumb mapping. Both the scrollbars and their internal ranges kept the global RTL default, so the range stayed flipped relative to the LTR-pinned code content. (A first attempt that pinned only the scrollbar widgets was ineffective for exactly this reason.)

Fix

Replace the individual direction pins in SourceView with one recursive pin over the whole widget subtree, reaching the internal ranges. This covers all code views (tutorial blocks, editor, debugger hexdump/disassembly/memory monitor) and removes the pin-one-widget-at-a-time whack-a-mole.

Verification

GJS micro-tests against the real internal scrollbar structure under global RTL with an LTR-pinned GtkTextView (the same structure as SourceView):

variant h-thumb at hadjustment value 0 v-thumb at vadjustment value 0
widget-level pins (first attempt) RIGHT (inverted) ❌ TOP ✓
recursive pin (this PR) LEFT (correct) ✓ TOP ✓

Vertical scrolling is direction-independent in GTK (should_invert() ignores text direction for vertical ranges, verified against gtk-4-18 gtkrange.c/gtkscrolledwindow.c) and stays unchanged.

The message console is unaffected on purpose: it is not direction-pinned, so its content and scrollbars are consistently RTL.

JumpLink added 3 commits June 11, 2026 19:58
The scrollbars are internal children of the scrolled window and
were created before the LTR pin from the RTL mirroring exemption,
so they kept the RTL default direction. An RTL scrollbar maps the
adjustment mirrored, while the pinned code content stays anchored
left: the thumb sat at the right while the view showed the left
edge, and dragging felt inverted.
Pinning the scrollbar widgets was not enough: each scrollbar holds
an internal GtkRange child that does the actual value-to-thumb
mapping, and gtk_widget_set_direction does not propagate to
children. The range kept the RTL default, so the horizontal thumb
still sat at the right end while the view showed the left edge.

Replace the individual pins with one recursive pin over the whole
SourceView subtree, verified against the internal scrollbar
structure (scrollbar > range > trough > slider). Vertical scroll
behavior is direction-independent in GTK and stays unchanged.
…r-direction

# Conflicts:
#	packages/app-gnome/src/widgets/source-view.ts
@JumpLink JumpLink merged commit cde75d2 into main Jun 12, 2026
3 checks passed
@JumpLink JumpLink deleted the fix/rtl-code-scrollbar-direction branch June 12, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant