state: Move shell behind RwLock
This commit is contained in:
parent
647deb81f1
commit
5d5a510691
45 changed files with 2657 additions and 2097 deletions
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
focus::{target::PointerFocusTarget, FocusDirection},
|
||||
grabs::{ReleaseMode, ResizeEdge},
|
||||
layout::tiling::NodeDesc,
|
||||
Direction, Shell,
|
||||
Direction,
|
||||
},
|
||||
state::State,
|
||||
utils::{
|
||||
|
|
@ -664,14 +664,25 @@ impl Program for CosmicStackInternal {
|
|||
let active = self.active.load(Ordering::SeqCst);
|
||||
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
Shell::move_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
&state.common.xdg_activation_state,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -683,7 +694,13 @@ impl Program for CosmicStackInternal {
|
|||
*self.potential_drag.lock().unwrap() = None;
|
||||
if let Some(surface) = self.windows.lock().unwrap().get(idx).cloned() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) = state.common.shell.element_for_surface(&surface) {
|
||||
if let Some(mapped) = state
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.element_for_surface(&surface)
|
||||
{
|
||||
mapped.stack_ref().unwrap().set_active(&surface);
|
||||
}
|
||||
});
|
||||
|
|
@ -703,11 +720,10 @@ impl Program for CosmicStackInternal {
|
|||
let active = self.active.load(Ordering::SeqCst);
|
||||
if let Some(surface) = self.windows.lock().unwrap()[active].wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_surface(&surface).cloned()
|
||||
{
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
state.common.shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
|
|
@ -715,9 +731,7 @@ impl Program for CosmicStackInternal {
|
|||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) =
|
||||
state.common.shell.space_for_mut(&mapped)
|
||||
{
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
|
|
@ -732,14 +746,22 @@ impl Program for CosmicStackInternal {
|
|||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
Shell::menu_request(
|
||||
state,
|
||||
let res = shell.menu_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
true,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -749,28 +771,36 @@ impl Program for CosmicStackInternal {
|
|||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||
if let Some(surface) = self.windows.lock().unwrap()[idx].wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_surface(&surface).cloned()
|
||||
{
|
||||
if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
let position = elem_geo.loc.to_global(&workspace.output);
|
||||
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
cursor.y -= TAB_HEIGHT;
|
||||
Shell::menu_request(
|
||||
state,
|
||||
let res = shell.menu_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1175,18 +1205,30 @@ impl PointerTarget<State> for CosmicStack {
|
|||
.with_program(|p| p.windows.lock().unwrap().get(dragged_out).cloned())
|
||||
{
|
||||
let seat = seat.clone();
|
||||
let serial = event.serial;
|
||||
surface.try_force_undecorated(false);
|
||||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface() {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::move_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
None,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
)
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
&state.common.xdg_activation_state,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1220,8 +1262,7 @@ impl PointerTarget<State> for CosmicStack {
|
|||
return;
|
||||
};
|
||||
self.0.loop_handle().insert_idle(move |state| {
|
||||
Shell::resize_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().resize_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
|
|
@ -1236,7 +1277,16 @@ impl PointerTarget<State> for CosmicStack {
|
|||
Focus::ResizeRight => ResizeEdge::RIGHT,
|
||||
Focus::Header => unreachable!(),
|
||||
},
|
||||
)
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
None => {}
|
||||
|
|
@ -1279,14 +1329,25 @@ impl PointerTarget<State> for CosmicStack {
|
|||
surface.send_configure();
|
||||
if let Some(surface) = surface.wl_surface() {
|
||||
let _ = data.common.event_loop_handle.insert_idle(move |state| {
|
||||
Shell::move_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
None,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
true,
|
||||
)
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
&state.common.xdg_activation_state,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use crate::{
|
|||
shell::{
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{ReleaseMode, ResizeEdge},
|
||||
Shell,
|
||||
},
|
||||
state::State,
|
||||
utils::{
|
||||
|
|
@ -387,14 +386,25 @@ impl Program for CosmicWindowInternal {
|
|||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||
if let Some(surface) = self.window.wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
Shell::move_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
&state.common.xdg_activation_state,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -402,10 +412,9 @@ impl Program for CosmicWindowInternal {
|
|||
Message::Minimize => {
|
||||
if let Some(surface) = self.window.wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_surface(&surface).cloned()
|
||||
{
|
||||
state.common.shell.minimize_request(&mapped)
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
shell.minimize_request(&mapped)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -413,11 +422,10 @@ impl Program for CosmicWindowInternal {
|
|||
Message::Maximize => {
|
||||
if let Some(surface) = self.window.wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_surface(&surface).cloned()
|
||||
{
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
state.common.shell.maximize_toggle(&mapped, &seat)
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let seat = shell.seats.last_active().clone();
|
||||
shell.maximize_toggle(&mapped, &seat)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -427,11 +435,10 @@ impl Program for CosmicWindowInternal {
|
|||
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
|
||||
if let Some(surface) = self.window.wl_surface() {
|
||||
loop_handle.insert_idle(move |state| {
|
||||
if let Some(mapped) =
|
||||
state.common.shell.element_for_surface(&surface).cloned()
|
||||
{
|
||||
let shell = state.common.shell.read().unwrap();
|
||||
if let Some(mapped) = shell.element_for_surface(&surface).cloned() {
|
||||
let position = if let Some((output, set)) =
|
||||
state.common.shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
shell.workspaces.sets.iter().find(|(_, set)| {
|
||||
set.sticky_layer.mapped().any(|m| m == &mapped)
|
||||
}) {
|
||||
set.sticky_layer
|
||||
|
|
@ -439,9 +446,7 @@ impl Program for CosmicWindowInternal {
|
|||
.unwrap()
|
||||
.loc
|
||||
.to_global(output)
|
||||
} else if let Some(workspace) =
|
||||
state.common.shell.space_for_mut(&mapped)
|
||||
{
|
||||
} else if let Some(workspace) = shell.space_for(&mapped) {
|
||||
let Some(elem_geo) = workspace.element_geometry(&mapped) else {
|
||||
return;
|
||||
};
|
||||
|
|
@ -450,20 +455,24 @@ impl Program for CosmicWindowInternal {
|
|||
return;
|
||||
};
|
||||
|
||||
let mut cursor = seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.current_location()
|
||||
.to_i32_round();
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let mut cursor = pointer.current_location().to_i32_round();
|
||||
cursor.y -= SSD_HEIGHT;
|
||||
Shell::menu_request(
|
||||
state,
|
||||
|
||||
let res = shell.menu_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
cursor - position.as_logical(),
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -734,8 +743,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
return;
|
||||
};
|
||||
self.0.loop_handle().insert_idle(move |state| {
|
||||
Shell::resize_request(
|
||||
state,
|
||||
let res = state.common.shell.write().unwrap().resize_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
|
|
@ -750,7 +758,17 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
Focus::ResizeRight => ResizeEdge::RIGHT,
|
||||
Focus::Header => unreachable!(),
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
None => {}
|
||||
|
|
|
|||
|
|
@ -107,9 +107,13 @@ impl Shell {
|
|||
) {
|
||||
let element = match target {
|
||||
Some(KeyboardFocusTarget::Element(mapped)) => Some(mapped.clone()),
|
||||
Some(KeyboardFocusTarget::Fullscreen(window)) => {
|
||||
state.common.shell.element_for_surface(window).cloned()
|
||||
}
|
||||
Some(KeyboardFocusTarget::Fullscreen(window)) => state
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.element_for_surface(window)
|
||||
.cloned(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
|
@ -117,7 +121,12 @@ impl Shell {
|
|||
if mapped.is_minimized() {
|
||||
return;
|
||||
}
|
||||
state.common.shell.append_focus_stack(&mapped, seat);
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.write()
|
||||
.unwrap()
|
||||
.append_focus_stack(&mapped, seat);
|
||||
}
|
||||
|
||||
// update keyboard focus
|
||||
|
|
@ -130,7 +139,7 @@ impl Shell {
|
|||
);
|
||||
}
|
||||
|
||||
state.common.shell.update_active();
|
||||
state.common.shell.write().unwrap().update_active();
|
||||
}
|
||||
|
||||
pub fn append_focus_stack(&mut self, mapped: &CosmicMapped, seat: &Seat<State>) {
|
||||
|
|
@ -233,25 +242,27 @@ fn raise_with_children(floating_layer: &mut FloatingLayout, focused: &CosmicMapp
|
|||
|
||||
impl Common {
|
||||
pub fn refresh_focus(state: &mut State) {
|
||||
for seat in state
|
||||
let seats = state
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
{
|
||||
.collect::<Vec<_>>();
|
||||
for seat in seats.into_iter() {
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let output = seat.active_output();
|
||||
if !state.common.shell.outputs().any(|o| o == &output) {
|
||||
seat.set_active_output(&state.common.shell.outputs().next().unwrap());
|
||||
if !shell.outputs().any(|o| o == &output) {
|
||||
seat.set_active_output(&shell.outputs().next().unwrap());
|
||||
continue;
|
||||
}
|
||||
let last_known_focus = ActiveFocus::get(&seat);
|
||||
|
||||
if let Some(target) = last_known_focus {
|
||||
if target.alive() {
|
||||
if focus_target_is_valid(&mut state.common.shell, &seat, &output, target) {
|
||||
if focus_target_is_valid(&mut *shell, &seat, &output, target) {
|
||||
continue; // Focus is valid
|
||||
} else {
|
||||
trace!("Wrong Window, focus fixup");
|
||||
|
|
@ -266,6 +277,8 @@ impl Common {
|
|||
if !popup_grab.has_ended() {
|
||||
if let Some(new) = popup_grab.current_grab() {
|
||||
trace!("restore focus to previous popup grab");
|
||||
std::mem::drop(shell);
|
||||
|
||||
if let Some(keyboard) = seat.get_keyboard() {
|
||||
keyboard.set_focus(
|
||||
state,
|
||||
|
|
@ -285,7 +298,7 @@ impl Common {
|
|||
trace!("Surface dead, focus fixup");
|
||||
}
|
||||
} else {
|
||||
let workspace = state.common.shell.active_space(&output);
|
||||
let workspace = shell.active_space(&output);
|
||||
let focus_stack = workspace.focus_stack.get(&seat);
|
||||
|
||||
if focus_stack.last().is_none() {
|
||||
|
|
@ -309,7 +322,9 @@ impl Common {
|
|||
}
|
||||
|
||||
// update keyboard focus
|
||||
let target = update_focus_target(&state.common.shell, &seat, &output);
|
||||
let target = update_focus_target(&*shell, &seat, &output);
|
||||
std::mem::drop(shell);
|
||||
|
||||
if let Some(keyboard) = seat.get_keyboard() {
|
||||
debug!("Restoring focus to {:?}", target.as_ref());
|
||||
keyboard.set_focus(state, target.clone(), SERIAL_COUNTER.next_serial());
|
||||
|
|
@ -318,7 +333,7 @@ impl Common {
|
|||
}
|
||||
}
|
||||
|
||||
state.common.shell.update_active()
|
||||
state.common.shell.write().unwrap().update_active()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ impl PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toplevel(&self, data: &mut State) -> Option<CosmicSurface> {
|
||||
pub fn toplevel(&self, shell: &Shell) -> Option<CosmicSurface> {
|
||||
match &self {
|
||||
PointerFocusTarget::WlSurface {
|
||||
toplevel: Some(PointerFocusToplevel::Surface(surface)),
|
||||
|
|
@ -142,12 +142,7 @@ impl PointerFocusTarget {
|
|||
toplevel: Some(PointerFocusToplevel::Popup(PopupKind::Xdg(popup))),
|
||||
..
|
||||
} => get_popup_toplevel(popup)
|
||||
.and_then(|s| {
|
||||
data.common
|
||||
.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)| {
|
||||
m.windows()
|
||||
.find(|(w, _)| w.wl_surface().map(|s2| s == s2).unwrap_or(false))
|
||||
|
|
@ -210,7 +205,8 @@ impl IsAlive for KeyboardFocusTarget {
|
|||
|
||||
impl PointerTarget<State> for PointerFocusTarget {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
if let Some(element) = self.toplevel(data) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(Some(
|
||||
event
|
||||
|
|
@ -238,7 +234,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
if let Some(element) = self.toplevel(data) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(Some(
|
||||
event
|
||||
|
|
@ -308,7 +305,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
|
||||
if let Some(element) = self.toplevel(data) {
|
||||
let toplevel = self.toplevel(&*data.common.shell.read().unwrap());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
session.set_cursor_pos(None);
|
||||
session.set_cursor_hotspot((0, 0));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use smithay::wayland::seat::WaylandFocus;
|
||||
use smithay::{input::pointer::MotionEvent, utils::SERIAL_COUNTER, wayland::seat::WaylandFocus};
|
||||
|
||||
use crate::{
|
||||
config::{Action, StaticConfig},
|
||||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
shell::{
|
||||
element::{CosmicMapped, CosmicWindow},
|
||||
grabs::ReleaseMode,
|
||||
CosmicSurface, Shell,
|
||||
CosmicSurface, PointGlobalExt, Shell,
|
||||
},
|
||||
state::State,
|
||||
utils::{prelude::SeatExt, screenshot::screenshot_window},
|
||||
|
|
@ -15,61 +15,57 @@ use crate::{
|
|||
use super::{Item, ResizeEdge};
|
||||
|
||||
fn toggle_stacking(state: &mut State, mapped: &CosmicMapped) {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
if let Some(new_focus) = state.common.shell.toggle_stacking(mapped) {
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
if let Some(new_focus) = shell.toggle_stacking(mapped) {
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(state, Some(&new_focus), &seat, None);
|
||||
}
|
||||
}
|
||||
|
||||
fn move_prev_workspace(state: &mut State, mapped: &CosmicMapped) {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let (current_handle, output) = {
|
||||
let Some(ws) = state.common.shell.space_for(mapped) else {
|
||||
let Some(ws) = shell.space_for(mapped) else {
|
||||
return;
|
||||
};
|
||||
(ws.handle, ws.output.clone())
|
||||
};
|
||||
let maybe_handle = state
|
||||
.common
|
||||
.shell
|
||||
let maybe_handle = shell
|
||||
.workspaces
|
||||
.spaces_for_output(&output)
|
||||
.enumerate()
|
||||
.find_map(|(i, space)| (space.handle == current_handle).then_some(i))
|
||||
.and_then(|i| i.checked_sub(1))
|
||||
.and_then(|i| {
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.get(i, &output)
|
||||
.map(|s| s.handle)
|
||||
});
|
||||
.and_then(|i| shell.workspaces.get(i, &output).map(|s| s.handle));
|
||||
if let Some(prev_handle) = maybe_handle {
|
||||
if let Some((target, _)) = state.common.shell.move_window(
|
||||
let res = shell.move_window(
|
||||
Some(&seat),
|
||||
mapped,
|
||||
¤t_handle,
|
||||
&prev_handle,
|
||||
true,
|
||||
None,
|
||||
) {
|
||||
&mut state.common.workspace_state.update(),
|
||||
);
|
||||
if let Some((target, _)) = res {
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(state, Some(&target), &seat, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn move_next_workspace(state: &mut State, mapped: &CosmicMapped) {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let (current_handle, output) = {
|
||||
let Some(ws) = state.common.shell.space_for(mapped) else {
|
||||
let Some(ws) = shell.space_for(mapped) else {
|
||||
return;
|
||||
};
|
||||
(ws.handle, ws.output.clone())
|
||||
};
|
||||
let maybe_handle = state
|
||||
.common
|
||||
.shell
|
||||
let maybe_handle = shell
|
||||
.workspaces
|
||||
.spaces_for_output(&output)
|
||||
.skip_while(|space| space.handle != current_handle)
|
||||
|
|
@ -77,14 +73,17 @@ fn move_next_workspace(state: &mut State, mapped: &CosmicMapped) {
|
|||
.next()
|
||||
.map(|space| space.handle);
|
||||
if let Some(next_handle) = maybe_handle {
|
||||
if let Some((target, _point)) = state.common.shell.move_window(
|
||||
let res = shell.move_window(
|
||||
Some(&seat),
|
||||
mapped,
|
||||
¤t_handle,
|
||||
&next_handle,
|
||||
true,
|
||||
None,
|
||||
) {
|
||||
&mut state.common.workspace_state.update(),
|
||||
);
|
||||
if let Some((target, _point)) = res {
|
||||
std::mem::drop(shell);
|
||||
Shell::set_focus(state, Some(&target), &seat, None)
|
||||
}
|
||||
}
|
||||
|
|
@ -114,9 +113,10 @@ pub fn tab_items(
|
|||
)
|
||||
.into();
|
||||
|
||||
let seat = state.common.shell.seats.last_active();
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let output = seat.active_output();
|
||||
let workspace = state.common.shell.workspaces.active_mut(&output);
|
||||
let workspace = shell.workspaces.active_mut(&output);
|
||||
if is_tiled {
|
||||
for mapped in workspace
|
||||
.mapped()
|
||||
|
|
@ -127,7 +127,7 @@ pub fn tab_items(
|
|||
{
|
||||
workspace.unmaximize_request(&mapped);
|
||||
}
|
||||
let focus_stack = workspace.focus_stack.get(seat);
|
||||
let focus_stack = workspace.focus_stack.get(&seat);
|
||||
workspace
|
||||
.tiling_layer
|
||||
.map(mapped, Some(focus_stack.iter()), None);
|
||||
|
|
@ -197,7 +197,12 @@ pub fn window_items(
|
|||
Item::new(fl!("window-menu-minimize"), move |handle| {
|
||||
let mapped = minimize_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
state.common.shell.minimize_request(&mapped);
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.write()
|
||||
.unwrap()
|
||||
.minimize_request(&mapped);
|
||||
});
|
||||
})
|
||||
.shortcut(config.get_shortcut_for_action(&Action::Minimize)),
|
||||
|
|
@ -206,8 +211,9 @@ pub fn window_items(
|
|||
Item::new(fl!("window-menu-maximize"), move |handle| {
|
||||
let mapped = maximize_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
state.common.shell.maximize_toggle(&mapped, &seat);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
shell.maximize_toggle(&mapped, &seat);
|
||||
});
|
||||
})
|
||||
.shortcut(config.get_shortcut_for_action(&Action::Maximize))
|
||||
|
|
@ -217,8 +223,9 @@ pub fn window_items(
|
|||
Item::new(fl!("window-menu-tiled"), move |handle| {
|
||||
let tile_clone = tile_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
if let Some(ws) = state.common.shell.space_for_mut(&tile_clone) {
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
if let Some(ws) = shell.space_for_mut(&tile_clone) {
|
||||
ws.toggle_floating_window(&seat, &tile_clone);
|
||||
}
|
||||
});
|
||||
|
|
@ -238,8 +245,36 @@ pub fn window_items(
|
|||
let move_clone = move_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
if let Some(surface) = move_clone.wl_surface() {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
Shell::move_request(state, &surface, &seat, None, ReleaseMode::Click, false);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let res = shell.move_request(
|
||||
&surface,
|
||||
&seat,
|
||||
None,
|
||||
ReleaseMode::Click,
|
||||
false,
|
||||
&state.common.config,
|
||||
&state.common.event_loop_handle,
|
||||
&state.common.xdg_activation_state,
|
||||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
)
|
||||
} else {
|
||||
seat.get_pointer().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
focus,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})),
|
||||
|
|
@ -249,32 +284,122 @@ pub fn window_items(
|
|||
Item::new(fl!("window-menu-resize-edge-top"), move |handle| {
|
||||
let resize_clone = resize_top_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
Shell::menu_resize_request(state, &resize_clone, &seat, ResizeEdge::TOP);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let res = shell.menu_resize_request(&resize_clone, &seat, ResizeEdge::TOP);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: 0,
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.disabled(!possible_resizes.contains(ResizeEdge::TOP)),
|
||||
Item::new(fl!("window-menu-resize-edge-left"), move |handle| {
|
||||
let resize_clone = resize_left_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
Shell::menu_resize_request(state, &resize_clone, &seat, ResizeEdge::LEFT);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let res = shell.menu_resize_request(&resize_clone, &seat, ResizeEdge::LEFT);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: 0,
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.disabled(!possible_resizes.contains(ResizeEdge::LEFT)),
|
||||
Item::new(fl!("window-menu-resize-edge-right"), move |handle| {
|
||||
let resize_clone = resize_right_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
Shell::menu_resize_request(state, &resize_clone, &seat, ResizeEdge::RIGHT);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let res =
|
||||
shell.menu_resize_request(&resize_clone, &seat, ResizeEdge::RIGHT);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: 0,
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.disabled(!possible_resizes.contains(ResizeEdge::RIGHT)),
|
||||
Item::new(fl!("window-menu-resize-edge-bottom"), move |handle| {
|
||||
let resize_clone = resize_bottom_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
Shell::menu_resize_request(state, &resize_clone, &seat, ResizeEdge::BOTTOM);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
let res =
|
||||
shell.menu_resize_request(&resize_clone, &seat, ResizeEdge::BOTTOM);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: 0,
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.disabled(!possible_resizes.contains(ResizeEdge::BOTTOM)),
|
||||
|
|
@ -301,8 +426,9 @@ pub fn window_items(
|
|||
Item::new(fl!("window-menu-sticky"), move |handle| {
|
||||
let mapped = sticky_clone.clone();
|
||||
let _ = handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active().clone();
|
||||
state.common.shell.toggle_sticky(&seat, &mapped);
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
let seat = shell.seats.last_active().clone();
|
||||
shell.toggle_sticky(&seat, &mapped);
|
||||
});
|
||||
})
|
||||
.toggled(is_sticky),
|
||||
|
|
|
|||
|
|
@ -216,7 +216,14 @@ impl Program for ContextMenu {
|
|||
if let Some(Item::Submenu { items, .. }) = self.items.get_mut(idx) {
|
||||
let items = items.clone();
|
||||
let _ = loop_handle.insert_idle(move |state| {
|
||||
let seat = state.common.shell.seats.last_active();
|
||||
let seat = state
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.last_active()
|
||||
.clone();
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
|
|
@ -301,7 +308,14 @@ impl Program for ContextMenu {
|
|||
Message::ItemLeft(idx, _) => {
|
||||
if let Some(Item::Submenu { .. }) = self.items.get_mut(idx) {
|
||||
let _ = loop_handle.insert_idle(|state| {
|
||||
let seat = state.common.shell.seats.last_active();
|
||||
let seat = state
|
||||
.common
|
||||
.shell
|
||||
.read()
|
||||
.unwrap()
|
||||
.seats
|
||||
.last_active()
|
||||
.clone();
|
||||
let grab_state = seat
|
||||
.user_data()
|
||||
.get::<SeatMenuGrabState>()
|
||||
|
|
|
|||
|
|
@ -153,6 +153,15 @@ impl From<ResizeForkGrab> for ResizeGrab {
|
|||
}
|
||||
}
|
||||
|
||||
impl ResizeGrab {
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => grab.is_touch_grab(),
|
||||
ResizeGrab::Tiling(grab) => grab.is_touch_grab(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PointerGrab<State> for ResizeGrab {
|
||||
fn motion(
|
||||
&mut self,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
CosmicMapped, CosmicSurface, Direction, ManagedLayer,
|
||||
},
|
||||
utils::prelude::*,
|
||||
wayland::protocols::toplevel_info::{toplevel_enter_output, toplevel_enter_workspace},
|
||||
};
|
||||
|
||||
use calloop::LoopHandle;
|
||||
|
|
@ -326,10 +327,10 @@ pub struct MoveGrab {
|
|||
|
||||
impl MoveGrab {
|
||||
fn update_location(&mut self, state: &mut State, location: Point<f64, Logical>) {
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
|
||||
let Some(current_output) =
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
shell
|
||||
.outputs()
|
||||
.find(|output| {
|
||||
output.geometry().as_logical().overlaps_or_touches(
|
||||
|
|
@ -341,9 +342,7 @@ impl MoveGrab {
|
|||
return;
|
||||
};
|
||||
if self.cursor_output != current_output {
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
shell
|
||||
.workspaces
|
||||
.active_mut(&self.cursor_output)
|
||||
.tiling_layer
|
||||
|
|
@ -362,7 +361,7 @@ impl MoveGrab {
|
|||
|
||||
let mut window_geo = self.window.geometry();
|
||||
window_geo.loc += location.to_i32_round() + grab_state.window_offset;
|
||||
for output in state.common.shell.outputs() {
|
||||
for output in shell.outputs() {
|
||||
if let Some(overlap) = output.geometry().as_logical().intersection(window_geo) {
|
||||
if self.window_outputs.insert(output.clone()) {
|
||||
self.window.output_enter(output, overlap);
|
||||
|
|
@ -380,10 +379,7 @@ impl MoveGrab {
|
|||
}
|
||||
}
|
||||
|
||||
let indicator_location = state
|
||||
.common
|
||||
.shell
|
||||
.stacking_indicator(¤t_output, self.previous);
|
||||
let indicator_location = shell.stacking_indicator(¤t_output, self.previous);
|
||||
if indicator_location.is_some() != grab_state.stacking_indicator.is_some() {
|
||||
grab_state.stacking_indicator = indicator_location.map(|geo| {
|
||||
let element = stack_hover(
|
||||
|
|
@ -695,6 +691,13 @@ impl MoveGrab {
|
|||
pub fn is_tiling_grab(&self) -> bool {
|
||||
self.previous == ManagedLayer::Tiling
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for MoveGrab {
|
||||
|
|
@ -716,23 +719,17 @@ impl Drop for MoveGrab {
|
|||
if grab_state.window.alive() {
|
||||
let window_location =
|
||||
(grab_state.location.to_i32_round() + grab_state.window_offset).as_global();
|
||||
let mut shell = state.common.shell.write().unwrap();
|
||||
|
||||
let workspace_handle = state.common.shell.active_space(&output).handle;
|
||||
let workspace_handle = shell.active_space(&output).handle;
|
||||
for old_output in window_outputs.iter().filter(|o| *o != &output) {
|
||||
grab_state.window.output_leave(old_output);
|
||||
}
|
||||
|
||||
for (window, _) in grab_state.window.windows() {
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_output(&window, &output);
|
||||
toplevel_enter_output(&window, &output);
|
||||
if previous != ManagedLayer::Sticky {
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_workspace(&window, &workspace_handle);
|
||||
toplevel_enter_workspace(&window, &workspace_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -742,19 +739,15 @@ impl Drop for MoveGrab {
|
|||
window_location,
|
||||
grab_state.window.geometry().size.as_global(),
|
||||
));
|
||||
let set = state.common.shell.workspaces.sets.get_mut(&output).unwrap();
|
||||
let set = shell.workspaces.sets.get_mut(&output).unwrap();
|
||||
let (window, location) = set
|
||||
.sticky_layer
|
||||
.drop_window(grab_state.window, window_location.to_local(&output));
|
||||
|
||||
Some((window, location.to_global(&output)))
|
||||
}
|
||||
ManagedLayer::Tiling
|
||||
if state.common.shell.active_space(&output).tiling_enabled =>
|
||||
{
|
||||
let (window, location) = state
|
||||
.common
|
||||
.shell
|
||||
ManagedLayer::Tiling if shell.active_space(&output).tiling_enabled => {
|
||||
let (window, location) = shell
|
||||
.active_space_mut(&output)
|
||||
.tiling_layer
|
||||
.drop_window(grab_state.window);
|
||||
|
|
@ -765,8 +758,8 @@ impl Drop for MoveGrab {
|
|||
window_location,
|
||||
grab_state.window.geometry().size.as_global(),
|
||||
));
|
||||
let theme = state.common.shell.theme.clone();
|
||||
let workspace = state.common.shell.active_space_mut(&output);
|
||||
let theme = shell.theme.clone();
|
||||
let workspace = shell.active_space_mut(&output);
|
||||
let (window, location) = workspace.floating_layer.drop_window(
|
||||
grab_state.window,
|
||||
window_location.to_local(&workspace.output),
|
||||
|
|
@ -775,7 +768,7 @@ impl Drop for MoveGrab {
|
|||
if previous == ManagedLayer::Floating {
|
||||
if let Some(sz) = grab_state.snapping_zone {
|
||||
if sz == SnappingZone::Maximize {
|
||||
state.common.shell.maximize_toggle(&window, &seat);
|
||||
shell.maximize_toggle(&window, &seat);
|
||||
} else {
|
||||
let directions = match sz {
|
||||
SnappingZone::Maximize => vec![],
|
||||
|
|
|
|||
|
|
@ -123,6 +123,13 @@ impl ResizeSurfaceGrab {
|
|||
|
||||
false
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||
|
|
|
|||
|
|
@ -218,7 +218,8 @@ impl ResizeForkGrab {
|
|||
let delta = location - self.last_loc.as_logical();
|
||||
|
||||
if let Some(output) = self.output.upgrade() {
|
||||
let tiling_layer = &mut data.common.shell.active_space_mut(&output).tiling_layer;
|
||||
let mut shell = data.common.shell.write().unwrap();
|
||||
let tiling_layer = &mut shell.active_space_mut(&output).tiling_layer;
|
||||
let gaps = tiling_layer.gaps();
|
||||
|
||||
let tree = &mut tiling_layer.queue.trees.back_mut().unwrap().0;
|
||||
|
|
@ -321,6 +322,13 @@ impl ResizeForkGrab {
|
|||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PointerGrab<State> for ResizeForkGrab {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ impl KeyboardGrab<State> for SwapWindowGrab {
|
|||
serial: Serial,
|
||||
time: u32,
|
||||
) {
|
||||
if !matches!(&data.common.shell.overview_mode, OverviewMode::Started(Trigger::KeyboardSwap(_, d), _) if d == &self.desc)
|
||||
if !matches!(&data.common.shell.read().unwrap().overview_mode, OverviewMode::Started(Trigger::KeyboardSwap(_, d), _) if d == &self.desc)
|
||||
{
|
||||
handle.unset_grab(data, serial, false);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,13 @@ use crate::{
|
|||
utils::{prelude::*, tween::EaseRectangle},
|
||||
wayland::{
|
||||
handlers::xdg_shell::popup::get_popup_toplevel,
|
||||
protocols::{toplevel_info::ToplevelInfoState, workspace::WorkspaceHandle},
|
||||
protocols::{
|
||||
toplevel_info::{
|
||||
toplevel_enter_output, toplevel_enter_workspace, toplevel_leave_output,
|
||||
toplevel_leave_workspace,
|
||||
},
|
||||
workspace::WorkspaceHandle,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -633,7 +639,6 @@ impl TilingLayout {
|
|||
seat: &Seat<State>,
|
||||
focus_stack: impl Iterator<Item = &'a CosmicMapped> + 'a,
|
||||
desc: NodeDesc,
|
||||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||
) -> Option<KeyboardFocusTarget> {
|
||||
let this_handle = &desc.handle;
|
||||
let mut this_tree = this.queue.trees.back().unwrap().0.copy_clone();
|
||||
|
|
@ -662,13 +667,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&this.output);
|
||||
mapped.output_enter(&other.output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_output(surface, &this.output);
|
||||
toplevel_info_state.toplevel_enter_output(surface, &other.output);
|
||||
toplevel_leave_output(surface, &this.output);
|
||||
toplevel_enter_output(surface, &other.output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(surface, other_handle);
|
||||
toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_enter_workspace(surface, other_handle);
|
||||
}
|
||||
|
||||
mapped.set_tiled(true);
|
||||
|
|
@ -725,13 +730,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&this.output);
|
||||
mapped.output_enter(&other.output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_output(surface, &this.output);
|
||||
toplevel_info_state.toplevel_enter_output(surface, &other.output);
|
||||
toplevel_leave_output(surface, &this.output);
|
||||
toplevel_enter_output(surface, &other.output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(surface, other_handle);
|
||||
toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_enter_workspace(surface, other_handle);
|
||||
}
|
||||
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(id.clone());
|
||||
|
|
@ -759,15 +764,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&this.output);
|
||||
mapped.output_enter(&other.output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_output(surface, &this.output);
|
||||
toplevel_info_state
|
||||
.toplevel_enter_output(surface, &other.output);
|
||||
toplevel_leave_output(surface, &this.output);
|
||||
toplevel_enter_output(surface, &other.output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(surface, other_handle);
|
||||
toplevel_leave_workspace(surface, this_handle);
|
||||
toplevel_enter_workspace(surface, other_handle);
|
||||
}
|
||||
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(new_id.clone());
|
||||
|
|
@ -806,7 +809,6 @@ impl TilingLayout {
|
|||
mut other: Option<&mut Self>,
|
||||
this_desc: &NodeDesc,
|
||||
other_desc: &NodeDesc,
|
||||
toplevel_info_state: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||
) -> Option<KeyboardFocusTarget> {
|
||||
let other_output = other
|
||||
.as_ref()
|
||||
|
|
@ -860,13 +862,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&other_output);
|
||||
mapped.output_enter(&this.output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_output(surface, &other_output);
|
||||
toplevel_info_state.toplevel_enter_output(surface, &this.output);
|
||||
toplevel_leave_output(surface, &other_output);
|
||||
toplevel_enter_output(surface, &this.output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_workspace(surface, &other_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(surface, &this_desc.handle);
|
||||
}
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(this_desc.node.clone());
|
||||
}
|
||||
|
|
@ -875,13 +877,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&this.output);
|
||||
mapped.output_enter(&other_output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_output(surface, &this.output);
|
||||
toplevel_info_state.toplevel_enter_output(surface, &other_output);
|
||||
toplevel_leave_output(surface, &this.output);
|
||||
toplevel_enter_output(surface, &other_output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state.toplevel_leave_workspace(surface, &this_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(surface, &other_desc.handle);
|
||||
toplevel_leave_workspace(surface, &this_desc.handle);
|
||||
toplevel_enter_workspace(surface, &other_desc.handle);
|
||||
}
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(other_desc.node.clone());
|
||||
}
|
||||
|
|
@ -914,17 +916,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&this.output);
|
||||
mapped.output_enter(&other_output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_output(surface, &this.output);
|
||||
toplevel_info_state
|
||||
.toplevel_enter_output(surface, &other_output);
|
||||
toplevel_leave_output(surface, &this.output);
|
||||
toplevel_enter_output(surface, &other_output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_workspace(surface, &this_desc.handle);
|
||||
toplevel_info_state
|
||||
.toplevel_enter_workspace(surface, &other_desc.handle);
|
||||
toplevel_leave_workspace(surface, &this_desc.handle);
|
||||
toplevel_enter_workspace(surface, &other_desc.handle);
|
||||
}
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(new_id.clone());
|
||||
}
|
||||
|
|
@ -964,17 +962,13 @@ impl TilingLayout {
|
|||
mapped.output_leave(&other_output);
|
||||
mapped.output_enter(&this.output, mapped.bbox());
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_output(surface, &other_output);
|
||||
toplevel_info_state
|
||||
.toplevel_enter_output(surface, &this.output);
|
||||
toplevel_leave_output(surface, &other_output);
|
||||
toplevel_enter_output(surface, &this.output);
|
||||
}
|
||||
}
|
||||
for (ref surface, _) in mapped.windows() {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_workspace(surface, &other_desc.handle);
|
||||
toplevel_info_state
|
||||
.toplevel_enter_workspace(surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(surface, &this_desc.handle);
|
||||
}
|
||||
*mapped.tiling_node_id.lock().unwrap() = Some(new_id.clone());
|
||||
}
|
||||
|
|
@ -1034,23 +1028,23 @@ impl TilingLayout {
|
|||
if this.output != other_output {
|
||||
surface.output_leave(&other_output);
|
||||
surface.output_enter(&this.output, surface.bbox());
|
||||
toplevel_info_state.toplevel_leave_output(&surface, &other_output);
|
||||
toplevel_info_state.toplevel_enter_output(&surface, &this.output);
|
||||
toplevel_leave_output(&surface, &other_output);
|
||||
toplevel_enter_output(&surface, &this.output);
|
||||
}
|
||||
if this_desc.handle != other_desc.handle {
|
||||
toplevel_info_state.toplevel_leave_workspace(&surface, &other_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(&surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(&surface, &this_desc.handle);
|
||||
}
|
||||
this_stack.add_window(surface, Some(this_idx + i));
|
||||
}
|
||||
if this.output != other_output {
|
||||
this_surface.output_leave(&this.output);
|
||||
toplevel_info_state.toplevel_leave_output(&this_surface, &this.output);
|
||||
toplevel_info_state.toplevel_enter_output(&this_surface, &other_output);
|
||||
toplevel_leave_output(this_surface, &this.output);
|
||||
toplevel_enter_output(this_surface, &other_output);
|
||||
}
|
||||
if this_desc.handle != other_desc.handle {
|
||||
toplevel_info_state.toplevel_leave_workspace(&this_surface, &this_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&this_surface, &other_desc.handle);
|
||||
toplevel_leave_workspace(this_surface, &this_desc.handle);
|
||||
toplevel_enter_workspace(this_surface, &other_desc.handle);
|
||||
}
|
||||
this_stack.remove_window(&this_surface);
|
||||
|
||||
|
|
@ -1121,24 +1115,23 @@ impl TilingLayout {
|
|||
if this.output != other_output {
|
||||
surface.output_leave(&this.output);
|
||||
surface.output_enter(&other_output, surface.bbox());
|
||||
toplevel_info_state.toplevel_leave_output(&surface, &this.output);
|
||||
toplevel_info_state.toplevel_enter_output(&surface, &other_output);
|
||||
toplevel_leave_output(&surface, &this.output);
|
||||
toplevel_enter_output(&surface, &other_output);
|
||||
}
|
||||
if this_desc.handle != other_desc.handle {
|
||||
toplevel_info_state.toplevel_leave_workspace(&surface, &this_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&surface, &other_desc.handle);
|
||||
toplevel_leave_workspace(&surface, &this_desc.handle);
|
||||
toplevel_enter_workspace(&surface, &other_desc.handle);
|
||||
}
|
||||
other_stack.add_window(surface, Some(other_idx + i));
|
||||
}
|
||||
if this.output != other_output {
|
||||
other_surface.output_leave(&other_output);
|
||||
toplevel_info_state.toplevel_leave_output(&other_surface, &other_output);
|
||||
toplevel_info_state.toplevel_enter_output(&other_surface, &this.output);
|
||||
toplevel_leave_output(other_surface, &other_output);
|
||||
toplevel_enter_output(other_surface, &this.output);
|
||||
}
|
||||
if this_desc.handle != other_desc.handle {
|
||||
toplevel_info_state
|
||||
.toplevel_leave_workspace(&other_surface, &other_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&other_surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(other_surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(other_surface, &this_desc.handle);
|
||||
}
|
||||
other_stack.remove_window(&other_surface);
|
||||
|
||||
|
|
@ -1205,17 +1198,16 @@ impl TilingLayout {
|
|||
other_stack.add_window(this_surface.clone(), Some(other_idx));
|
||||
|
||||
if this.output != other_output {
|
||||
toplevel_info_state.toplevel_leave_output(&this_surface, &this.output);
|
||||
toplevel_info_state.toplevel_leave_output(&other_surface, &other_output);
|
||||
toplevel_info_state.toplevel_enter_output(&this_surface, &other_output);
|
||||
toplevel_info_state.toplevel_enter_output(&other_surface, &this.output);
|
||||
toplevel_leave_output(this_surface, &this.output);
|
||||
toplevel_leave_output(other_surface, &other_output);
|
||||
toplevel_enter_output(this_surface, &other_output);
|
||||
toplevel_enter_output(other_surface, &this.output);
|
||||
}
|
||||
if this_desc.handle != other_desc.handle {
|
||||
toplevel_info_state.toplevel_leave_workspace(&this_surface, &this_desc.handle);
|
||||
toplevel_info_state
|
||||
.toplevel_leave_workspace(&other_surface, &other_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&this_surface, &other_desc.handle);
|
||||
toplevel_info_state.toplevel_enter_workspace(&other_surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(this_surface, &this_desc.handle);
|
||||
toplevel_leave_workspace(other_surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(this_surface, &other_desc.handle);
|
||||
toplevel_enter_workspace(other_surface, &this_desc.handle);
|
||||
}
|
||||
|
||||
other_stack.remove_window(&other_surface);
|
||||
|
|
@ -1802,7 +1794,7 @@ impl TilingLayout {
|
|||
}
|
||||
|
||||
pub fn next_focus<'a>(
|
||||
&mut self,
|
||||
&self,
|
||||
direction: FocusDirection,
|
||||
seat: &Seat<State>,
|
||||
focus_stack: impl Iterator<Item = &'a CosmicMapped> + 'a,
|
||||
|
|
|
|||
1369
src/shell/mod.rs
1369
src/shell/mod.rs
File diff suppressed because it is too large
Load diff
|
|
@ -206,6 +206,8 @@ pub trait SeatExt {
|
|||
fn active_output(&self) -> Output;
|
||||
fn set_active_output(&self, output: &Output);
|
||||
fn devices(&self) -> &Devices;
|
||||
fn supressed_keys(&self) -> &SupressedKeys;
|
||||
fn modifiers_shortcut_queue(&self) -> &ModifiersShortcutQueue;
|
||||
|
||||
fn cursor_geometry(
|
||||
&self,
|
||||
|
|
@ -239,6 +241,14 @@ impl SeatExt for Seat<State> {
|
|||
self.user_data().get::<Devices>().unwrap()
|
||||
}
|
||||
|
||||
fn supressed_keys(&self) -> &SupressedKeys {
|
||||
self.user_data().get::<SupressedKeys>().unwrap()
|
||||
}
|
||||
|
||||
fn modifiers_shortcut_queue(&self) -> &ModifiersShortcutQueue {
|
||||
self.user_data().get::<ModifiersShortcutQueue>().unwrap()
|
||||
}
|
||||
|
||||
fn cursor_geometry(
|
||||
&self,
|
||||
loc: impl Into<Point<f64, Buffer>>,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::{
|
|||
wayland::{
|
||||
handlers::screencopy::ScreencopySessions,
|
||||
protocols::{
|
||||
toplevel_info::ToplevelInfoState,
|
||||
toplevel_info::{toplevel_enter_output, toplevel_leave_output},
|
||||
workspace::{WorkspaceHandle, WorkspaceUpdateGuard},
|
||||
},
|
||||
},
|
||||
|
|
@ -365,23 +365,19 @@ impl Workspace {
|
|||
&self.output
|
||||
}
|
||||
|
||||
pub fn set_output(
|
||||
&mut self,
|
||||
output: &Output,
|
||||
toplevel_info: &mut ToplevelInfoState<State, CosmicSurface>,
|
||||
) {
|
||||
pub fn set_output(&mut self, output: &Output) {
|
||||
self.tiling_layer.set_output(output);
|
||||
self.floating_layer.set_output(output);
|
||||
for mapped in self.mapped() {
|
||||
for (surface, _) in mapped.windows() {
|
||||
toplevel_info.toplevel_leave_output(&surface, &self.output);
|
||||
toplevel_info.toplevel_enter_output(&surface, output);
|
||||
toplevel_leave_output(&surface, &self.output);
|
||||
toplevel_enter_output(&surface, output);
|
||||
}
|
||||
}
|
||||
for window in self.minimized_windows.iter() {
|
||||
for (surface, _) in window.window.windows() {
|
||||
toplevel_info.toplevel_leave_output(&surface, &self.output);
|
||||
toplevel_info.toplevel_enter_output(&surface, output);
|
||||
toplevel_leave_output(&surface, &self.output);
|
||||
toplevel_enter_output(&surface, output);
|
||||
}
|
||||
}
|
||||
let output_name = output.name();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue