Skip to content

Commit

Permalink
Fixes elkowar#608 make exclusive more configurable on wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
viandoxdev committed Oct 29, 2022
1 parent 964cafc commit c33a8dd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
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! { "window type", 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

0 comments on commit c33a8dd

Please sign in to comment.