Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixes #608 make exclusive more configurable on wayland #609

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions crates/eww/src/display_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod platform {
use gdk;
use gtk::prelude::*;
use yuck::config::{
backend_window_options::ExclusiveZone,
window_definition::{WindowDefinition, WindowStacking},
window_geometry::AnchorAlignment,
};
Expand Down Expand Up @@ -84,9 +85,12 @@ mod platform {
gtk_layer_shell::set_margin(&window, gtk_layer_shell::Edge::Top, yoffset);
}
}
if window_def.backend_options.exclusive {
gtk_layer_shell::auto_exclusive_zone_enable(&window);
}
match window_def.backend_options.exclusive {
ExclusiveZone::Exclusive => gtk_layer_shell::auto_exclusive_zone_enable(&window),
ExclusiveZone::Ignore => gtk_layer_shell::set_exclusive_zone(&window, -1),
// Normal means using the default value
ExclusiveZone::Normal => {}
};
Some(window)
}
}
Expand Down
23 changes: 21 additions & 2 deletions crates/yuck/src/config/backend_window_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,36 @@ mod backend {
use super::*;
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)]
pub struct BackendWindowOptions {
pub exclusive: bool,
pub exclusive: ExclusiveZone,
pub focusable: bool,
}
impl BackendWindowOptions {
pub fn from_attrs(attrs: &mut Attributes) -> DiagResult<Self> {
Ok(Self {
exclusive: attrs.primitive_optional("exclusive")?.unwrap_or(false),
exclusive: attrs.primitive_optional("exclusive")?.unwrap_or(ExclusiveZone::Normal),
focusable: attrs.primitive_optional("focusable")?.unwrap_or(false),
})
}
}

#[derive(Debug, Clone, PartialEq, Eq, smart_default::SmartDefault, serde::Serialize)]
pub enum ExclusiveZone {
#[default]
Normal,
Ignore,
Exclusive,
}
impl FromStr for ExclusiveZone {
type Err = EnumParseError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
enum_parse! { "exclusive zone", s,
"normal" => Self::Normal,
"ignore" => Self::Ignore,
"exclusive" => Self::Exclusive,
}
}
}
}

#[cfg(not(any(feature = "x11", feature = "wayland")))]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Depending on if you are using X11 or Wayland, some additional properties exist:
| Property | Description |
| ----------: | ------------------------------------------------------------ |
| `stacking` | Where the window should appear in the stack. Possible values: `fg`, `bg`, `overlay`, `bottom`. |
| `exclusive` | Whether the compositor should reserve space for the window automatically. |
| `exclusive` | Specify if the compositor should reserve space for the window automatically or how the window should interact with windows that do. Possible values: `exclusive` (space should be reserved), `normal` (the window should move if occluding another), `ignore` (the window should not be moved). Default: `normal` |
| `focusable` | Whether the window should be able to be focused. This is necessary for any widgets that use the keyboard to work. |


Expand Down