dropdown for capture_method + random tweaks
This commit is contained in:
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
use wlx_common::{
|
||||
astr_containers::AStrMap,
|
||||
config::{GeneralConfig, SerializedWindowSet, SerializedWindowStates},
|
||||
config::{CaptureMethod, GeneralConfig, SerializedWindowSet, SerializedWindowStates},
|
||||
config_io,
|
||||
overlays::BackendAttribValue,
|
||||
};
|
||||
@@ -138,6 +138,7 @@ pub struct AutoSettings {
|
||||
pub opaque_background: bool,
|
||||
pub xwayland_by_default: bool,
|
||||
pub context_menu_hold_and_release: bool,
|
||||
pub capture_method: CaptureMethod,
|
||||
}
|
||||
|
||||
fn get_settings_path() -> PathBuf {
|
||||
@@ -181,6 +182,7 @@ pub fn save_settings(config: &GeneralConfig) -> anyhow::Result<()> {
|
||||
opaque_background: config.opaque_background,
|
||||
xwayland_by_default: config.xwayland_by_default,
|
||||
context_menu_hold_and_release: config.context_menu_hold_and_release,
|
||||
capture_method: config.capture_method,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string_pretty(&conf).unwrap(); // want panic
|
||||
|
||||
@@ -20,7 +20,7 @@ use wgui::{
|
||||
parser::{self, AttribPair, CustomAttribsInfoOwned, Fetchable, ParserState},
|
||||
taffy,
|
||||
widget::EventResult,
|
||||
windowing::context_menu::{ContextMenu, OpenParams},
|
||||
windowing::context_menu::{Blueprint, ContextMenu, OpenParams},
|
||||
};
|
||||
use wlx_common::overlays::ToastTopic;
|
||||
|
||||
@@ -207,8 +207,9 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
let callback: EventCallback<AppState, S> = match command {
|
||||
"::ContextMenuOpen" => {
|
||||
let Some(template_name) = args.next() else {
|
||||
log::warn!(
|
||||
"{command} has incorrect arguments. Should be: {command} <context_menu>"
|
||||
log::error!(
|
||||
"{:?}: {command} has invalid arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
@@ -230,8 +231,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
move |_common, data, _app, _| {
|
||||
context_menu.borrow_mut().open(OpenParams {
|
||||
on_custom_attribs: Some(on_custom_attribs.clone()),
|
||||
template_name: template_name.clone(),
|
||||
template_params: template_params.clone(),
|
||||
blueprint: Blueprint::Template {
|
||||
template_name: template_name.clone(),
|
||||
template_params: template_params.clone(),
|
||||
},
|
||||
position: data.metadata.get_mouse_pos_absolute().unwrap(), //want panic
|
||||
});
|
||||
Ok(EventResult::Consumed)
|
||||
@@ -249,14 +252,18 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
}
|
||||
"::ElementSetDisplay" => {
|
||||
let (Some(id), Some(value)) = (args.next(), args.next()) else {
|
||||
log::warn!(
|
||||
"{command} has incorrect arguments. Should be: {command} <element_id> <display>"
|
||||
log::error!(
|
||||
"{:?}: {command} has invalid arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(widget_id) = parser_state.data.get_widget_id(id) else {
|
||||
log::warn!("{command}: no element exists with ID '{id}'");
|
||||
log::warn!(
|
||||
"{:?}: {command}: no element exists with ID '{id}'",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -290,7 +297,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::SetToggle" => {
|
||||
let arg = args.next().unwrap_or_default();
|
||||
let Ok(set_idx) = arg.parse() else {
|
||||
log::error!("{command} has invalid argument: \"{arg}\"");
|
||||
log::error!(
|
||||
"{:?}: {command} has invalid argument: \"{arg}\"",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
Box::new(move |_common, data, app, _| {
|
||||
@@ -306,7 +316,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::SetSwitch" => {
|
||||
let arg = args.next().unwrap_or_default();
|
||||
let Ok(set_idx) = arg.parse::<i32>() else {
|
||||
log::error!("{command} has invalid argument: \"{arg}\"");
|
||||
log::error!(
|
||||
"{:?}: {command} has invalid argument: \"{arg}\"",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
let maybe_set = if set_idx < 0 {
|
||||
@@ -327,7 +340,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::OverlayReset" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -346,7 +362,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::OverlayToggle" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -366,7 +385,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::OverlayDrop" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -402,7 +424,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::CustomOverlayReload" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -440,7 +465,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::WvrOverlayCloseWindow" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
Box::new(move |_common, data, app, _| {
|
||||
@@ -463,7 +491,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::WvrOverlayKillProcess" | "::WvrOverlayTermProcess" => {
|
||||
let arg: Arc<str> = args.collect::<Vec<_>>().join(" ").into();
|
||||
if arg.len() < 1 {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -585,7 +616,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
}),
|
||||
"::SendKey" => {
|
||||
let Some(key) = args.next().and_then(|s| VirtualKey::from_str(s).ok()) else {
|
||||
log::error!("{command} has bad/missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has bad/missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
let Some(down) = args.next().and_then(|s| match s.to_lowercase().as_str() {
|
||||
@@ -593,7 +627,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"up" => Some(false),
|
||||
_ => None,
|
||||
}) else {
|
||||
log::error!("{command} has bad/missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has bad/missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
Box::new(move |_common, data, app, _| {
|
||||
@@ -640,7 +677,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
use crate::subsystem::osc::parse_osc_value;
|
||||
|
||||
let Some(address) = args.next().map(std::string::ToString::to_string) else {
|
||||
log::error!("{command} has missing arguments");
|
||||
log::error!(
|
||||
"{:?}: {command} has bad/missing arguments",
|
||||
parser_state.path.get_path_buf()
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use std::{any, cell::RefCell, rc::Rc};
|
||||
|
||||
use button::setup_custom_button;
|
||||
use glam::{Affine2, Vec2, vec2};
|
||||
|
||||
@@ -18,7 +18,10 @@ use crate::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender, ui_transform,
|
||||
},
|
||||
};
|
||||
use wlx_common::overlays::{BackendAttrib, BackendAttribValue, MouseTransform, StereoMode};
|
||||
use wlx_common::{
|
||||
config::CaptureMethod,
|
||||
overlays::{BackendAttrib, BackendAttribValue, MouseTransform, StereoMode},
|
||||
};
|
||||
|
||||
use super::capture::{ScreenPipeline, WlxCaptureIn, WlxCaptureOut, receive_callback};
|
||||
|
||||
@@ -144,10 +147,12 @@ impl OverlayBackend for ScreenBackend {
|
||||
.ext_external_memory_dma_buf
|
||||
&& self.capture.supports_dmbuf();
|
||||
|
||||
let allow_dmabuf = &*app.session.config.capture_method != "pw_fallback"
|
||||
&& &*app.session.config.capture_method != "screencopy";
|
||||
let capture_method = app.session.config.capture_method;
|
||||
|
||||
let capture_method = app.session.config.capture_method.clone();
|
||||
let allow_dmabuf = !matches!(
|
||||
capture_method,
|
||||
CaptureMethod::PwFallback | CaptureMethod::ScreenCopy
|
||||
);
|
||||
|
||||
let dmabuf_formats = if !supports_dmabuf {
|
||||
log::info!("Capture method does not support DMA-buf");
|
||||
@@ -158,7 +163,10 @@ impl OverlayBackend for ScreenBackend {
|
||||
}
|
||||
&Vec::new()
|
||||
} else if !allow_dmabuf {
|
||||
log::info!("Not using DMA-buf capture due to {capture_method}");
|
||||
log::info!(
|
||||
"Not using DMA-buf capture due to {}",
|
||||
capture_method.as_ref()
|
||||
);
|
||||
if app.gfx_extras.queue_capture.is_none() {
|
||||
log::warn!(
|
||||
"Current GPU does not support multiple queues. Software capture will take place on the main thread. Expect degraded performance."
|
||||
|
||||
@@ -6,7 +6,10 @@ use wlx_capture::{
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
wlr_screencopy::WlrScreencopyCapture,
|
||||
};
|
||||
use wlx_common::{astr_containers::AStrMapExt, config::PwTokenMap};
|
||||
use wlx_common::{
|
||||
astr_containers::AStrMapExt,
|
||||
config::{CaptureMethod, PwTokenMap},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
overlays::screen::create_screen_from_backend,
|
||||
@@ -43,18 +46,14 @@ impl ScreenBackend {
|
||||
#[allow(clippy::useless_let_if_seq)]
|
||||
pub fn create_screen_renderer_wl(
|
||||
output: &WlxOutput,
|
||||
has_wlr_dmabuf: bool,
|
||||
has_wlr_screencopy: bool,
|
||||
pw_token_store: &mut PwTokenMap,
|
||||
app: &mut AppState,
|
||||
) -> Option<ScreenBackend> {
|
||||
let mut capture: Option<ScreenBackend> = None;
|
||||
if (&*app.session.config.capture_method == "wlr-dmabuf") && has_wlr_dmabuf {
|
||||
log::info!("{}: Using Wlr DMA-Buf", &output.name);
|
||||
capture = ScreenBackend::new_wlr_dmabuf(output, app);
|
||||
}
|
||||
|
||||
if &*app.session.config.capture_method == "screencopy" && has_wlr_screencopy {
|
||||
if matches!(app.session.config.capture_method, CaptureMethod::ScreenCopy) && has_wlr_screencopy
|
||||
{
|
||||
log::info!("{}: Using Wlr Screencopy Wl-SHM", &output.name);
|
||||
capture = ScreenBackend::new_wlr_screencopy(output, app);
|
||||
}
|
||||
@@ -102,7 +101,6 @@ pub fn create_screens_wayland(wl: &mut WlxClient, app: &mut AppState) -> ScreenC
|
||||
let mut pw_tokens: PwTokenMap = load_pw_token_config().unwrap_or_default();
|
||||
|
||||
let pw_tokens_copy = pw_tokens.clone();
|
||||
let has_wlr_dmabuf = wl.maybe_wlr_dmabuf_mgr.is_some();
|
||||
let has_wlr_screencopy = wl.maybe_wlr_screencopy_mgr.is_some();
|
||||
|
||||
for (id, output) in &wl.outputs {
|
||||
@@ -118,13 +116,9 @@ pub fn create_screens_wayland(wl: &mut WlxClient, app: &mut AppState) -> ScreenC
|
||||
output.logical_pos,
|
||||
);
|
||||
|
||||
if let Some(mut backend) = create_screen_renderer_wl(
|
||||
output,
|
||||
has_wlr_dmabuf,
|
||||
has_wlr_screencopy,
|
||||
&mut pw_tokens,
|
||||
app,
|
||||
) {
|
||||
if let Some(mut backend) =
|
||||
create_screen_renderer_wl(output, has_wlr_screencopy, &mut pw_tokens, app)
|
||||
{
|
||||
backend.logical_pos = vec2(output.logical_pos.0 as f32, output.logical_pos.1 as f32);
|
||||
backend.logical_size = vec2(output.logical_size.0 as f32, output.logical_size.1 as f32);
|
||||
backend.mouse_transform_original = output.transform;
|
||||
|
||||
Reference in New Issue
Block a user