Skip to content

Commit

Permalink
chore: tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Aug 6, 2024
1 parent 5e09639 commit 927901b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
12 changes: 7 additions & 5 deletions iced_examples/counter_muti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use iced_layershell::actions::{
use iced_runtime::command::Action;
use iced_runtime::window::Action as WindowAction;

use iced_layershell::reexport::{Anchor, Layer, NewLayerShellSettings};
use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings};
use iced_layershell::settings::{LayerShellSettings, Settings};
use iced_layershell::MultiApplication;
pub fn main() -> Result<(), iced_layershell::Error> {
Expand Down Expand Up @@ -189,10 +189,11 @@ impl MultiApplication for Counter {
LayershellCustomActionsWithInfo::NewLayerShell((
NewLayerShellSettings {
size: Some((100, 100)),
exclude_zone: None,
exclusize_zone: None,
anchor: Anchor::Left | Anchor::Bottom,
layer: Layer::Top,
margin: None,
margins: None,
keyboard_interactivity: KeyboardInteractivity::None,
},
WindowInfo::Left,
)),
Expand All @@ -205,10 +206,11 @@ impl MultiApplication for Counter {
LayershellCustomActionsWithInfo::NewLayerShell((
NewLayerShellSettings {
size: Some((100, 100)),
exclude_zone: None,
exclusize_zone: None,
anchor: Anchor::Right | Anchor::Bottom,
layer: Layer::Top,
margin: None,
margins: None,
keyboard_interactivity: KeyboardInteractivity::None,
},
WindowInfo::Right,
)),
Expand Down
20 changes: 17 additions & 3 deletions layershellev/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use wayland_protocols_wlr::layer_shell::v1::client::{
zwlr_layer_shell_v1::Layer, zwlr_layer_surface_v1::Anchor,
zwlr_layer_shell_v1::Layer,
zwlr_layer_surface_v1::{Anchor, KeyboardInteractivity},
};

use wayland_client::{
Expand Down Expand Up @@ -55,10 +56,23 @@ pub struct NewLayerShellSettings {
pub size: Option<(u32, u32)>,
pub layer: Layer,
pub anchor: Anchor,
pub exclude_zone: Option<i32>,
pub margin: Option<(i32, i32, i32, i32)>,
pub exclusize_zone: Option<i32>,
pub margins: Option<(i32, i32, i32, i32)>,
pub keyboard_interactivity: KeyboardInteractivity,
}

impl Default for NewLayerShellSettings {
fn default() -> Self {
NewLayerShellSettings {
anchor: Anchor::Bottom | Anchor::Left | Anchor::Right,
layer: Layer::Top,
exclusize_zone: None,
size: None,
margins: Some((0, 0, 0, 0)),
keyboard_interactivity: KeyboardInteractivity::OnDemand,
}
}
}
/// the return data
/// Note: when event is RequestBuffer, you must return WlBuffer
/// Note: when receive InitRequest, you can request to bind extra wayland-protocols. this time you
Expand Down
7 changes: 4 additions & 3 deletions layershellev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1767,8 +1767,9 @@ impl<T: Debug + 'static, INFO: 'static + Clone> WindowState<T, INFO> {
size,
layer,
anchor,
exclude_zone: exclusive_zone,
margin,
exclusize_zone: exclusive_zone,
margins: margin,
keyboard_interactivity
},
info,
)) => {
Expand All @@ -1791,7 +1792,7 @@ impl<T: Debug + 'static, INFO: 'static + Clone> WindowState<T, INFO> {
(),
);
layer.set_anchor(anchor);
layer.set_keyboard_interactivity(self.keyboard_interactivity);
layer.set_keyboard_interactivity(keyboard_interactivity);
if let Some((init_w, init_h)) = size {
layer.set_size(init_w, init_h);
}
Expand Down

0 comments on commit 927901b

Please sign in to comment.