Update libcosmic
This commit is contained in:
parent
8d91f3c4ea
commit
d4d2773715
5 changed files with 682 additions and 580 deletions
1147
Cargo.lock
generated
1147
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -8,11 +8,15 @@ chrono = "0.4.31"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
freedesktop_entry_parser = "1.3.0"
|
freedesktop_entry_parser = "1.3.0"
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
logind-zbus = { version = "3.1.2", optional = true }
|
|
||||||
pam-client = "0.5.0"
|
pam-client = "0.5.0"
|
||||||
pwd = "1.4.0"
|
pwd = "1.4.0"
|
||||||
shlex = "1.2.0"
|
shlex = "1.2.0"
|
||||||
wayland-client = "0.31.1"
|
wayland-client = "0.31.1"
|
||||||
|
# For network status using networkmanager feature
|
||||||
|
cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
|
||||||
|
# For logind integration using logind feature
|
||||||
|
logind-zbus = { version = "3.1.2", optional = true }
|
||||||
|
# Required for some features
|
||||||
zbus = { version = "3.14.1", optional = true }
|
zbus = { version = "3.14.1", optional = true }
|
||||||
|
|
||||||
[dependencies.cosmic-bg-config]
|
[dependencies.cosmic-bg-config]
|
||||||
|
|
@ -35,5 +39,6 @@ version = "1.33.0"
|
||||||
features = ["full"]
|
features = ["full"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["logind"]
|
default = ["logind", "networkmanager"]
|
||||||
logind = ["logind-zbus", "zbus"]
|
logind = ["logind-zbus", "zbus"]
|
||||||
|
networkmanager = ["cosmic-dbus-networkmanager", "zbus"]
|
||||||
|
|
|
||||||
|
|
@ -584,20 +584,24 @@ impl cosmic::Application for App {
|
||||||
match &self.prompt_opt {
|
match &self.prompt_opt {
|
||||||
Some((prompt, secret, value_opt)) => match value_opt {
|
Some((prompt, secret, value_opt)) => match value_opt {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let mut text_input = widget::text_input(&prompt, &value)
|
let mut text_input =
|
||||||
.id(self.text_input_id.clone())
|
widget::text_input(prompt.clone(), value.clone())
|
||||||
.leading_icon(
|
.id(self.text_input_id.clone())
|
||||||
widget::icon::from_name("system-lock-screen-symbolic")
|
.leading_icon(
|
||||||
.into(),
|
widget::icon::from_name("system-lock-screen-symbolic")
|
||||||
)
|
.into(),
|
||||||
.trailing_icon(
|
)
|
||||||
widget::icon::from_name("document-properties-symbolic")
|
.trailing_icon(
|
||||||
.into(),
|
widget::icon::from_name("document-properties-symbolic")
|
||||||
)
|
.into(),
|
||||||
.on_input(|value| {
|
)
|
||||||
Message::Prompt(prompt.clone(), *secret, Some(value))
|
.on_input(|value| {
|
||||||
})
|
Message::Prompt(prompt.clone(), *secret, Some(value))
|
||||||
.on_submit(Message::Auth(socket.clone(), Some(value.clone())));
|
})
|
||||||
|
.on_submit(Message::Auth(
|
||||||
|
socket.clone(),
|
||||||
|
Some(value.clone()),
|
||||||
|
));
|
||||||
|
|
||||||
if *secret {
|
if *secret {
|
||||||
text_input = text_input.password()
|
text_input = text_input.password()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use cosmic::iced::widget::{
|
use cosmic::iced::widget::{
|
||||||
image::{draw, Handle},
|
image::{draw, FilterMethod, Handle},
|
||||||
Container,
|
Container,
|
||||||
};
|
};
|
||||||
use cosmic::iced::ContentFit;
|
use cosmic::iced::ContentFit;
|
||||||
|
|
@ -69,8 +69,13 @@ where
|
||||||
Widget::height(&self.container)
|
Widget::height(&self.container)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node {
|
fn layout(
|
||||||
self.container.layout(renderer, limits)
|
&self,
|
||||||
|
tree: &mut Tree,
|
||||||
|
renderer: &Renderer,
|
||||||
|
limits: &layout::Limits,
|
||||||
|
) -> layout::Node {
|
||||||
|
self.container.layout(tree, renderer, limits)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn operate(
|
fn operate(
|
||||||
|
|
@ -127,6 +132,7 @@ where
|
||||||
layout,
|
layout,
|
||||||
image,
|
image,
|
||||||
self.content_fit,
|
self.content_fit,
|
||||||
|
FilterMethod::Linear,
|
||||||
[0.0, 0.0, 0.0, 0.0],
|
[0.0, 0.0, 0.0, 0.0],
|
||||||
),
|
),
|
||||||
None => {}
|
None => {}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ use cosmic::{
|
||||||
executor,
|
executor,
|
||||||
iced::{
|
iced::{
|
||||||
self, alignment,
|
self, alignment,
|
||||||
event::wayland::{Event as WaylandEvent, OutputEvent, SessionLockEvent},
|
event::{
|
||||||
|
self,
|
||||||
|
wayland::{Event as WaylandEvent, OutputEvent, SessionLockEvent},
|
||||||
|
},
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
subscription,
|
subscription,
|
||||||
wayland::session_lock::{destroy_lock_surface, get_lock_surface, lock, unlock},
|
wayland::session_lock::{destroy_lock_surface, get_lock_surface, lock, unlock},
|
||||||
|
|
@ -87,11 +90,6 @@ pub fn pam_thread(username: String, conversation: Conversation) -> Result<(), pa
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn text_input_id(surface_id: SurfaceId) -> widget::Id {
|
|
||||||
//TODO: store this in a map?
|
|
||||||
widget::Id(iced::id::Internal::Unique(surface_id.0 as u64))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Conversation {
|
pub struct Conversation {
|
||||||
msg_tx: futures::channel::mpsc::Sender<Message>,
|
msg_tx: futures::channel::mpsc::Sender<Message>,
|
||||||
value_rx: mpsc::Receiver<String>,
|
value_rx: mpsc::Receiver<String>,
|
||||||
|
|
@ -207,15 +205,14 @@ pub enum Message {
|
||||||
pub struct App {
|
pub struct App {
|
||||||
core: Core,
|
core: Core,
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
next_surface_id: SurfaceId,
|
|
||||||
surface_ids: HashMap<WlOutput, SurfaceId>,
|
surface_ids: HashMap<WlOutput, SurfaceId>,
|
||||||
active_surface_id_opt: Option<SurfaceId>,
|
active_surface_id_opt: Option<SurfaceId>,
|
||||||
surface_images: HashMap<SurfaceId, widget::image::Handle>,
|
surface_images: HashMap<SurfaceId, widget::image::Handle>,
|
||||||
surface_names: HashMap<SurfaceId, String>,
|
surface_names: HashMap<SurfaceId, String>,
|
||||||
|
text_input_ids: HashMap<SurfaceId, widget::Id>,
|
||||||
value_tx_opt: Option<mpsc::Sender<String>>,
|
value_tx_opt: Option<mpsc::Sender<String>>,
|
||||||
prompt_opt: Option<(String, bool, Option<String>)>,
|
prompt_opt: Option<(String, bool, Option<String>)>,
|
||||||
error_opt: Option<String>,
|
error_opt: Option<String>,
|
||||||
exited: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
|
|
@ -300,15 +297,14 @@ impl cosmic::Application for App {
|
||||||
App {
|
App {
|
||||||
core,
|
core,
|
||||||
flags,
|
flags,
|
||||||
next_surface_id: SurfaceId(1),
|
|
||||||
surface_ids: HashMap::new(),
|
surface_ids: HashMap::new(),
|
||||||
active_surface_id_opt: None,
|
active_surface_id_opt: None,
|
||||||
surface_images: HashMap::new(),
|
surface_images: HashMap::new(),
|
||||||
surface_names: HashMap::new(),
|
surface_names: HashMap::new(),
|
||||||
|
text_input_ids: HashMap::new(),
|
||||||
value_tx_opt: None,
|
value_tx_opt: None,
|
||||||
prompt_opt: None,
|
prompt_opt: None,
|
||||||
error_opt: None,
|
error_opt: None,
|
||||||
exited: false,
|
|
||||||
},
|
},
|
||||||
lock(),
|
lock(),
|
||||||
)
|
)
|
||||||
|
|
@ -323,16 +319,14 @@ impl cosmic::Application for App {
|
||||||
OutputEvent::Created(output_info_opt) => {
|
OutputEvent::Created(output_info_opt) => {
|
||||||
log::info!("output {}: created", output.id());
|
log::info!("output {}: created", output.id());
|
||||||
|
|
||||||
let surface_id = self.next_surface_id;
|
let surface_id = SurfaceId::unique();
|
||||||
self.next_surface_id.0 += 1;
|
|
||||||
|
|
||||||
match self.surface_ids.insert(output.clone(), surface_id) {
|
match self.surface_ids.insert(output.clone(), surface_id) {
|
||||||
Some(old_surface_id) => {
|
Some(old_surface_id) => {
|
||||||
//TODO: remove old surface?
|
//TODO: remove old surface?
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"output {}: already had surface ID {}",
|
"output {}: already had surface ID {:?}",
|
||||||
output.id(),
|
output.id(),
|
||||||
old_surface_id.0
|
old_surface_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
|
|
@ -354,9 +348,13 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let text_input_id = widget::Id::unique();
|
||||||
|
self.text_input_ids
|
||||||
|
.insert(surface_id, text_input_id.clone());
|
||||||
|
|
||||||
return Command::batch([
|
return Command::batch([
|
||||||
get_lock_surface(surface_id, output),
|
get_lock_surface(surface_id, output),
|
||||||
widget::text_input::focus(text_input_id(surface_id)),
|
widget::text_input::focus(text_input_id),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
OutputEvent::Removed => {
|
OutputEvent::Removed => {
|
||||||
|
|
@ -365,6 +363,7 @@ impl cosmic::Application for App {
|
||||||
Some(surface_id) => {
|
Some(surface_id) => {
|
||||||
self.surface_images.remove(&surface_id);
|
self.surface_images.remove(&surface_id);
|
||||||
self.surface_names.remove(&surface_id);
|
self.surface_names.remove(&surface_id);
|
||||||
|
self.text_input_ids.remove(&surface_id);
|
||||||
return destroy_lock_surface(surface_id);
|
return destroy_lock_surface(surface_id);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
@ -379,12 +378,14 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::SessionLockEvent(session_lock_event) => match session_lock_event {
|
Message::SessionLockEvent(session_lock_event) => match session_lock_event {
|
||||||
SessionLockEvent::Focused(_, surface_id) => {
|
SessionLockEvent::Focused(_, surface_id) => {
|
||||||
log::info!("focus surface {}", surface_id.0);
|
log::info!("focus surface {:?}", surface_id);
|
||||||
self.active_surface_id_opt = Some(surface_id);
|
self.active_surface_id_opt = Some(surface_id);
|
||||||
return widget::text_input::focus(text_input_id(surface_id));
|
if let Some(text_input_id) = self.text_input_ids.get(&surface_id) {
|
||||||
|
return widget::text_input::focus(text_input_id.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SessionLockEvent::Unlocked => {
|
SessionLockEvent::Unlocked => {
|
||||||
self.exited = true;
|
return iced::window::close(SurfaceId::MAIN);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
|
@ -401,7 +402,9 @@ impl cosmic::Application for App {
|
||||||
self.prompt_opt = Some((prompt, secret, value_opt));
|
self.prompt_opt = Some((prompt, secret, value_opt));
|
||||||
if prompt_was_none {
|
if prompt_was_none {
|
||||||
if let Some(surface_id) = self.active_surface_id_opt {
|
if let Some(surface_id) = self.active_surface_id_opt {
|
||||||
return widget::text_input::focus(text_input_id(surface_id));
|
if let Some(text_input_id) = self.text_input_ids.get(&surface_id) {
|
||||||
|
return widget::text_input::focus(text_input_id.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -446,6 +449,7 @@ impl cosmic::Application for App {
|
||||||
for (_output, surface_id) in self.surface_ids.drain() {
|
for (_output, surface_id) in self.surface_ids.drain() {
|
||||||
self.surface_images.remove(&surface_id);
|
self.surface_images.remove(&surface_id);
|
||||||
self.surface_names.remove(&surface_id);
|
self.surface_names.remove(&surface_id);
|
||||||
|
self.text_input_ids.remove(&surface_id);
|
||||||
commands.push(destroy_lock_surface(surface_id));
|
commands.push(destroy_lock_surface(surface_id));
|
||||||
}
|
}
|
||||||
commands.push(unlock());
|
commands.push(unlock());
|
||||||
|
|
@ -456,10 +460,6 @@ impl cosmic::Application for App {
|
||||||
Command::none()
|
Command::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_exit(&self) -> bool {
|
|
||||||
self.exited
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not used for layer surface window
|
// Not used for layer surface window
|
||||||
fn view(&self) -> Element<Self::Message> {
|
fn view(&self) -> Element<Self::Message> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
|
@ -565,8 +565,7 @@ impl cosmic::Application for App {
|
||||||
match &self.prompt_opt {
|
match &self.prompt_opt {
|
||||||
Some((prompt, secret, value_opt)) => match value_opt {
|
Some((prompt, secret, value_opt)) => match value_opt {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let mut text_input = widget::text_input(&prompt, &value)
|
let mut text_input = widget::text_input(prompt.clone(), value.clone())
|
||||||
.id(text_input_id(surface_id))
|
|
||||||
.leading_icon(
|
.leading_icon(
|
||||||
widget::icon::from_name("system-lock-screen-symbolic").into(),
|
widget::icon::from_name("system-lock-screen-symbolic").into(),
|
||||||
)
|
)
|
||||||
|
|
@ -576,6 +575,10 @@ impl cosmic::Application for App {
|
||||||
.on_input(|value| Message::Prompt(prompt.clone(), *secret, Some(value)))
|
.on_input(|value| Message::Prompt(prompt.clone(), *secret, Some(value)))
|
||||||
.on_submit(Message::Submit);
|
.on_submit(Message::Submit);
|
||||||
|
|
||||||
|
if let Some(text_input_id) = self.text_input_ids.get(&surface_id) {
|
||||||
|
text_input = text_input.id(text_input_id.clone());
|
||||||
|
}
|
||||||
|
|
||||||
if *secret {
|
if *secret {
|
||||||
text_input = text_input.password()
|
text_input = text_input.password()
|
||||||
}
|
}
|
||||||
|
|
@ -636,10 +639,6 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Self::Message> {
|
fn subscription(&self) -> Subscription<Self::Message> {
|
||||||
if self.exited {
|
|
||||||
return Subscription::none();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct BackgroundSubscription;
|
struct BackgroundSubscription;
|
||||||
struct HeartbeatSubscription;
|
struct HeartbeatSubscription;
|
||||||
struct PamSubscription;
|
struct PamSubscription;
|
||||||
|
|
@ -647,7 +646,7 @@ impl cosmic::Application for App {
|
||||||
//TODO: how to avoid cloning this on every time subscription is called?
|
//TODO: how to avoid cloning this on every time subscription is called?
|
||||||
let username = self.flags.current_user.name.clone();
|
let username = self.flags.current_user.name.clone();
|
||||||
Subscription::batch([
|
Subscription::batch([
|
||||||
subscription::events_with(|event, _| match event {
|
event::listen_with(|event, _| match event {
|
||||||
iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(
|
iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(
|
||||||
wayland_event,
|
wayland_event,
|
||||||
)) => match wayland_event {
|
)) => match wayland_event {
|
||||||
|
|
@ -714,7 +713,6 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: how to properly kill this task?
|
|
||||||
loop {
|
loop {
|
||||||
time::sleep(time::Duration::new(1, 0)).await;
|
time::sleep(time::Duration::new(1, 0)).await;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue