Skip to content

phone/dev: fit the phone window to the screen - #329

Merged
derekross merged 1 commit into
derekross:mainfrom
Nerkyator:phone-dev-fit
Nov 2, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
Nerkyator:phone-dev-fit

Conversation

@Nerkyator

Copy link
Copy Markdown
Contributor

What and why

Closes #146. run-desktop and hyprland.lua both hard-coded 600x1300 at scale 1.25, so on a 1920x1080 screen at 1.25 (864 logical pixels high, 840 below Omarchy's bar) the window ran off the top and the bottom.

  • Sized from the focused monitor, read before the exec. run-desktop takes the largest 6n x 13n (the phone's 13:6 shape) that fits the focused monitor once its reserved area (the bar) and 24 pixels for the border and gaps are taken off, with width and height swapped for transforms 1, 3, 5 and 7, and n a multiple of 10 (see below) up to 100. It passes the mode and the scale n/80 to hyprland.lua through the environment (PHONE_DEV_MODE, PHONE_DEV_SCALE) and uses the same numbers for the float resize. The formula is in a comment above the code. The shell always sees 480x1040 logical pixels, as on the Pixel 7 Pro, and a screen with room still gets the old 600x1300 at 1.25 (n = 100).
  • An override: PHONE_DEV_N=<n>, a multiple of 10 from 40 to 100, forces a 6n x 13n window without reading the monitor, so it also works where hyprctl can't answer. Any other non-empty value is refused with a message; an empty one counts as unset.
  • A floor: below n = 40 (a 240x520 window) the harness says how much room the monitor has and stops; PHONE_DEV_N opens it anyway. It also stops when hyprctl gives no focused monitor, rather than falling back to 600x1300. Both checks run right after the existing pre-flight checks, before the harness copies or writes anything.
  • The soft text is explained in the script's header and in phone/README.md: on a desktop scaled above 1, the nested output renders at the window's logical size and the desktop scales it up.

One change from my proposal: n is a multiple of 10, not just even. I wrote in the issue that even n was enough for Hyprland to keep the scale. Your arithmetic holds (n/80 = 1.5n/120, so an even n stays on the 1/120 steps), but Hyprland also needs the pixel size divided by the scale to come out whole, and for some even n it comes out a hair off: 54 gives 324 / 0.675 = 479.99999999999994. In a nested Hyprland 0.56.2 started at 324x702 and 0.675, the monitor came up at scale 0.6666667, so the shell would lay out at 486x1053 instead of 480x1040. Between 40 and 100 the even n with that problem are 44, 46, 54, 56, 82, 88, 92 and 98. Others pass: 62 (372x806 at 0.775) kept its scale in the same test. I still went with multiples of 10, because then the scale is a multiple of 1/8, which any floating-point type holds exactly, so the harness doesn't depend on how Hyprland rounds. The cost is a slightly smaller window: on this laptop 360x780 rather than 372x806. If you'd rather have the even n that pass, I can switch, but the harness would then have to copy Hyprland's check.

You offered stacking on #173 or waiting: I waited, and this is rebased onto main with #173 in it. Nothing under packages/ changes, and nothing here runs on a phone.

Device and build

  • Phone: none: the desktop harness only, on a laptop (Omarchy 4.0.6-1, Hyprland 0.56.2, a 1920x1080 screen at 1.25)
  • Kernel release (uname -r): n/a, nothing runs on a phone
  • Packages changed, with versions: none (phone/ only)

Checks (no phone needed)

  • tools/pr-check passes, against upstream main at 53b906d (my origin is my fork)
  • tests/all passes, on the rebased branch
  • tests/packages: n/a, no package touched
  • Each changed package has its version bumped: n/a, no package touched
  • Commits have area prefixes and bodies that say why; AI help is a Co-Authored-By: trailer

On the phone

  • I ran this on my own phone, booted into this build: n/a, the change is the desktop harness only
  • Runbook steps passed: n/a; what ran in the harness is below
  • What I did not test: more than one monitor; Omarchy 4.5 (4.0.6 only); and, except with a fake hyprctl (below), a rotated, 4K or scale-1 monitor, a screen too small for n = 40, or a failing hyprctl
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1): it never runs on a phone

No tools/phone-smoke report: nothing here runs on a phone.

Tested in the harness

On the laptop above (1920x1080 at 1.25, the bar's 24 pixels reserved at the top):

  • Default: the window floats at 360x780 at y 54-834, inside the 864-pixel-high screen. In the nested session hyprctl monitors reports 360x780 at scale 0.75 (480.0x1040.0 logical), and the shell's bar, home and dock lay out as on the phone.

  • PHONE_DEV_N=100: the nested monitor is 600x1300 at 1.25 (480.0x1040.0 logical), as before; on this screen the window runs from y -206 to 1094, which is what the override is for.

  • With a fake hyprctl in front of run-desktop (and a fake Hyprland that prints what it gets), the bar's 24 pixels reserved at the top:

    Focused monitor Window
    1920x1080 at 1.25 360x780 (n = 60)
    1920x1080 at 1 420x910 (n = 70)
    2560x1440 at 1.25 480x1040 (n = 80); turned (transforms 1, 3, 5, 7): 600x1300
    2880x1800 at 1.8 420x910 (n = 70)
    3840x2160 at 2 420x910 (n = 70)
    3840x2160 at 1.5 600x1300 (n = 100)
    1280x800 at 1.25 240x520 (n = 40)
    1366x768 at 1.5 stops: "the focused monitor has room for 886x464, and the phone window needs at least 240x520"

    A failing hyprctl, no focused monitor, or a monitor without a reserved area stops with "could not read the focused monitor from hyprctl". PHONE_DEV_N 55, 30, 110, 0100, abc, " 100", 100x, 62 and non-ASCII digits are refused. A stop leaves the harness directory as it was, and the resize sent to the desktop always matched the mode passed to hyprland.lua.

  • For every n from 40 to 100 in steps of 10, 6n and 13n divided by the scale come out exactly 480 and 1040.

  • After the runs, the desktop still had its windows and a single Hyprland instance, and its shell was the same process throughout.

Screenshots

1080p at 1.25: the window as it appears on the desktop (360x780 logical, captured at the screen's 450x975 pixels, so the text is as soft as it looks there):

pr-fit-1080p

PHONE_DEV_N=100: captured from the nested compositor itself (600x1300, its own pixels, with no desktop scaling):

pr-n100

Not in this PR

  • Rendering the nested output at the window's physical pixels, so the text isn't soft: the follow-up you mentioned.
  • The nested shell still sometimes crashes at start inside OpenSSL, like the crashes noted in phone/dev: apps, panels and the terminal open in the nested session #173: 2 of my 8 runs here, once in Qt's OpenSSL backend and once from QCryptographicHash on Qt Quick's render thread.

🤖 Generated with Claude Code

run-desktop always floated the nested Hyprland at 600x1300 logical
pixels, taller than a 1080p screen at scale 1.25 (864 logical, 840
below Omarchy's bar): the window ran off the top and the bottom and
had to be resized by hand (derekross#146).

It now takes the largest 6n x 13n (the phone's 13:6 shape) that fits
the focused monitor beside its bars, with n a multiple of 10 up to 100,
and passes the nested monitor's mode and scale n/80 to hyprland.lua.
The shell still sees 480x1040 logical pixels, as on the Pixel 7 Pro,
so layouts don't change; n = 100 is the old 600x1300 at 1.25, so
screens with room see no change. n is a multiple of 10 because Hyprland
keeps a monitor scale only when the logical size comes out whole: a
scale that is a multiple of 1/8 always does, while for some even n it
comes out a hair off (54: 324 / 0.675 = 479.99999999999994), and
Hyprland then substitutes another scale (in a nested Hyprland 0.56.2
at 324x702 and 0.675, 2/3, so the shell would lay out at 486x1053).
On a 1080p screen at 1.25 that gives n = 60 (360x780) rather than 62.

PHONE_DEV_N=<n>, a multiple of 10 from 40 to 100, forces a size, to
compare screenshots across machines or keep the big window on a small
screen. Below n = 40 (240x520) the shell is too small to use, so the
harness stops with a message, as it does when hyprctl gives no focused
monitor to measure. Both checks run before the harness copies or
writes anything.

Tested on the laptop (Omarchy 4.0.6, Hyprland 0.56.2, 1920x1080 at
1.25): the window is 360x780 at y 54-834, inside the screen; the
nested monitor is 360x780 at scale 0.75 (480.0x1040.0 logical), and
the shell's bar, home and dock lay out as on the phone. With
PHONE_DEV_N=100 the window is 600x1300 at 1.25, as before. A fake
hyprctl covered 1080p to 4K, rotated and flipped monitors, the floor,
a failing hyprctl and invalid PHONE_DEV_N values. Text is smaller on
small screens, and a little soft on a desktop scaled above 1, since
the nested output renders at the window's logical size and the desktop
scales it up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross
derekross merged commit 03424dd into derekross:main Nov 2, 2026
2 checks passed
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
run-desktop always floated the nested Hyprland at 600x1300 logical
pixels, taller than a 1080p screen at scale 1.25 (864 logical, 840
below Omarchy's bar): the window ran off the top and the bottom and
had to be resized by hand (derekross#146).

It now takes the largest 6n x 13n (the phone's 13:6 shape) that fits
the focused monitor beside its bars, with n a multiple of 10 up to 100,
and passes the nested monitor's mode and scale n/80 to hyprland.lua.
The shell still sees 480x1040 logical pixels, as on the Pixel 7 Pro,
so layouts don't change; n = 100 is the old 600x1300 at 1.25, so
screens with room see no change. n is a multiple of 10 because Hyprland
keeps a monitor scale only when the logical size comes out whole: a
scale that is a multiple of 1/8 always does, while for some even n it
comes out a hair off (54: 324 / 0.675 = 479.99999999999994), and
Hyprland then substitutes another scale (in a nested Hyprland 0.56.2
at 324x702 and 0.675, 2/3, so the shell would lay out at 486x1053).
On a 1080p screen at 1.25 that gives n = 60 (360x780) rather than 62.

PHONE_DEV_N=<n>, a multiple of 10 from 40 to 100, forces a size, to
compare screenshots across machines or keep the big window on a small
screen. Below n = 40 (240x520) the shell is too small to use, so the
harness stops with a message, as it does when hyprctl gives no focused
monitor to measure. Both checks run before the harness copies or
writes anything.

Tested on the laptop (Omarchy 4.0.6, Hyprland 0.56.2, 1920x1080 at
1.25): the window is 360x780 at y 54-834, inside the screen; the
nested monitor is 360x780 at scale 0.75 (480.0x1040.0 logical), and
the shell's bar, home and dock lay out as on the phone. With
PHONE_DEV_N=100 the window is 600x1300 at 1.25, as before. A fake
hyprctl covered 1080p to 4K, rotated and flipped monitors, the floor,
a failing hyprctl and invalid PHONE_DEV_N values. Text is smaller on
small screens, and a little soft on a desktop scaled above 1, since
the nested output renders at the window's logical size and the desktop
scales it up.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

phone/dev/run-desktop: the phone window is taller than a 1080p screen at scale 1.25

2 participants