fix: reposition subsurface after layer surface size update
This commit is contained in:
parent
0e2141ac6c
commit
16185fe21e
2 changed files with 57 additions and 23 deletions
42
Cargo.lock
generated
42
Cargo.lock
generated
|
|
@ -1113,7 +1113,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config"
|
name = "cosmic-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"calloop 0.14.3",
|
"calloop 0.14.3",
|
||||||
|
|
@ -1136,7 +1136,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-config-derive"
|
name = "cosmic-config-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.106",
|
"syn 2.0.106",
|
||||||
|
|
@ -1366,7 +1366,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-theme"
|
name = "cosmic-theme"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1844,7 +1844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2667,7 +2667,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dnd",
|
"dnd",
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
|
|
@ -2685,7 +2685,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_accessibility"
|
name = "iced_accessibility"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
|
|
@ -2694,7 +2694,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.2",
|
"bitflags 2.9.2",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
@ -2719,7 +2719,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2745,7 +2745,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.2",
|
"bitflags 2.9.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2767,7 +2767,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2779,7 +2779,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"cosmic-client-toolkit",
|
"cosmic-client-toolkit",
|
||||||
|
|
@ -2795,7 +2795,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2811,7 +2811,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"as-raw-xcb-connection",
|
"as-raw-xcb-connection",
|
||||||
"bitflags 2.9.2",
|
"bitflags 2.9.2",
|
||||||
|
|
@ -2842,7 +2842,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-client-toolkit",
|
"cosmic-client-toolkit",
|
||||||
"dnd",
|
"dnd",
|
||||||
|
|
@ -2862,7 +2862,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_winit"
|
name = "iced_winit"
|
||||||
version = "0.14.0-dev"
|
version = "0.14.0-dev"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmic-client-toolkit",
|
"cosmic-client-toolkit",
|
||||||
"dnd",
|
"dnd",
|
||||||
|
|
@ -3553,7 +3553,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi 0.5.2",
|
"hermit-abi 0.5.2",
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -3737,7 +3737,7 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#29f38f83a38b550ae0de2b130fde9f2c36341fab"
|
source = "git+https://github.com/pop-os/libcosmic#66a2632e2ee72a1e3a9888cd5638821f6af2f861"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
@ -5581,7 +5581,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.4.15",
|
"linux-raw-sys 0.4.15",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -5594,7 +5594,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.9.4",
|
"linux-raw-sys 0.9.4",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -6134,7 +6134,7 @@ dependencies = [
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.3",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.0.8",
|
"rustix 1.0.8",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -7088,7 +7088,7 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22"
|
checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ use crate::wayland::{self, WaylandUpdate};
|
||||||
use cctk::sctk::reexports::calloop;
|
use cctk::sctk::reexports::calloop;
|
||||||
use cosmic::app::{Core, Settings, Task};
|
use cosmic::app::{Core, Settings, Task};
|
||||||
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
|
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
|
||||||
use cosmic::iced::{Point, Size};
|
use cosmic::iced::event::listen_with;
|
||||||
|
use cosmic::iced::{Point, Size, window};
|
||||||
use cosmic::iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings;
|
use cosmic::iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings;
|
||||||
use cosmic::widget::text;
|
use cosmic::widget::text;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
|
@ -23,6 +24,7 @@ use cosmic::{
|
||||||
shell::wayland::commands::layer_surface::{
|
shell::wayland::commands::layer_surface::{
|
||||||
Anchor, KeyboardInteractivity, Layer, destroy_layer_surface, get_layer_surface,
|
Anchor, KeyboardInteractivity, Layer, destroy_layer_surface, get_layer_surface,
|
||||||
},
|
},
|
||||||
|
shell::wayland::commands::subsurface::reposition_subsurface,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
iced_runtime::core::window::Id as SurfaceId,
|
iced_runtime::core::window::Id as SurfaceId,
|
||||||
|
|
@ -53,7 +55,6 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use tokio::process::Child;
|
use tokio::process::Child;
|
||||||
use tokio::sync::oneshot;
|
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
|
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
|
||||||
use zbus::{Connection, proxy};
|
use zbus::{Connection, proxy};
|
||||||
|
|
@ -366,6 +367,7 @@ pub enum Message {
|
||||||
Login,
|
Login,
|
||||||
Reconnect,
|
Reconnect,
|
||||||
Reload(cosmic::Theme),
|
Reload(cosmic::Theme),
|
||||||
|
RepositionMenu(window::Id, Size),
|
||||||
Restart,
|
Restart,
|
||||||
Session(String),
|
Session(String),
|
||||||
Shutdown,
|
Shutdown,
|
||||||
|
|
@ -402,6 +404,7 @@ pub struct App {
|
||||||
heartbeat_handle: Option<cosmic::iced::task::Handle>,
|
heartbeat_handle: Option<cosmic::iced::task::Handle>,
|
||||||
entering_name: bool,
|
entering_name: bool,
|
||||||
theme_builder: cosmic_theme::ThemeBuilder,
|
theme_builder: cosmic_theme::ThemeBuilder,
|
||||||
|
surface_id_pairs: Vec<(window::Id, window::Id)>,
|
||||||
|
|
||||||
randr_list: Option<cosmic_randr_shell::List>,
|
randr_list: Option<cosmic_randr_shell::List>,
|
||||||
|
|
||||||
|
|
@ -1080,6 +1083,7 @@ impl cosmic::Application for App {
|
||||||
accessibility,
|
accessibility,
|
||||||
theme_builder: Default::default(),
|
theme_builder: Default::default(),
|
||||||
randr_list: None,
|
randr_list: None,
|
||||||
|
surface_id_pairs: Vec::new(),
|
||||||
};
|
};
|
||||||
(app, Task::batch(tasks))
|
(app, Task::batch(tasks))
|
||||||
}
|
}
|
||||||
|
|
@ -1097,6 +1101,8 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
let surface_id = SurfaceId::unique();
|
let surface_id = SurfaceId::unique();
|
||||||
let subsurface_id = SurfaceId::unique();
|
let subsurface_id = SurfaceId::unique();
|
||||||
|
self.surface_id_pairs
|
||||||
|
.push((surface_id.clone(), subsurface_id.clone()));
|
||||||
|
|
||||||
match self.common.surface_ids.insert(output.clone(), surface_id) {
|
match self.common.surface_ids.insert(output.clone(), surface_id) {
|
||||||
Some(old_surface_id) => {
|
Some(old_surface_id) => {
|
||||||
|
|
@ -1296,6 +1302,11 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
if let Some(randr_list) = self.randr_list.as_ref() {
|
||||||
|
return self.update(Message::RandrUpdate {
|
||||||
|
randr: Arc::new(Ok(randr_list.clone())),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::ConfigUpdateUser => {
|
Message::ConfigUpdateUser => {
|
||||||
|
|
@ -1707,6 +1718,22 @@ impl cosmic::Application for App {
|
||||||
log::error!("Randr error: {err}");
|
log::error!("Randr error: {err}");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Message::RepositionMenu(id, size) => {
|
||||||
|
let Some(subsurface_id) = self
|
||||||
|
.surface_id_pairs
|
||||||
|
.iter()
|
||||||
|
.find_map(|(p, s)| (*p == id).then_some(s))
|
||||||
|
else {
|
||||||
|
log::error!("Failed to find subsurface menu id");
|
||||||
|
return Task::none();
|
||||||
|
};
|
||||||
|
let loc = if size.width > 800. {
|
||||||
|
Point::new(size.width / 2. - 400., 32.)
|
||||||
|
} else {
|
||||||
|
Point::new(0., 32.)
|
||||||
|
};
|
||||||
|
return reposition_subsurface(*subsurface_id, loc.x as i32, loc.y as i32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
@ -1735,6 +1762,13 @@ impl cosmic::Application for App {
|
||||||
self.common.subscription().map(Message::from),
|
self.common.subscription().map(Message::from),
|
||||||
ipc::subscription(),
|
ipc::subscription(),
|
||||||
wayland::a11y_subscription().map(Message::WaylandUpdate),
|
wayland::a11y_subscription().map(Message::WaylandUpdate),
|
||||||
|
listen_with(|event, _status, id| match event {
|
||||||
|
iced::Event::Window(window::Event::Resized(size))
|
||||||
|
| iced::Event::Window(window::Event::Opened { size, .. }) => {
|
||||||
|
Some(Message::RepositionMenu(id, size))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue