Skip to content

Commit 2f0772b

Browse files
committed
Improve documentation and refactor some code
1 parent 20c2713 commit 2f0772b

File tree

3 files changed

+133
-105
lines changed

3 files changed

+133
-105
lines changed

src/monitor.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ impl std::fmt::Display for VideoModeHandle {
9898
///
9999
/// Allows you to retrieve information about a given monitor and can be used in [`Window`] creation.
100100
///
101+
/// ## Platform-specific
102+
///
103+
/// **Web:** A [`MonitorHandle`] created without
104+
#[cfg_attr(
105+
any(web_platform, docsrs),
106+
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
107+
)]
108+
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
109+
/// will always represent the current monitor the browser window is in instead of a specific
110+
/// monitor. See
111+
#[cfg_attr(
112+
any(web_platform, docsrs),
113+
doc = "[`MonitorHandleExtWeb::is_detailed()`][crate::platform::web::MonitorHandleExtWeb::is_detailed]"
114+
)]
115+
#[cfg_attr(not(any(web_platform, docsrs)), doc = "`MonitorHandleExtWeb::is_detailed()`")]
116+
/// to check.
117+
///
101118
/// [`Window`]: crate::window::Window
102119
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
103120
pub struct MonitorHandle {

src/platform/web.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,26 @@ pub trait EventLoopExtWeb {
226226
/// [`ControlFlow::WaitUntil`]: crate::event_loop::ControlFlow::WaitUntil
227227
fn wait_until_strategy(&self) -> WaitUntilStrategy;
228228

229-
/// Returns if the users device has multiple screens.
229+
/// Returns if the users device has multiple screens. Useful to check before prompting the user
230+
/// with [`EventLoopExtWeb::request_detailed_monitor_permission()`].
230231
///
231232
/// Browsers might always return [`false`] to reduce fingerprinting.
232233
fn has_multiple_screens(&self) -> Result<bool, NotSupportedError>;
233234

234235
/// Prompts the user for permission to query detailed information about available monitors. The
235236
/// returned [`MonitorPermissionFuture`] can be dropped without aborting the request.
236237
///
238+
/// Check [`EventLoopExtWeb::has_multiple_screens()`] before unnecessarily prompting the user
239+
/// for such permissions.
240+
///
237241
/// [`MonitorHandle`]s don't automatically make use of this after permission is granted. New
238242
/// [`MonitorHandle`]s have to be created instead.
239243
fn request_detailed_monitor_permission(&self) -> MonitorPermissionFuture;
240244

241245
/// Returns whether the user has given permission to access detailed monitor information.
246+
///
247+
/// [`MonitorHandle`]s don't automatically make use of detailed monitor information after
248+
/// permission is granted. New [`MonitorHandle`]s have to be created instead.
242249
fn has_detailed_monitor_permission(&self) -> HasMonitorPermissionFuture;
243250
}
244251

@@ -314,22 +321,26 @@ pub trait ActiveEventLoopExtWeb {
314321
/// [`CursorGrabMode::Locked`]: crate::window::CursorGrabMode::Locked
315322
fn is_cursor_lock_raw(&self) -> bool;
316323

317-
/// Returns if the users device has multiple screens.
324+
/// Returns if the users device has multiple screens. Useful to check before prompting the user
325+
/// with [`EventLoopExtWeb::request_detailed_monitor_permission()`].
318326
///
319327
/// Browsers might always return [`false`] to reduce fingerprinting.
320328
fn has_multiple_screens(&self) -> Result<bool, NotSupportedError>;
321329

322330
/// Prompts the user for permission to query detailed information about available monitors. The
323331
/// returned [`MonitorPermissionFuture`] can be dropped without aborting the request.
324332
///
333+
/// Check [`EventLoopExtWeb::has_multiple_screens()`] before unnecessarily prompting the user
334+
/// for such permissions.
335+
///
325336
/// [`MonitorHandle`]s don't automatically make use of this after permission is granted. New
326337
/// [`MonitorHandle`]s have to be created instead.
327338
fn request_detailed_monitor_permission(&self) -> MonitorPermissionFuture;
328339

329340
/// Returns whether the user has given permission to access detailed monitor information.
330341
///
331-
/// [`MonitorHandle`]s don't automatically make use of this after permission is granted. New
332-
/// [`MonitorHandle`]s have to be created instead.
342+
/// [`MonitorHandle`]s don't automatically make use of detailed monitor information after
343+
/// permission is granted. New [`MonitorHandle`]s have to be created instead.
333344
fn has_detailed_monitor_permission(&self) -> bool;
334345
}
335346

@@ -608,7 +619,9 @@ pub trait MonitorHandleExtWeb {
608619
/// Will fail if a locking call is in progress.
609620
fn unlock(&self) -> Result<(), OrientationLockError>;
610621

611-
/// Returns whether this [`MonitorHandle`] was created using detailed monitor permissions.
622+
/// Returns whether this [`MonitorHandle`] was created using detailed monitor permissions. If
623+
/// [`false`] will always represent the current monitor the browser window is in instead of a
624+
/// specific monitor.
612625
///
613626
/// See [`ActiveEventLoop::request_detailed_monitor_permission()`].
614627
fn is_detailed(&self) -> bool;

0 commit comments

Comments
 (0)