jay_config/xwayland.rs
1//! Tools for configuring Xwayland.
2
3use serde::{Deserialize, Serialize};
4
5/// The scaling mode of X windows.
6#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
7pub struct XScalingMode(pub u32);
8
9impl XScalingMode {
10 /// The default mode.
11 ///
12 /// Currently this means that windows are rendered at the lowest scale and then
13 /// upscaled if necessary.
14 pub const DEFAULT: Self = Self(0);
15 /// Windows are rendered at the highest integer scale and then downscaled.
16 ///
17 /// This has significant performance implications unless the window is running on the
18 /// output with the highest scale and that scale is an integer scale.
19 ///
20 /// For example, on a 3840x2160 output with a 1.5 scale, a fullscreen window will be
21 /// rendered at 3840x2160 * 2 / 1.5 = 5120x2880 pixels and then downscaled to
22 /// 3840x2160. This overhead gets worse the lower the scale of the output is.
23 ///
24 /// Additionally, this mode requires the X window to scale its contents itself. In the
25 /// example above, you might achieve this by setting the environment variable
26 /// `GDK_SCALE=2`.
27 pub const DOWNSCALED: Self = Self(1);
28}
29
30/// Sets the scaling mode for X windows.
31pub fn set_x_scaling_mode(mode: XScalingMode) {
32 get!().set_x_scaling_mode(mode)
33}