Skip to content

correct legacy-path bugs without breaking the public API - #406

Open
romanstingler wants to merge 1 commit into
hyprland-community:masterfrom
romanstingler:pr/legacy-fixes
Open

romanstingler wants to merge 1 commit into
hyprland-community:masterfrom
romanstingler:pr/legacy-fixes

Conversation

@romanstingler

Copy link
Copy Markdown
Contributor

needs PR #401 and PR #405

fixes a batch of bugs on the legacy dispatch, keyword and event paths

the legacy path is being deleted upstream in #15539 but it's still what
distros on .conf configs run, so these are worth fixing properly rather
than leaving them to rot.

bug fixes:

  • changefloatingmode reported floating inverted. the second field is
    CWindowTarget::floating(), so 1 is floating. the crate's own FIXME asked
    this exact question and picked the wrong branch.

  • ScreencastEventData::monitor was permanently false. the field is
    formatted as "monitor"/"window"/"region"/"ERR NONE", never "1", so the
    == "1" check could never match.

  • three dispatchers hardcoded a space after the name (MoveActive,
    ChangeSplitRatio, ToggleSpecialWorkspace). hyprland parses bind lines as
    CVarList(value, 4), so only the dispatcher name takes a comma. a space
    makes the whole string the dispatcher name and the bind gets rejected.

  • format_relative(0) returned a bare "+0" and dropped the monitor prefix,
    so RelativeMonitor(0) read as a relative workspace.

  • HyprColor rejected 8 hex digit colours, which is what hyprland actually
    writes. it was rejecting its own documented example. this also fixes
    gradient parsing.

  • OptionValue had no css/gradient/font_weight arms so those came back
    Unknown. all three map onto existing variants so nothing breaks.

  • parse_args(0) hit splitn(0, ",") and panicked. reachable on configreloaded.

  • WindowMoved built addresses with fmt_new, giving "0x0x55a". switched to
    Address::new like the other eight parsers.

  • ctl::output::create sent "output create headless foo" but the syntax is
    "output create headless name=foo". the old form registers an output
    literally called name=foo that output remove foo can't find.

OptionValue::Bool is deliberately not here. OptionValue is a public enum
with no #[non_exhaustive], so a new variant breaks every exhaustive match
downstream. That belongs in 0.5.0 and there's a test pinning the current
behaviour so the bump is a visible change.

@Mirilindo

Copy link
Copy Markdown

@romanstingler, following your plan in #391 (Lua or legacy picked at runtime from configProvider), I stacked the Lua half on top of this PR, #401 and #405, in case it saves you time when you get there:

Mirilindo/hyprland-rs@eb9dd34...lua-runtime

Four commits on top of your three:

  • 4af81d7: the escaping helpers from feat(lua): add helpers to escape strings for the Lua config #399 (lua::quote_string, lua::escape_string), unchanged.
  • 5180299, 5751176: Lua forms for every DispatchType variant the published downstream crates use, plus a few neighbours (list in MIGRATION.md); Custom passes its text through as is. On a Lua config, the other variants return HyprError::NoLuaForm, which names the dispatcher and points to Custom.
  • 355bfa9: Instance::config_mode() reads configProvider from j/status once per instance and caches it. On a legacy config, dispatchers get the same legacy strings as with your branch.

Tested: 47 unit tests, 6 integration tests against a fake Hyprland socket that record what each mode sends, ./test.sh passes, and end to end on Hyprland 0.57.2 with a Lua config. Not tested on a real Hyprland: the legacy path (I have no machine on hyprland.conf) and SetCursor.

One limit: on 0.56, hyprctl reload full-reset can switch the config provider while Hyprland runs, and the cache won't notice. It is documented in src/config_mode.rs.

Take whatever is useful, or none of it. I won't open a PR unless you want one.

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.

2 participants