From dd18d1eabc8b6a335f661351fd44dfd607c10f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 23 Aug 2026 03:06:25 +0200 Subject: [PATCH] stream_dvdnav: reset a stale selected button on menu changes A menu change keeps the VM's selected-button register unless the link command carried a button number or the new button set forces one via fosl_btnn. Select the first button in that case. --- stream/stream_dvdnav.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index c068f82b34..8c0af5ea0b 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -609,6 +609,21 @@ static int process_event(stream_t *s, int event, void *buf, int len) priv->pci = *pnavpci; priv->pci_valid = true; MP_TRACE(s, "start pts = %"PRIu32"\n", pnavpci->pci_gi.vobu_s_ptm); + // Reset selection to first button if the current selection is out of + // range. libdvdnav holds stale button selections when the menu changes, + // which makes the new page unusable. + if (in_menu_domain(dvdnav) && pnavpci->hli.hl_gi.hli_ss && + pnavpci->hli.hl_gi.btn_ns > 0) + { + int32_t btn = 0; + dvdnav_get_current_highlight(dvdnav, &btn); + if (btn <= 0 || btn > pnavpci->hli.hl_gi.btn_ns) { + MP_VERBOSE(s, "stale button %d for a %d-button menu, " + "selecting button 1\n", btn, + pnavpci->hli.hl_gi.btn_ns); + dvdnav_button_select(dvdnav, pnavpci, 1); + } + } // Each NAV packet can change the highlighted button or the // available button set; keep our mirrored state in sync. update_highlight(priv);