refactor: lock surface subsurface menu
This commit is contained in:
parent
b84ee1827c
commit
d6b94406e6
5 changed files with 573 additions and 616 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
|
@ -1046,7 +1046,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"calloop 0.14.2",
|
||||
|
|
@ -1069,7 +1069,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -1212,7 +1212,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
|
|
@ -2487,7 +2487,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2505,7 +2505,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_winit",
|
||||
|
|
@ -2514,7 +2514,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bytes",
|
||||
|
|
@ -2538,7 +2538,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2564,7 +2564,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"bitflags 2.8.0",
|
||||
"bytemuck",
|
||||
|
|
@ -2586,7 +2586,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -2598,7 +2598,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"cosmic-client-toolkit",
|
||||
|
|
@ -2613,7 +2613,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -2629,7 +2629,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"as-raw-xcb-connection",
|
||||
"bitflags 2.8.0",
|
||||
|
|
@ -2660,7 +2660,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -2678,7 +2678,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_winit"
|
||||
version = "0.14.0-dev"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"cosmic-client-toolkit",
|
||||
"dnd",
|
||||
|
|
@ -3144,7 +3144,7 @@ checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#4c78a5620218a67f6653b171e9136f4bd9e89bf1"
|
||||
source = "git+https://github.com/pop-os/libcosmic//?branch=drop-menu-tree-changes#5976b48f677649067d1240f6386d153261204278"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd 0.9.2",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ mod ipc;
|
|||
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
|
||||
use cosmic::iced::{Point, Rectangle, Size};
|
||||
use cosmic::iced::{Point, Size};
|
||||
use cosmic::iced_core::{image, window};
|
||||
use cosmic::iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings;
|
||||
use cosmic::surface;
|
||||
|
|
@ -400,11 +400,11 @@ pub enum Message {
|
|||
DropdownToggle(Dropdown),
|
||||
Error(String),
|
||||
Exit,
|
||||
Focus(SurfaceId),
|
||||
// Sets channel used to communicate with the greetd IPC subscription.
|
||||
GreetdChannel(tokio::sync::mpsc::Sender<Request>),
|
||||
Heartbeat,
|
||||
KeyboardLayout(usize),
|
||||
LayerEvent(LayerEvent, SurfaceId),
|
||||
Login,
|
||||
NetworkIcon(Option<&'static str>),
|
||||
None,
|
||||
|
|
@ -419,7 +419,6 @@ pub enum Message {
|
|||
Surface(surface::Action),
|
||||
Suspend,
|
||||
Username(String),
|
||||
WindowOpen(SurfaceId),
|
||||
}
|
||||
|
||||
/// The [`App`] stores application-specific state.
|
||||
|
|
@ -718,9 +717,6 @@ impl App {
|
|||
)
|
||||
.id(text_input_id)
|
||||
.manage_value(true)
|
||||
// .on_input(|value| {
|
||||
// Message::Prompt(prompt.clone(), *secret, Some(value))
|
||||
// })
|
||||
.on_submit(|v| Message::Auth(Some(v)));
|
||||
|
||||
if let Some(text_input_id) = self
|
||||
|
|
@ -1141,13 +1137,16 @@ impl cosmic::Application for App {
|
|||
Size::new(800., unwrapped_size.1 as f32 - 32.),
|
||||
)
|
||||
} else {
|
||||
(Point::ORIGIN, Size::new(1920., 1080.))
|
||||
(
|
||||
Point::new(0., 32.),
|
||||
Size::new(unwrapped_size.0 as f32, unwrapped_size.1 as f32 - 32.),
|
||||
)
|
||||
};
|
||||
self.window_size.insert(
|
||||
surface_id,
|
||||
Size::new(unwrapped_size.0 as f32, unwrapped_size.1 as f32),
|
||||
);
|
||||
dbg!(loc, size);
|
||||
|
||||
let msg = cosmic::surface::action::subsurface(
|
||||
move |_: &mut App| SctkSubsurfaceSettings {
|
||||
parent: surface_id,
|
||||
|
|
@ -1209,20 +1208,6 @@ impl cosmic::Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
Message::LayerEvent(layer_event, surface_id) => match layer_event {
|
||||
LayerEvent::Focused => {
|
||||
log::info!("focus surface {:?}", surface_id);
|
||||
self.active_surface_id_opt = Some(surface_id);
|
||||
if let Some(text_input_id) = self
|
||||
.surface_names
|
||||
.get(&surface_id)
|
||||
.and_then(|id| self.text_input_ids.get(id))
|
||||
{
|
||||
return widget::text_input::focus(text_input_id.clone());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Message::Socket(socket_state) => {
|
||||
self.socket_state = socket_state;
|
||||
match &self.socket_state {
|
||||
|
|
@ -1481,22 +1466,17 @@ impl cosmic::Application for App {
|
|||
cosmic::app::Action::Surface(a),
|
||||
));
|
||||
}
|
||||
Message::WindowOpen(id) if self.surface_ids.values().any(|i| *i == id) => {
|
||||
if let Some(text_input_id) = self.surface_names.get(&id).and_then(|id| {
|
||||
if self
|
||||
.active_surface_id_opt
|
||||
.and_then(|active_id| self.surface_names.get(&active_id))
|
||||
== Some(id)
|
||||
{
|
||||
self.text_input_ids.get(id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}) {
|
||||
|
||||
Message::Focus(surface_id) => {
|
||||
self.active_surface_id_opt = Some(surface_id);
|
||||
if let Some(text_input_id) = self
|
||||
.surface_names
|
||||
.get(&surface_id)
|
||||
.and_then(|id| self.text_input_ids.get(id))
|
||||
{
|
||||
return widget::text_input::focus(text_input_id.clone());
|
||||
}
|
||||
}
|
||||
Message::WindowOpen(_) => {}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
|
@ -1530,12 +1510,10 @@ impl cosmic::Application for App {
|
|||
WaylandEvent::Output(output_event, output) => {
|
||||
Some(Message::OutputEvent(output_event, output))
|
||||
}
|
||||
WaylandEvent::Layer(layer_event, _surface, surface_id) => {
|
||||
Some(Message::LayerEvent(layer_event, surface_id))
|
||||
}
|
||||
|
||||
_ => None,
|
||||
},
|
||||
iced::Event::Window(window::Event::Opened { .. }) => Some(Message::WindowOpen(id)),
|
||||
iced::Event::Window(iced::window::Event::Focused) => Some(Message::Focus(id)),
|
||||
_ => None,
|
||||
}),
|
||||
Subscription::run_with_id(
|
||||
|
|
|
|||
|
|
@ -1,160 +0,0 @@
|
|||
use cosmic::iced::ContentFit;
|
||||
use cosmic::iced::{
|
||||
widget::{
|
||||
image::{draw, FilterMethod, Handle},
|
||||
Container,
|
||||
},
|
||||
Rotation,
|
||||
};
|
||||
use cosmic::iced_core::event::{self, Event};
|
||||
use cosmic::iced_core::layout;
|
||||
use cosmic::iced_core::mouse;
|
||||
use cosmic::iced_core::overlay;
|
||||
use cosmic::iced_core::renderer;
|
||||
use cosmic::iced_core::widget::{Operation, Tree};
|
||||
use cosmic::iced_core::{Clipboard, Element, Layout, Length, Rectangle, Shell, Size, Widget};
|
||||
use cosmic::{Renderer, Theme};
|
||||
|
||||
pub struct ImageContainer<'a, Message> {
|
||||
container: Container<'a, Message, Theme, Renderer>,
|
||||
image_opt: Option<Handle>,
|
||||
content_fit: ContentFit,
|
||||
}
|
||||
|
||||
impl<'a, Message> ImageContainer<'a, Message> {
|
||||
pub fn new(container: Container<'a, Message, Theme, Renderer>) -> Self {
|
||||
Self {
|
||||
container,
|
||||
image_opt: None,
|
||||
content_fit: ContentFit::None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn image(mut self, image: Handle) -> Self {
|
||||
self.image_opt = Some(image);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn content_fit(mut self, content_fit: ContentFit) -> Self {
|
||||
self.content_fit = content_fit;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> Widget<Message, Theme, Renderer> for ImageContainer<'a, Message> {
|
||||
fn children(&self) -> Vec<Tree> {
|
||||
self.container.children()
|
||||
}
|
||||
|
||||
fn diff(&mut self, tree: &mut Tree) {
|
||||
self.container.diff(tree)
|
||||
}
|
||||
|
||||
fn size(&self) -> Size<Length> {
|
||||
self.container.size()
|
||||
}
|
||||
|
||||
fn layout(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
renderer: &Renderer,
|
||||
limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
self.container.layout(tree, renderer, limits)
|
||||
}
|
||||
|
||||
fn operate(
|
||||
&self,
|
||||
tree: &mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
operation: &mut dyn Operation<()>,
|
||||
) {
|
||||
self.container.operate(tree, layout, renderer, operation)
|
||||
}
|
||||
|
||||
fn on_event(
|
||||
&mut self,
|
||||
tree: &mut Tree,
|
||||
event: Event,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
renderer: &Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
self.container.on_event(
|
||||
tree, event, layout, cursor, renderer, clipboard, shell, viewport,
|
||||
)
|
||||
}
|
||||
|
||||
fn mouse_interaction(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
viewport: &Rectangle,
|
||||
renderer: &Renderer,
|
||||
) -> mouse::Interaction {
|
||||
self.container
|
||||
.mouse_interaction(tree, layout, cursor, viewport, renderer)
|
||||
}
|
||||
|
||||
fn draw(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
renderer: &mut Renderer,
|
||||
theme: &Theme,
|
||||
renderer_style: &renderer::Style,
|
||||
layout: Layout<'_>,
|
||||
cursor: mouse::Cursor,
|
||||
viewport: &Rectangle,
|
||||
) {
|
||||
match &self.image_opt {
|
||||
Some(image) => draw(
|
||||
renderer,
|
||||
layout,
|
||||
image,
|
||||
self.content_fit,
|
||||
FilterMethod::Linear,
|
||||
Rotation::default(),
|
||||
1.,
|
||||
[0.0, 0.0, 0.0, 0.0],
|
||||
),
|
||||
None => {}
|
||||
}
|
||||
|
||||
use cosmic::iced_renderer::core::Renderer as IcedRenderer;
|
||||
renderer.with_layer(layout.bounds(), |renderer| {
|
||||
self.container.draw(
|
||||
tree,
|
||||
renderer,
|
||||
theme,
|
||||
renderer_style,
|
||||
layout,
|
||||
cursor,
|
||||
viewport,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
fn overlay<'b>(
|
||||
&'b mut self,
|
||||
state: &'b mut Tree,
|
||||
layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
translation: cosmic::iced::Vector,
|
||||
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
|
||||
self.container.overlay(state, layout, renderer, translation)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> From<ImageContainer<'a, Message>> for Element<'a, Message, Theme, Renderer>
|
||||
where
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(container: ImageContainer<'a, Message>) -> Element<'a, Message, Theme, Renderer> {
|
||||
Element::new(container)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
pub mod greeter;
|
||||
pub mod locker;
|
||||
|
||||
mod image_container;
|
||||
mod localize;
|
||||
|
||||
#[cfg(feature = "logind")]
|
||||
|
|
|
|||
942
src/locker.rs
942
src/locker.rs
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue