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

feat: add subscriber for wayland #86

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
130 changes: 15 additions & 115 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"iced_layershell_macros",
"iced_sessionlock",
"iced_sessionlock_macros",
"starcolorkeyboard",
"iced_wayland_subscriber",
"sessionlockev",
"waycrate_xkbkeycode",
"iced_examples/*",
Expand All @@ -28,6 +28,7 @@ readme = "README.md"
[workspace.dependencies]
layershellev = { version = "0.9.7", path = "./layershellev" }
sessionlockev = { version = "0.9.7", path = "./sessionlockev" }
iced_wayland_subscriber = { version = "0.9.7", path = "./iced_wayland_subscriber" }

iced_layershell = { version = "0.9.7", path = "./iced_layershell" }
iced_layershell_macros = { version = "0.9.7", path = "./iced_layershell_macros" }
Expand Down Expand Up @@ -79,7 +80,7 @@ bitflags = "2.6.0"
log = "0.4.22"

xkbcommon-dl = "0.4.2"
smol_str = "0.2.2" #NOTE: follow iced
smol_str = "0.2.2" #NOTE: follow iced
memmap2 = "0.9.5"

tracing = "0.1.40"
Expand Down
2 changes: 2 additions & 0 deletions iced_examples/counter_muti/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ readme.workspace = true
iced.workspace = true
iced_runtime.workspace = true
iced_layershell.workspace = true

iced_wayland_subscriber.workspace = true
35 changes: 31 additions & 4 deletions iced_examples/counter_muti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ use iced_layershell::actions::{IcedNewMenuSettings, MenuDirection};
use iced_runtime::window::Action as WindowAction;
use iced_runtime::{task, Action};

use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings};
use iced_layershell::reexport::{
Anchor, KeyboardInteractivity, Layer, LayerOutputSetting, NewLayerShellSettings,
};
use iced_layershell::settings::{LayerShellSettings, Settings, StartMode};
use iced_layershell::to_layer_message;
use iced_layershell::MultiApplication;

use iced_wayland_subscriber::WaylandEvents;

pub fn main() -> Result<(), iced_layershell::Error> {
Counter::run(Settings {
layer_settings: LayerShellSettings {
Expand All @@ -36,6 +40,7 @@ enum WindowInfo {
Left,
Right,
PopUp,
TopBar,
}

#[derive(Debug, Clone, Copy)]
Expand All @@ -57,6 +62,7 @@ enum Message {
TextInput(String),
Direction(WindowDirection),
IcedEvent(Event),
Wayland(WaylandEvents),
}

impl Counter {
Expand Down Expand Up @@ -105,7 +111,10 @@ impl MultiApplication for Counter {
}

fn subscription(&self) -> iced::Subscription<Self::Message> {
event::listen().map(Message::IcedEvent)
iced::Subscription::batch([
event::listen().map(Message::IcedEvent),
iced_wayland_subscriber::listen().map(Message::Wayland),
])
}

fn update(&mut self, message: Message) -> Command<Message> {
Expand Down Expand Up @@ -180,7 +189,7 @@ impl MultiApplication for Counter {
layer: Layer::Top,
margin: None,
keyboard_interactivity: KeyboardInteractivity::Exclusive,
use_last_output: false,
output_setting: LayerOutputSetting::None,
..Default::default()
},
info: WindowInfo::Left,
Expand All @@ -193,12 +202,27 @@ impl MultiApplication for Counter {
layer: Layer::Top,
margin: None,
keyboard_interactivity: KeyboardInteractivity::Exclusive,
use_last_output: false,
output_setting: LayerOutputSetting::None,
..Default::default()
},
info: WindowInfo::Right,
}),
Message::Close(id) => task::effect(Action::Window(WindowAction::Close(id))),
Message::Wayland(WaylandEvents::OutputInsert(output)) => {
Command::done(Message::NewLayerShell {
settings: NewLayerShellSettings {
size: Some((0, 20)),
exclusive_zone: Some(20),
anchor: Anchor::Top | Anchor::Right | Anchor::Left,
layer: Layer::Top,
margin: None,
keyboard_interactivity: KeyboardInteractivity::None,
output_setting: LayerOutputSetting::ChosenOutput(output),
..Default::default()
},
info: WindowInfo::TopBar,
})
}
_ => unreachable!(),
}
}
Expand All @@ -210,6 +234,9 @@ impl MultiApplication for Counter {
if let Some(WindowInfo::Right) = self.id_info(id) {
return button("close right").on_press(Message::Close(id)).into();
}
if let Some(WindowInfo::TopBar) = self.id_info(id) {
return text("hello here is topbar").into();
}
if let Some(WindowInfo::PopUp) = self.id_info(id) {
return container(button("close PopUp").on_press(Message::Close(id)))
.center_x(Length::Fill)
Expand Down
6 changes: 4 additions & 2 deletions iced_examples/zbus_invoked_widget/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use iced_layershell::actions::{
use iced_runtime::window::Action as WindowAction;
use iced_runtime::Action;

use iced_layershell::reexport::{Anchor, KeyboardInteractivity, Layer, NewLayerShellSettings};
use iced_layershell::reexport::{
Anchor, KeyboardInteractivity, Layer, LayerOutputSetting, NewLayerShellSettings,
};
use iced_layershell::settings::{LayerShellSettings, Settings, StartMode};
use iced_layershell::MultiApplication;
use zbus::{connection, interface};
Expand Down Expand Up @@ -53,7 +55,7 @@ impl TryInto<LaLaShellIdAction> for Message {
layer: Layer::Top,
margin: Some((100, 100, 100, 100)),
keyboard_interactivity: KeyboardInteractivity::OnDemand,
use_last_output: false,
output_setting: LayerOutputSetting::None,
..Default::default()
},
(),
Expand Down
6 changes: 3 additions & 3 deletions iced_layershell/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct IcedNewMenuSettings {
pub direction: MenuDirection,
}

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub enum LayershellCustomActionsWithInfo<INFO: Clone> {
AnchorChange(Anchor),
LayerChange(Layer),
Expand All @@ -55,7 +55,7 @@ pub enum LayershellCustomActionsWithInfo<INFO: Clone> {

pub type LayershellCustomActions = LayershellCustomActionsWithInfo<()>;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub struct LayershellCustomActionsWithIdAndInfo<INFO: Clone>(
pub Option<IcedId>,
pub LayershellCustomActionsWithInfo<INFO>,
Expand All @@ -70,7 +70,7 @@ impl<INFO: Clone> LayershellCustomActionsWithIdAndInfo<INFO> {
pub type LayershellCustomActionsWithId = LayershellCustomActionsWithIdAndInfo<()>;

// first one means
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub(crate) struct LayershellCustomActionsWithIdInner<INFO: Clone>(
pub Option<LayerId>, // come from
pub Option<LayerId>, // target if has one
Expand Down
1 change: 1 addition & 0 deletions iced_layershell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod reexport {
pub use layershellev::reexport::Anchor;
pub use layershellev::reexport::KeyboardInteractivity;
pub use layershellev::reexport::Layer;
pub use layershellev::LayerOutputSetting;
pub use layershellev::NewLayerShellSettings;
}

Expand Down
1 change: 1 addition & 0 deletions iced_wayland_subscriber/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading