feat(ui): taille de l'écran virtuel au choix, mire de test rangée en Débogage
CI / Formatting, tests and builds (push) Successful in 2m58s
CI / Formatting, tests and builds (push) Successful in 2m58s
Écran virtuel (#89): un réglage `virtual_size` (1920 x 1080 par défaut, dimensions paires de 640 x 480 à 7680 x 4320) donne sa taille à l'écran que crée le portail. Sous la liste des sources, l'application de bureau propose les résolutions courantes de tablettes et d'écrans, ou une taille libre. En plein partage, « Changer de source » recrée l'écran à la nouvelle taille sans déconnecter les spectateurs. Un choix d'écran virtuel sans taille reçoit celle du réglage. Mire de test (#91): elle n'est plus proposée par défaut. La section Débogage des réglages la fait apparaître (`test_pattern`), et accueille aussi l'export des diagnostics. `rustscreen-cli --synthetic` et `--list` ne dépendent pas du réglage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19a0902400
commit
e6c7e833cc
18 files changed
+463
-39
No files matched your search
@@ -8,8 +8,8 @@ import { SettingsDialog } from './components/SettingsDialog';
|
||||
import { SharePanel } from './components/SharePanel';
|
||||
import { SourcePicker } from './components/SourcePicker';
|
||||
import { effectiveLanguage, I18nProvider, useI18n } from './i18n';
|
||||
import type { Host } from './lib/host';
|
||||
import { actions, key, say, status, trayTexts } from './lib/view';
|
||||
import { type Host, rejectionsOf } from './lib/host';
|
||||
import { actions, isVirtual, key, say, status, trayTexts, withSize } from './lib/view';
|
||||
|
||||
/**
|
||||
* The language comes from the host settings, or from the desktop. Changing it
|
||||
@@ -90,6 +90,31 @@ function Shell({ host, onLanguage }: { host: Host; onLanguage: (code: string | n
|
||||
});
|
||||
}, [host]);
|
||||
|
||||
// The size is a setting (#89): saved at once, it applies to the next start
|
||||
// or, while sharing, to the next "Switch to".
|
||||
const changeVirtualSize = useCallback(
|
||||
async (size: [number, number]) => {
|
||||
const settings = await host.settings();
|
||||
try {
|
||||
await host.updateSettings({ ...settings, virtual_size: size });
|
||||
} catch (e) {
|
||||
throw rejectionsOf(e)
|
||||
.map((r) => say(r.message, t))
|
||||
.join('; ');
|
||||
}
|
||||
setSelection((choice) => choice && withSize(choice, size));
|
||||
setSources(
|
||||
(list) =>
|
||||
list?.map((s) =>
|
||||
isVirtual(s.choice)
|
||||
? { ...s, choice: withSize(s.choice, size), width: size[0], height: size[1] }
|
||||
: s,
|
||||
) ?? null,
|
||||
);
|
||||
},
|
||||
[host, t],
|
||||
);
|
||||
|
||||
const phase = state?.phase;
|
||||
useEffect(() => {
|
||||
if (phase === 'stopped') {
|
||||
@@ -158,6 +183,7 @@ function Shell({ host, onLanguage }: { host: Host; onLanguage: (code: string | n
|
||||
enabled={buttons.pick || picking}
|
||||
onPick={setSelection}
|
||||
onRefresh={refresh}
|
||||
onVirtualSize={changeVirtualSize}
|
||||
/>
|
||||
)}
|
||||
</main>
|
||||
@@ -253,6 +279,8 @@ function Shell({ host, onLanguage }: { host: Host; onLanguage: (code: string | n
|
||||
onSaved={(s) => {
|
||||
setTheme(s.theme);
|
||||
onLanguage(s.language);
|
||||
// The test pattern comes and goes with its setting (#91).
|
||||
if (buttons.pick) refresh();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -66,4 +66,13 @@ confirm_quit: boolean, trusted_devices: Array<TrustedDevice>,
|
||||
* Names the host gave to devices, by device id (#37). They win over the
|
||||
* name a viewer announces, and survive a restart.
|
||||
*/
|
||||
aliases: Array<DeviceAlias>, };
|
||||
aliases: Array<DeviceAlias>,
|
||||
/**
|
||||
* Width and height of the virtual screen the portal creates (#89).
|
||||
*/
|
||||
virtual_size: [number, number],
|
||||
/**
|
||||
* Offer the test pattern among the sources (#91): a debugging aid, off
|
||||
* by default. The command line's `--synthetic` does not depend on it.
|
||||
*/
|
||||
test_pattern: boolean, };
|
||||
@@ -316,6 +316,24 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
<span className='field-error'>{error('trusted_devices')}</span>
|
||||
)}
|
||||
</div>
|
||||
<fieldset className='debug'>
|
||||
<legend>{t('debug')}</legend>
|
||||
<label className='checkbox' title={t('testPatternHelp')}>
|
||||
<input
|
||||
type='checkbox'
|
||||
checked={settings.test_pattern}
|
||||
onChange={(e) => change('test_pattern', e.target.checked)}
|
||||
/>
|
||||
{t('testPattern')}
|
||||
</label>
|
||||
<div className='field'>
|
||||
<button type='button' className='button muted' onClick={exportDiagnostics}>
|
||||
{t('diagnostics')}
|
||||
</button>
|
||||
<span className='help'>{t('diagnosticsHelp')}</span>
|
||||
{error('diagnostics') && <span className='field-error'>{error('diagnostics')}</span>}
|
||||
</div>
|
||||
</fieldset>
|
||||
{error('file') && <p className='field-error'>{error('file')}</p>}
|
||||
{message && (
|
||||
<p className='confirmation' role='status'>
|
||||
@@ -325,10 +343,6 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
</p>
|
||||
)}
|
||||
<div className='dialog-actions'>
|
||||
<button type='button' className='button muted' onClick={exportDiagnostics}>
|
||||
{t('diagnostics')}
|
||||
</button>
|
||||
<span className='spacer' />
|
||||
<button type='button' className='button muted' onClick={onClose}>
|
||||
{t('close')}
|
||||
</button>
|
||||
@@ -336,8 +350,6 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
{t('save')}
|
||||
</button>
|
||||
</div>
|
||||
<p className='help'>{t('diagnosticsHelp')}</p>
|
||||
{error('diagnostics') && <p className='field-error'>{error('diagnostics')}</p>}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useId, useMemo, useState } from 'react';
|
||||
import type { SourceChoice } from '../bindings/SourceChoice';
|
||||
import type { SourceOption } from '../bindings/SourceOption';
|
||||
import { useI18n } from '../i18n';
|
||||
import { displayName, filter, key } from '../lib/view';
|
||||
import { displayName, filter, isVirtual, isVirtualSize, key, VIRTUAL_SIZES } from '../lib/view';
|
||||
|
||||
type Props = {
|
||||
sources: SourceOption[] | null;
|
||||
@@ -10,12 +10,21 @@ type Props = {
|
||||
enabled: boolean;
|
||||
onPick: (choice: SourceChoice) => void;
|
||||
onRefresh: () => void;
|
||||
/** Saves a new size for the virtual screen (#89); rejects with its message. */
|
||||
onVirtualSize: (size: [number, number]) => Promise<void>;
|
||||
};
|
||||
|
||||
/** Beyond this, the list gets long to scan: the search field appears. */
|
||||
const SEARCH_THRESHOLD = 6;
|
||||
|
||||
export function SourcePicker({ sources, selection, enabled, onPick, onRefresh }: Props) {
|
||||
export function SourcePicker({
|
||||
sources,
|
||||
selection,
|
||||
enabled,
|
||||
onPick,
|
||||
onRefresh,
|
||||
onVirtualSize,
|
||||
}: Props) {
|
||||
const { t } = useI18n();
|
||||
const [search, setSearch] = useState('');
|
||||
const visible = useMemo(() => filter(sources ?? [], search, t), [sources, search, t]);
|
||||
@@ -78,6 +87,119 @@ export function SourcePicker({ sources, selection, enabled, onPick, onRefresh }:
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{selection?.type === 'portal' && isVirtual(selection) && selection.size && (
|
||||
<VirtualSize size={selection.size} enabled={enabled} onChange={onVirtualSize} />
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const CUSTOM = 'custom';
|
||||
const SEPARATOR = 'x';
|
||||
|
||||
/** The value of a size in the select, not a displayed text. */
|
||||
function sizeValue([width, height]: [number, number]): string {
|
||||
return [width, height].join(SEPARATOR);
|
||||
}
|
||||
|
||||
/** The size of the virtual screen: a common one, or any even size (#89). */
|
||||
function VirtualSize({
|
||||
size,
|
||||
enabled,
|
||||
onChange,
|
||||
}: {
|
||||
size: [number, number];
|
||||
enabled: boolean;
|
||||
onChange: (size: [number, number]) => Promise<void>;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
const id = useId();
|
||||
const preset = VIRTUAL_SIZES.find(([w, h]) => w === size[0] && h === size[1]);
|
||||
const [custom, setCustom] = useState(!preset);
|
||||
const [width, setWidth] = useState(String(size[0]));
|
||||
const [height, setHeight] = useState(String(size[1]));
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const apply = async (next: [number, number]) => {
|
||||
if (!isVirtualSize(next)) {
|
||||
setError(t('virtualSizeInvalid'));
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
try {
|
||||
await onChange(next);
|
||||
} catch (e) {
|
||||
setError(String(e));
|
||||
}
|
||||
};
|
||||
const typed: [number, number] = [Number(width), Number(height)];
|
||||
|
||||
return (
|
||||
<div className='virtual-size'>
|
||||
<label htmlFor={`${id}-size`}>{t('virtualSize')}</label>
|
||||
<select
|
||||
id={`${id}-size`}
|
||||
disabled={!enabled}
|
||||
value={custom || !preset ? CUSTOM : sizeValue(preset)}
|
||||
onChange={(e) => {
|
||||
if (e.target.value === CUSTOM) {
|
||||
setCustom(true);
|
||||
return;
|
||||
}
|
||||
setCustom(false);
|
||||
const [w, h] = e.target.value.split(SEPARATOR).map(Number);
|
||||
setWidth(String(w));
|
||||
setHeight(String(h));
|
||||
void apply([w ?? 0, h ?? 0]);
|
||||
}}
|
||||
>
|
||||
{VIRTUAL_SIZES.map(([w, h]) => (
|
||||
<option key={sizeValue([w, h])} value={sizeValue([w, h])}>
|
||||
{w} × {h}
|
||||
</option>
|
||||
))}
|
||||
<option value={CUSTOM}>{t('virtualSizeCustom')}</option>
|
||||
</select>
|
||||
{(custom || !preset) && (
|
||||
<>
|
||||
<input
|
||||
type='number'
|
||||
className='size-input'
|
||||
min={640}
|
||||
max={7680}
|
||||
step={2}
|
||||
aria-label={t('virtualWidth')}
|
||||
value={width}
|
||||
disabled={!enabled}
|
||||
onChange={(e) => setWidth(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
type='number'
|
||||
className='size-input'
|
||||
min={480}
|
||||
max={4320}
|
||||
step={2}
|
||||
aria-label={t('virtualHeight')}
|
||||
value={height}
|
||||
disabled={!enabled}
|
||||
onChange={(e) => setHeight(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
type='button'
|
||||
className='button muted'
|
||||
disabled={!enabled || (typed[0] === size[0] && typed[1] === size[1])}
|
||||
onClick={() => void apply(typed)}
|
||||
>
|
||||
{t('apply')}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<span className='help'>{t('virtualSizeHelp')}</span>
|
||||
{error && (
|
||||
<span className='field-error' role='alert'>
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { HostState } from '../bindings/HostState';
|
||||
import type { Share } from '../bindings/Share';
|
||||
import type { SourceChoice } from '../bindings/SourceChoice';
|
||||
import type { SourceOption } from '../bindings/SourceOption';
|
||||
import { effectiveLanguage, LANGUAGES, translatorFor } from '../i18n';
|
||||
import {
|
||||
@@ -10,12 +11,15 @@ import {
|
||||
duration,
|
||||
expiry,
|
||||
filter,
|
||||
isVirtualSize,
|
||||
key,
|
||||
noticeOf,
|
||||
outcomeSummary,
|
||||
say,
|
||||
status,
|
||||
trayTexts,
|
||||
VIRTUAL_SIZES,
|
||||
withSize,
|
||||
} from './view';
|
||||
|
||||
const t = translatorFor('fr');
|
||||
@@ -218,3 +222,32 @@ describe('language (#21)', () => {
|
||||
expect(tray.live.other).toBe('En direct, {count} spectateurs');
|
||||
});
|
||||
});
|
||||
|
||||
describe('virtual screen size (#89)', () => {
|
||||
it('every offered size is accepted, odd or out of bounds ones are not', () => {
|
||||
for (const size of VIRTUAL_SIZES) expect(isVirtualSize(size)).toBe(true);
|
||||
expect(isVirtualSize([1281, 800])).toBe(false);
|
||||
expect(isVirtualSize([320, 240])).toBe(false);
|
||||
expect(isVirtualSize([8192, 4320])).toBe(false);
|
||||
expect(isVirtualSize([Number.NaN, 800])).toBe(false);
|
||||
});
|
||||
|
||||
it('only a virtual screen changes size', () => {
|
||||
const virtual: SourceChoice = {
|
||||
type: 'portal',
|
||||
virtual_display: true,
|
||||
window: false,
|
||||
size: [1920, 1080],
|
||||
};
|
||||
expect(withSize(virtual, [1280, 800])).toEqual({ ...virtual, size: [1280, 800] });
|
||||
const screen: SourceChoice = {
|
||||
type: 'portal',
|
||||
virtual_display: false,
|
||||
window: false,
|
||||
size: null,
|
||||
};
|
||||
expect(withSize(screen, [1280, 800])).toBe(screen);
|
||||
// The identity does not depend on the size: the selection survives.
|
||||
expect(key(withSize(virtual, [1280, 800]))).toBe(key(virtual));
|
||||
});
|
||||
});
|
||||
@@ -66,6 +66,45 @@ export function status(state: HostState, t: Translate): Status {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sizes offered for a virtual screen (#89): common tablet and monitor
|
||||
* resolutions, in landscape. Any other even size can be typed.
|
||||
*/
|
||||
export const VIRTUAL_SIZES: [number, number][] = [
|
||||
[1280, 800],
|
||||
[1920, 1080],
|
||||
[1920, 1200],
|
||||
[2048, 1536],
|
||||
[2360, 1640],
|
||||
[2560, 1600],
|
||||
[2732, 2048],
|
||||
[3840, 2160],
|
||||
];
|
||||
|
||||
/** Mirrors `rs_store::is_virtual_size`: even, from 640 × 480 to 7680 × 4320. */
|
||||
export function isVirtualSize([width, height]: [number, number]): boolean {
|
||||
return (
|
||||
Number.isInteger(width) &&
|
||||
Number.isInteger(height) &&
|
||||
width % 2 === 0 &&
|
||||
height % 2 === 0 &&
|
||||
width >= 640 &&
|
||||
width <= 7680 &&
|
||||
height >= 480 &&
|
||||
height <= 4320
|
||||
);
|
||||
}
|
||||
|
||||
/** Is this choice a virtual screen, whose size can be chosen? */
|
||||
export function isVirtual(choice: SourceChoice | null): boolean {
|
||||
return choice?.type === 'portal' && choice.virtual_display;
|
||||
}
|
||||
|
||||
/** The same virtual screen at another size; any other choice unchanged. */
|
||||
export function withSize(choice: SourceChoice, size: [number, number]): SourceChoice {
|
||||
return choice.type === 'portal' && choice.virtual_display ? { ...choice, size } : choice;
|
||||
}
|
||||
|
||||
/** Stable identity of a choice, for the selection and React keys. */
|
||||
export function key(choice: SourceChoice): string {
|
||||
switch (choice.type) {
|
||||
|
||||
@@ -542,6 +542,34 @@ h2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.debug {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.6rem;
|
||||
margin: 0;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.debug legend {
|
||||
padding: 0 0.3rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.virtual-size {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.9rem;
|
||||
}
|
||||
|
||||
.size-input {
|
||||
width: 5.5rem;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
color: var(--danger);
|
||||
font-size: 0.85rem;
|
||||
|
||||
@@ -387,7 +387,12 @@ async fn test_portal() -> Result<(), Error> {
|
||||
/// log: they say what the user is doing (ADR 0008).
|
||||
fn list() -> Result<(), Error> {
|
||||
let environment = rs_platform::Environment::detect();
|
||||
for source in rs_session::sources::list(&environment, None) {
|
||||
// The command line shows everything it can start, test pattern included.
|
||||
let offer = rs_session::sources::Offer {
|
||||
virtual_size: rs_session::capture::DEFAULT_VIRTUAL_SIZE,
|
||||
test_pattern: true,
|
||||
};
|
||||
for source in rs_session::sources::list(&environment, None, offer) {
|
||||
let id = match &source.choice {
|
||||
SourceChoice::X11 { id } => id.clone(),
|
||||
SourceChoice::Synthetic { .. } => "--synthetic".into(),
|
||||
|
||||
@@ -21,7 +21,7 @@ use rs_store::Notice;
|
||||
use crate::state::{Label, SharedSource, SourceChoice};
|
||||
|
||||
/// Size of a virtual screen when the user gives none.
|
||||
pub const DEFAULT_VIRTUAL_SIZE: (u32, u32) = (1920, 1080);
|
||||
pub use rs_store::DEFAULT_VIRTUAL_SIZE;
|
||||
|
||||
/// An open capture, ready to serve.
|
||||
pub struct StartedCapture {
|
||||
|
||||
@@ -267,9 +267,12 @@ impl Host {
|
||||
pub async fn sources(&self) -> Vec<SourceOption> {
|
||||
let environment = self.0.environment.clone();
|
||||
let portal = self.0.portal;
|
||||
tokio::task::spawn_blocking(move || crate::sources::list(&environment, portal.as_ref()))
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
let offer = crate::sources::Offer::of(&self.settings());
|
||||
tokio::task::spawn_blocking(move || {
|
||||
crate::sources::list(&environment, portal.as_ref(), offer)
|
||||
})
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn settings(&self) -> Settings {
|
||||
@@ -618,6 +621,7 @@ impl Host {
|
||||
|
||||
async fn open(&self, choice: SourceChoice) -> Result<Active, Notice> {
|
||||
let settings = self.settings();
|
||||
let choice = with_virtual_size(choice, settings.virtual_size);
|
||||
let overrides = self.0.config.overrides;
|
||||
let stream_settings = StreamSettings::for_preset(settings.quality);
|
||||
let codec = capture::Encoding {
|
||||
@@ -951,7 +955,10 @@ impl Host {
|
||||
return Ok(None);
|
||||
};
|
||||
let switching = choice.is_some();
|
||||
let choice = choice.unwrap_or_else(|| opened.choice.clone());
|
||||
let choice = match choice {
|
||||
Some(choice) => with_virtual_size(choice, self.settings().virtual_size),
|
||||
None => opened.choice.clone(),
|
||||
};
|
||||
let started = capture::start(
|
||||
&choice,
|
||||
&opened.settings,
|
||||
@@ -1187,6 +1194,22 @@ fn empty_state(
|
||||
}
|
||||
}
|
||||
|
||||
/// A virtual screen without a size takes the configured one (#89).
|
||||
fn with_virtual_size(choice: SourceChoice, configured: (u32, u32)) -> SourceChoice {
|
||||
match choice {
|
||||
SourceChoice::Portal {
|
||||
virtual_display: true,
|
||||
window,
|
||||
size: None,
|
||||
} => SourceChoice::Portal {
|
||||
virtual_display: true,
|
||||
window,
|
||||
size: Some(configured),
|
||||
},
|
||||
choice => choice,
|
||||
}
|
||||
}
|
||||
|
||||
/// The listen address: the one of the chosen interface, or all of them.
|
||||
fn listen_address(interface: Option<&str>) -> Result<IpAddr, Notice> {
|
||||
let Some(name) = interface else {
|
||||
|
||||
@@ -11,7 +11,6 @@ use rs_capture::CapturedFrame;
|
||||
use rs_platform::{Environment, PortalInfo, SessionType};
|
||||
use rs_proto::SourceKind;
|
||||
|
||||
use crate::capture::DEFAULT_VIRTUAL_SIZE;
|
||||
use crate::state::{Label, SourceChoice, SourceNote, SourceOption};
|
||||
|
||||
/// Maximum width of a thumbnail: enough to recognize a screen, small enough
|
||||
@@ -19,8 +18,30 @@ use crate::state::{Label, SourceChoice, SourceNote, SourceOption};
|
||||
const THUMBNAIL_WIDTH: u32 = 320;
|
||||
const THUMBNAIL_HEIGHT: u32 = 180;
|
||||
|
||||
/// What the settings change in the list.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Offer {
|
||||
/// Size of the virtual screen (#89).
|
||||
pub virtual_size: (u32, u32),
|
||||
/// Offer the test pattern (#91).
|
||||
pub test_pattern: bool,
|
||||
}
|
||||
|
||||
impl Offer {
|
||||
pub fn of(settings: &rs_store::Settings) -> Self {
|
||||
Self {
|
||||
virtual_size: settings.virtual_size,
|
||||
test_pattern: settings.test_pattern,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The sources of this machine. Blocking (X11): call it outside the runtime.
|
||||
pub fn list(environment: &Environment, portal: Option<&PortalInfo>) -> Vec<SourceOption> {
|
||||
pub fn list(
|
||||
environment: &Environment,
|
||||
portal: Option<&PortalInfo>,
|
||||
offer: Offer,
|
||||
) -> Vec<SourceOption> {
|
||||
let mut sources = Vec::new();
|
||||
match environment.session {
|
||||
SessionType::Wayland => {
|
||||
@@ -66,12 +87,12 @@ pub fn list(environment: &Environment, portal: Option<&PortalInfo>) -> Vec<Sourc
|
||||
});
|
||||
}
|
||||
if portal.is_some_and(PortalInfo::supports_virtual_display) {
|
||||
let (width, height) = DEFAULT_VIRTUAL_SIZE;
|
||||
let (width, height) = offer.virtual_size;
|
||||
sources.push(SourceOption {
|
||||
choice: SourceChoice::Portal {
|
||||
virtual_display: true,
|
||||
window: false,
|
||||
size: Some(DEFAULT_VIRTUAL_SIZE),
|
||||
size: Some(offer.virtual_size),
|
||||
},
|
||||
kind: SourceKind::Screen,
|
||||
name: "A second screen (virtual)".into(),
|
||||
@@ -87,8 +108,16 @@ pub fn list(environment: &Environment, portal: Option<&PortalInfo>) -> Vec<Sourc
|
||||
SessionType::X11 => sources.extend(x11()),
|
||||
SessionType::Headless => {}
|
||||
}
|
||||
if offer.test_pattern {
|
||||
sources.push(test_pattern());
|
||||
}
|
||||
sources
|
||||
}
|
||||
|
||||
/// The generated test pattern, a debugging aid (#91).
|
||||
fn test_pattern() -> SourceOption {
|
||||
let (width, height) = (1280, 720);
|
||||
sources.push(SourceOption {
|
||||
SourceOption {
|
||||
choice: SourceChoice::Synthetic { width, height },
|
||||
kind: SourceKind::Screen,
|
||||
name: "Test pattern".into(),
|
||||
@@ -101,8 +130,7 @@ pub fn list(environment: &Environment, portal: Option<&PortalInfo>) -> Vec<Sourc
|
||||
.and_then(|frame| thumbnail(&frame)),
|
||||
note: Some(SourceNote::TestPattern),
|
||||
available: true,
|
||||
});
|
||||
sources
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -231,9 +259,16 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_headless_machine_still_offers_the_test_pattern() {
|
||||
fn the_test_pattern_is_offered_only_when_asked() {
|
||||
let environment = Environment::from_vars(|_| None);
|
||||
let sources = list(&environment, None);
|
||||
let offer = Offer::of(&rs_store::Settings::default());
|
||||
assert!(list(&environment, None, offer).is_empty());
|
||||
|
||||
let offer = Offer {
|
||||
test_pattern: true,
|
||||
..offer
|
||||
};
|
||||
let sources = list(&environment, None, offer);
|
||||
assert_eq!(sources.len(), 1);
|
||||
assert!(matches!(sources[0].choice, SourceChoice::Synthetic { .. }));
|
||||
assert!(sources[0].thumbnail.is_some());
|
||||
|
||||
@@ -50,6 +50,12 @@ pub const MIN_PORT: u16 = 1024;
|
||||
pub const MAX_LIMIT: u8 = 20;
|
||||
/// Validity of an access code, in minutes, at most one day.
|
||||
pub const MAX_CODE_VALIDITY_MIN: u32 = 24 * 60;
|
||||
/// Default size of a virtual screen (#89).
|
||||
pub const DEFAULT_VIRTUAL_SIZE: (u32, u32) = (1920, 1080);
|
||||
/// Smallest virtual screen: below it, a desktop is not usable.
|
||||
pub const MIN_VIRTUAL_SIZE: (u32, u32) = (640, 480);
|
||||
/// Largest virtual screen: 8K, beyond what an encoder keeps up with.
|
||||
pub const MAX_VIRTUAL_SIZE: (u32, u32) = (7680, 4320);
|
||||
|
||||
/// Theme of the host interface.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
@@ -175,6 +181,11 @@ pub struct Settings {
|
||||
/// Names the host gave to devices, by device id (#37). They win over the
|
||||
/// name a viewer announces, and survive a restart.
|
||||
pub aliases: Vec<DeviceAlias>,
|
||||
/// Width and height of the virtual screen the portal creates (#89).
|
||||
pub virtual_size: (u32, u32),
|
||||
/// Offer the test pattern among the sources (#91): a debugging aid, off
|
||||
/// by default. The command line's `--synthetic` does not depend on it.
|
||||
pub test_pattern: bool,
|
||||
}
|
||||
|
||||
/// The host's name for a device (#37).
|
||||
@@ -213,6 +224,8 @@ impl Default for Settings {
|
||||
confirm_quit: true,
|
||||
trusted_devices: Vec::new(),
|
||||
aliases: Vec::new(),
|
||||
virtual_size: DEFAULT_VIRTUAL_SIZE,
|
||||
test_pattern: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,6 +362,21 @@ impl Settings {
|
||||
),
|
||||
));
|
||||
}
|
||||
if !is_virtual_size(self.virtual_size) {
|
||||
let (min, max) = (MIN_VIRTUAL_SIZE, MAX_VIRTUAL_SIZE);
|
||||
rejections.push(Rejection::new(
|
||||
"virtual_size",
|
||||
Notice::new(
|
||||
"virtual_size_range",
|
||||
format!(
|
||||
"even dimensions, from {}x{} to {}x{}",
|
||||
min.0, min.1, max.0, max.1
|
||||
),
|
||||
)
|
||||
.with("min", format!("{} × {}", min.0, min.1))
|
||||
.with("max", format!("{} × {}", max.0, max.1)),
|
||||
));
|
||||
}
|
||||
rejections
|
||||
}
|
||||
|
||||
@@ -366,12 +394,23 @@ impl Settings {
|
||||
"code_validity_min" => self.code_validity_min = default.code_validity_min,
|
||||
"trusted_devices" => self.trusted_devices.retain(|d| !d.id.0.trim().is_empty()),
|
||||
"aliases" => self.aliases.retain(DeviceAlias::is_valid),
|
||||
"virtual_size" => self.virtual_size = default.virtual_size,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Even dimensions (the I420 conversion halves them) within
|
||||
/// [`MIN_VIRTUAL_SIZE`] and [`MAX_VIRTUAL_SIZE`].
|
||||
pub fn is_virtual_size((width, height): (u32, u32)) -> bool {
|
||||
let (min, max) = (MIN_VIRTUAL_SIZE, MAX_VIRTUAL_SIZE);
|
||||
width % 2 == 0
|
||||
&& height % 2 == 0
|
||||
&& (min.0..=max.0).contains(&width)
|
||||
&& (min.1..=max.1).contains(&height)
|
||||
}
|
||||
|
||||
/// A simple BCP 47 language code: language, then alphanumeric subtags (`fr`,
|
||||
/// `pt-BR`, `zh-Hant`). Enough to name a file, nothing that leaves the
|
||||
/// `locales` directory.
|
||||
@@ -697,6 +736,8 @@ mod tests {
|
||||
added_ms: 0,
|
||||
}],
|
||||
aliases: Vec::new(),
|
||||
virtual_size: DEFAULT_VIRTUAL_SIZE,
|
||||
test_pattern: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -961,4 +1002,21 @@ mod media_port_tests {
|
||||
assert_eq!(rejections[0].field, "media_port");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_virtual_size_is_even_and_within_bounds() {
|
||||
for size in [(1280, 800), (2048, 1536), (640, 480), (7680, 4320)] {
|
||||
assert!(is_virtual_size(size), "{size:?}");
|
||||
}
|
||||
for size in [(1281, 800), (1280, 801), (320, 240), (8192, 4320), (0, 0)] {
|
||||
let settings = Settings {
|
||||
virtual_size: size,
|
||||
..Settings::default()
|
||||
};
|
||||
let rejections = settings.validate();
|
||||
assert_eq!(rejections.len(), 1, "{size:?}: {rejections:?}");
|
||||
assert_eq!(rejections[0].field, "virtual_size");
|
||||
assert_eq!(rejections[0].message.code, "virtual_size_range");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ bureau, et à quelle étape d'une session les choses se sont arrêtées.
|
||||
|
||||
## Exporter
|
||||
|
||||
- Depuis la fenêtre: **Réglages → Exporter les diagnostics**. L'archive est écrite dans le dossier
|
||||
- Depuis la fenêtre: **Réglages**, section **Débogage**, **Exporter les diagnostics**. L'archive est écrite dans le dossier
|
||||
Téléchargements et son chemin s'affiche.
|
||||
- En ligne de commande: `rustscreen-cli --diagnostics`.
|
||||
|
||||
|
||||
+5
-2
@@ -51,8 +51,11 @@ partage de connexion du téléphone.
|
||||
## Je veux que la tablette soit un second écran, pas une copie
|
||||
|
||||
Choisir **Un second écran (virtuel)** dans la liste des sources: le bureau crée un écran qui
|
||||
n'existe pas physiquement, à la taille choisie, et la tablette l'affiche. Disponible sous GNOME 46
|
||||
et KDE Plasma sous Wayland. Ailleurs, la fenêtre dit que ce bureau ne sait pas le faire; un
|
||||
n'existe pas physiquement, et la tablette l'affiche. Sa taille se choisit juste sous la liste:
|
||||
une résolution courante de tablette ou d'écran, ou **Autre taille…** pour taper celle de votre
|
||||
appareil (largeur et hauteur paires). Elle est retenue pour la fois suivante. En plein partage,
|
||||
**Changer de source** puis **Partager cette source** recrée l'écran à la nouvelle taille sans
|
||||
déconnecter la tablette. Disponible sous GNOME 46 et KDE Plasma sous Wayland. Ailleurs, la fenêtre dit que ce bureau ne sait pas le faire; un
|
||||
adaptateur HDMI « factice » branché sur l'ordinateur crée alors un vrai second écran à partager.
|
||||
|
||||
## L'image est saccadée ou floue
|
||||
|
||||
+7
-1
@@ -9,7 +9,13 @@ est un choix: il dit ce que voit l'utilisateur, pas seulement ce que fait le cod
|
||||
| --- | --- | --- |
|
||||
| X11 | chaque moniteur RandR (le principal en tête), puis « Tous les écrans », puis chaque fenêtre | oui |
|
||||
| Wayland | « Un écran », et « Un second écran (virtuel) » si le portail l'annonce | non |
|
||||
| toutes | la mire de test | oui |
|
||||
| toutes | la mire de test, si **Réglages → Débogage** la propose (#91) | oui |
|
||||
|
||||
La mire de test n'est plus proposée par défaut: c'est un outil de vérification, pas une source
|
||||
d'usage courant. `rustscreen-cli --synthetic` la démarre toujours, et `--list` la montre.
|
||||
|
||||
L'écran virtuel prend la taille du réglage `virtual_size` (1920 × 1080 par défaut, #89), choisie
|
||||
sous la liste des sources. Un `SourceChoice` d'écran virtuel sans taille reçoit celle du réglage.
|
||||
|
||||
Sous Wayland, l'application ne peut ni lister les écrans ni en prendre une image avant l'accord de
|
||||
l'utilisateur: c'est le sélecteur du bureau qui montre les trois moniteurs et fait choisir. Le
|
||||
|
||||
@@ -37,7 +37,8 @@ Le chemin retenu est **le portail lui-même** (ADR 0009): `SelectSources` avec l
|
||||
(4) demande au compositeur de créer une sortie qui n'existe pas, et rend son flux PipeWire comme
|
||||
pour un moniteur. Aucun droit particulier, aucun pilote, et la même capture que pour un écran réel.
|
||||
Le compositeur prend la résolution que fixe le consommateur: `rustscreen-cli --virtual --size 1280x800`
|
||||
crée un écran à la taille de la tablette.
|
||||
crée un écran à la taille de la tablette, et l'application de bureau la fait choisir sous la liste
|
||||
des sources (réglage `virtual_size`, #89).
|
||||
|
||||
La décision se prend à l'exécution, d'après la propriété `AvailableSourceTypes` du portail, pas
|
||||
d'après le nom du bureau:
|
||||
@@ -98,9 +99,9 @@ Deux conséquences :
|
||||
|
||||
En attendant, trois choses servent directement le cas d'usage et ne demandent aucun pilote :
|
||||
|
||||
- **Adapter le flux au format de la tablette.** Aujourd'hui la résolution est fixée au lancement,
|
||||
quel que soit le spectateur. Une tablette en 4:3 ou en portrait reçoit du 16:9 avec des bandes
|
||||
noires, et paie le décodage de pixels inutiles.
|
||||
- **Adapter le flux au format de la tablette.** La taille de l'écran virtuel se choisit à la main
|
||||
(#89), mais rien ne la déduit encore du spectateur. Une tablette en 4:3 ou en portrait qui reçoit
|
||||
du 16:9 affiche des bandes noires, et paie le décodage de pixels inutiles.
|
||||
- **Soigner la lisibilité du texte.** Résolution native, débit adapté, images clés plus fréquentes:
|
||||
sur du texte, une compression agressive se voit immédiatement.
|
||||
- **Reprendre après la mise en veille.** Une tablette s'endort en permanence. La reconnexion existe
|
||||
|
||||
+13
-2
@@ -301,7 +301,18 @@
|
||||
"pending_media_port": "media ports: those of connected viewers stay open until the next share",
|
||||
"hardware_fallback": "Hardware encoding unavailable, {codec} is encoded by the processor: {detail}",
|
||||
"codec_lost": "The new capture cannot be encoded as {codec}: the share keeps its source.",
|
||||
"pending_hardware_encoding": "hardware encoding: the encoder of the current share stays until the next one"
|
||||
}
|
||||
"pending_hardware_encoding": "hardware encoding: the encoder of the current share stays until the next one",
|
||||
"virtual_size_range": "Even width and height, from {min} to {max}."
|
||||
},
|
||||
"debug": "Debugging",
|
||||
"testPattern": "Offer the test pattern among the sources",
|
||||
"testPatternHelp": "A generated image, without a screen: to check the connection and measure latency.",
|
||||
"virtualSize": "Virtual screen size",
|
||||
"virtualSizeCustom": "Other size…",
|
||||
"virtualWidth": "Width",
|
||||
"virtualHeight": "Height",
|
||||
"virtualSizeHelp": "Pick the resolution of the tablet. While sharing, it applies at the next \"Share this source\".",
|
||||
"virtualSizeInvalid": "Even width and height, from 640 × 480 to 7680 × 4320.",
|
||||
"apply": "Apply"
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -301,7 +301,18 @@
|
||||
"pending_media_port": "ports du média : ceux des spectateurs connectés restent ouverts jusqu'au prochain partage",
|
||||
"hardware_fallback": "Encodage matériel indisponible, {codec} est encodé par le processeur : {detail}",
|
||||
"codec_lost": "La nouvelle capture ne peut pas être encodée en {codec} : le partage garde sa source.",
|
||||
"pending_hardware_encoding": "encodage matériel : l'encodeur du partage en cours reste jusqu'au suivant"
|
||||
}
|
||||
"pending_hardware_encoding": "encodage matériel : l'encodeur du partage en cours reste jusqu'au suivant",
|
||||
"virtual_size_range": "Largeur et hauteur paires, de {min} à {max}."
|
||||
},
|
||||
"debug": "Débogage",
|
||||
"testPattern": "Proposer la mire de test parmi les sources",
|
||||
"testPatternHelp": "Une image générée, sans écran : pour vérifier la connexion et mesurer la latence.",
|
||||
"virtualSize": "Taille de l'écran virtuel",
|
||||
"virtualSizeCustom": "Autre taille…",
|
||||
"virtualWidth": "Largeur",
|
||||
"virtualHeight": "Hauteur",
|
||||
"virtualSizeHelp": "Choisissez la résolution de la tablette. En plein partage, elle s'applique au prochain « Partager cette source ».",
|
||||
"virtualSizeInvalid": "Largeur et hauteur paires, de 640 × 480 à 7680 × 4320.",
|
||||
"apply": "Appliquer"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user