Skip to content

feat(framebuffer): Change orientation at runtime - #25059

Merged
MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/fb-runtime-orientation
Oct 7, 2026
Merged

MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/fb-runtime-orientation

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25058

PR Type:

✨ Feature

What changed? 🚀

Until now, the Linux framebuffer's display orientation was fixed at startup by FramebufferHostBuilder.Orientation(...). This PR adds an overload that also hands the app a setter, which can change the orientation while the app runs:

Action<DisplayOrientations>? setOrientation = null;

var host = UnoPlatformHostBuilder.Create()
    .App(() => new App())
    .UseLinuxFrameBuffer(fb => fb.Orientation(DisplayOrientations.Landscape, out setOrientation))
    .Build();

// later, from any thread; applied on the UI thread
setOrientation?.Invoke(DisplayOrientations.Portrait);

Behavior:

  • A change rotates rendering, remaps pointer and touch input, and updates the window bounds (raising SizeChanged when width and height swap). It also requests a redraw, because a 180° turn leaves the bounds unchanged.
  • The setter accepts only Landscape, Portrait, LandscapeFlipped and PortraitFlipped, and throws ArgumentOutOfRangeException for anything else.
  • Called before the host exists, it only changes the orientation the app starts in.
  • DisplayInformation.CurrentOrientation now reports the actual orientation. It previously always returned Landscape on the framebuffer. DisplayInformation.OrientationChanged is raised on each change, through a new internal NotifyOrientationChanged on Skia.

Implementation:

  • FrameBufferWindowWrapper keeps the orientation and the unrotated screen size together in one immutable snapshot, swapped atomically.
  • The renderer reads one snapshot per frame, and pointer and touch mapping read one per event. So neither can combine a new orientation with an old size while a change is in progress.
  • The input mapping now works from the unrotated size. It gives the same results as the previous per-orientation formulas.

Validation:

  • Runtime: a self-contained master SamplesApp in a QEMU VM on the framebuffer's software renderer, which is also what CI's framebuffer lane uses.
    • The new Given_DisplayInformation_FrameBufferOrientation passed 5 of 5: a quarter turn and a half turn on the running app, two rejected values, and a call before the host exists.
    • A temporary test, not committed, held each orientation while QEMU screendumps were taken. Markers placed at the logical top-left and bottom-right landed in the expected physical corners for all four orientations, with bounds of 1280×800 and 800×1280.
  • Compile: Uno.UI.Runtime.Linux.FrameBuffer and Uno.UI.RuntimeTests.Skia build with analyzers on.
  • Not covered at runtime:
    • Pointer and touch mapping: the VM has no absolute pointing device. The new mapping was checked by hand against the old per-orientation formulas.
    • The DRM renderer path: the rotation code is shared by both renderers.

PR Checklist ✅

🤖 Generated with Claude Code

Closes unoplatform#25058.

FramebufferHostBuilder.Orientation(orientation, out setOrientation)
hands the app a setter it can call at any time, from any thread. The
change is applied on the UI thread: rendering and input rotate, the
window bounds swap, and DisplayInformation reports the orientation and
raises OrientationChanged. CurrentOrientation previously always
reported Landscape on the framebuffer.

Orientation and the unrotated screen size are kept in one snapshot so
the render and input threads never pair a new orientation with a stale
size.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation labels Oct 6, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237766 found UI Test snapshots differences: skia-linux-screenshots: 130, skia-windows-screenshots: 216

Details
  • skia-linux-screenshots: 130 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ColorPickerSample.png-dark
    • ColorPickerSample.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • ClipboardTests.png-dark
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • CalendarView_Theming.png-dark
    • DisplayInformation.png-dark
    • DynamicFont.png-dark
    • DynamicFont.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ExpanderColorValidationPage.png-dark
  • skia-windows-screenshots: 216 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Grid_DynamicRowColumn.png-dark
    • Grid_DynamicRowColumn.png
    • Grid_with_Text_VerticalAlignment_With_Margin.png-dark
    • Grid_with_Text_VerticalAlignment_With_Margin.png
    • Grid_with_three_UserControl_With_5_Margin.png-dark
    • Grid_with_three_UserControl_With_5_Margin.png
    • Grid_with_UILabel_TextAlignmentVertical_Bottom.png-dark
    • Grid_with_UILabel_TextAlignmentVertical_Bottom.png
    • Grid_with_UserControlMargin.png-dark
    • Grid_with_UserControlMargin.png
    • Grid_left_column_Auto.png-dark
    • Grid_left_column_Auto.png
    • Grid_Margin_And_Padding.png-dark

@MartinZikmund
MartinZikmund merged commit 69c4dca into unoplatform:master Oct 7, 2026
53 checks passed
@ramezgerges
ramezgerges deleted the dev/rara/fb-runtime-orientation branch October 7, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux Framebuffer] Change the display orientation at runtime

4 participants