The on-screen keyboard is capped at 40 % of the screen height, and the runtime publishes the logical size of the output the main surface is on
CI / build + test (push) Canceled after 0s
CI / cargo audit (push) Canceled after 0s

The keyboard. The keys of the on-screen panel are as tall as one unit of the widest row is wide, so the panel's height follows its width. On a portrait phone that is about a quarter of the screen; turned to landscape the width becomes the long side, the keys grow with it and the six rows of a terminal keyboard take more than the screen. `Panel::height_within( width, scale, screen_height )` keeps `height` within 40 % of the screen height, the new `MAX_HEIGHT_FRACTION`, and `place_osk` uses it for the keyboard of a surface of ltk's own. `set_rect` no longer assumes it was given the natural height: the key height is the smaller of the unit and what the rectangle left after the padding and the gaps shares among the rows, so a capped panel gets wide and low keys, as the keyboards of other platforms have in landscape, while the key widths and the centring of the narrower rows are as before. A portrait screen is not affected, the natural height being below the cap there. A host that lays the panel out itself, as a compositor does, calls `height_within` for the height it reserves and `set_rect` with the rectangle it gets, so both agree.
The output's size. `ltk::output_logical_size()` returns the logical size of the screen the main surface is on, or `None` before the compositor has described one, and `set_output_logical_size` records it. `viewport_size` follows the window, which is the wrong reference for a thing that has to be sized relative to the display, such as a window that must not be wider than the screen. The runtime now publishes the size when an output appears, changes or goes away, and when the main surface enters one, preferring the output of the main surface to the first one listed, and taking the current mode over the scale when the compositor sent no logical size. `window_fit` shares that lookup, `output_logical_size`, with what it did before, so the bounds it keeps a window size hint inside are unchanged.
Not done. The 40 % is a constant and not a setting, the key labels are not scaled to the lower keys, and nothing offers the keyboard at the side of the screen in landscape, which would give the application more room on a wide display.
This commit is contained in:
2026-10-06 23:09:43 +02:00
parent 1ad9898f66
commit 17e649dd32
6 changed files with 65 additions and 8 deletions
+21
View File
@@ -790,6 +790,27 @@ pub fn viewport_size() -> ( u32, u32 )
( VIEWPORT_W.load( Ordering::Relaxed ), VIEWPORT_H.load( Ordering::Relaxed ) )
}
static OUTPUT_W: AtomicU32 = AtomicU32::new( 0 );
static OUTPUT_H: AtomicU32 = AtomicU32::new( 0 );
/// Record the logical size of the output the main surface is on. The
/// runtime calls this when outputs appear, change or go away, and when the
/// main surface enters one. `( 0, 0 )` clears it.
pub fn set_output_logical_size( width: u32, height: u32 )
{
OUTPUT_W.store( width, Ordering::Relaxed );
OUTPUT_H.store( height, Ordering::Relaxed );
}
/// Logical size of the screen the main surface is on, or `None` before the
/// compositor has described one. Unlike [`viewport_size`] it does not follow
/// the window, so it can size things relative to the display.
pub fn output_logical_size() -> Option<( u32, u32 )>
{
let size = ( OUTPUT_W.load( Ordering::Relaxed ), OUTPUT_H.load( Ordering::Relaxed ) );
( size.0 > 0 && size.1 > 0 ).then_some( size )
}
/// Orientation of the main surface: [`Orientation::Landscape`] when wider
/// than tall, [`Orientation::Portrait`] otherwise (square counts as
/// portrait, matching [`Length::orient`]'s resolution rule). Usable