Fix window sizing and maximize on Linux (minHeight exceeds 768px displays) - #406
Open
Jonny-O wants to merge 1 commit into
Open
Fix window sizing and maximize on Linux (minHeight exceeds 768px displays)#406Jonny-O wants to merge 1 commit into
Jonny-O wants to merge 1 commit into
Conversation
The window could not be resized to fit the screen or maximized on
Ubuntu 26.04. Measured on the target hardware, the cause was
minHeight: 850 against a 768px-tall display - the window's minimum
was 82px taller than the screen, so shrinking it to fit was
impossible and maximize was an unsatisfiable constraint. Upstream's
own comment "1366 * 768 == minimum to cater for" sits directly above
that line.
- Lower window minimums from 1000x850 to 800x600.
- Clamp the initial window size to the available work area.
- Use native window decorations on Linux, so the window manager owns
maximize, resize, snapping and tiling. A frameless window gets no
compositor resize edges under Wayland. Windows and macOS keep the
custom titlebar.
- Hide the in-page titlebar on Linux, before first paint in
index.html so no duplicate titlebar flashes on launch, and via the
new status.driver.nativeframe flag in websocket.js.
- Bind F11 to toggle fullscreen, since hiding the in-page titlebar
removes the only fullscreen control.
- Track maximized state from window events instead of isMaximized(),
which is not dependable under Wayland.
- Show the window from ready-to-show, with a 10s fallback timer, so
an unpainted frame is never put on screen first.
- Use event.preventDefault() in the close handler; returning false
does not cancel an Electron close, so close-to-tray was broken.
- Report status.driver.operatingsystem correctly on Linux and on
an argument-less Windows launch.
Verified on Ubuntu 26.04 (GNOME 50, Wayland) against a 1280x768
display. WM_NORMAL_HINTS min goes 1000x850 -> 800x600, the window
opens at 1000x699 fully on screen instead of 1000x850 hanging 114px
off the bottom, and maximize/unmaximize/resize all behave.
Add GPL-3.0 section 5(a) modification notices to the three changed
source files, and a README section documenting the fork and the
GPL/AGPL discrepancy inherited from upstream. LICENSE and
package.json are deliberately unmodified.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
On Ubuntu 26.04 the CONTROL window cannot be resized to fit the screen and does not maximize correctly.
The cause is not Wayland, and it is not the frameless window — those were my first two guesses and measurement disproved both. It is
minHeight: 850increateJogWindow(), against a display that is 768px tall.The window's minimum height is 82px taller than the entire screen. That makes both symptoms unavoidable: the window cannot be shrunk to fit, and maximize is an unsatisfiable constraint against a 736px work area. Upstream's own comment sits directly above the line:
768px-tall panels are common on the small industrial displays people bolt to a machine. The one I tested against is a Dell W1700 at 1280x768.
Changes
The fix:
screen.getPrimaryDisplay().workAreaSize, so it opens at a size that fits.Linux window decorations — upstream creates a frameless window and draws its own titlebar. A frameless window gets no compositor resize edges under Wayland and does not reliably report maximized state, so on Linux the window manager now draws the titlebar and owns maximize, resize, snapping and tiling. This is gated on
process.platform === 'linux'; Windows and macOS keep the existing custom titlebar and are behaviourally unchanged.Consequences of that, all Linux-only:
index.htmlso no duplicate titlebar flashes on launch, and via a newstatus.driver.nativeframeflag inwebsocket.jsfor the socket path.F11is bound to toggle fullscreen, since hiding the in-page titlebar removes the only fullscreen control. It was not previously bound anywhere inkeyboard.js.maximize/unmaximizeevents rather thanisMaximized(), which is not dependable under Wayland.Two bugs found along the way, both platform-independent:
closehandler returnedfalseto cancel the close. That does not work in Electron — it needsevent.preventDefault(). Close-to-tray was broken everywhere, not just on Linux.status.driver.operatingsystemwas only set inside anargv.length >= 2check, so it was never set on Linux at all, and not set on Windows when launched without arguments.Window is now shown from
ready-to-showrather than immediately, so an unpainted frame is never put on screen first. There is a 10s fallback timer behind this: ifready-to-shownever fires the window is shown anyway, so a failed load cannot leave it permanently invisible. This matters because GNOME hides Electron tray icons without an AppIndicator extension, so there would be no way to recover it. I simulated both paths and confirmed the window becomes visible exactly once in each.Verification
Measured on the target hardware with
xprop, stock 1.0.390 vs. this branch. Ubuntu 26.04, GNOME 50.1, Wayland, 1280x768 display.WM_NORMAL_HINTSmin_MOTIF_WM_HINTSdecorations0x0(none)0x1(all)_NET_FRAME_EXTENTS0, 0, 37, 0Functional tests via
_NET_WM_STATEclient messages:DOM state confirmed over CDP:
{titlebarExists: true, computed: "none", visible: false, platform: "linux", bodyH: 699}— the in-page titlebar is present but hidden, not removed, so nothing that queries it breaks.Note for maintainers
The README section and the notices at the top of the three changed source files are fork bookkeeping — GPL-3.0 §5(a) requires me to mark modified files with a date when I distribute them. They are not meaningful in this repository and should be dropped if you merge this. The functional change is entirely in
index.js, plus the two small titlebar-hiding hunks inapp/index.htmlandapp/js/websocket.js.LICENSEandpackage.jsonare deliberately untouched. There is a discrepancy between them —LICENSEis GPL-3.0,package.jsondeclaresAGPL-3.0, both since the first commit — which I have documented rather than guessed at, since resolving it is yours to do and not mine.