Merge pull request #132 from pop-os/current-pending-checks_jammy
shell: Allow querying current vs pending state
This commit is contained in:
commit
9444eed4c3
8 changed files with 111 additions and 69 deletions
|
|
@ -247,14 +247,14 @@ impl CosmicMapped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_resizing(&self) -> Option<bool> {
|
pub fn is_resizing(&self, pending: bool) -> Option<bool> {
|
||||||
let window = match &self.element {
|
let window = match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.active(),
|
CosmicMappedInternal::Stack(s) => s.active(),
|
||||||
CosmicMappedInternal::Window(w) => w.surface(),
|
CosmicMappedInternal::Window(w) => w.surface(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
window.is_resizing()
|
window.is_resizing(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_tiled(&self, tiled: bool) {
|
pub fn set_tiled(&self, tiled: bool) {
|
||||||
|
|
@ -268,14 +268,14 @@ impl CosmicMapped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_tiled(&self) -> Option<bool> {
|
pub fn is_tiled(&self, pending: bool) -> Option<bool> {
|
||||||
let window = match &self.element {
|
let window = match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.active(),
|
CosmicMappedInternal::Stack(s) => s.active(),
|
||||||
CosmicMappedInternal::Window(w) => w.surface(),
|
CosmicMappedInternal::Window(w) => w.surface(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
window.is_tiled()
|
window.is_tiled(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_fullscreen(&self, fullscreen: bool) {
|
pub fn set_fullscreen(&self, fullscreen: bool) {
|
||||||
|
|
@ -290,14 +290,14 @@ impl CosmicMapped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_fullscreen(&self) -> bool {
|
pub fn is_fullscreen(&self, pending: bool) -> bool {
|
||||||
let window = match &self.element {
|
let window = match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.active(),
|
CosmicMappedInternal::Stack(s) => s.active(),
|
||||||
CosmicMappedInternal::Window(w) => w.surface(),
|
CosmicMappedInternal::Window(w) => w.surface(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
window.is_fullscreen()
|
window.is_fullscreen(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_maximized(&self, maximized: bool) {
|
pub fn set_maximized(&self, maximized: bool) {
|
||||||
|
|
@ -312,14 +312,14 @@ impl CosmicMapped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_maximized(&self) -> bool {
|
pub fn is_maximized(&self, pending: bool) -> bool {
|
||||||
let window = match &self.element {
|
let window = match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.active(),
|
CosmicMappedInternal::Stack(s) => s.active(),
|
||||||
CosmicMappedInternal::Window(w) => w.surface(),
|
CosmicMappedInternal::Window(w) => w.surface(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
window.is_maximized()
|
window.is_maximized(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_activated(&self, activated: bool) {
|
pub fn set_activated(&self, activated: bool) {
|
||||||
|
|
@ -334,14 +334,14 @@ impl CosmicMapped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_activated(&self) -> bool {
|
pub fn is_activated(&self, pending: bool) -> bool {
|
||||||
let window = match &self.element {
|
let window = match &self.element {
|
||||||
CosmicMappedInternal::Stack(s) => s.active(),
|
CosmicMappedInternal::Stack(s) => s.active(),
|
||||||
CosmicMappedInternal::Window(w) => w.surface(),
|
CosmicMappedInternal::Window(w) => w.surface(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
window.is_activated()
|
window.is_activated(pending)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
pub fn set_geometry(&self, geo: Rectangle<i32, Logical>) {
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,21 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_activated(&self) -> bool {
|
pub fn is_activated(&self, pending: bool) -> bool {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => window
|
CosmicSurface::Wayland(window) => {
|
||||||
.toplevel()
|
if pending {
|
||||||
.current_state()
|
window.toplevel().with_pending_state(|pending| {
|
||||||
.states
|
pending.states.contains(ToplevelState::Activated)
|
||||||
.contains(ToplevelState::Activated),
|
})
|
||||||
|
} else {
|
||||||
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.states
|
||||||
|
.contains(ToplevelState::Activated)
|
||||||
|
}
|
||||||
|
}
|
||||||
CosmicSurface::X11(surface) => surface.is_activated(),
|
CosmicSurface::X11(surface) => surface.is_activated(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
@ -157,29 +165,46 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_decorated(&self) -> bool {
|
pub fn is_decorated(&self, pending: bool) -> bool {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => window
|
CosmicSurface::Wayland(window) => {
|
||||||
.toplevel()
|
if pending {
|
||||||
.current_state()
|
window.toplevel().with_pending_state(|pending| {
|
||||||
.decoration_mode
|
pending
|
||||||
.map(|mode| mode == DecorationMode::ClientSide)
|
.decoration_mode
|
||||||
.unwrap_or(true),
|
.map(|mode| mode == DecorationMode::ClientSide)
|
||||||
|
.unwrap_or(true)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.decoration_mode
|
||||||
|
.map(|mode| mode == DecorationMode::ClientSide)
|
||||||
|
.unwrap_or(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
CosmicSurface::X11(surface) => surface.is_decorated(),
|
CosmicSurface::X11(surface) => surface.is_decorated(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_resizing(&self) -> Option<bool> {
|
pub fn is_resizing(&self, pending: bool) -> Option<bool> {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => {
|
CosmicSurface::Wayland(window) => {
|
||||||
let xdg = window.toplevel();
|
if pending {
|
||||||
Some(
|
Some(window.toplevel().with_pending_state(|pending| {
|
||||||
xdg.current_state().states.contains(ToplevelState::Resizing)
|
pending.states.contains(ToplevelState::Resizing)
|
||||||
|| xdg.with_pending_state(|states| {
|
}))
|
||||||
states.states.contains(ToplevelState::Resizing)
|
} else {
|
||||||
}),
|
Some(
|
||||||
)
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.states
|
||||||
|
.contains(ToplevelState::Resizing),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
@ -198,15 +223,23 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_tiled(&self) -> Option<bool> {
|
pub fn is_tiled(&self, pending: bool) -> Option<bool> {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => Some(
|
CosmicSurface::Wayland(window) => {
|
||||||
window
|
if pending {
|
||||||
.toplevel()
|
Some(window.toplevel().with_pending_state(|pending| {
|
||||||
.current_state()
|
pending.states.contains(ToplevelState::TiledLeft)
|
||||||
.states
|
}))
|
||||||
.contains(ToplevelState::TiledLeft),
|
} else {
|
||||||
),
|
Some(
|
||||||
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.states
|
||||||
|
.contains(ToplevelState::TiledLeft),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,16 +263,20 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_fullscreen(&self) -> bool {
|
pub fn is_fullscreen(&self, pending: bool) -> bool {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => {
|
CosmicSurface::Wayland(window) => {
|
||||||
let xdg = window.toplevel();
|
if pending {
|
||||||
xdg.current_state()
|
window.toplevel().with_pending_state(|pending| {
|
||||||
.states
|
pending.states.contains(ToplevelState::Fullscreen)
|
||||||
.contains(ToplevelState::Fullscreen)
|
|
||||||
|| xdg.with_pending_state(|state| {
|
|
||||||
state.states.contains(ToplevelState::Fullscreen)
|
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.states
|
||||||
|
.contains(ToplevelState::Fullscreen)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CosmicSurface::X11(surface) => surface.is_fullscreen(),
|
CosmicSurface::X11(surface) => surface.is_fullscreen(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
@ -262,15 +299,20 @@ impl CosmicSurface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_maximized(&self) -> bool {
|
pub fn is_maximized(&self, pending: bool) -> bool {
|
||||||
match self {
|
match self {
|
||||||
CosmicSurface::Wayland(window) => {
|
CosmicSurface::Wayland(window) => {
|
||||||
let xdg = window.toplevel();
|
if pending {
|
||||||
xdg.current_state()
|
window.toplevel().with_pending_state(|pending| {
|
||||||
.states
|
pending.states.contains(ToplevelState::Maximized)
|
||||||
.contains(ToplevelState::Maximized)
|
})
|
||||||
|| xdg
|
} else {
|
||||||
.with_pending_state(|state| state.states.contains(ToplevelState::Maximized))
|
window
|
||||||
|
.toplevel()
|
||||||
|
.current_state()
|
||||||
|
.states
|
||||||
|
.contains(ToplevelState::Maximized)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CosmicSurface::X11(surface) => surface.is_maximized(),
|
CosmicSurface::X11(surface) => surface.is_maximized(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
@ -311,7 +353,7 @@ impl CosmicSurface {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
.map(|size| {
|
.map(|size| {
|
||||||
if self.is_decorated() {
|
if self.is_decorated(false) {
|
||||||
size + (0, SSD_HEIGHT).into()
|
size + (0, SSD_HEIGHT).into()
|
||||||
} else {
|
} else {
|
||||||
size
|
size
|
||||||
|
|
@ -337,7 +379,7 @@ impl CosmicSurface {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
.map(|size| {
|
.map(|size| {
|
||||||
if self.is_decorated() {
|
if self.is_decorated(false) {
|
||||||
size + (0, SSD_HEIGHT).into()
|
size + (0, SSD_HEIGHT).into()
|
||||||
} else {
|
} else {
|
||||||
size
|
size
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ impl CosmicWindowInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_ssd(&self) -> bool {
|
pub fn has_ssd(&self) -> bool {
|
||||||
!self.window.is_decorated()
|
!self.window.is_decorated(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,7 +259,7 @@ impl Program for CosmicWindowInternal {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn background_color(&self) -> Color {
|
fn background_color(&self) -> Color {
|
||||||
if self.window.is_activated() {
|
if self.window.is_activated(false) {
|
||||||
Color {
|
Color {
|
||||||
r: 0.1176,
|
r: 0.1176,
|
||||||
g: 0.1176,
|
g: 0.1176,
|
||||||
|
|
@ -281,7 +281,7 @@ impl Program for CosmicWindowInternal {
|
||||||
pixels: &mut tiny_skia::PixmapMut<'_>,
|
pixels: &mut tiny_skia::PixmapMut<'_>,
|
||||||
damage: &[Rectangle<i32, BufferCoords>],
|
damage: &[Rectangle<i32, BufferCoords>],
|
||||||
) {
|
) {
|
||||||
if !self.window.is_activated() {
|
if !self.window.is_activated(false) {
|
||||||
let mask = self.mask.lock().unwrap();
|
let mask = self.mask.lock().unwrap();
|
||||||
let mut paint = tiny_skia::Paint::default();
|
let mut paint = tiny_skia::Paint::default();
|
||||||
paint.set_color_rgba8(0, 0, 0, 102);
|
paint.set_color_rgba8(0, 0, 0, 102);
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ impl ResizeSurfaceGrab {
|
||||||
|
|
||||||
// Finish resizing.
|
// Finish resizing.
|
||||||
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state {
|
if let Some(ResizeState::WaitingForCommit(_)) = *resize_state {
|
||||||
if !window.is_resizing().unwrap_or(false) {
|
if !window.is_resizing(false).unwrap_or(false) {
|
||||||
*resize_state = None;
|
*resize_state = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ impl FloatingLayout {
|
||||||
|
|
||||||
pub fn unmap(&mut self, window: &CosmicMapped) -> bool {
|
pub fn unmap(&mut self, window: &CosmicMapped) -> bool {
|
||||||
#[allow(irrefutable_let_patterns)]
|
#[allow(irrefutable_let_patterns)]
|
||||||
let is_maximized = window.is_maximized();
|
let is_maximized = window.is_maximized(true);
|
||||||
|
|
||||||
if !is_maximized {
|
if !is_maximized {
|
||||||
if let Some(location) = self.space.element_location(window) {
|
if let Some(location) = self.space.element_location(window) {
|
||||||
|
|
|
||||||
|
|
@ -1415,7 +1415,7 @@ impl TilingLayout {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Data::Mapped { mapped, .. } => {
|
Data::Mapped { mapped, .. } => {
|
||||||
if !(mapped.is_fullscreen() || mapped.is_maximized()) {
|
if !(mapped.is_fullscreen(true) || mapped.is_maximized(true)) {
|
||||||
mapped.set_tiled(true);
|
mapped.set_tiled(true);
|
||||||
let internal_geometry = Rectangle::from_loc_and_size(
|
let internal_geometry = Rectangle::from_loc_and_size(
|
||||||
geo.loc + output.geometry().loc,
|
geo.loc + output.geometry().loc,
|
||||||
|
|
@ -1460,7 +1460,7 @@ impl TilingLayout {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.filter(|node| node.data().is_mapped(None))
|
.filter(|node| node.data().is_mapped(None))
|
||||||
.filter(|node| match node.data() {
|
.filter(|node| match node.data() {
|
||||||
Data::Mapped { mapped, .. } => mapped.is_activated(),
|
Data::Mapped { mapped, .. } => mapped.is_activated(false),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
})
|
})
|
||||||
.map(|node| match node.data() {
|
.map(|node| match node.data() {
|
||||||
|
|
@ -1480,7 +1480,7 @@ impl TilingLayout {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.filter(|node| node.data().is_mapped(None))
|
.filter(|node| node.data().is_mapped(None))
|
||||||
.filter(|node| match node.data() {
|
.filter(|node| match node.data() {
|
||||||
Data::Mapped { mapped, .. } => !mapped.is_activated(),
|
Data::Mapped { mapped, .. } => !mapped.is_activated(false),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
})
|
})
|
||||||
.map(|node| match node.data() {
|
.map(|node| match node.data() {
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ impl Workspace {
|
||||||
assert!(was_floating != was_tiling);
|
assert!(was_floating != was_tiling);
|
||||||
}
|
}
|
||||||
|
|
||||||
if mapped.is_maximized() || mapped.is_fullscreen() {
|
if mapped.is_maximized(true) || mapped.is_fullscreen(true) {
|
||||||
self.unmaximize_request(&mapped.active_window());
|
self.unmaximize_request(&mapped.active_window());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ impl Workspace {
|
||||||
start_data: PointerGrabStartData<State>,
|
start_data: PointerGrabStartData<State>,
|
||||||
edges: ResizeEdge,
|
edges: ResizeEdge,
|
||||||
) -> Option<ResizeGrab> {
|
) -> Option<ResizeGrab> {
|
||||||
if mapped.is_fullscreen() || mapped.is_maximized() {
|
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -355,7 +355,7 @@ impl Workspace {
|
||||||
let mapped = self.element_for_surface(&window)?.clone();
|
let mapped = self.element_for_surface(&window)?.clone();
|
||||||
let mut initial_window_location = self.element_geometry(&mapped).unwrap().loc;
|
let mut initial_window_location = self.element_geometry(&mapped).unwrap().loc;
|
||||||
|
|
||||||
if mapped.is_fullscreen() || mapped.is_maximized() {
|
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
|
||||||
// If surface is maximized then unmaximize it
|
// If surface is maximized then unmaximize it
|
||||||
let new_size = self.unmaximize_request(window);
|
let new_size = self.unmaximize_request(window);
|
||||||
let ratio = pos.x / output.geometry().size.w as f64;
|
let ratio = pos.x / output.geometry().size.w as f64;
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,15 @@ impl Window for CosmicSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_activated(&self) -> bool {
|
fn is_activated(&self) -> bool {
|
||||||
CosmicSurface::is_activated(self)
|
CosmicSurface::is_activated(self, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_maximized(&self) -> bool {
|
fn is_maximized(&self) -> bool {
|
||||||
CosmicSurface::is_maximized(self)
|
CosmicSurface::is_maximized(self, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_fullscreen(&self) -> bool {
|
fn is_fullscreen(&self) -> bool {
|
||||||
CosmicSurface::is_fullscreen(self)
|
CosmicSurface::is_fullscreen(self, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_minimized(&self) -> bool {
|
fn is_minimized(&self) -> bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue