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
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
use smithay::{
|
||||
backend::renderer::{
|
||||
element::{AsRenderElements, RenderElement},
|
||||
ImportAll, Renderer,
|
||||
ImportAll, ImportMem, Renderer,
|
||||
},
|
||||
desktop::space::SpaceElement,
|
||||
input::{
|
||||
|
|
@ -38,7 +38,7 @@ pub struct MoveGrabState {
|
|||
impl MoveGrabState {
|
||||
pub fn render<I, R>(&self, renderer: &mut R, seat: &Seat<State>, output: &Output) -> Vec<I>
|
||||
where
|
||||
R: Renderer + ImportAll + AsGlowRenderer,
|
||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||
<R as Renderer>::TextureId: 'static,
|
||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||
I: From<CosmicMappedRenderElement<R>>,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
shell::{element::CosmicMapped, focus::target::PointerFocusTarget, grabs::ResizeEdge},
|
||||
shell::{
|
||||
element::CosmicMapped, focus::target::PointerFocusTarget, grabs::ResizeEdge, CosmicSurface,
|
||||
},
|
||||
utils::prelude::*,
|
||||
};
|
||||
use smithay::{
|
||||
|
|
@ -84,18 +86,10 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
|
||||
let (min_size, max_size) = (self.window.min_size(), self.window.max_size());
|
||||
|
||||
let min_width = min_size.w.max(1);
|
||||
let min_height = min_size.h.max(1);
|
||||
let max_width = if max_size.w == 0 {
|
||||
i32::max_value()
|
||||
} else {
|
||||
max_size.w
|
||||
};
|
||||
let max_height = if max_size.h == 0 {
|
||||
i32::max_value()
|
||||
} else {
|
||||
max_size.h
|
||||
};
|
||||
let min_width = min_size.map(|s| s.w).unwrap_or(1);
|
||||
let min_height = min_size.map(|s| s.h).unwrap_or(1);
|
||||
let max_width = max_size.map(|s| s.w).unwrap_or(i32::max_value());
|
||||
let max_height = max_size.map(|s| s.h).unwrap_or(i32::max_value());
|
||||
|
||||
new_window_width = new_window_width.max(min_width).min(max_width);
|
||||
new_window_height = new_window_height.max(min_height).min(max_height);
|
||||
|
|
@ -210,7 +204,7 @@ impl ResizeSurfaceGrab {
|
|||
|
||||
// Finish resizing.
|
||||
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state {
|
||||
if !window.is_resizing() {
|
||||
if !window.is_resizing().unwrap_or(false) {
|
||||
*resize_state = None;
|
||||
}
|
||||
}
|
||||
|
|
@ -218,11 +212,13 @@ impl ResizeSurfaceGrab {
|
|||
|
||||
if let Some(new_location) = new_location {
|
||||
for (window, offset) in window.windows() {
|
||||
update_reactive_popups(
|
||||
&window,
|
||||
new_location + offset,
|
||||
space.floating_layer.space.outputs(),
|
||||
);
|
||||
if let CosmicSurface::Wayland(window) = window {
|
||||
update_reactive_popups(
|
||||
&window,
|
||||
new_location + offset,
|
||||
space.floating_layer.space.outputs(),
|
||||
);
|
||||
}
|
||||
}
|
||||
space
|
||||
.floating_layer
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::{
|
||||
backend::renderer::{element::RenderElement, ImportAll, Renderer},
|
||||
desktop::{layer_map_for_output, space::SpaceElement, Space, Window},
|
||||
backend::renderer::{element::RenderElement, ImportAll, ImportMem, Renderer},
|
||||
desktop::{layer_map_for_output, space::SpaceElement, Space},
|
||||
input::{pointer::GrabStartData as PointerGrabStartData, Seat},
|
||||
output::Output,
|
||||
utils::{Logical, Point, Rectangle, Serial},
|
||||
utils::{Logical, Point, Rectangle, Serial, Size},
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ use crate::{
|
|||
shell::{
|
||||
element::{CosmicMapped, CosmicMappedRenderElement},
|
||||
grabs::ResizeEdge,
|
||||
OutputNotMapped,
|
||||
CosmicSurface, OutputNotMapped,
|
||||
},
|
||||
state::State,
|
||||
utils::prelude::*,
|
||||
|
|
@ -81,7 +81,10 @@ impl FloatingLayout {
|
|||
win_geo.size = size;
|
||||
}
|
||||
{
|
||||
let (min_size, max_size) = (mapped.min_size(), mapped.max_size());
|
||||
let (min_size, max_size) = (
|
||||
mapped.min_size().unwrap_or((0, 0).into()),
|
||||
mapped.max_size().unwrap_or((0, 0).into()),
|
||||
);
|
||||
if win_geo.size.w > geometry.size.w / 3 * 2 {
|
||||
// try a more reasonable size
|
||||
let mut width = geometry.size.w / 3 * 2;
|
||||
|
|
@ -155,7 +158,7 @@ impl FloatingLayout {
|
|||
self.space.element_geometry(elem)
|
||||
}
|
||||
|
||||
pub fn maximize_request(&mut self, window: &Window) {
|
||||
pub fn maximize_request(&mut self, window: &CosmicSurface) {
|
||||
if let Some(mapped) = self
|
||||
.space
|
||||
.elements()
|
||||
|
|
@ -170,7 +173,7 @@ impl FloatingLayout {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn unmaximize_request(&mut self, window: &Window) {
|
||||
pub fn unmaximize_request(&mut self, window: &CosmicSurface) -> Option<Size<i32, Logical>> {
|
||||
let maybe_mapped = self
|
||||
.space
|
||||
.elements()
|
||||
|
|
@ -179,9 +182,13 @@ impl FloatingLayout {
|
|||
|
||||
if let Some(mapped) = maybe_mapped {
|
||||
let last_geometry = mapped.last_geometry.lock().unwrap().clone();
|
||||
mapped.set_size(last_geometry.map(|g| g.size).expect("No previous size?"));
|
||||
let last_size = last_geometry.map(|g| g.size).expect("No previous size?");
|
||||
mapped.set_size(last_size);
|
||||
let last_location = last_geometry.map(|g| g.loc).expect("No previous location?");
|
||||
self.space.map_element(mapped, last_location, true);
|
||||
Some(last_size)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +220,7 @@ impl FloatingLayout {
|
|||
self.space.elements()
|
||||
}
|
||||
|
||||
pub fn windows(&self) -> impl Iterator<Item = Window> + '_ {
|
||||
pub fn windows(&self) -> impl Iterator<Item = CosmicSurface> + '_ {
|
||||
self.mapped().flat_map(|e| e.windows().map(|(w, _)| w))
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +305,7 @@ impl FloatingLayout {
|
|||
output: &Output,
|
||||
) -> Result<Vec<CosmicMappedRenderElement<R>>, OutputNotMapped>
|
||||
where
|
||||
R: Renderer + ImportAll + AsGlowRenderer,
|
||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||
<R as Renderer>::TextureId: 'static,
|
||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
use regex::RegexSet;
|
||||
use smithay::{
|
||||
desktop::Window,
|
||||
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceRoleAttributes},
|
||||
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceData},
|
||||
xwayland::xwm::WmWindowType,
|
||||
};
|
||||
use std::sync::Mutex;
|
||||
|
||||
use super::CosmicSurface;
|
||||
|
||||
pub mod floating;
|
||||
pub mod tiling;
|
||||
|
|
@ -95,33 +96,52 @@ lazy_static::lazy_static! {
|
|||
]).unwrap();
|
||||
}
|
||||
|
||||
pub fn should_be_floating(window: &Window) -> bool {
|
||||
let surface = window.toplevel().wl_surface();
|
||||
with_states(surface, |states| {
|
||||
let attrs = states
|
||||
.data_map
|
||||
.get::<Mutex<XdgToplevelSurfaceRoleAttributes>>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
// simple heuristic taken from
|
||||
// sway/desktop/xdg_shell.c:188 @ 0ee54a52
|
||||
if attrs.parent.is_some()
|
||||
|| (attrs.min_size.w != 0 && attrs.min_size.h != 0 && attrs.min_size == attrs.max_size)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// else take a look at our exceptions
|
||||
let appid_matches = EXCEPTIONS_APPID.matches(attrs.app_id.as_deref().unwrap_or(""));
|
||||
let title_matches = EXCEPTIONS_TITLE.matches(attrs.app_id.as_deref().unwrap_or(""));
|
||||
for idx in appid_matches.into_iter() {
|
||||
if title_matches.matched(idx) {
|
||||
pub fn should_be_floating(window: &CosmicSurface) -> bool {
|
||||
// Check "window type"
|
||||
match window {
|
||||
CosmicSurface::Wayland(window) => {
|
||||
if with_states(window.toplevel().wl_surface(), |states| {
|
||||
let attrs = states
|
||||
.data_map
|
||||
.get::<XdgToplevelSurfaceData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
attrs.parent.is_some()
|
||||
}) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
CosmicSurface::X11(surface) => {
|
||||
if surface.is_override_redirect()
|
||||
|| surface.is_popup()
|
||||
|| !matches!(
|
||||
surface.window_type(),
|
||||
None | Some(WmWindowType::Normal) | Some(WmWindowType::Utility)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
false
|
||||
})
|
||||
// Check if sizing suggest dialog
|
||||
let max_size = window.max_size();
|
||||
let min_size = window.min_size();
|
||||
|
||||
if min_size.is_some() && min_size == max_size {
|
||||
return true;
|
||||
}
|
||||
|
||||
// else take a look at our exceptions
|
||||
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
||||
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
||||
for idx in appid_matches.into_iter() {
|
||||
if title_matches.matched(idx) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
},
|
||||
grabs::ResizeEdge,
|
||||
layout::Orientation,
|
||||
OutputNotMapped,
|
||||
CosmicSurface, OutputNotMapped,
|
||||
},
|
||||
utils::prelude::*,
|
||||
wayland::handlers::xdg_shell::popup::get_popup_toplevel,
|
||||
|
|
@ -20,12 +20,13 @@ use id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBeh
|
|||
use smithay::{
|
||||
backend::renderer::{
|
||||
element::{AsRenderElements, RenderElement},
|
||||
ImportAll, Renderer,
|
||||
ImportAll, ImportMem, Renderer,
|
||||
},
|
||||
desktop::{layer_map_for_output, space::SpaceElement, PopupKind, Window},
|
||||
desktop::{layer_map_for_output, space::SpaceElement, PopupKind},
|
||||
input::{pointer::GrabStartData as PointerGrabStartData, Seat},
|
||||
output::Output,
|
||||
utils::{IsAlive, Logical, Point, Rectangle, Scale, Serial},
|
||||
wayland::seat::WaylandFocus,
|
||||
};
|
||||
use std::{borrow::Borrow, collections::HashMap, hash::Hash, sync::Arc};
|
||||
|
||||
|
|
@ -1003,7 +1004,7 @@ impl TilingLayout {
|
|||
.find(|node| match node.data() {
|
||||
Data::Mapped { mapped, .. } => mapped
|
||||
.windows()
|
||||
.any(|(w, _)| w.toplevel().wl_surface() == &toplevel_surface),
|
||||
.any(|(w, _)| w.wl_surface().as_ref() == Some(&toplevel_surface)),
|
||||
_ => false,
|
||||
})?;
|
||||
|
||||
|
|
@ -1200,7 +1201,9 @@ impl TilingLayout {
|
|||
.flatten()
|
||||
}
|
||||
|
||||
pub fn windows(&self) -> impl Iterator<Item = (Output, Window, Point<i32, Logical>)> + '_ {
|
||||
pub fn windows(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (Output, CosmicSurface, Point<i32, Logical>)> + '_ {
|
||||
self.mapped().flat_map(|(output, mapped, loc)| {
|
||||
mapped
|
||||
.windows()
|
||||
|
|
@ -1265,7 +1268,7 @@ impl TilingLayout {
|
|||
output: &Output,
|
||||
) -> Result<Vec<CosmicMappedRenderElement<R>>, OutputNotMapped>
|
||||
where
|
||||
R: Renderer + ImportAll + AsGlowRenderer,
|
||||
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
|
||||
<R as Renderer>::TextureId: 'static,
|
||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue