Update smithay, with xwayland shell, Cow, etc.
This commit is contained in:
parent
dfb3bea595
commit
4f076e0753
32 changed files with 220 additions and 87 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -4556,7 +4556,7 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay"
|
name = "smithay"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/smithay//smithay?rev=64356be#64356be949f2ad5f70f601cd10255eafed2ce2ce"
|
source = "git+https://github.com/smithay//smithay?rev=8f132ec#8f132ecded5705e55fc1ce6cfa4b59850c6b038e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"appendlist",
|
"appendlist",
|
||||||
"ash",
|
"ash",
|
||||||
|
|
|
||||||
|
|
@ -118,4 +118,4 @@ inherits = "release"
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
|
|
||||||
[patch."https://github.com/Smithay/smithay.git"]
|
[patch."https://github.com/Smithay/smithay.git"]
|
||||||
smithay = {git = "https://github.com/smithay//smithay", rev = "64356be"}
|
smithay = {git = "https://github.com/smithay//smithay", rev = "8f132ec"}
|
||||||
|
|
|
||||||
|
|
@ -1478,7 +1478,7 @@ impl Surface {
|
||||||
let buffer = frame.buffer();
|
let buffer = frame.buffer();
|
||||||
if let Ok(dmabuf) = get_dmabuf(&buffer) {
|
if let Ok(dmabuf) = get_dmabuf(&buffer) {
|
||||||
renderer
|
renderer
|
||||||
.bind(dmabuf)
|
.bind(dmabuf.clone())
|
||||||
.map_err(RenderError::<GlMultiRenderer>::Rendering)?;
|
.map_err(RenderError::<GlMultiRenderer>::Rendering)?;
|
||||||
} else {
|
} else {
|
||||||
let size = buffer_dimensions(&buffer).ok_or(RenderError::<
|
let size = buffer_dimensions(&buffer).ok_or(RenderError::<
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
gles::GlesTexture,
|
gles::GlesTexture,
|
||||||
glow::{GlowFrame, GlowRenderer},
|
glow::{GlowFrame, GlowRenderer},
|
||||||
utils::{CommitCounter, DamageSet},
|
utils::{CommitCounter, DamageSet, OpaqueRegions},
|
||||||
Frame, ImportAll, ImportMem, Renderer,
|
Frame, ImportAll, ImportMem, Renderer,
|
||||||
},
|
},
|
||||||
utils::{Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale},
|
utils::{Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale},
|
||||||
|
|
@ -142,7 +142,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
|
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
|
||||||
match self {
|
match self {
|
||||||
CosmicElement::Workspace(elem) => elem.opaque_regions(scale),
|
CosmicElement::Workspace(elem) => elem.opaque_regions(scale),
|
||||||
CosmicElement::Cursor(elem) => elem.opaque_regions(scale),
|
CosmicElement::Cursor(elem) => elem.opaque_regions(scale),
|
||||||
|
|
|
||||||
|
|
@ -1057,7 +1057,9 @@ where
|
||||||
|
|
||||||
if let (Some(ref damage), _) = &res {
|
if let (Some(ref damage), _) = &res {
|
||||||
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
||||||
renderer.bind(dmabuf).map_err(RenderError::Rendering)?;
|
renderer
|
||||||
|
.bind(dmabuf.clone())
|
||||||
|
.map_err(RenderError::Rendering)?;
|
||||||
} else {
|
} else {
|
||||||
let size = buffer_dimensions(buffer).unwrap();
|
let size = buffer_dimensions(buffer).unwrap();
|
||||||
let format = with_buffer_contents(buffer, |_, _, data| {
|
let format = with_buffer_contents(buffer, |_, _, data| {
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ use xkbcommon::xkb::{Keycode, Keysym};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
|
borrow::Cow,
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
os::unix::process::CommandExt,
|
os::unix::process::CommandExt,
|
||||||
thread,
|
thread,
|
||||||
|
|
@ -642,8 +643,8 @@ impl State {
|
||||||
ptr.frame(self);
|
ptr.frame(self);
|
||||||
|
|
||||||
// If pointer is now in a constraint region, activate it
|
// If pointer is now in a constraint region, activate it
|
||||||
if let Some((under, surface_location)) =
|
if let Some((under, surface_location)) = new_under
|
||||||
new_under.and_then(|(target, loc)| Some((target.wl_surface()?, loc)))
|
.and_then(|(target, loc)| Some((target.wl_surface()?.into_owned(), loc)))
|
||||||
{
|
{
|
||||||
with_pointer_constraint(&under, &ptr, |constraint| match constraint {
|
with_pointer_constraint(&under, &ptr, |constraint| match constraint {
|
||||||
Some(constraint) if !constraint.is_active() => {
|
Some(constraint) if !constraint.is_active() => {
|
||||||
|
|
@ -872,7 +873,9 @@ impl State {
|
||||||
// These cases are handled by the XwaylandKeyboardGrab.
|
// These cases are handled by the XwaylandKeyboardGrab.
|
||||||
if let Some(target) = shell.element_under(pos, &output) {
|
if let Some(target) = shell.element_under(pos, &output) {
|
||||||
if seat.get_keyboard().unwrap().modifier_state().logo {
|
if seat.get_keyboard().unwrap().modifier_state().logo {
|
||||||
if let Some(surface) = target.toplevel() {
|
if let Some(surface) =
|
||||||
|
target.toplevel().map(Cow::into_owned)
|
||||||
|
{
|
||||||
let seat_clone = seat.clone();
|
let seat_clone = seat.clone();
|
||||||
self.common.event_loop_handle.insert_idle(
|
self.common.event_loop_handle.insert_idle(
|
||||||
move |state| {
|
move |state| {
|
||||||
|
|
@ -1523,7 +1526,8 @@ impl State {
|
||||||
|
|
||||||
tool.motion(
|
tool.motion(
|
||||||
position.as_logical(),
|
position.as_logical(),
|
||||||
under.and_then(|(f, loc)| f.wl_surface().map(|s| (s, loc))),
|
under
|
||||||
|
.and_then(|(f, loc)| f.wl_surface().map(|s| (s.into_owned(), loc))),
|
||||||
&tablet,
|
&tablet,
|
||||||
SERIAL_COUNTER.next_serial(),
|
SERIAL_COUNTER.next_serial(),
|
||||||
event.time_msec(),
|
event.time_msec(),
|
||||||
|
|
@ -1573,9 +1577,9 @@ impl State {
|
||||||
if let Some(tablet) = tablet {
|
if let Some(tablet) = tablet {
|
||||||
match event.state() {
|
match event.state() {
|
||||||
ProximityState::In => {
|
ProximityState::In => {
|
||||||
if let Some(under) =
|
if let Some(under) = under.and_then(|(f, loc)| {
|
||||||
under.and_then(|(f, loc)| f.wl_surface().map(|s| (s, loc)))
|
f.wl_surface().map(|s| (s.into_owned(), loc))
|
||||||
{
|
}) {
|
||||||
tool.proximity_in(
|
tool.proximity_in(
|
||||||
position.as_logical(),
|
position.as_logical(),
|
||||||
under,
|
under,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
gles::element::PixelShaderElement,
|
gles::element::PixelShaderElement,
|
||||||
glow::GlowRenderer,
|
glow::GlowRenderer,
|
||||||
utils::DamageSet,
|
utils::{DamageSet, OpaqueRegions},
|
||||||
ImportAll, ImportMem, Renderer,
|
ImportAll, ImportMem, Renderer,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -42,6 +42,7 @@ use smithay::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt,
|
fmt,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
|
@ -222,7 +223,7 @@ impl CosmicMapped {
|
||||||
};
|
};
|
||||||
|
|
||||||
if surface_type.contains(WindowSurfaceType::TOPLEVEL) {
|
if surface_type.contains(WindowSurfaceType::TOPLEVEL) {
|
||||||
if toplevel == *surface {
|
if *toplevel == *surface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -936,10 +937,14 @@ impl KeyboardTarget<State> for CosmicMapped {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandFocus for CosmicMapped {
|
impl WaylandFocus for CosmicMapped {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
match &self.element {
|
match &self.element {
|
||||||
CosmicMappedInternal::Window(w) => w.surface().wl_surface().clone(),
|
CosmicMappedInternal::Window(w) => {
|
||||||
CosmicMappedInternal::Stack(s) => s.active().wl_surface().clone(),
|
w.surface().wl_surface().map(|s| Cow::Owned(s.into_owned()))
|
||||||
|
}
|
||||||
|
CosmicMappedInternal::Stack(s) => {
|
||||||
|
s.active().wl_surface().map(|s| Cow::Owned(s.into_owned()))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1168,7 +1173,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
|
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
|
||||||
match self {
|
match self {
|
||||||
CosmicMappedRenderElement::Stack(elem) => elem.opaque_regions(scale),
|
CosmicMappedRenderElement::Stack(elem) => elem.opaque_regions(scale),
|
||||||
CosmicMappedRenderElement::Window(elem) => elem.opaque_regions(scale),
|
CosmicMappedRenderElement::Window(elem) => elem.opaque_regions(scale),
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ use smithay::{
|
||||||
wayland::seat::WaylandFocus,
|
wayland::seat::WaylandFocus,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
fmt,
|
fmt,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
|
@ -609,7 +610,7 @@ impl CosmicStack {
|
||||||
let seat = seat.clone();
|
let seat = seat.clone();
|
||||||
surface.try_force_undecorated(false);
|
surface.try_force_undecorated(false);
|
||||||
surface.send_configure();
|
surface.send_configure();
|
||||||
if let Some(surface) = surface.wl_surface() {
|
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||||
let res = state.common.shell.write().unwrap().move_request(
|
let res = state.common.shell.write().unwrap().move_request(
|
||||||
&surface,
|
&surface,
|
||||||
|
|
@ -701,7 +702,10 @@ impl Program for CosmicStackInternal {
|
||||||
Message::DragStart => {
|
Message::DragStart => {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
let active = self.active.load(Ordering::SeqCst);
|
let active = self.active.load(Ordering::SeqCst);
|
||||||
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
|
if let Some(surface) = self.windows.lock().unwrap()[active]
|
||||||
|
.wl_surface()
|
||||||
|
.map(Cow::into_owned)
|
||||||
|
{
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let res = state.common.shell.write().unwrap().move_request(
|
let res = state.common.shell.write().unwrap().move_request(
|
||||||
&surface,
|
&surface,
|
||||||
|
|
@ -757,7 +761,10 @@ impl Program for CosmicStackInternal {
|
||||||
Message::Menu => {
|
Message::Menu => {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
let active = self.active.load(Ordering::SeqCst);
|
let active = self.active.load(Ordering::SeqCst);
|
||||||
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
|
if let Some(surface) = self.windows.lock().unwrap()[active]
|
||||||
|
.wl_surface()
|
||||||
|
.map(Cow::into_owned)
|
||||||
|
{
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let shell = state.common.shell.read().unwrap();
|
let shell = state.common.shell.read().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||||
|
|
@ -808,7 +815,10 @@ impl Program for CosmicStackInternal {
|
||||||
}
|
}
|
||||||
Message::TabMenu(idx) => {
|
Message::TabMenu(idx) => {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
if let Some(surface) = self.windows.lock().unwrap()[idx].wl_surface() {
|
if let Some(surface) = self.windows.lock().unwrap()[idx]
|
||||||
|
.wl_surface()
|
||||||
|
.map(Cow::into_owned)
|
||||||
|
{
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let shell = state.common.shell.read().unwrap();
|
let shell = state.common.shell.read().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||||
|
|
@ -1260,7 +1270,7 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
let seat = seat.clone();
|
let seat = seat.clone();
|
||||||
let Some(surface) = self.0.with_program(|p| {
|
let Some(surface) = self.0.with_program(|p| {
|
||||||
let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
|
let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
|
||||||
window.wl_surface()
|
window.wl_surface().map(Cow::into_owned)
|
||||||
}) else {
|
}) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -1330,7 +1340,7 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
let seat = seat.clone();
|
let seat = seat.clone();
|
||||||
surface.try_force_undecorated(false);
|
surface.try_force_undecorated(false);
|
||||||
surface.send_configure();
|
surface.send_configure();
|
||||||
if let Some(surface) = surface.wl_surface() {
|
if let Some(surface) = surface.wl_surface().map(Cow::into_owned) {
|
||||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||||
let res = state.common.shell.write().unwrap().move_request(
|
let res = state.common.shell.write().unwrap().move_request(
|
||||||
&surface,
|
&surface,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
sync::atomic::{AtomicBool, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
@ -69,7 +70,7 @@ impl From<X11Surface> for CosmicSurface {
|
||||||
|
|
||||||
impl PartialEq<WlSurface> for CosmicSurface {
|
impl PartialEq<WlSurface> for CosmicSurface {
|
||||||
fn eq(&self, other: &WlSurface) -> bool {
|
fn eq(&self, other: &WlSurface) -> bool {
|
||||||
self.wl_surface().map_or(false, |s| &s == other)
|
self.wl_surface().map_or(false, |s| &*s == other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -720,7 +721,7 @@ impl KeyboardTarget<State> for CosmicSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandFocus for CosmicSurface {
|
impl WaylandFocus for CosmicSurface {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
self.0.wl_surface()
|
self.0.wl_surface()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ use smithay::{
|
||||||
wayland::seat::WaylandFocus,
|
wayland::seat::WaylandFocus,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
fmt,
|
fmt,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
|
|
@ -384,7 +385,7 @@ impl Program for CosmicWindowInternal {
|
||||||
match message {
|
match message {
|
||||||
Message::DragStart => {
|
Message::DragStart => {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
if let Some(surface) = self.window.wl_surface() {
|
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let res = state.common.shell.write().unwrap().move_request(
|
let res = state.common.shell.write().unwrap().move_request(
|
||||||
&surface,
|
&surface,
|
||||||
|
|
@ -410,7 +411,7 @@ impl Program for CosmicWindowInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Minimize => {
|
Message::Minimize => {
|
||||||
if let Some(surface) = self.window.wl_surface() {
|
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let mut shell = state.common.shell.write().unwrap();
|
let mut shell = state.common.shell.write().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||||
|
|
@ -420,7 +421,7 @@ impl Program for CosmicWindowInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Maximize => {
|
Message::Maximize => {
|
||||||
if let Some(surface) = self.window.wl_surface() {
|
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let mut shell = state.common.shell.write().unwrap();
|
let mut shell = state.common.shell.write().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||||
|
|
@ -433,7 +434,7 @@ impl Program for CosmicWindowInternal {
|
||||||
Message::Close => self.window.close(),
|
Message::Close => self.window.close(),
|
||||||
Message::Menu => {
|
Message::Menu => {
|
||||||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||||
if let Some(surface) = self.window.wl_surface() {
|
if let Some(surface) = self.window.wl_surface().map(Cow::into_owned) {
|
||||||
loop_handle.insert_idle(move |state| {
|
loop_handle.insert_idle(move |state| {
|
||||||
let shell = state.common.shell.read().unwrap();
|
let shell = state.common.shell.read().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||||
|
|
@ -739,7 +740,7 @@ impl PointerTarget<State> for CosmicWindow {
|
||||||
Some(x) => {
|
Some(x) => {
|
||||||
let serial = event.serial;
|
let serial = event.serial;
|
||||||
let seat = seat.clone();
|
let seat = seat.clone();
|
||||||
let Some(surface) = self.wl_surface() else {
|
let Some(surface) = self.wl_surface().map(Cow::into_owned) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.0.loop_handle().insert_idle(move |state| {
|
self.0.loop_handle().insert_idle(move |state| {
|
||||||
|
|
@ -906,8 +907,12 @@ impl TouchTarget<State> for CosmicWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandFocus for CosmicWindow {
|
impl WaylandFocus for CosmicWindow {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
self.0.with_program(|p| p.window.wl_surface())
|
self.0.with_program(|p| {
|
||||||
|
p.window
|
||||||
|
.wl_surface()
|
||||||
|
.map(|s| Cow::Owned(Cow::into_owned(s)))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use smithay::{
|
||||||
shell::wlr_layer::{KeyboardInteractivity, Layer},
|
shell::wlr_layer::{KeyboardInteractivity, Layer},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::cell::RefCell;
|
use std::{borrow::Cow, cell::RefCell};
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
||||||
use self::target::{KeyboardFocusTarget, WindowGroup};
|
use self::target::{KeyboardFocusTarget, WindowGroup};
|
||||||
|
|
@ -229,7 +229,7 @@ fn raise_with_children(floating_layer: &mut FloatingLayout, focused: &CosmicMapp
|
||||||
.0
|
.0
|
||||||
.toplevel()
|
.toplevel()
|
||||||
.and_then(|toplevel| toplevel.parent());
|
.and_then(|toplevel| toplevel.parent());
|
||||||
parent == focused.active_window().wl_surface()
|
parent == focused.active_window().wl_surface().map(Cow::into_owned)
|
||||||
})
|
})
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{sync::Weak, time::Duration};
|
use std::{borrow::Cow, sync::Weak, time::Duration};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{
|
shell::{
|
||||||
|
|
@ -79,12 +79,12 @@ impl From<KeyboardFocusTarget> for PointerFocusTarget {
|
||||||
let window = elem.active_window();
|
let window = elem.active_window();
|
||||||
let surface = window.wl_surface().unwrap();
|
let surface = window.wl_surface().unwrap();
|
||||||
PointerFocusTarget::WlSurface {
|
PointerFocusTarget::WlSurface {
|
||||||
surface,
|
surface: surface.into_owned(),
|
||||||
toplevel: Some(window.into()),
|
toplevel: Some(window.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyboardFocusTarget::Fullscreen(elem) => PointerFocusTarget::WlSurface {
|
KeyboardFocusTarget::Fullscreen(elem) => PointerFocusTarget::WlSurface {
|
||||||
surface: elem.wl_surface().unwrap(),
|
surface: elem.wl_surface().unwrap().into_owned(),
|
||||||
toplevel: Some(elem.into()),
|
toplevel: Some(elem.into()),
|
||||||
},
|
},
|
||||||
KeyboardFocusTarget::LayerSurface(layer) => PointerFocusTarget::WlSurface {
|
KeyboardFocusTarget::LayerSurface(layer) => PointerFocusTarget::WlSurface {
|
||||||
|
|
@ -145,7 +145,7 @@ impl PointerFocusTarget {
|
||||||
.and_then(|s| shell.element_for_surface(&s).map(|mapped| (mapped, s)))
|
.and_then(|s| shell.element_for_surface(&s).map(|mapped| (mapped, s)))
|
||||||
.and_then(|(m, s)| {
|
.and_then(|(m, s)| {
|
||||||
m.windows()
|
m.windows()
|
||||||
.find(|(w, _)| w.wl_surface().map(|s2| s == s2).unwrap_or(false))
|
.find(|(w, _)| w.wl_surface().map(|s2| s == *s2).unwrap_or(false))
|
||||||
.map(|(s, _)| s)
|
.map(|(s, _)| s)
|
||||||
}),
|
}),
|
||||||
PointerFocusTarget::StackUI(stack) => Some(stack.active()),
|
PointerFocusTarget::StackUI(stack) => Some(stack.active()),
|
||||||
|
|
@ -156,10 +156,12 @@ impl PointerFocusTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeyboardFocusTarget {
|
impl KeyboardFocusTarget {
|
||||||
pub fn toplevel(&self) -> Option<WlSurface> {
|
pub fn toplevel(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
match self {
|
match self {
|
||||||
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
|
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
|
||||||
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => get_popup_toplevel(&xdg),
|
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => {
|
||||||
|
get_popup_toplevel(&xdg).map(Cow::Owned)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -686,14 +688,14 @@ impl KeyboardTarget<State> for KeyboardFocusTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandFocus for KeyboardFocusTarget {
|
impl WaylandFocus for KeyboardFocusTarget {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
match self {
|
match self {
|
||||||
KeyboardFocusTarget::Element(w) => WaylandFocus::wl_surface(w),
|
KeyboardFocusTarget::Element(w) => WaylandFocus::wl_surface(w),
|
||||||
KeyboardFocusTarget::Fullscreen(w) => WaylandFocus::wl_surface(w),
|
KeyboardFocusTarget::Fullscreen(w) => WaylandFocus::wl_surface(w),
|
||||||
KeyboardFocusTarget::Group(_) => None,
|
KeyboardFocusTarget::Group(_) => None,
|
||||||
KeyboardFocusTarget::LayerSurface(l) => Some(l.wl_surface().clone()),
|
KeyboardFocusTarget::LayerSurface(l) => Some(Cow::Borrowed(l.wl_surface())),
|
||||||
KeyboardFocusTarget::Popup(p) => Some(p.wl_surface().clone()),
|
KeyboardFocusTarget::Popup(p) => Some(Cow::Borrowed(p.wl_surface())),
|
||||||
KeyboardFocusTarget::LockSurface(l) => Some(l.wl_surface().clone()),
|
KeyboardFocusTarget::LockSurface(l) => Some(Cow::Borrowed(l.wl_surface())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
||||||
|
|
@ -709,9 +711,9 @@ impl WaylandFocus for KeyboardFocusTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandFocus for PointerFocusTarget {
|
impl WaylandFocus for PointerFocusTarget {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
PointerFocusTarget::WlSurface { surface, .. } => surface.clone(),
|
PointerFocusTarget::WlSurface { surface, .. } => Cow::Borrowed(surface),
|
||||||
PointerFocusTarget::ResizeFork(_)
|
PointerFocusTarget::ResizeFork(_)
|
||||||
| PointerFocusTarget::StackUI(_)
|
| PointerFocusTarget::StackUI(_)
|
||||||
| PointerFocusTarget::WindowUI(_) => {
|
| PointerFocusTarget::WindowUI(_) => {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl MenuGrabState {
|
||||||
pub fn render<I, R>(&self, renderer: &mut R, output: &Output) -> Vec<I>
|
pub fn render<I, R>(&self, renderer: &mut R, output: &Output) -> Vec<I>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportMem,
|
R: Renderer + ImportMem,
|
||||||
<R as Renderer>::TextureId: 'static,
|
<R as Renderer>::TextureId: Clone + 'static,
|
||||||
I: From<MemoryRenderBufferRenderElement<R>>,
|
I: From<MemoryRenderBufferRenderElement<R>>,
|
||||||
{
|
{
|
||||||
let scale = output.current_scale().fractional_scale();
|
let scale = output.current_scale().fractional_scale();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
touch::{
|
touch::{
|
||||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||||
TouchGrab, TouchInnerHandle, UpEvent,
|
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel,
|
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel,
|
||||||
|
|
@ -387,6 +387,32 @@ impl TouchGrab<State> for ResizeGrab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shape(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &ShapeEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
match self {
|
||||||
|
ResizeGrab::Floating(grab) => TouchGrab::shape(grab, data, handle, event, seq),
|
||||||
|
ResizeGrab::Tiling(grab) => TouchGrab::shape(grab, data, handle, event, seq),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn orientation(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &OrientationEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
match self {
|
||||||
|
ResizeGrab::Floating(grab) => TouchGrab::orientation(grab, data, handle, event, seq),
|
||||||
|
ResizeGrab::Tiling(grab) => TouchGrab::orientation(grab, data, handle, event, seq),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn start_data(&self) -> &TouchGrabStartData<State> {
|
fn start_data(&self) -> &TouchGrabStartData<State> {
|
||||||
match self {
|
match self {
|
||||||
ResizeGrab::Floating(grab) => TouchGrab::start_data(grab),
|
ResizeGrab::Floating(grab) => TouchGrab::start_data(grab),
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,26 @@ impl TouchGrab<State> for MoveGrab {
|
||||||
handle.unset_grab(self, data);
|
handle.unset_grab(self, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shape(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &touch::ShapeEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.shape(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn orientation(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &touch::OrientationEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.orientation(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
fn start_data(&self) -> &TouchGrabStartData<State> {
|
fn start_data(&self) -> &TouchGrabStartData<State> {
|
||||||
match &self.start_data {
|
match &self.start_data {
|
||||||
GrabStartData::Touch(start_data) => start_data,
|
GrabStartData::Touch(start_data) => start_data,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
touch::{
|
touch::{
|
||||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||||
TouchGrab, TouchInnerHandle, UpEvent,
|
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
|
||||||
},
|
},
|
||||||
Seat,
|
Seat,
|
||||||
},
|
},
|
||||||
|
|
@ -328,6 +328,26 @@ impl TouchGrab<State> for ResizeSurfaceGrab {
|
||||||
handle.unset_grab(self, data);
|
handle.unset_grab(self, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shape(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &ShapeEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.shape(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn orientation(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &OrientationEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.orientation(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
fn start_data(&self) -> &TouchGrabStartData<State> {
|
fn start_data(&self) -> &TouchGrabStartData<State> {
|
||||||
match &self.start_data {
|
match &self.start_data {
|
||||||
GrabStartData::Touch(start_data) => start_data,
|
GrabStartData::Touch(start_data) => start_data,
|
||||||
|
|
|
||||||
|
|
@ -1132,7 +1132,7 @@ impl FloatingLayout {
|
||||||
};
|
};
|
||||||
self.space
|
self.space
|
||||||
.elements()
|
.elements()
|
||||||
.find(|elem| elem.wl_surface().as_ref() == Some(&toplevel_surface))
|
.find(|elem| elem.wl_surface().as_deref() == Some(&toplevel_surface))
|
||||||
}
|
}
|
||||||
KeyboardFocusTarget::Element(elem) => self.space.elements().find(|x| *x == &elem),
|
KeyboardFocusTarget::Element(elem) => self.space.elements().find(|x| *x == &elem),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,16 @@ impl TouchGrab<State> for ResizeForkGrab {
|
||||||
handle.unset_grab(self, data);
|
handle.unset_grab(self, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shape(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &ShapeEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.shape(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
fn start_data(&self) -> &TouchGrabStartData<State> {
|
fn start_data(&self) -> &TouchGrabStartData<State> {
|
||||||
match &self.start_data {
|
match &self.start_data {
|
||||||
GrabStartData::Touch(start_data) => start_data,
|
GrabStartData::Touch(start_data) => start_data,
|
||||||
|
|
@ -532,5 +542,15 @@ impl TouchGrab<State> for ResizeForkGrab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn orientation(
|
||||||
|
&mut self,
|
||||||
|
data: &mut State,
|
||||||
|
handle: &mut TouchInnerHandle<'_, State>,
|
||||||
|
event: &OrientationEvent,
|
||||||
|
seq: Serial,
|
||||||
|
) {
|
||||||
|
handle.orientation(data, event, seq)
|
||||||
|
}
|
||||||
|
|
||||||
fn unset(&mut self, _data: &mut State) {}
|
fn unset(&mut self, _data: &mut State) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2791,7 +2791,7 @@ impl TilingLayout {
|
||||||
.find(|node| match node.data() {
|
.find(|node| match node.data() {
|
||||||
Data::Mapped { mapped, .. } => mapped
|
Data::Mapped { mapped, .. } => mapped
|
||||||
.windows()
|
.windows()
|
||||||
.any(|(w, _)| w.wl_surface().as_ref() == Some(&toplevel_surface)),
|
.any(|(w, _)| w.wl_surface().as_deref() == Some(&toplevel_surface)),
|
||||||
_ => false,
|
_ => false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2206,7 +2206,7 @@ impl Shell {
|
||||||
let mapped = self.element_for_surface(surface).cloned()?;
|
let mapped = self.element_for_surface(surface).cloned()?;
|
||||||
let (_, relative_loc) = mapped
|
let (_, relative_loc) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
|
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let (global_position, edge, is_tiled, is_stacked, is_sticky, tiling_enabled) =
|
let (global_position, edge, is_tiled, is_stacked, is_sticky, tiling_enabled) =
|
||||||
|
|
@ -2279,7 +2279,7 @@ impl Shell {
|
||||||
} else {
|
} else {
|
||||||
let (tab, _) = mapped
|
let (tab, _) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(s, _)| s.wl_surface().as_ref() == Some(surface))
|
.find(|(s, _)| s.wl_surface().as_deref() == Some(surface))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Box::new(tab_items(&mapped, &tab, is_tiled, &config.static_conf))
|
Box::new(tab_items(&mapped, &tab, is_tiled, &config.static_conf))
|
||||||
as Box<dyn Iterator<Item = Item>>
|
as Box<dyn Iterator<Item = Item>>
|
||||||
|
|
@ -2320,7 +2320,7 @@ impl Shell {
|
||||||
|
|
||||||
let (window, _) = old_mapped
|
let (window, _) = old_mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
|
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mapped = if move_out_of_stack {
|
let mapped = if move_out_of_stack {
|
||||||
|
|
@ -2502,7 +2502,7 @@ impl Shell {
|
||||||
.space
|
.space
|
||||||
.elements()
|
.elements()
|
||||||
.chain(workspace.mapped())
|
.chain(workspace.mapped())
|
||||||
.find(|elem| elem.wl_surface().as_ref() == Some(&toplevel_surface))
|
.find(|elem| elem.wl_surface().as_deref() == Some(&toplevel_surface))
|
||||||
}
|
}
|
||||||
KeyboardFocusTarget::Element(elem) => sticky_layer
|
KeyboardFocusTarget::Element(elem) => sticky_layer
|
||||||
.space
|
.space
|
||||||
|
|
@ -2664,7 +2664,8 @@ impl Shell {
|
||||||
),
|
),
|
||||||
(ResizeGrab, Focus),
|
(ResizeGrab, Focus),
|
||||||
)> {
|
)> {
|
||||||
let surface = mapped.active_window().wl_surface()?;
|
let active_window = mapped.active_window();
|
||||||
|
let surface = active_window.wl_surface()?;
|
||||||
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
|
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
gles::{GlesError, GlesTexture},
|
gles::{GlesError, GlesTexture},
|
||||||
glow::{GlowFrame, GlowRenderer},
|
glow::{GlowFrame, GlowRenderer},
|
||||||
utils::DamageSet,
|
utils::{DamageSet, OpaqueRegions},
|
||||||
ImportAll, ImportMem, Renderer,
|
ImportAll, ImportMem, Renderer,
|
||||||
},
|
},
|
||||||
desktop::{layer_map_for_output, space::SpaceElement},
|
desktop::{layer_map_for_output, space::SpaceElement},
|
||||||
|
|
@ -328,7 +328,7 @@ impl Workspace {
|
||||||
if let Some(signal) = f.animation_signal.take() {
|
if let Some(signal) = f.animation_signal.take() {
|
||||||
signal.store(true, Ordering::SeqCst);
|
signal.store(true, Ordering::SeqCst);
|
||||||
if let Some(client) =
|
if let Some(client) =
|
||||||
f.surface.wl_surface().as_ref().and_then(Resource::client)
|
f.surface.wl_surface().as_deref().and_then(Resource::client)
|
||||||
{
|
{
|
||||||
clients.insert(client.id(), client);
|
clients.insert(client.id(), client);
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +342,7 @@ impl Workspace {
|
||||||
if let Some(signal) = f.animation_signal.take() {
|
if let Some(signal) = f.animation_signal.take() {
|
||||||
signal.store(true, Ordering::SeqCst);
|
signal.store(true, Ordering::SeqCst);
|
||||||
if let Some(client) =
|
if let Some(client) =
|
||||||
f.surface.wl_surface().as_ref().and_then(Resource::client)
|
f.surface.wl_surface().as_deref().and_then(Resource::client)
|
||||||
{
|
{
|
||||||
clients.insert(client.id(), client);
|
clients.insert(client.id(), client);
|
||||||
}
|
}
|
||||||
|
|
@ -823,7 +823,7 @@ impl Workspace {
|
||||||
if self
|
if self
|
||||||
.fullscreen
|
.fullscreen
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|f| f.surface.wl_surface().as_ref() == Some(&toplevel))
|
.is_some_and(|f| f.surface.wl_surface().as_deref() == Some(&toplevel))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1332,7 +1332,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, smithay::utils::Physical>> {
|
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, smithay::utils::Physical> {
|
||||||
match self {
|
match self {
|
||||||
WorkspaceRenderElement::OverrideRedirect(elem) => elem.opaque_regions(scale),
|
WorkspaceRenderElement::OverrideRedirect(elem) => elem.opaque_regions(scale),
|
||||||
WorkspaceRenderElement::Fullscreen(elem) => elem.opaque_regions(scale),
|
WorkspaceRenderElement::Fullscreen(elem) => elem.opaque_regions(scale),
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ use smithay::{
|
||||||
virtual_keyboard::VirtualKeyboardManagerState,
|
virtual_keyboard::VirtualKeyboardManagerState,
|
||||||
xdg_activation::XdgActivationState,
|
xdg_activation::XdgActivationState,
|
||||||
xwayland_keyboard_grab::XWaylandKeyboardGrabState,
|
xwayland_keyboard_grab::XWaylandKeyboardGrabState,
|
||||||
|
xwayland_shell::XWaylandShellState,
|
||||||
},
|
},
|
||||||
xwayland::XWaylandClientData,
|
xwayland::XWaylandClientData,
|
||||||
};
|
};
|
||||||
|
|
@ -219,6 +220,7 @@ pub struct Common {
|
||||||
pub xdg_activation_state: XdgActivationState,
|
pub xdg_activation_state: XdgActivationState,
|
||||||
pub workspace_state: WorkspaceState<State>,
|
pub workspace_state: WorkspaceState<State>,
|
||||||
pub xwayland_state: Option<XWaylandState>,
|
pub xwayland_state: Option<XWaylandState>,
|
||||||
|
pub xwayland_shell_state: XWaylandShellState,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -427,6 +429,7 @@ impl State {
|
||||||
let session_lock_manager_state =
|
let session_lock_manager_state =
|
||||||
SessionLockManagerState::new::<Self, _>(&dh, client_is_privileged);
|
SessionLockManagerState::new::<Self, _>(&dh, client_is_privileged);
|
||||||
XWaylandKeyboardGrabState::new::<Self>(&dh);
|
XWaylandKeyboardGrabState::new::<Self>(&dh);
|
||||||
|
let xwayland_shell_state = XWaylandShellState::new::<Self>(&dh);
|
||||||
PointerConstraintsState::new::<Self>(&dh);
|
PointerConstraintsState::new::<Self>(&dh);
|
||||||
PointerGesturesState::new::<Self>(&dh);
|
PointerGesturesState::new::<Self>(&dh);
|
||||||
TabletManagerState::new::<Self>(&dh);
|
TabletManagerState::new::<Self>(&dh);
|
||||||
|
|
@ -533,6 +536,7 @@ impl State {
|
||||||
xdg_activation_state,
|
xdg_activation_state,
|
||||||
workspace_state,
|
workspace_state,
|
||||||
xwayland_state: None,
|
xwayland_state: None,
|
||||||
|
xwayland_shell_state,
|
||||||
},
|
},
|
||||||
backend: BackendData::Unset,
|
backend: BackendData::Unset,
|
||||||
ready: Once::new(),
|
ready: Once::new(),
|
||||||
|
|
|
||||||
|
|
@ -843,7 +843,7 @@ impl<P, R> AsRenderElements<R> for IcedElement<P>
|
||||||
where
|
where
|
||||||
P: Program + Send + 'static,
|
P: Program + Send + 'static,
|
||||||
R: Renderer + ImportMem,
|
R: Renderer + ImportMem,
|
||||||
<R as Renderer>::TextureId: 'static,
|
<R as Renderer>::TextureId: Clone + 'static,
|
||||||
{
|
{
|
||||||
type RenderElement = MemoryRenderBufferRenderElement<R>;
|
type RenderElement = MemoryRenderBufferRenderElement<R>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ impl CompositorHandler for State {
|
||||||
.buffer
|
.buffer
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|assignment| match assignment {
|
.and_then(|assignment| match assignment {
|
||||||
BufferAssignment::NewBuffer(buffer) => get_dmabuf(buffer).ok(),
|
BufferAssignment::NewBuffer(buffer) => get_dmabuf(buffer).ok().cloned(),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
@ -134,7 +134,7 @@ impl CompositorHandler for State {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&mut self, surface: &WlSurface) {
|
fn commit(&mut self, surface: &WlSurface) {
|
||||||
X11Wm::commit_hook::<State>(surface);
|
X11Wm::commit_hook::<State>(self, surface);
|
||||||
// first load the buffer for various smithay helper functions (which also initializes the RendererSurfaceState)
|
// first load the buffer for various smithay helper functions (which also initializes the RendererSurfaceState)
|
||||||
on_commit_buffer_handler::<Self>(surface);
|
on_commit_buffer_handler::<Self>(surface);
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ impl CompositorHandler for State {
|
||||||
if let Some((window, _, _)) = shell
|
if let Some((window, _, _)) = shell
|
||||||
.pending_windows
|
.pending_windows
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(window, _, _)| window.wl_surface().as_ref() == Some(surface))
|
.find(|(window, _, _)| window.wl_surface().as_deref() == Some(surface))
|
||||||
.cloned()
|
.cloned()
|
||||||
{
|
{
|
||||||
if let Some(toplevel) = window.0.toplevel() {
|
if let Some(toplevel) = window.0.toplevel() {
|
||||||
|
|
@ -220,7 +220,7 @@ impl CompositorHandler for State {
|
||||||
.windows()
|
.windows()
|
||||||
.any(|(s, _)| {
|
.any(|(s, _)| {
|
||||||
s.wl_surface()
|
s.wl_surface()
|
||||||
.as_ref()
|
.as_deref()
|
||||||
.map(|s| s == surface)
|
.map(|s| s == surface)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
|
|
@ -231,7 +231,7 @@ impl CompositorHandler for State {
|
||||||
let stack = window.stack_ref_mut().unwrap();
|
let stack = window.stack_ref_mut().unwrap();
|
||||||
if let Some(i) = stack.surfaces().position(|s| {
|
if let Some(i) = stack.surfaces().position(|s| {
|
||||||
s.wl_surface()
|
s.wl_surface()
|
||||||
.as_ref()
|
.as_deref()
|
||||||
.map(|s| s == surface)
|
.map(|s| s == surface)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}) {
|
}) {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
|
||||||
if mapped.is_stack() {
|
if mapped.is_stack() {
|
||||||
if let Some((window, _)) = mapped
|
if let Some((window, _)) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
|
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
|
||||||
{
|
{
|
||||||
if let Some(toplevel) = window.0.toplevel() {
|
if let Some(toplevel) = window.0.toplevel() {
|
||||||
toplevel
|
toplevel
|
||||||
|
|
@ -70,7 +70,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
|
||||||
} else {
|
} else {
|
||||||
if let Some((window, _)) = mapped
|
if let Some((window, _)) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
|
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
|
||||||
{
|
{
|
||||||
if let Some(toplevel) = window.0.toplevel() {
|
if let Some(toplevel) = window.0.toplevel() {
|
||||||
toplevel
|
toplevel
|
||||||
|
|
@ -85,7 +85,7 @@ pub fn new_decoration(mapped: &CosmicMapped, surface: &WlSurface) -> KdeMode {
|
||||||
pub fn request_mode(mapped: &CosmicMapped, surface: &WlSurface, mode: XdgMode) {
|
pub fn request_mode(mapped: &CosmicMapped, surface: &WlSurface, mode: XdgMode) {
|
||||||
if let Some((window, _)) = mapped
|
if let Some((window, _)) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
|
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
|
||||||
{
|
{
|
||||||
if let Some(toplevel) = window.0.toplevel() {
|
if let Some(toplevel) = window.0.toplevel() {
|
||||||
PreferredDecorationMode::update(&window.0, Some(mode));
|
PreferredDecorationMode::update(&window.0, Some(mode));
|
||||||
|
|
@ -100,7 +100,7 @@ pub fn request_mode(mapped: &CosmicMapped, surface: &WlSurface, mode: XdgMode) {
|
||||||
pub fn unset_mode(mapped: &CosmicMapped, surface: &WlSurface) {
|
pub fn unset_mode(mapped: &CosmicMapped, surface: &WlSurface) {
|
||||||
if let Some((window, _)) = mapped
|
if let Some((window, _)) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(window, _)| window.wl_surface().as_ref() == Some(surface))
|
.find(|(window, _)| window.wl_surface().as_deref() == Some(surface))
|
||||||
{
|
{
|
||||||
if let Some(toplevel) = window.0.toplevel() {
|
if let Some(toplevel) = window.0.toplevel() {
|
||||||
PreferredDecorationMode::update(&window.0, None);
|
PreferredDecorationMode::update(&window.0, None);
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,4 @@ pub mod workspace;
|
||||||
pub mod xdg_activation;
|
pub mod xdg_activation;
|
||||||
pub mod xdg_shell;
|
pub mod xdg_shell;
|
||||||
pub mod xwayland_keyboard_grab;
|
pub mod xwayland_keyboard_grab;
|
||||||
|
pub mod xwayland_shell;
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,7 @@ impl PointerConstraintsHandler for State {
|
||||||
// XXX region
|
// XXX region
|
||||||
if pointer
|
if pointer
|
||||||
.current_focus()
|
.current_focus()
|
||||||
.and_then(|x| x.wl_surface())
|
.map_or(false, |x| x.wl_surface().as_deref() == Some(surface))
|
||||||
.as_ref()
|
|
||||||
== Some(surface)
|
|
||||||
{
|
{
|
||||||
with_pointer_constraint(surface, pointer, |constraint| {
|
with_pointer_constraint(surface, pointer, |constraint| {
|
||||||
constraint.unwrap().activate();
|
constraint.unwrap().activate();
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ pub fn render_workspace_to_buffer(
|
||||||
render_workspace::<_, _, GlesRenderbuffer>(
|
render_workspace::<_, _, GlesRenderbuffer>(
|
||||||
None,
|
None,
|
||||||
renderer,
|
renderer,
|
||||||
dmabuf,
|
dmabuf.clone(),
|
||||||
dt,
|
dt,
|
||||||
age,
|
age,
|
||||||
additional_damage,
|
additional_damage,
|
||||||
|
|
@ -581,7 +581,7 @@ pub fn render_window_to_buffer(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
||||||
renderer.bind(dmabuf).map_err(DTError::Rendering)?;
|
renderer.bind(dmabuf.clone()).map_err(DTError::Rendering)?;
|
||||||
} else {
|
} else {
|
||||||
let size = buffer_dimensions(buffer).unwrap();
|
let size = buffer_dimensions(buffer).unwrap();
|
||||||
let format =
|
let format =
|
||||||
|
|
@ -794,7 +794,7 @@ pub fn render_cursor_to_buffer(
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
if let Ok(dmabuf) = get_dmabuf(buffer) {
|
||||||
renderer.bind(dmabuf).map_err(DTError::Rendering)?;
|
renderer.bind(dmabuf.clone()).map_err(DTError::Rendering)?;
|
||||||
} else {
|
} else {
|
||||||
let size = buffer_dimensions(buffer).unwrap();
|
let size = buffer_dimensions(buffer).unwrap();
|
||||||
let format =
|
let format =
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ impl XdgShellHandler for State {
|
||||||
let mut shell = self.common.shell.write().unwrap();
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
if let Some(mapped) = shell.element_for_surface(surface.wl_surface()).cloned() {
|
if let Some(mapped) = shell.element_for_surface(surface.wl_surface()).cloned() {
|
||||||
if !mapped.is_stack()
|
if !mapped.is_stack()
|
||||||
|| mapped.active_window().wl_surface().as_ref() == Some(surface.wl_surface())
|
|| mapped.active_window().wl_surface().as_deref() == Some(surface.wl_surface())
|
||||||
{
|
{
|
||||||
shell.minimize_request(&mapped)
|
shell.minimize_request(&mapped)
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ impl XdgShellHandler for State {
|
||||||
let stack = mapped.stack_ref().unwrap();
|
let stack = mapped.stack_ref().unwrap();
|
||||||
let surface = stack
|
let surface = stack
|
||||||
.surfaces()
|
.surfaces()
|
||||||
.find(|s| s.wl_surface().as_ref() == Some(surface.wl_surface()))
|
.find(|s| s.wl_surface().as_deref() == Some(surface.wl_surface()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
stack.remove_window(&surface);
|
stack.remove_window(&surface);
|
||||||
CosmicMapped::from(CosmicWindow::new(
|
CosmicMapped::from(CosmicWindow::new(
|
||||||
|
|
@ -286,7 +286,7 @@ impl XdgShellHandler for State {
|
||||||
let stack = mapped.stack_ref().unwrap();
|
let stack = mapped.stack_ref().unwrap();
|
||||||
let surface = stack
|
let surface = stack
|
||||||
.surfaces()
|
.surfaces()
|
||||||
.find(|s| s.wl_surface().as_ref() == Some(surface.wl_surface()))
|
.find(|s| s.wl_surface().as_deref() == Some(surface.wl_surface()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
stack.remove_window(&surface);
|
stack.remove_window(&surface);
|
||||||
(
|
(
|
||||||
|
|
@ -325,7 +325,7 @@ impl XdgShellHandler for State {
|
||||||
} else {
|
} else {
|
||||||
let (window, _) = mapped
|
let (window, _) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface.wl_surface()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
workspace.fullscreen_request(&window, None, from, &seat)
|
workspace.fullscreen_request(&window, None, from, &seat)
|
||||||
}
|
}
|
||||||
|
|
@ -334,7 +334,7 @@ impl XdgShellHandler for State {
|
||||||
if let Some(o) = shell
|
if let Some(o) = shell
|
||||||
.pending_windows
|
.pending_windows
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|(s, _, _)| s.wl_surface().as_ref() == Some(surface.wl_surface()))
|
.find(|(s, _, _)| s.wl_surface().as_deref() == Some(surface.wl_surface()))
|
||||||
.map(|(_, _, o)| o)
|
.map(|(_, _, o)| o)
|
||||||
{
|
{
|
||||||
*o = Some(output);
|
*o = Some(output);
|
||||||
|
|
@ -348,7 +348,7 @@ impl XdgShellHandler for State {
|
||||||
if let Some(workspace) = shell.space_for_mut(&mapped) {
|
if let Some(workspace) = shell.space_for_mut(&mapped) {
|
||||||
let (window, _) = mapped
|
let (window, _) = mapped
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface.wl_surface()))
|
.find(|(w, _)| w.wl_surface().as_deref() == Some(surface.wl_surface()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Some((layer, previous_workspace)) = workspace.unfullscreen_request(&window) {
|
if let Some((layer, previous_workspace)) = workspace.unfullscreen_request(&window) {
|
||||||
let old_handle = workspace.handle.clone();
|
let old_handle = workspace.handle.clone();
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ impl Shell {
|
||||||
|
|
||||||
let (window, offset) = elem
|
let (window, offset) = elem
|
||||||
.windows()
|
.windows()
|
||||||
.find(|(w, _)| w.wl_surface().as_ref() == Some(&parent))
|
.find(|(w, _)| w.wl_surface().as_deref() == Some(&parent))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let window_geo_offset = window.geometry().loc;
|
let window_geo_offset = window.geometry().loc;
|
||||||
let window_loc: Point<i32, Global> =
|
let window_loc: Point<i32, Global> =
|
||||||
|
|
|
||||||
15
src/wayland/handlers/xwayland_shell.rs
Normal file
15
src/wayland/handlers/xwayland_shell.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use crate::state::State;
|
||||||
|
use smithay::{
|
||||||
|
delegate_xwayland_shell,
|
||||||
|
wayland::xwayland_shell::{XWaylandShellHandler, XWaylandShellState},
|
||||||
|
};
|
||||||
|
|
||||||
|
impl XWaylandShellHandler for State {
|
||||||
|
fn xwayland_shell_state(&mut self) -> &mut XWaylandShellState {
|
||||||
|
&mut self.common.xwayland_shell_state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate_xwayland_shell!(State);
|
||||||
|
|
@ -83,7 +83,6 @@ impl State {
|
||||||
|
|
||||||
let mut wm = match X11Wm::start_wm(
|
let mut wm = match X11Wm::start_wm(
|
||||||
data.common.event_loop_handle.clone(),
|
data.common.event_loop_handle.clone(),
|
||||||
data.common.display_handle.clone(),
|
|
||||||
x11_socket,
|
x11_socket,
|
||||||
client.clone(),
|
client.clone(),
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue