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 {
|
||||
CosmicMappedInternal::Stack(s) => s.active(),
|
||||
CosmicMappedInternal::Window(w) => w.surface(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
window.is_resizing()
|
||||
window.is_resizing(pending)
|
||||
}
|
||||
|
||||
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 {
|
||||
CosmicMappedInternal::Stack(s) => s.active(),
|
||||
CosmicMappedInternal::Window(w) => w.surface(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
window.is_tiled()
|
||||
window.is_tiled(pending)
|
||||
}
|
||||
|
||||
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 {
|
||||
CosmicMappedInternal::Stack(s) => s.active(),
|
||||
CosmicMappedInternal::Window(w) => w.surface(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
window.is_fullscreen()
|
||||
window.is_fullscreen(pending)
|
||||
}
|
||||
|
||||
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 {
|
||||
CosmicMappedInternal::Stack(s) => s.active(),
|
||||
CosmicMappedInternal::Window(w) => w.surface(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
window.is_maximized()
|
||||
window.is_maximized(pending)
|
||||
}
|
||||
|
||||
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 {
|
||||
CosmicMappedInternal::Stack(s) => s.active(),
|
||||
CosmicMappedInternal::Window(w) => w.surface(),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
window.is_activated()
|
||||
window.is_activated(pending)
|
||||
}
|
||||
|
||||
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 {
|
||||
CosmicSurface::Wayland(window) => window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Activated),
|
||||
CosmicSurface::Wayland(window) => {
|
||||
if pending {
|
||||
window.toplevel().with_pending_state(|pending| {
|
||||
pending.states.contains(ToplevelState::Activated)
|
||||
})
|
||||
} else {
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Activated)
|
||||
}
|
||||
}
|
||||
CosmicSurface::X11(surface) => surface.is_activated(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
@ -157,29 +165,46 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_decorated(&self) -> bool {
|
||||
pub fn is_decorated(&self, pending: bool) -> bool {
|
||||
match self {
|
||||
CosmicSurface::Wayland(window) => window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.decoration_mode
|
||||
.map(|mode| mode == DecorationMode::ClientSide)
|
||||
.unwrap_or(true),
|
||||
CosmicSurface::Wayland(window) => {
|
||||
if pending {
|
||||
window.toplevel().with_pending_state(|pending| {
|
||||
pending
|
||||
.decoration_mode
|
||||
.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(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_resizing(&self) -> Option<bool> {
|
||||
pub fn is_resizing(&self, pending: bool) -> Option<bool> {
|
||||
match self {
|
||||
CosmicSurface::Wayland(window) => {
|
||||
let xdg = window.toplevel();
|
||||
Some(
|
||||
xdg.current_state().states.contains(ToplevelState::Resizing)
|
||||
|| xdg.with_pending_state(|states| {
|
||||
states.states.contains(ToplevelState::Resizing)
|
||||
}),
|
||||
)
|
||||
if pending {
|
||||
Some(window.toplevel().with_pending_state(|pending| {
|
||||
pending.states.contains(ToplevelState::Resizing)
|
||||
}))
|
||||
} else {
|
||||
Some(
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Resizing),
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => 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 {
|
||||
CosmicSurface::Wayland(window) => Some(
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::TiledLeft),
|
||||
),
|
||||
CosmicSurface::Wayland(window) => {
|
||||
if pending {
|
||||
Some(window.toplevel().with_pending_state(|pending| {
|
||||
pending.states.contains(ToplevelState::TiledLeft)
|
||||
}))
|
||||
} else {
|
||||
Some(
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::TiledLeft),
|
||||
)
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -230,16 +263,20 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_fullscreen(&self) -> bool {
|
||||
pub fn is_fullscreen(&self, pending: bool) -> bool {
|
||||
match self {
|
||||
CosmicSurface::Wayland(window) => {
|
||||
let xdg = window.toplevel();
|
||||
xdg.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Fullscreen)
|
||||
|| xdg.with_pending_state(|state| {
|
||||
state.states.contains(ToplevelState::Fullscreen)
|
||||
if pending {
|
||||
window.toplevel().with_pending_state(|pending| {
|
||||
pending.states.contains(ToplevelState::Fullscreen)
|
||||
})
|
||||
} else {
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Fullscreen)
|
||||
}
|
||||
}
|
||||
CosmicSurface::X11(surface) => surface.is_fullscreen(),
|
||||
_ => unreachable!(),
|
||||
|
|
@ -262,15 +299,20 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_maximized(&self) -> bool {
|
||||
pub fn is_maximized(&self, pending: bool) -> bool {
|
||||
match self {
|
||||
CosmicSurface::Wayland(window) => {
|
||||
let xdg = window.toplevel();
|
||||
xdg.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Maximized)
|
||||
|| xdg
|
||||
.with_pending_state(|state| state.states.contains(ToplevelState::Maximized))
|
||||
if pending {
|
||||
window.toplevel().with_pending_state(|pending| {
|
||||
pending.states.contains(ToplevelState::Maximized)
|
||||
})
|
||||
} else {
|
||||
window
|
||||
.toplevel()
|
||||
.current_state()
|
||||
.states
|
||||
.contains(ToplevelState::Maximized)
|
||||
}
|
||||
}
|
||||
CosmicSurface::X11(surface) => surface.is_maximized(),
|
||||
_ => unreachable!(),
|
||||
|
|
@ -311,7 +353,7 @@ impl CosmicSurface {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
.map(|size| {
|
||||
if self.is_decorated() {
|
||||
if self.is_decorated(false) {
|
||||
size + (0, SSD_HEIGHT).into()
|
||||
} else {
|
||||
size
|
||||
|
|
@ -337,7 +379,7 @@ impl CosmicSurface {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
.map(|size| {
|
||||
if self.is_decorated() {
|
||||
if self.is_decorated(false) {
|
||||
size + (0, SSD_HEIGHT).into()
|
||||
} else {
|
||||
size
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ impl CosmicWindowInternal {
|
|||
}
|
||||
|
||||
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 {
|
||||
if self.window.is_activated() {
|
||||
if self.window.is_activated(false) {
|
||||
Color {
|
||||
r: 0.1176,
|
||||
g: 0.1176,
|
||||
|
|
@ -281,7 +281,7 @@ impl Program for CosmicWindowInternal {
|
|||
pixels: &mut tiny_skia::PixmapMut<'_>,
|
||||
damage: &[Rectangle<i32, BufferCoords>],
|
||||
) {
|
||||
if !self.window.is_activated() {
|
||||
if !self.window.is_activated(false) {
|
||||
let mask = self.mask.lock().unwrap();
|
||||
let mut paint = tiny_skia::Paint::default();
|
||||
paint.set_color_rgba8(0, 0, 0, 102);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ impl ResizeSurfaceGrab {
|
|||
|
||||
// Finish resizing.
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ impl FloatingLayout {
|
|||
|
||||
pub fn unmap(&mut self, window: &CosmicMapped) -> bool {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let is_maximized = window.is_maximized();
|
||||
let is_maximized = window.is_maximized(true);
|
||||
|
||||
if !is_maximized {
|
||||
if let Some(location) = self.space.element_location(window) {
|
||||
|
|
|
|||
|
|
@ -1415,7 +1415,7 @@ impl TilingLayout {
|
|||
}
|
||||
},
|
||||
Data::Mapped { mapped, .. } => {
|
||||
if !(mapped.is_fullscreen() || mapped.is_maximized()) {
|
||||
if !(mapped.is_fullscreen(true) || mapped.is_maximized(true)) {
|
||||
mapped.set_tiled(true);
|
||||
let internal_geometry = Rectangle::from_loc_and_size(
|
||||
geo.loc + output.geometry().loc,
|
||||
|
|
@ -1460,7 +1460,7 @@ impl TilingLayout {
|
|||
.unwrap()
|
||||
.filter(|node| node.data().is_mapped(None))
|
||||
.filter(|node| match node.data() {
|
||||
Data::Mapped { mapped, .. } => mapped.is_activated(),
|
||||
Data::Mapped { mapped, .. } => mapped.is_activated(false),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.map(|node| match node.data() {
|
||||
|
|
@ -1480,7 +1480,7 @@ impl TilingLayout {
|
|||
.unwrap()
|
||||
.filter(|node| node.data().is_mapped(None))
|
||||
.filter(|node| match node.data() {
|
||||
Data::Mapped { mapped, .. } => !mapped.is_activated(),
|
||||
Data::Mapped { mapped, .. } => !mapped.is_activated(false),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.map(|node| match node.data() {
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ impl Workspace {
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ impl Workspace {
|
|||
start_data: PointerGrabStartData<State>,
|
||||
edges: ResizeEdge,
|
||||
) -> Option<ResizeGrab> {
|
||||
if mapped.is_fullscreen() || mapped.is_maximized() {
|
||||
if mapped.is_fullscreen(true) || mapped.is_maximized(true) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ impl Workspace {
|
|||
let mapped = self.element_for_surface(&window)?.clone();
|
||||
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
|
||||
let new_size = self.unmaximize_request(window);
|
||||
let ratio = pos.x / output.geometry().size.w as f64;
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ impl Window for CosmicSurface {
|
|||
}
|
||||
|
||||
fn is_activated(&self) -> bool {
|
||||
CosmicSurface::is_activated(self)
|
||||
CosmicSurface::is_activated(self, false)
|
||||
}
|
||||
|
||||
fn is_maximized(&self) -> bool {
|
||||
CosmicSurface::is_maximized(self)
|
||||
CosmicSurface::is_maximized(self, false)
|
||||
}
|
||||
|
||||
fn is_fullscreen(&self) -> bool {
|
||||
CosmicSurface::is_fullscreen(self)
|
||||
CosmicSurface::is_fullscreen(self, false)
|
||||
}
|
||||
|
||||
fn is_minimized(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue