[PR #108] [MERGED] Keep the compositor's fullscreen; copy and paste in every text field #2327

Closed
opened 2026-11-02 15:55:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/108
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/wayland-fullscreen-clipboard


📝 Commits (1)

  • 832a8e3 Keep the compositor's fullscreen, and copy/paste in every text field

📊 Changes

22 files changed (+1063 additions, -68 deletions)

View changed files

📝 crates/horizon-client/src/chat.rs (+12 -0)
➕ crates/horizon-client/src/clipboard.rs (+455 -0)
📝 crates/horizon-client/src/game.rs (+54 -28)
📝 crates/horizon-client/src/game/books.rs (+77 -5)
📝 crates/horizon-client/src/game/chat.rs (+11 -0)
➕ crates/horizon-client/src/game/clipboard.rs (+106 -0)
📝 crates/horizon-client/src/game/control.rs (+1 -1)
📝 crates/horizon-client/src/game/debug_keys.rs (+2 -10)
📝 crates/horizon-client/src/game/lan_screen.rs (+5 -0)
📝 crates/horizon-client/src/game/options.rs (+27 -5)
📝 crates/horizon-client/src/game/recipe_book.rs (+10 -0)
📝 crates/horizon-client/src/game/remote.rs (+18 -1)
📝 crates/horizon-client/src/game/sign_edit.rs (+53 -11)
📝 crates/horizon-client/src/game/stations.rs (+30 -2)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/multiplayer.rs (+10 -0)
📝 crates/horizon-client/src/options_ui.rs (+25 -0)
📝 crates/horizon-client/src/pack_screen.rs (+15 -0)
📝 crates/horizon-client/src/screen_draw.rs (+34 -0)
📝 crates/horizon-client/src/title.rs (+14 -0)

...and 2 more files

📄 Description

What was wrong

Fullscreen. apply_ui_settings compared the Fullscreen option with what the window reported (Window::fullscreen()) on every settings apply and forced the window back to the option. Settings are applied by every option button, joining a world, dimension travel and pack reloads. A window the compositor made fullscreen (a Hyprland fullscreen keybind or window rule) while the option was off went back to windowed on the next click. Reproduced on vscreen's sway: swaymsg fullscreen enable, then one VSync button click dropped fullscreen.

Copy and paste. Only F3+C/F3+I used the clipboard (#90). Ctrl+C/X/V/A did nothing in any text field.

What vanilla 26.3 does

  • com.mojang.blaze3d.platform.Window keeps fullscreenRequested (set by the option, Window.setFullscreen) separate from fullscreen (the window's state). Minecraft.renderFrame → Window.updateFullscreenIfChanged changes the window only when the two differ. A change the window system makes (SDL fullscreen events) runs updateFullscreenState → Minecraft.fullscreenStateChanged, which sets and saves the option. The window is created fullscreen when options.txt says so.
  • InputWithModifiers.isSelectAll/isCopy/isPaste/isCut: the layout's letter (shortcutKey, SDL's keycode) with InputQuirks.EDIT_SHORTCUT_KEY_MODIFIER (Cmd on macOS, Ctrl elsewhere) and no Shift/Alt. The modifiers come from the event's modifier state.
  • EditBox.keyPressed → insertText: StringUtil.filterText, cut to maxLength.
  • MultilineTextField (book page, MultiLineEditBox with 1024 characters / 14 lines): filterText(text, true) keeps line breaks, truncates to the characters left, rejects a paste that overflows the line limit.
  • TextFieldHelper (signs): getClipboardContents strips § codes and \r, and a paste that makes the line too wide is rejected whole.
  • KeyboardHandler.setClipboard skips empty text; getClipboard returns "" on failure.

The change

  • window::FullscreenState: the requested/actual pair. apply_ui_settings only calls set_fullscreen when the option changed; each frame (and on resize) the window's reported state is observed and adopted by the option, saved to options.txt. The window is created with with_fullscreen from options.txt.
  • New clipboard module: SystemClipboard (arboard; on Wayland its data-control backend, falling back to arboard's X11 path on compositors without it; text copied in the game still pastes in the game if no system clipboard can be reached, and a failed connection is reopened on the next use), shortcut detection on winit's ModifiersChanged state and the logical key (US-position fallback for non-Latin layouts, like SDL's latin_letters), filter_text, strip_formatting.
  • ui::EditBox and screen_draw::TextField get shortcut() with their real selection: chat, recipe-book search, language search, pack search, LAN port.
  • Horizon's append-only fields (no cursor: signs, book page and title, anvil, creative search, world name and seed, server name/address/direct connect, multiplayer chat) get an AppendSelection: Select All covers the whole value, which the next copy, cut, paste, typed text or Backspace uses; each paste follows the field's vanilla rules above.
  • ui::EditBox.insert_text now uses filterText (it dropped U+0080–U+009F, which vanilla allows). The creative search box and paste respect vanilla's 50-character limit.

How it was tested

  • Unit tests: window::tests::fullscreen_* (settings applied again leave a compositor fullscreen alone, an option change is requested once, the compositor's word wins) and clipboard::tests (shortcut detection and layouts, filterText/stripFormatting, EditBox shortcuts, append-only Select All, sign width rejection).
  • On vscreen (headless sway, Wayland, data-control), driving real key events with wtype and checking with wl-copy/wl-paste: paste, Select All + copy, Select All + cut and Select All + paste-replace in Direct Connection, world name (32-character cap) and seed, chat (command colouring updates), sign (§c…\r stripped; too-wide paste rejected), book page (\r, §, tab dropped, newlines kept), book title (15-character cap), anvil (§ and newline dropped; Select All replaces), creative search (results filter), language search and pack search.
  • Fullscreen on sway: compositor fullscreen is adopted (Video Settings shows ON, options.txt saved) and survives VSync clicks, Done, and screen changes; the Fullscreen button leaves and re-enters fullscreen; compositor un-fullscreen is adopted (OFF); start-up with fullscreen:true opens fullscreen. The same steps with the old block restored drop fullscreen on the first click.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace, tools/check_public_tree.py; cargo check for x86_64-pc-windows-msvc and natively on macOS (Mac mini).

Notes

  • Tested on sway, not Hyprland. Hyprland's fullscreen dispatcher sets the same xdg_toplevel fullscreen state, which winit reports through last_configure; that is the case the old code undid. Hyprland's "maximize" fullscreen mode is not xdg fullscreen, so the option stays off there (as with SDL).
  • On X11 and Windows winit reports the requested state rather than the WM's, so a WM-forced change is not adopted there (it is on Wayland and macOS).
  • Not covered end to end: the multiplayer chat box (needs a server), the recipe-book search and LAN port (both use the same EditBox::shortcut as the tested language search).
  • The append-only fields do not draw a selection highlight after Ctrl+A; the anvil box still draws long names past its edge (existing, unchanged). Horizon has no command block edit screen yet, so there was nothing to wire there.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/108 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/wayland-fullscreen-clipboard` --- ### 📝 Commits (1) - [`832a8e3`](https://github.com/horizon-rust/horizon/commit/832a8e3f46e2ceb56b0842cf5614d5d5f8232315) Keep the compositor's fullscreen, and copy/paste in every text field ### 📊 Changes **22 files changed** (+1063 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/chat.rs` (+12 -0) ➕ `crates/horizon-client/src/clipboard.rs` (+455 -0) 📝 `crates/horizon-client/src/game.rs` (+54 -28) 📝 `crates/horizon-client/src/game/books.rs` (+77 -5) 📝 `crates/horizon-client/src/game/chat.rs` (+11 -0) ➕ `crates/horizon-client/src/game/clipboard.rs` (+106 -0) 📝 `crates/horizon-client/src/game/control.rs` (+1 -1) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+2 -10) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+5 -0) 📝 `crates/horizon-client/src/game/options.rs` (+27 -5) 📝 `crates/horizon-client/src/game/recipe_book.rs` (+10 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+18 -1) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+53 -11) 📝 `crates/horizon-client/src/game/stations.rs` (+30 -2) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/multiplayer.rs` (+10 -0) 📝 `crates/horizon-client/src/options_ui.rs` (+25 -0) 📝 `crates/horizon-client/src/pack_screen.rs` (+15 -0) 📝 `crates/horizon-client/src/screen_draw.rs` (+34 -0) 📝 `crates/horizon-client/src/title.rs` (+14 -0) _...and 2 more files_ </details> ### 📄 Description ## What was wrong **Fullscreen.** `apply_ui_settings` compared the Fullscreen option with what the window reported (`Window::fullscreen()`) on every settings apply and forced the window back to the option. Settings are applied by every option button, joining a world, dimension travel and pack reloads. A window the compositor made fullscreen (a Hyprland `fullscreen` keybind or window rule) while the option was off went back to windowed on the next click. Reproduced on vscreen's sway: `swaymsg fullscreen enable`, then one VSync button click dropped fullscreen. **Copy and paste.** Only F3+C/F3+I used the clipboard (#90). Ctrl+C/X/V/A did nothing in any text field. ## What vanilla 26.3 does - `com.mojang.blaze3d.platform.Window` keeps `fullscreenRequested` (set by the option, `Window.setFullscreen`) separate from `fullscreen` (the window's state). `Minecraft.renderFrame` → `Window.updateFullscreenIfChanged` changes the window only when the two differ. A change the window system makes (SDL fullscreen events) runs `updateFullscreenState` → `Minecraft.fullscreenStateChanged`, which sets and saves the option. The window is created fullscreen when options.txt says so. - `InputWithModifiers.isSelectAll/isCopy/isPaste/isCut`: the layout's letter (`shortcutKey`, SDL's keycode) with `InputQuirks.EDIT_SHORTCUT_KEY_MODIFIER` (Cmd on macOS, Ctrl elsewhere) and no Shift/Alt. The modifiers come from the event's modifier state. - `EditBox.keyPressed` → `insertText`: `StringUtil.filterText`, cut to `maxLength`. - `MultilineTextField` (book page, `MultiLineEditBox` with 1024 characters / 14 lines): `filterText(text, true)` keeps line breaks, truncates to the characters left, rejects a paste that overflows the line limit. - `TextFieldHelper` (signs): `getClipboardContents` strips `§` codes and `\r`, and a paste that makes the line too wide is rejected whole. - `KeyboardHandler.setClipboard` skips empty text; `getClipboard` returns "" on failure. ## The change - `window::FullscreenState`: the requested/actual pair. `apply_ui_settings` only calls `set_fullscreen` when the option changed; each frame (and on resize) the window's reported state is observed and adopted by the option, saved to options.txt. The window is created with `with_fullscreen` from options.txt. - New `clipboard` module: `SystemClipboard` (arboard; on Wayland its data-control backend, falling back to arboard's X11 path on compositors without it; text copied in the game still pastes in the game if no system clipboard can be reached, and a failed connection is reopened on the next use), shortcut detection on winit's `ModifiersChanged` state and the logical key (US-position fallback for non-Latin layouts, like SDL's `latin_letters`), `filter_text`, `strip_formatting`. - `ui::EditBox` and `screen_draw::TextField` get `shortcut()` with their real selection: chat, recipe-book search, language search, pack search, LAN port. - Horizon's append-only fields (no cursor: signs, book page and title, anvil, creative search, world name and seed, server name/address/direct connect, multiplayer chat) get an `AppendSelection`: Select All covers the whole value, which the next copy, cut, paste, typed text or Backspace uses; each paste follows the field's vanilla rules above. - `ui::EditBox.insert_text` now uses `filterText` (it dropped U+0080–U+009F, which vanilla allows). The creative search box and paste respect vanilla's 50-character limit. ## How it was tested - Unit tests: `window::tests::fullscreen_*` (settings applied again leave a compositor fullscreen alone, an option change is requested once, the compositor's word wins) and `clipboard::tests` (shortcut detection and layouts, `filterText`/`stripFormatting`, EditBox shortcuts, append-only Select All, sign width rejection). - On vscreen (headless sway, Wayland, data-control), driving real key events with wtype and checking with `wl-copy`/`wl-paste`: paste, Select All + copy, Select All + cut and Select All + paste-replace in Direct Connection, world name (32-character cap) and seed, chat (command colouring updates), sign (`§c…\r` stripped; too-wide paste rejected), book page (`\r`, `§`, tab dropped, newlines kept), book title (15-character cap), anvil (`§` and newline dropped; Select All replaces), creative search (results filter), language search and pack search. - Fullscreen on sway: compositor fullscreen is adopted (Video Settings shows ON, options.txt saved) and survives VSync clicks, Done, and screen changes; the Fullscreen button leaves and re-enters fullscreen; compositor un-fullscreen is adopted (OFF); start-up with `fullscreen:true` opens fullscreen. The same steps with the old block restored drop fullscreen on the first click. - `cargo fmt`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace`, `tools/check_public_tree.py`; `cargo check` for `x86_64-pc-windows-msvc` and natively on macOS (Mac mini). ## Notes - Tested on sway, not Hyprland. Hyprland's `fullscreen` dispatcher sets the same `xdg_toplevel` fullscreen state, which winit reports through `last_configure`; that is the case the old code undid. Hyprland's "maximize" fullscreen mode is not xdg fullscreen, so the option stays off there (as with SDL). - On X11 and Windows winit reports the requested state rather than the WM's, so a WM-forced change is not adopted there (it is on Wayland and macOS). - Not covered end to end: the multiplayer chat box (needs a server), the recipe-book search and LAN port (both use the same `EditBox::shortcut` as the tested language search). - The append-only fields do not draw a selection highlight after Ctrl+A; the anvil box still draws long names past its edge (existing, unchanged). Horizon has no command block edit screen yet, so there was nothing to wire there. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:00 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2327
No description provided.