update smithay, iced; reworked window for xwayland
This commit is contained in:
parent
47dfc85314
commit
7992ad67f6
27 changed files with 2285 additions and 1106 deletions
|
|
@ -1,6 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{state::BackendData, utils::prelude::*, wayland::protocols::screencopy::SessionType};
|
||||
use crate::{
|
||||
shell::CosmicSurface, state::BackendData, utils::prelude::*,
|
||||
wayland::protocols::screencopy::SessionType,
|
||||
};
|
||||
use smithay::{
|
||||
backend::renderer::utils::{on_commit_buffer_handler, with_renderer_surface_state},
|
||||
delegate_compositor,
|
||||
|
|
@ -8,6 +11,7 @@ use smithay::{
|
|||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
wayland::{
|
||||
compositor::{with_states, CompositorHandler, CompositorState},
|
||||
seat::WaylandFocus,
|
||||
shell::{
|
||||
wlr_layer::LayerSurfaceAttributes,
|
||||
xdg::{
|
||||
|
|
@ -113,17 +117,28 @@ impl CompositorHandler for State {
|
|||
.shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.find(|(window, _)| window.toplevel().wl_surface() == surface)
|
||||
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
|
||||
.cloned()
|
||||
{
|
||||
let toplevel = window.toplevel();
|
||||
if self.toplevel_ensure_initial_configure(&toplevel)
|
||||
&& with_renderer_surface_state(&surface, |state| state.wl_buffer().is_some())
|
||||
{
|
||||
let output = seat.active_output();
|
||||
Shell::map_window(self, &window, &output);
|
||||
} else {
|
||||
return;
|
||||
match window {
|
||||
CosmicSurface::Wayland(ref wl_window) => {
|
||||
let toplevel = wl_window.toplevel();
|
||||
if self.toplevel_ensure_initial_configure(&toplevel)
|
||||
&& with_renderer_surface_state(&surface, |state| {
|
||||
state.wl_buffer().is_some()
|
||||
})
|
||||
{
|
||||
let output = seat.active_output();
|
||||
Shell::map_window(self, &window, &output);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
CosmicSurface::X11(_) => {
|
||||
let output = seat.active_output();
|
||||
Shell::map_window(self, &window, &output);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use smithay::{
|
|||
Bind, Blit, BufferType, ExportMem, ImportAll, ImportMem, Offscreen, Renderer,
|
||||
},
|
||||
},
|
||||
desktop::Window,
|
||||
desktop::space::SpaceElement,
|
||||
output::Output,
|
||||
reexports::wayland_server::{
|
||||
protocol::{wl_buffer::WlBuffer, wl_shm::Format as ShmFormat, wl_surface::WlSurface},
|
||||
|
|
@ -33,6 +33,7 @@ use smithay::{
|
|||
utils::{IsAlive, Logical, Physical, Rectangle, Scale, Transform},
|
||||
wayland::{
|
||||
dmabuf::get_dmabuf,
|
||||
seat::WaylandFocus,
|
||||
shm::{with_buffer_contents, with_buffer_contents_mut},
|
||||
},
|
||||
};
|
||||
|
|
@ -43,7 +44,7 @@ use crate::{
|
|||
element::{AsGlowRenderer, CosmicElement},
|
||||
render_output, render_workspace, CursorMode, CLEAR_COLOR,
|
||||
},
|
||||
shell::CosmicMappedRenderElement,
|
||||
shell::{CosmicMappedRenderElement, CosmicSurface},
|
||||
state::{BackendData, ClientState, Common, State},
|
||||
utils::prelude::OutputExt,
|
||||
wayland::protocols::{
|
||||
|
|
@ -159,8 +160,8 @@ impl ScreencopyHandler for State {
|
|||
formats
|
||||
}
|
||||
|
||||
fn capture_toplevel(&mut self, toplevel: Window, session: Session) -> Vec<BufferInfo> {
|
||||
let surface = toplevel.toplevel().wl_surface();
|
||||
fn capture_toplevel(&mut self, toplevel: CosmicSurface, session: Session) -> Vec<BufferInfo> {
|
||||
let Some(surface) = toplevel.wl_surface() else { return Vec::new() };
|
||||
let size = toplevel.geometry().size.to_buffer(1, Transform::Normal);
|
||||
|
||||
let mut _kms_renderer = None;
|
||||
|
|
@ -843,7 +844,7 @@ pub fn render_window_to_buffer(
|
|||
state: &mut State,
|
||||
session: &Session,
|
||||
params: BufferParams,
|
||||
window: &Window,
|
||||
window: &CosmicSurface,
|
||||
) -> Result<bool, (FailureReason, anyhow::Error)> {
|
||||
let geometry = window.geometry();
|
||||
let buffer_size = buffer_dimensions(¶ms.buffer).unwrap();
|
||||
|
|
@ -858,7 +859,7 @@ pub fn render_window_to_buffer(
|
|||
age: usize,
|
||||
session: &Session,
|
||||
common: &mut Common,
|
||||
window: &Window,
|
||||
window: &CosmicSurface,
|
||||
geometry: Rectangle<i32, Logical>,
|
||||
) -> Result<
|
||||
(Option<Vec<Rectangle<i32, Physical>>>, RenderElementStates),
|
||||
|
|
@ -889,12 +890,12 @@ pub fn render_window_to_buffer(
|
|||
for seat in common.seats() {
|
||||
if let Some(location) = {
|
||||
// we need to find the mapped element in that case
|
||||
if let Some(mapped) = common
|
||||
.shell
|
||||
.element_for_surface(window.toplevel().wl_surface())
|
||||
if let Some(mapped) = window
|
||||
.wl_surface()
|
||||
.and_then(|surf| common.shell.element_for_surface(&surf))
|
||||
{
|
||||
mapped.cursor_position(seat).and_then(|mut p| {
|
||||
p -= mapped.active_window_offset().loc.to_f64();
|
||||
p -= mapped.active_window_offset().to_f64();
|
||||
if p.x < 0. || p.y < 0. {
|
||||
None
|
||||
} else {
|
||||
|
|
@ -1076,7 +1077,7 @@ impl UserdataExt for Output {
|
|||
}
|
||||
}
|
||||
|
||||
impl UserdataExt for Window {
|
||||
impl UserdataExt for CosmicSurface {
|
||||
fn sessions(&self) -> Vec<Session> {
|
||||
self.user_data()
|
||||
.get::<ScreencopySessions>()
|
||||
|
|
@ -1101,7 +1102,7 @@ impl State {
|
|||
pub fn schedule_window_session(&mut self, surface: &WlSurface) {
|
||||
if let Some(element) = self.common.shell.element_for_surface(surface).cloned() {
|
||||
let active = element.active_window();
|
||||
if active.toplevel().wl_surface() == surface {
|
||||
if active.wl_surface().as_ref() == Some(surface) {
|
||||
for (session, params) in active.pending_buffers() {
|
||||
let window = active.clone();
|
||||
self.common.event_loop_handle.insert_idle(move |data| {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,54 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::utils::user_data::UserDataMap;
|
||||
|
||||
use crate::{
|
||||
shell::CosmicSurface,
|
||||
state::State,
|
||||
wayland::protocols::toplevel_info::{
|
||||
delegate_toplevel_info, ToplevelInfoHandler, ToplevelInfoState,
|
||||
delegate_toplevel_info, ToplevelInfoHandler, ToplevelInfoState, Window,
|
||||
},
|
||||
};
|
||||
|
||||
impl ToplevelInfoHandler for State {
|
||||
fn toplevel_info_state(&self) -> &ToplevelInfoState<State> {
|
||||
type Window = CosmicSurface;
|
||||
|
||||
fn toplevel_info_state(&self) -> &ToplevelInfoState<State, Self::Window> {
|
||||
&self.common.shell.toplevel_info_state
|
||||
}
|
||||
fn toplevel_info_state_mut(&mut self) -> &mut ToplevelInfoState<State> {
|
||||
fn toplevel_info_state_mut(&mut self) -> &mut ToplevelInfoState<State, Self::Window> {
|
||||
&mut self.common.shell.toplevel_info_state
|
||||
}
|
||||
}
|
||||
|
||||
delegate_toplevel_info!(State);
|
||||
impl Window for CosmicSurface {
|
||||
fn title(&self) -> String {
|
||||
CosmicSurface::title(self)
|
||||
}
|
||||
|
||||
fn app_id(&self) -> String {
|
||||
CosmicSurface::app_id(self)
|
||||
}
|
||||
|
||||
fn is_activated(&self) -> bool {
|
||||
CosmicSurface::is_activated(self)
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> bool {
|
||||
CosmicSurface::is_maximized(self)
|
||||
}
|
||||
|
||||
fn is_fullscreen(&self) -> bool {
|
||||
CosmicSurface::is_fullscreen(self)
|
||||
}
|
||||
|
||||
fn is_minimized(&self) -> bool {
|
||||
false // TODO
|
||||
}
|
||||
|
||||
fn user_data(&self) -> &UserDataMap {
|
||||
CosmicSurface::user_data(self)
|
||||
}
|
||||
}
|
||||
|
||||
delegate_toplevel_info!(State, CosmicSurface);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::{desktop::Window, input::Seat, reexports::wayland_server::DisplayHandle};
|
||||
use smithay::{input::Seat, reexports::wayland_server::DisplayHandle};
|
||||
|
||||
use crate::{
|
||||
shell::CosmicSurface,
|
||||
utils::prelude::*,
|
||||
wayland::protocols::toplevel_management::{
|
||||
delegate_toplevel_management, ToplevelManagementHandler, ToplevelManagementState,
|
||||
wayland::protocols::{
|
||||
toplevel_info::ToplevelInfoHandler,
|
||||
toplevel_management::{
|
||||
delegate_toplevel_management, ManagementWindow, ToplevelManagementHandler,
|
||||
ToplevelManagementState,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -14,7 +19,12 @@ impl ToplevelManagementHandler for State {
|
|||
&mut self.common.shell.toplevel_management_state
|
||||
}
|
||||
|
||||
fn activate(&mut self, _dh: &DisplayHandle, window: &Window, seat: Option<Seat<Self>>) {
|
||||
fn activate(
|
||||
&mut self,
|
||||
_dh: &DisplayHandle,
|
||||
window: &<Self as ToplevelInfoHandler>::Window,
|
||||
seat: Option<Seat<Self>>,
|
||||
) {
|
||||
for output in self
|
||||
.common
|
||||
.shell
|
||||
|
|
@ -47,8 +57,14 @@ impl ToplevelManagementHandler for State {
|
|||
}
|
||||
}
|
||||
|
||||
fn close(&mut self, _dh: &DisplayHandle, window: &Window) {
|
||||
window.toplevel().send_close();
|
||||
fn close(&mut self, _dh: &DisplayHandle, window: &<Self as ToplevelInfoHandler>::Window) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
impl ManagementWindow for CosmicSurface {
|
||||
fn close(&self) {
|
||||
CosmicSurface::close(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{utils::prelude::*, wayland::protocols::screencopy::SessionType};
|
||||
use crate::{shell::CosmicSurface, utils::prelude::*, wayland::protocols::screencopy::SessionType};
|
||||
use smithay::{
|
||||
delegate_xdg_shell,
|
||||
desktop::{
|
||||
|
|
@ -39,7 +39,7 @@ impl XdgShellHandler for State {
|
|||
|
||||
fn new_toplevel(&mut self, surface: ToplevelSurface) {
|
||||
let seat = self.common.last_active_seat().clone();
|
||||
let window = Window::new(surface);
|
||||
let window = CosmicSurface::Wayland(Window::new(surface));
|
||||
self.common.shell.toplevel_info_state.new_toplevel(&window);
|
||||
self.common.shell.pending_windows.push((window, seat));
|
||||
// We will position the window after the first commit, when we know its size hints
|
||||
|
|
@ -149,7 +149,7 @@ impl XdgShellHandler for State {
|
|||
let output = seat.active_output();
|
||||
let (window, _) = mapped
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel() == &surface)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
||||
.unwrap();
|
||||
if let Some(grab) =
|
||||
workspace.move_request(&window, &seat, &output, serial, start_data)
|
||||
|
|
@ -213,7 +213,7 @@ impl XdgShellHandler for State {
|
|||
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
|
||||
let (window, _) = mapped
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel() == &surface)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
||||
.unwrap();
|
||||
workspace.maximize_request(&window, &output)
|
||||
}
|
||||
|
|
@ -230,9 +230,9 @@ impl XdgShellHandler for State {
|
|||
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
|
||||
let (window, _) = mapped
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel() == &surface)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
||||
.unwrap();
|
||||
workspace.unmaximize_request(&window)
|
||||
workspace.unmaximize_request(&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ impl XdgShellHandler for State {
|
|||
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
|
||||
let (window, _) = mapped
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel() == &surface)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
||||
.unwrap();
|
||||
workspace.fullscreen_request(&window, &output)
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ impl XdgShellHandler for State {
|
|||
if let Some(workspace) = self.common.shell.space_for_mut(&mapped) {
|
||||
let (window, _) = mapped
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel() == &surface)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
||||
.unwrap();
|
||||
workspace.unfullscreen_request(&window)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
use crate::{shell::Shell, utils::prelude::*};
|
||||
use smithay::{
|
||||
desktop::{
|
||||
layer_map_for_output, LayerSurface, PopupKind, PopupManager, Window, WindowSurfaceType,
|
||||
layer_map_for_output, space::SpaceElement, LayerSurface, PopupKind, PopupManager, Window,
|
||||
WindowSurfaceType,
|
||||
},
|
||||
output::Output,
|
||||
reexports::{
|
||||
|
|
@ -15,6 +16,7 @@ use smithay::{
|
|||
utils::{Logical, Point, Rectangle},
|
||||
wayland::{
|
||||
compositor::{get_role, with_states},
|
||||
seat::WaylandFocus,
|
||||
shell::xdg::{
|
||||
PopupSurface, PositionerState, SurfaceCachedState, XdgPopupSurfaceRoleAttributes,
|
||||
XDG_POPUP_ROLE,
|
||||
|
|
@ -31,12 +33,12 @@ impl Shell {
|
|||
let element_geo = workspace.element_geometry(elem).unwrap();
|
||||
let (window, offset) = elem
|
||||
.windows()
|
||||
.find(|(w, _)| w.toplevel().wl_surface() == &parent)
|
||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(&parent))
|
||||
.unwrap();
|
||||
let window_geo_offset = window.geometry().loc;
|
||||
let window_loc = element_geo.loc + offset + window_geo_offset;
|
||||
let anchor_point = get_anchor_point(&positioner) + window_loc;
|
||||
if elem.is_tiled() {
|
||||
if elem.is_tiled().unwrap() {
|
||||
if !unconstrain_xdg_popup_tile(surface, element_geo) {
|
||||
if let Some(output) = workspace.output_under(anchor_point) {
|
||||
unconstrain_xdg_popup(surface, window_loc, output.geometry());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue