fix dropdowns being stuck open; multi button events

This commit is contained in:
galister
2026-01-25 12:21:57 +09:00
parent a5146e0396
commit 554029aacf
4 changed files with 675 additions and 653 deletions

View File

@@ -165,21 +165,21 @@
<blueprint name="menu_handsfree"> <blueprint name="menu_handsfree">
<context_menu > <context_menu >
<cell translation="BAR.HANDSFREE.NONE" _press="::HandsfreeMode None" /> <cell translation="BAR.HANDSFREE.NONE" _press="::HandsfreeMode None" _press2="::ContextMenuClose" />
<cell translation="BAR.HANDSFREE.HMD" _press="::HandsfreeMode Hmd" /> <cell translation="BAR.HANDSFREE.HMD" _press="::HandsfreeMode Hmd" _press2="::ContextMenuClose" />
<cell translation="BAR.HANDSFREE.HMD_ONLY" _press="::HandsfreeMode HmdOnly" /> <cell translation="BAR.HANDSFREE.HMD_ONLY" _press="::HandsfreeMode HmdOnly" _press2="::ContextMenuClose" />
<cell translation="BAR.HANDSFREE.EYE_TRACKING" _press="::HandsfreeMode EyeTracking" /> <cell translation="BAR.HANDSFREE.EYE_TRACKING" _press="::HandsfreeMode EyeTracking" _press2="::ContextMenuClose" />
<cell translation="BAR.HANDSFREE.EYE_ONLY" _press="::HandsfreeMode EyeTrackingOnly" /> <cell translation="BAR.HANDSFREE.EYE_ONLY" _press="::HandsfreeMode EyeTrackingOnly" _press2="::ContextMenuClose" />
</context_menu> </context_menu>
</blueprint> </blueprint>
<blueprint name="menu_burger"> <blueprint name="menu_burger">
<context_menu > <context_menu >
<cell translation="BAR.EDIT_MODE_TOGGLE" _press="::EditToggle" _press2="::ContextMenuClose" />
<cell translation="BAR.HANDSFREE.TITLE" _press="::ContextMenuOpen menu_handsfree" />
<cell translation="BAR.ADD_MIRROR" _press="::NewMirror" /> <cell translation="BAR.ADD_MIRROR" _press="::NewMirror" />
<cell translation="BAR.EDIT_MODE_TOGGLE" _press="::EditToggle" />
<cell translation="BAR.ADD_NEW_SET" _press="::AddSet" /> <cell translation="BAR.ADD_NEW_SET" _press="::AddSet" />
<cell translation="BAR.DELETE_CURRENT_SET" _press="::DeleteSet" /> <cell translation="BAR.DELETE_CURRENT_SET" _press="::DeleteSet" />
<cell translation="BAR.HANDSFREE.TITLE" _press="::ContextMenuOpen menu_handsfree" />
</context_menu> </context_menu>
</blueprint> </blueprint>

View File

@@ -37,6 +37,8 @@ use crate::{
windowing::{OverlaySelector, backend::OverlayEventData, window::OverlayCategory}, windowing::{OverlaySelector, backend::OverlayEventData, window::OverlayCategory},
}; };
pub const BUTTON_EVENT_SUFFIX: &[&str] = &["", "2", "3", "4", "5", "6", "7", "8", "9"];
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub const BUTTON_EVENTS: [( pub const BUTTON_EVENTS: [(
&str, &str,
@@ -196,8 +198,11 @@ pub(super) fn setup_custom_button<S: 'static>(
const TAG: &str = "Button"; const TAG: &str = "Button";
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS { for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
for suffix in BUTTON_EVENT_SUFFIX {
let name = &format!("{name}{suffix}");
let Some(action) = attribs.get_value(name) else { let Some(action) = attribs.get_value(name) else {
continue; //if no _press2 then don't attempt _press3 etc
break;
}; };
let mut args = action.split_whitespace(); let mut args = action.split_whitespace();
@@ -392,10 +397,9 @@ pub(super) fn setup_custom_button<S: 'static>(
return Ok(EventResult::Pass); return Ok(EventResult::Pass);
} }
app.tasks app.tasks.enqueue(TaskType::Overlay(OverlayTask::Drop(
.enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Name( OverlaySelector::Name(arg.clone()),
arg.clone(), )));
))));
Ok(EventResult::Consumed) Ok(EventResult::Consumed)
}) })
} }
@@ -470,7 +474,10 @@ pub(super) fn setup_custom_button<S: 'static>(
Box::new(move |app, owc| { Box::new(move |app, owc| {
let _ = owc let _ = owc
.backend .backend
.notify(app, OverlayEventData::WvrCommand(WvrCommand::CloseWindow)) .notify(
app,
OverlayEventData::WvrCommand(WvrCommand::CloseWindow),
)
.log_warn("Could not close window"); .log_warn("Could not close window");
}), }),
))); )));
@@ -502,7 +509,9 @@ pub(super) fn setup_custom_button<S: 'static>(
.backend .backend
.notify( .notify(
app, app,
OverlayEventData::WvrCommand(WvrCommand::KillProcess(signal)), OverlayEventData::WvrCommand(WvrCommand::KillProcess(
signal,
)),
) )
.log_warn("Could not kill process"); .log_warn("Could not kill process");
}), }),
@@ -741,6 +750,7 @@ pub(super) fn setup_custom_button<S: 'static>(
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id); log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
} }
} }
}
#[derive(Default)] #[derive(Default)]
struct ShellButtonMutableState { struct ShellButtonMutableState {

View File

@@ -23,7 +23,10 @@ use crate::{
input::HoverResult, input::HoverResult,
task::{OverlayTask, TaskContainer, TaskType}, task::{OverlayTask, TaskContainer, TaskType},
}, },
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS}, gui::panel::{
GuiPanel, NewGuiPanelParams, OnCustomAttribFunc,
button::{BUTTON_EVENT_SUFFIX, BUTTON_EVENTS},
},
overlays::edit::{ overlays::edit::{
lock::InteractLockHandler, lock::InteractLockHandler,
mouse::new_mouse_tab_handler, mouse::new_mouse_tab_handler,
@@ -279,8 +282,10 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
}; };
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS { for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
for suffix in BUTTON_EVENT_SUFFIX {
let name = &format!("{name}{suffix}");
let Some(action) = attribs.get_value(name) else { let Some(action) = attribs.get_value(name) else {
continue; break;
}; };
let mut args = action.split_whitespace(); let mut args = action.split_whitespace();
@@ -407,6 +412,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
let id = layout.add_event_listener(attribs.widget_id, *kind, callback); let id = layout.add_event_listener(attribs.widget_id, *kind, callback);
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id); log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
} }
}
}); });
let mut panel = GuiPanel::new_from_template( let mut panel = GuiPanel::new_from_template(

View File

@@ -32,7 +32,10 @@ use crate::{
wayvr::{self, SurfaceBufWithImage, process::KillSignal, window::WindowHandle}, wayvr::{self, SurfaceBufWithImage, process::KillSignal, window::WindowHandle},
}, },
graphics::{ExtentExt, Vert2Uv, upload_quad_vertices}, graphics::{ExtentExt, Vert2Uv, upload_quad_vertices},
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS}, gui::panel::{
GuiPanel, NewGuiPanelParams, OnCustomAttribFunc,
button::{BUTTON_EVENT_SUFFIX, BUTTON_EVENTS},
},
overlays::screen::capture::ScreenPipeline, overlays::screen::capture::ScreenPipeline,
state::{self, AppState}, state::{self, AppState},
subsystem::{hid::WheelDelta, input::KeyboardFocus}, subsystem::{hid::WheelDelta, input::KeyboardFocus},
@@ -141,8 +144,10 @@ impl WvrWindowBackend {
}; };
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS { for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
for suffix in BUTTON_EVENT_SUFFIX {
let name = &format!("{name}{suffix}");
let Some(action) = attribs.get_value(name) else { let Some(action) = attribs.get_value(name) else {
continue; break;
}; };
let mut args = action.split_whitespace(); let mut args = action.split_whitespace();
@@ -168,6 +173,7 @@ impl WvrWindowBackend {
let id = layout.add_event_listener(attribs.widget_id, *kind, callback); let id = layout.add_event_listener(attribs.widget_id, *kind, callback);
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id); log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
} }
}
}); });
let mut panel = GuiPanel::new_from_template( let mut panel = GuiPanel::new_from_template(