Skip to content

Commit 13fe005

Browse files
committed
feat: add subscriber for wayland
This pr add a new crate to support listen to the addon of output. and allow new layershell be add to target output
1 parent 0cb7a19 commit 13fe005

File tree

13 files changed

+841
-143
lines changed

13 files changed

+841
-143
lines changed

Cargo.lock

Lines changed: 20 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66
"iced_layershell_macros",
77
"iced_sessionlock",
88
"iced_sessionlock_macros",
9-
"starcolorkeyboard",
9+
"iced_wayland_subscriber",
1010
"sessionlockev",
1111
"waycrate_xkbkeycode",
1212
"iced_examples/*",
@@ -28,6 +28,7 @@ readme = "README.md"
2828
[workspace.dependencies]
2929
layershellev = { version = "0.9.6", path = "./layershellev" }
3030
sessionlockev = { version = "0.9.6", path = "./sessionlockev" }
31+
iced_wayland_subscriber = { version = "0.9.6", path = "./iced_wayland_subscriber" }
3132

3233
iced_layershell = { version = "0.9.6", path = "./iced_layershell" }
3334
iced_layershell_macros = { version = "0.9.6", path = "./iced_layershell_macros" }
@@ -79,7 +80,7 @@ bitflags = "2.6.0"
7980
log = "0.4.22"
8081

8182
xkbcommon-dl = "0.4.2"
82-
smol_str = "0.2.2" #NOTE: follow iced
83+
smol_str = "0.2.2" #NOTE: follow iced
8384
memmap2 = "0.9.5"
8485

8586
tracing = "0.1.40"

iced_examples/counter_muti/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ readme.workspace = true
1515
iced.workspace = true
1616
iced_runtime.workspace = true
1717
iced_layershell.workspace = true
18+
19+
iced_wayland_subscriber.workspace = true

iced_examples/counter_muti/src/main.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ use iced_layershell::actions::{IcedNewMenuSettings, MenuDirection};
77
use iced_runtime::window::Action as WindowAction;
88
use iced_runtime::{task, Action};
99

10-
use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings};
10+
use iced_layershell::reexport::{
11+
Anchor, KeyboardInteractivity, Layer, LayerOutputSetting, NewLayerShellSettings,
12+
};
1113
use iced_layershell::settings::{LayerShellSettings, Settings, StartMode};
1214
use iced_layershell::to_layer_message;
1315
use iced_layershell::MultiApplication;
1416

17+
use iced_wayland_subscriber::WaylandEvents;
18+
1519
pub fn main() -> Result<(), iced_layershell::Error> {
1620
Counter::run(Settings {
1721
layer_settings: LayerShellSettings {
@@ -57,6 +61,7 @@ enum Message {
5761
TextInput(String),
5862
Direction(WindowDirection),
5963
IcedEvent(Event),
64+
Wayland(WaylandEvents),
6065
}
6166

6267
impl Counter {
@@ -105,7 +110,10 @@ impl MultiApplication for Counter {
105110
}
106111

107112
fn subscription(&self) -> iced::Subscription<Self::Message> {
108-
event::listen().map(Message::IcedEvent)
113+
iced::Subscription::batch([
114+
event::listen().map(Message::IcedEvent),
115+
iced_wayland_subscriber::listen().map(Message::Wayland),
116+
])
109117
}
110118

111119
fn update(&mut self, message: Message) -> Command<Message> {
@@ -180,7 +188,7 @@ impl MultiApplication for Counter {
180188
layer: Layer::Top,
181189
margin: None,
182190
keyboard_interactivity: KeyboardInteractivity::Exclusive,
183-
use_last_output: false,
191+
output_setting: LayerOutputSetting::None,
184192
},
185193
info: WindowInfo::Left,
186194
}),
@@ -192,11 +200,15 @@ impl MultiApplication for Counter {
192200
layer: Layer::Top,
193201
margin: None,
194202
keyboard_interactivity: KeyboardInteractivity::Exclusive,
195-
use_last_output: false,
203+
output_setting: LayerOutputSetting::None,
196204
},
197205
info: WindowInfo::Right,
198206
}),
199207
Message::Close(id) => task::effect(Action::Window(WindowAction::Close(id))),
208+
Message::Wayland(ev) => {
209+
println!("wayland events: {ev:?}");
210+
Command::none()
211+
}
200212
_ => unreachable!(),
201213
}
202214
}

iced_examples/zbus_invoked_widget/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use iced_layershell::actions::{
88
use iced_runtime::window::Action as WindowAction;
99
use iced_runtime::Action;
1010

11-
use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings};
11+
use iced_layershell::reexport::{
12+
Anchor, KeyboardInteractivity, Layer, LayerOutputSetting, NewLayerShellSettings,
13+
};
1214
use iced_layershell::settings::{LayerShellSettings, Settings, StartMode};
1315
use iced_layershell::MultiApplication;
1416
use zbus::{connection, interface};
@@ -53,7 +55,7 @@ impl TryInto<LaLaShellIdAction> for Message {
5355
layer: Layer::Top,
5456
margin: Some((100, 100, 100, 100)),
5557
keyboard_interactivity: KeyboardInteractivity::OnDemand,
56-
use_last_output: false,
58+
output_setting: LayerOutputSetting::None,
5759
},
5860
(),
5961
)),

iced_layershell/src/actions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct IcedNewMenuSettings {
3434
pub direction: MenuDirection,
3535
}
3636

37-
#[derive(Debug, Clone, Copy)]
37+
#[derive(Debug, Clone)]
3838
pub enum LayershellCustomActionsWithInfo<INFO: Clone> {
3939
AnchorChange(Anchor),
4040
LayerChange(Layer),
@@ -55,7 +55,7 @@ pub enum LayershellCustomActionsWithInfo<INFO: Clone> {
5555

5656
pub type LayershellCustomActions = LayershellCustomActionsWithInfo<()>;
5757

58-
#[derive(Debug, Clone, Copy)]
58+
#[derive(Debug, Clone)]
5959
pub struct LayershellCustomActionsWithIdAndInfo<INFO: Clone>(
6060
pub Option<IcedId>,
6161
pub LayershellCustomActionsWithInfo<INFO>,
@@ -70,7 +70,7 @@ impl<INFO: Clone> LayershellCustomActionsWithIdAndInfo<INFO> {
7070
pub type LayershellCustomActionsWithId = LayershellCustomActionsWithIdAndInfo<()>;
7171

7272
// first one means
73-
#[derive(Debug, Clone, Copy)]
73+
#[derive(Debug, Clone)]
7474
pub(crate) struct LayershellCustomActionsWithIdInner<INFO: Clone>(
7575
pub Option<LayerId>, // come from
7676
pub Option<LayerId>, // target if has one

iced_layershell/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod reexport {
1616
pub use layershellev::reexport::Anchor;
1717
pub use layershellev::reexport::KeyboardInteractivity;
1818
pub use layershellev::reexport::Layer;
19+
pub use layershellev::LayerOutputSetting;
1920
pub use layershellev::NewLayerShellSettings;
2021
}
2122

iced_wayland_subscriber/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)