Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make window decorations optional and use a better CSD on Wayland #395

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 74 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ categories = ["gui"]
[features]
default = ["wayland", "x11"]
x11 = ["copypasta/x11", "winit/x11"]
wayland = ["copypasta/wayland", "winit/wayland"]
wayland = ["copypasta/wayland", "winit/wayland", "winit/wayland-csd-adwaita"]

[dependencies]
# `anstream` and `anstyle` are both terminal helper crates used for our custom
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ impl Inlyne {
let window = {
let mut wb = WindowBuilder::new().with_title(utils::format_title(&file_path));

if let Some(decorations) = opts.decorations {
wb = wb.with_decorations(decorations);
}
if let Some(ref pos) = opts.position {
wb = wb.with_position(winit::dpi::PhysicalPosition::new(pos.x, pos.y));
}
Expand Down
4 changes: 4 additions & 0 deletions src/opts/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ pub struct View {
#[arg(short = 't', long = "theme", value_parser = value_parser!(ThemeType))]
pub theme: Option<ThemeType>,

/// Enable decorations
#[arg(short = 'd', long = "decorations")]
pub decorations: Option<bool>,

/// Factor to scale rendered file by [default: OS defined window scale factor]
#[arg(short = 's', long = "scale")]
pub scale: Option<f32>,
Expand Down
1 change: 1 addition & 0 deletions src/opts/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub struct Window {
#[serde(default, rename_all = "kebab-case")]
pub struct Config {
pub theme: Option<ThemeType>,
pub decorations: Option<bool>,
pub scale: Option<f32>,
pub page_width: Option<f32>,
pub lines_to_scroll: LinesToScroll,
Expand Down
5 changes: 5 additions & 0 deletions src/opts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct Opts {
pub history: History,
#[debug(skip)]
pub theme: color::Theme,
pub decorations: Option<bool>,
pub scale: Option<f32>,
pub page_width: Option<f32>,
pub lines_to_scroll: f32,
Expand Down Expand Up @@ -101,6 +102,7 @@ impl Opts {
) -> Result<Self> {
let Config {
theme: config_theme,
decorations: config_decorations,
scale: config_scale,
page_width: config_page_width,
lines_to_scroll,
Expand All @@ -115,6 +117,7 @@ impl Opts {
let View {
file_path,
theme: args_theme,
decorations,
scale: args_scale,
config: _,
page_width: args_page_width,
Expand Down Expand Up @@ -146,6 +149,7 @@ impl Opts {
}
};

let decorations = decorations.or(config_decorations);
let scale = args_scale.or(config_scale);
let font_opts = font_options.unwrap_or_default();
let page_width = args_page_width.or(config_page_width);
Expand All @@ -160,6 +164,7 @@ impl Opts {
Ok(Self {
history,
theme,
decorations,
scale,
page_width,
lines_to_scroll,
Expand Down
1 change: 1 addition & 0 deletions src/opts/tests/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl Opts {
Self {
history: History::new(file_path.as_ref()).unwrap(),
theme: ResolvedTheme::Light.as_theme(),
decorations: None,
scale: None,
page_width: None,
font_opts: FontOptions::default(),
Expand Down
Loading