deps: Update smithay
This commit is contained in:
parent
9e0a6e1b5f
commit
6690e13d54
31 changed files with 572 additions and 562 deletions
|
|
@ -7,12 +7,10 @@ use crate::{
|
|||
use indexmap::IndexSet;
|
||||
use smithay::{
|
||||
desktop::{PopupUngrabStrategy, Window, WindowSurfaceType},
|
||||
reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
|
||||
utils::IsAlive,
|
||||
wayland::{
|
||||
compositor::with_states, seat::Seat, shell::xdg::XdgToplevelSurfaceRoleAttributes, Serial,
|
||||
SERIAL_COUNTER,
|
||||
},
|
||||
input::Seat,
|
||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
utils::{IsAlive, Serial, SERIAL_COUNTER},
|
||||
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceRoleAttributes},
|
||||
};
|
||||
use std::{
|
||||
cell::{Ref, RefCell, RefMut},
|
||||
|
|
@ -112,15 +110,14 @@ impl ActiveFocus {
|
|||
|
||||
impl Shell {
|
||||
pub fn set_focus<'a>(
|
||||
&mut self,
|
||||
dh: &DisplayHandle,
|
||||
state: &mut State,
|
||||
surface: Option<&WlSurface>,
|
||||
active_seat: &Seat<State>,
|
||||
serial: Option<Serial>,
|
||||
) {
|
||||
// update FocusStack and notify layouts about new focus (if any window)
|
||||
if let Some(surface) = surface {
|
||||
if let Some(workspace) = self.space_for_window_mut(surface) {
|
||||
if let Some(workspace) = state.common.shell.space_for_window_mut(surface) {
|
||||
if let Some(window) = workspace
|
||||
.space
|
||||
.window_for_surface(surface, WindowSurfaceType::ALL)
|
||||
|
|
@ -136,7 +133,7 @@ impl Shell {
|
|||
.and_then(|x| x.take())
|
||||
{
|
||||
if !popup_grab.has_ended() {
|
||||
popup_grab.ungrab(dh, PopupUngrabStrategy::All);
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,8 +145,8 @@ impl Shell {
|
|||
if let Some(keyboard) = active_seat.get_keyboard() {
|
||||
ActiveFocus::set(active_seat, surface.cloned());
|
||||
keyboard.set_focus(
|
||||
dh,
|
||||
surface,
|
||||
state,
|
||||
surface.cloned(),
|
||||
serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()),
|
||||
);
|
||||
}
|
||||
|
|
@ -191,21 +188,21 @@ impl Shell {
|
|||
|
||||
impl Common {
|
||||
pub fn set_focus(
|
||||
&mut self,
|
||||
dh: &DisplayHandle,
|
||||
state: &mut State,
|
||||
surface: Option<&WlSurface>,
|
||||
active_seat: &Seat<State>,
|
||||
serial: Option<Serial>,
|
||||
) {
|
||||
self.shell.set_focus(dh, surface, active_seat, serial);
|
||||
self.shell.update_active(self.seats.iter());
|
||||
Shell::set_focus(state, surface, active_seat, serial);
|
||||
state.common.shell.update_active(state.common.seats.iter());
|
||||
}
|
||||
|
||||
pub fn refresh_focus(&mut self, dh: &DisplayHandle) {
|
||||
for seat in &self.seats {
|
||||
pub fn refresh_focus(state: &mut State) {
|
||||
let seats = state.common.seats.clone();
|
||||
for seat in seats {
|
||||
let mut fixup = false;
|
||||
let output = active_output(seat, &self);
|
||||
let last_known_focus = ActiveFocus::get(seat);
|
||||
let output = active_output(&seat, &state.common);
|
||||
let last_known_focus = ActiveFocus::get(&seat);
|
||||
|
||||
if let Some(surface) = last_known_focus {
|
||||
if surface.alive() {
|
||||
|
|
@ -219,7 +216,7 @@ impl Common {
|
|||
continue;
|
||||
}
|
||||
|
||||
let workspace = self.shell.active_space(&output);
|
||||
let workspace = state.common.shell.active_space(&output);
|
||||
if let Some(window) = workspace
|
||||
.space
|
||||
.window_for_surface(&surface, WindowSurfaceType::ALL)
|
||||
|
|
@ -244,24 +241,25 @@ impl Common {
|
|||
.and_then(|x| x.take())
|
||||
{
|
||||
if !popup_grab.has_ended() {
|
||||
popup_grab.ungrab(dh, PopupUngrabStrategy::All);
|
||||
popup_grab.ungrab(PopupUngrabStrategy::All);
|
||||
}
|
||||
}
|
||||
|
||||
// update keyboard focus
|
||||
let surface = self
|
||||
let surface = state
|
||||
.common
|
||||
.shell
|
||||
.active_space(&output)
|
||||
.focus_stack(seat)
|
||||
.focus_stack(&seat)
|
||||
.last()
|
||||
.map(|w| w.toplevel().wl_surface().clone());
|
||||
if let Some(keyboard) = seat.get_keyboard() {
|
||||
keyboard.set_focus(dh, surface.as_ref(), SERIAL_COUNTER.next_serial());
|
||||
ActiveFocus::set(seat, surface);
|
||||
keyboard.set_focus(state, surface.clone(), SERIAL_COUNTER.next_serial());
|
||||
ActiveFocus::set(&seat, surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.shell.update_active(self.seats.iter())
|
||||
state.common.shell.update_active(state.common.seats.iter())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,34 +11,35 @@ use smithay::{
|
|||
space::{RenderElement, SpaceOutputTuple},
|
||||
Kind, Window,
|
||||
},
|
||||
input::{
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, Focus, GrabStartData as PointerGrabStartData, MotionEvent,
|
||||
PointerGrab, PointerInnerHandle,
|
||||
},
|
||||
Seat,
|
||||
},
|
||||
reexports::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel::State as XdgState,
|
||||
wayland_server::DisplayHandle,
|
||||
},
|
||||
utils::{IsAlive, Logical, Physical, Point, Rectangle, Scale},
|
||||
wayland::{
|
||||
output::Output,
|
||||
seat::{
|
||||
AxisFrame, ButtonEvent, MotionEvent, PointerGrab, PointerGrabStartData,
|
||||
PointerInnerHandle,
|
||||
},
|
||||
seat::{Focus, Seat},
|
||||
Serial,
|
||||
wayland_server::protocol::wl_surface::WlSurface,
|
||||
},
|
||||
utils::{IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial},
|
||||
wayland::output::Output,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
||||
impl Shell {
|
||||
pub fn move_request(
|
||||
&mut self,
|
||||
state: &mut State,
|
||||
window: &Window,
|
||||
seat: &Seat<State>,
|
||||
serial: Serial,
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
) {
|
||||
// TODO touch grab
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
let workspace = self
|
||||
let workspace = state
|
||||
.common
|
||||
.shell
|
||||
.space_for_window_mut(window.toplevel().wl_surface())
|
||||
.unwrap();
|
||||
if workspace.fullscreen.values().any(|w| w == window) {
|
||||
|
|
@ -91,16 +92,25 @@ impl Shell {
|
|||
let workspace_is_empty = workspace.space.windows().next().is_none();
|
||||
|
||||
if workspace_is_empty {
|
||||
self.workspace_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspace_state
|
||||
.update()
|
||||
.add_workspace_state(&workspace_handle, WState::Hidden);
|
||||
}
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_leave_workspace(&window, &workspace_handle);
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_leave_output(&window, &output);
|
||||
|
||||
let state = MoveGrabState {
|
||||
let grab_state = MoveGrabState {
|
||||
window: window.clone(),
|
||||
was_tiled,
|
||||
initial_cursor_location: pointer.current_location(),
|
||||
|
|
@ -112,12 +122,12 @@ impl Shell {
|
|||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
.unwrap()
|
||||
.borrow_mut() = Some(state);
|
||||
pointer.set_grab(grab, serial, Focus::Clear);
|
||||
.borrow_mut() = Some(grab_state);
|
||||
pointer.set_grab(state, grab, serial, Focus::Clear);
|
||||
}
|
||||
}
|
||||
|
||||
fn drop_move(&mut self, dh: &DisplayHandle, seat: &Seat<State>, output: &Output) {
|
||||
fn drop_move(state: &mut State, seat: &Seat<State>, output: &Output) {
|
||||
if let Some(move_state) = seat
|
||||
.user_data()
|
||||
.get::<SeatMoveGrabState>()
|
||||
|
|
@ -134,16 +144,25 @@ impl Shell {
|
|||
(move_state.initial_window_location.to_f64() + delta).to_i32_round();
|
||||
let surface = window.toplevel().wl_surface().clone();
|
||||
|
||||
let workspace_handle = self.active_space(output).handle;
|
||||
self.workspace_state
|
||||
let workspace_handle = state.common.shell.active_space(output).handle;
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspace_state
|
||||
.update()
|
||||
.remove_workspace_state(&workspace_handle, WState::Hidden);
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_workspace(&window, &workspace_handle);
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_output(&window, &output);
|
||||
|
||||
let workspace = self.active_space_mut(output);
|
||||
let workspace = state.common.shell.active_space_mut(output);
|
||||
if move_state.was_tiled {
|
||||
let focus_stack = workspace.focus_stack(&seat);
|
||||
workspace.tiling_layer.map_window(
|
||||
|
|
@ -161,10 +180,10 @@ impl Shell {
|
|||
);
|
||||
}
|
||||
|
||||
self.set_focus(dh, Some(&surface), &seat, None);
|
||||
Shell::set_focus(state, Some(&surface), &seat, None);
|
||||
|
||||
for window in self.active_space(output).space.windows() {
|
||||
self.update_reactive_popups(window);
|
||||
for window in state.common.shell.active_space(output).space.windows() {
|
||||
state.common.shell.update_reactive_popups(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -267,7 +286,7 @@ impl MoveGrabState {
|
|||
|
||||
pub struct MoveSurfaceGrab {
|
||||
window: Window,
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
seat: Seat<State>,
|
||||
}
|
||||
|
||||
|
|
@ -275,48 +294,46 @@ impl PointerGrab<State> for MoveSurfaceGrab {
|
|||
fn motion(
|
||||
&mut self,
|
||||
state: &mut State,
|
||||
dh: &DisplayHandle,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(WlSurface, Point<i32, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
) {
|
||||
// While the grab is active, no client has pointer focus
|
||||
handle.motion(event.location, None, event.serial, event.time);
|
||||
handle.motion(state, None, event);
|
||||
if !self.window.alive() {
|
||||
self.ungrab(dh, state, handle, event.serial, event.time);
|
||||
self.ungrab(state, handle, event.serial, event.time);
|
||||
}
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
state: &mut State,
|
||||
dh: &DisplayHandle,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
) {
|
||||
handle.button(event.button, event.state, event.serial, event.time);
|
||||
handle.button(state, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
self.ungrab(dh, state, handle, event.serial, event.time);
|
||||
self.ungrab(state, handle, event.serial, event.time);
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
_state: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
) {
|
||||
handle.axis(details);
|
||||
handle.axis(state, details);
|
||||
}
|
||||
|
||||
fn start_data(&self) -> &PointerGrabStartData {
|
||||
fn start_data(&self) -> &PointerGrabStartData<State> {
|
||||
&self.start_data
|
||||
}
|
||||
}
|
||||
|
||||
impl MoveSurfaceGrab {
|
||||
pub fn new(
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
window: Window,
|
||||
seat: &Seat<State>,
|
||||
) -> MoveSurfaceGrab {
|
||||
|
|
@ -329,7 +346,6 @@ impl MoveSurfaceGrab {
|
|||
|
||||
fn ungrab(
|
||||
&mut self,
|
||||
dh: &DisplayHandle,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
serial: Serial,
|
||||
|
|
@ -337,12 +353,11 @@ impl MoveSurfaceGrab {
|
|||
) {
|
||||
// No more buttons are pressed, release the grab.
|
||||
let output = active_output(&self.seat, &state.common);
|
||||
let dh = dh.clone();
|
||||
let seat = self.seat.clone();
|
||||
|
||||
state.common.event_loop_handle.insert_idle(move |data| {
|
||||
data.state.common.shell.drop_move(&dh, &seat, &output);
|
||||
Shell::drop_move(&mut data.state, &seat, &output);
|
||||
});
|
||||
handle.unset_grab(serial, time);
|
||||
handle.unset_grab(state, serial, time);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
use crate::utils::prelude::*;
|
||||
use smithay::{
|
||||
desktop::{Kind, Window},
|
||||
reexports::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel, wayland_server::DisplayHandle,
|
||||
input::pointer::{
|
||||
AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab,
|
||||
PointerInnerHandle,
|
||||
},
|
||||
utils::{IsAlive, Logical, Point, Size},
|
||||
reexports::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel,
|
||||
wayland_server::protocol::wl_surface::WlSurface,
|
||||
},
|
||||
utils::{IsAlive, Logical, Point, Serial, Size},
|
||||
wayland::{
|
||||
compositor::with_states,
|
||||
seat::{
|
||||
AxisFrame, ButtonEvent, MotionEvent, PointerGrab, PointerGrabStartData,
|
||||
PointerInnerHandle,
|
||||
},
|
||||
shell::xdg::{SurfaceCachedState, ToplevelConfigure, XdgToplevelSurfaceRoleAttributes},
|
||||
Serial,
|
||||
},
|
||||
};
|
||||
use std::{cell::RefCell, convert::TryFrom, sync::Mutex};
|
||||
|
|
@ -78,7 +78,7 @@ impl Default for ResizeState {
|
|||
}
|
||||
|
||||
pub struct ResizeSurfaceGrab {
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
window: Window,
|
||||
edges: ResizeEdge,
|
||||
initial_window_size: Size<i32, Logical>,
|
||||
|
|
@ -88,17 +88,17 @@ pub struct ResizeSurfaceGrab {
|
|||
impl PointerGrab<State> for ResizeSurfaceGrab {
|
||||
fn motion(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(WlSurface, Point<i32, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
) {
|
||||
// While the grab is active, no client has pointer focus
|
||||
handle.motion(event.location, None, event.serial, event.time);
|
||||
handle.motion(data, None, event);
|
||||
|
||||
// It is impossible to get `min_size` and `max_size` of dead toplevel, so we return early.
|
||||
if !self.window.alive() {
|
||||
handle.unset_grab(event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -162,15 +162,14 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
|
||||
fn button(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
) {
|
||||
handle.button(event.button, event.state, event.serial, event.time);
|
||||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
// No more buttons are pressed, release the grab.
|
||||
handle.unset_grab(event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
|
||||
// If toplevel is dead, we can't resize it, so we return early.
|
||||
if !self.window.alive() {
|
||||
|
|
@ -202,22 +201,21 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
|
||||
fn axis(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
) {
|
||||
handle.axis(details)
|
||||
handle.axis(data, details)
|
||||
}
|
||||
|
||||
fn start_data(&self) -> &PointerGrabStartData {
|
||||
fn start_data(&self) -> &PointerGrabStartData<State> {
|
||||
&self.start_data
|
||||
}
|
||||
}
|
||||
|
||||
impl ResizeSurfaceGrab {
|
||||
pub fn new(
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
window: Window,
|
||||
edges: xdg_toplevel::ResizeEdge,
|
||||
initial_window_location: Point<i32, Logical>,
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
use smithay::{
|
||||
desktop::{layer_map_for_output, space::RenderZindex, Kind, Space, Window},
|
||||
input::{
|
||||
pointer::{Focus, GrabStartData as PointerGrabStartData},
|
||||
Seat,
|
||||
},
|
||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{
|
||||
ResizeEdge, State as XdgState,
|
||||
},
|
||||
utils::{IsAlive, Logical, Point, Rectangle},
|
||||
utils::{IsAlive, Logical, Point, Rectangle, Serial},
|
||||
wayland::{
|
||||
compositor::with_states,
|
||||
output::Output,
|
||||
seat::{Focus, PointerGrabStartData, Seat},
|
||||
shell::xdg::XdgToplevelSurfaceRoleAttributes,
|
||||
Serial,
|
||||
compositor::with_states, output::Output, shell::xdg::XdgToplevelSurfaceRoleAttributes,
|
||||
},
|
||||
};
|
||||
use std::{collections::HashSet, sync::Mutex};
|
||||
|
|
@ -232,14 +232,21 @@ impl FloatingLayout {
|
|||
}
|
||||
|
||||
pub fn resize_request(
|
||||
&mut self,
|
||||
space: &mut Space,
|
||||
state: &mut State,
|
||||
window: &Window,
|
||||
seat: &Seat<State>,
|
||||
serial: Serial,
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
edges: ResizeEdge,
|
||||
) {
|
||||
// it is so stupid, that we have to do this here. TODO: Refactor grabs
|
||||
let workspace = state
|
||||
.common
|
||||
.shell
|
||||
.space_for_window_mut(window.toplevel().wl_surface())
|
||||
.unwrap();
|
||||
let space = &mut workspace.space;
|
||||
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
let location = space.window_location(&window).unwrap();
|
||||
let size = window.geometry().size;
|
||||
|
|
@ -247,7 +254,7 @@ impl FloatingLayout {
|
|||
let grab =
|
||||
grabs::ResizeSurfaceGrab::new(start_data, window.clone(), edges, location, size);
|
||||
|
||||
pointer.set_grab(grab, serial, Focus::Clear);
|
||||
pointer.set_grab(state, grab, serial, Focus::Clear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ use crate::{input::ActiveOutput, state::State};
|
|||
use regex::RegexSet;
|
||||
use smithay::{
|
||||
desktop::{Space, Window},
|
||||
input::Seat,
|
||||
wayland::{
|
||||
compositor::with_states, output::Output, seat::Seat,
|
||||
shell::xdg::XdgToplevelSurfaceRoleAttributes,
|
||||
compositor::with_states, output::Output, shell::xdg::XdgToplevelSurfaceRoleAttributes,
|
||||
},
|
||||
};
|
||||
use std::sync::Mutex;
|
||||
|
|
|
|||
|
|
@ -3,16 +3,17 @@
|
|||
use crate::{shell::layout::Orientation, utils::prelude::*};
|
||||
use atomic_float::AtomicF64;
|
||||
use smithay::{
|
||||
reexports::wayland_server::DisplayHandle,
|
||||
utils::{Logical, Size},
|
||||
wayland::seat::{
|
||||
AxisFrame, ButtonEvent, MotionEvent, PointerGrab, PointerGrabStartData, PointerInnerHandle,
|
||||
input::pointer::{
|
||||
AxisFrame, ButtonEvent, GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab,
|
||||
PointerInnerHandle,
|
||||
},
|
||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
utils::{Logical, Point, Size},
|
||||
};
|
||||
use std::sync::{atomic::Ordering, Arc};
|
||||
|
||||
pub struct ResizeForkGrab {
|
||||
pub start_data: PointerGrabStartData,
|
||||
pub start_data: PointerGrabStartData<State>,
|
||||
pub orientation: Orientation,
|
||||
pub initial_size: Size<i32, Logical>,
|
||||
pub initial_ratio: f64,
|
||||
|
|
@ -22,13 +23,13 @@ pub struct ResizeForkGrab {
|
|||
impl PointerGrab<State> for ResizeForkGrab {
|
||||
fn motion(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(WlSurface, Point<i32, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
) {
|
||||
// While the grab is active, no client has pointer focus
|
||||
handle.motion(event.location, None, event.serial, event.time);
|
||||
handle.motion(data, None, event);
|
||||
|
||||
let delta = event.location - self.start_data.location;
|
||||
let delta = match self.orientation {
|
||||
|
|
@ -43,29 +44,27 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
|
||||
fn button(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
) {
|
||||
handle.button(event.button, event.state, event.serial, event.time);
|
||||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
// No more buttons are pressed, release the grab.
|
||||
handle.unset_grab(event.serial, event.time);
|
||||
handle.unset_grab(data, event.serial, event.time);
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
_data: &mut State,
|
||||
_dh: &DisplayHandle,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
) {
|
||||
handle.axis(details)
|
||||
handle.axis(data, details)
|
||||
}
|
||||
|
||||
fn start_data(&self) -> &PointerGrabStartData {
|
||||
fn start_data(&self) -> &PointerGrabStartData<State> {
|
||||
&self.start_data
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ use atomic_float::AtomicF64;
|
|||
use id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBehavior, Tree};
|
||||
use smithay::{
|
||||
desktop::{layer_map_for_output, Kind, Space, Window},
|
||||
input::{
|
||||
pointer::{Focus, GrabStartData as PointerGrabStartData},
|
||||
Seat,
|
||||
},
|
||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{
|
||||
ResizeEdge, State as XdgState,
|
||||
},
|
||||
utils::{IsAlive, Rectangle},
|
||||
wayland::{
|
||||
seat::{Focus, PointerGrabStartData, Seat},
|
||||
Serial,
|
||||
},
|
||||
utils::{IsAlive, Rectangle, Serial},
|
||||
};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
|
|
@ -233,18 +233,26 @@ impl TilingLayout {
|
|||
}
|
||||
|
||||
pub fn resize_request(
|
||||
&mut self,
|
||||
space: &mut Space,
|
||||
state: &mut State,
|
||||
window: &Window,
|
||||
seat: &Seat<State>,
|
||||
serial: Serial,
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
edges: ResizeEdge,
|
||||
) {
|
||||
// it is so stupid, that we have to do this here. TODO: Refactor grabs
|
||||
let workspace = state
|
||||
.common
|
||||
.shell
|
||||
.space_for_window_mut(window.toplevel().wl_surface())
|
||||
.unwrap();
|
||||
let space = &mut workspace.space;
|
||||
let trees = &mut workspace.tiling_layer.trees;
|
||||
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
if let Some(info) = window.user_data().get::<RefCell<WindowInfo>>() {
|
||||
let output = info.borrow().output;
|
||||
let tree = TilingLayout::active_tree(&mut self.trees, output);
|
||||
let tree = TilingLayout::active_tree(trees, output);
|
||||
let mut node_id = info.borrow().node.clone();
|
||||
|
||||
while let Some((fork, child)) = TilingLayout::find_fork(tree, node_id) {
|
||||
|
|
@ -261,18 +269,19 @@ impl TilingLayout {
|
|||
| (false, Orientation::Horizontal, ResizeEdge::Top)
|
||||
| (true, Orientation::Vertical, ResizeEdge::Right)
|
||||
| (false, Orientation::Vertical, ResizeEdge::Left) => {
|
||||
if let Some(output) = space.outputs().nth(output) {
|
||||
let output = space.outputs().nth(output).cloned();
|
||||
if let Some(output) = output {
|
||||
let grab = ResizeForkGrab {
|
||||
start_data,
|
||||
orientation: *orientation,
|
||||
initial_ratio: ratio.load(Ordering::SeqCst),
|
||||
initial_size: layer_map_for_output(output)
|
||||
initial_size: layer_map_for_output(&output)
|
||||
.non_exclusive_zone()
|
||||
.size,
|
||||
ratio: ratio.clone(),
|
||||
};
|
||||
|
||||
pointer.set_grab(grab, serial, Focus::Clear);
|
||||
pointer.set_grab(state, grab, serial, Focus::Clear);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@ use std::{cell::Cell, mem::MaybeUninit};
|
|||
|
||||
use smithay::{
|
||||
desktop::{layer_map_for_output, LayerSurface, PopupManager, Window, WindowSurfaceType},
|
||||
input::{pointer::MotionEvent, Seat},
|
||||
reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
|
||||
utils::{Logical, Point, Rectangle},
|
||||
utils::{Logical, Point, Rectangle, SERIAL_COUNTER},
|
||||
wayland::{
|
||||
compositor::with_states,
|
||||
output::Output,
|
||||
seat::{MotionEvent, Seat},
|
||||
shell::{
|
||||
wlr_layer::{
|
||||
KeyboardInteractivity, Layer, LayerSurfaceCachedState, WlrLayerShellState,
|
||||
},
|
||||
xdg::XdgShellState,
|
||||
},
|
||||
SERIAL_COUNTER,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -372,7 +371,6 @@ impl Shell {
|
|||
geometry.loc.y + (geometry.size.h / 2),
|
||||
))
|
||||
.to_f64(),
|
||||
focus: None, // This should actually be a surface, if there is one in the center
|
||||
serial: SERIAL_COUNTER.next_serial(),
|
||||
time: 0,
|
||||
});
|
||||
|
|
@ -593,16 +591,18 @@ impl Shell {
|
|||
.refresh(Some(&self.workspace_state));
|
||||
}
|
||||
|
||||
pub fn map_window(&mut self, window: &Window, output: &Output, dh: &DisplayHandle) {
|
||||
let pos = self
|
||||
pub fn map_window(state: &mut State, window: &Window, output: &Output) {
|
||||
let pos = state
|
||||
.common
|
||||
.shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.position(|(w, _)| w == window)
|
||||
.unwrap();
|
||||
let (window, seat) = self.pending_windows.remove(pos);
|
||||
let (window, seat) = state.common.shell.pending_windows.remove(pos);
|
||||
let surface = window.toplevel().wl_surface().clone();
|
||||
|
||||
let workspace = match &self.workspace_mode {
|
||||
let workspace = match &state.common.shell.workspace_mode {
|
||||
WorkspaceMode::OutputBound => {
|
||||
let active = output
|
||||
.user_data()
|
||||
|
|
@ -610,18 +610,27 @@ impl Shell {
|
|||
.unwrap()
|
||||
.active
|
||||
.get();
|
||||
&mut self.spaces[active]
|
||||
&mut state.common.shell.spaces[active]
|
||||
}
|
||||
WorkspaceMode::Global { active, .. } => &mut self.spaces[*active],
|
||||
WorkspaceMode::Global { active, .. } => &mut state.common.shell.spaces[*active],
|
||||
};
|
||||
self.workspace_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspace_state
|
||||
.update()
|
||||
.remove_workspace_state(&workspace.handle, WState::Hidden);
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_workspace(&window, &workspace.handle);
|
||||
self.toplevel_info_state
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.toplevel_info_state
|
||||
.toplevel_enter_output(&window, &output);
|
||||
if layout::should_be_floating(&window) || self.floating_default {
|
||||
if layout::should_be_floating(&window) || state.common.shell.floating_default {
|
||||
workspace
|
||||
.floating_layer
|
||||
.map_window(&mut workspace.space, window, &seat, None);
|
||||
|
|
@ -635,20 +644,22 @@ impl Shell {
|
|||
);
|
||||
}
|
||||
|
||||
self.set_focus(dh, Some(&surface), &seat, None);
|
||||
Shell::set_focus(state, Some(&surface), &seat, None);
|
||||
|
||||
for window in self.active_space(output).space.windows() {
|
||||
self.update_reactive_popups(window);
|
||||
for window in state.common.shell.active_space(output).space.windows() {
|
||||
state.common.shell.update_reactive_popups(window);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_layer(&mut self, layer_surface: &LayerSurface, dh: &DisplayHandle) {
|
||||
let pos = self
|
||||
pub fn map_layer(state: &mut State, layer_surface: &LayerSurface) {
|
||||
let pos = state
|
||||
.common
|
||||
.shell
|
||||
.pending_layers
|
||||
.iter()
|
||||
.position(|(l, _, _)| l == layer_surface)
|
||||
.unwrap();
|
||||
let (layer_surface, output, seat) = self.pending_layers.remove(pos);
|
||||
let (layer_surface, output, seat) = state.common.shell.pending_layers.remove(pos);
|
||||
|
||||
let surface = layer_surface.wl_surface();
|
||||
let wants_focus = {
|
||||
|
|
@ -660,10 +671,11 @@ impl Shell {
|
|||
};
|
||||
|
||||
let mut map = layer_map_for_output(&output);
|
||||
map.map_layer(dh, &layer_surface).unwrap();
|
||||
map.map_layer(&state.common.display_handle, &layer_surface)
|
||||
.unwrap();
|
||||
|
||||
if wants_focus {
|
||||
self.set_focus(dh, Some(surface), &seat, None)
|
||||
Shell::set_focus(state, Some(surface), &seat, None)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,14 @@ use crate::{
|
|||
};
|
||||
|
||||
use smithay::{
|
||||
desktop::{Kind, Space, Window},
|
||||
desktop::{Kind, Space, Window, WindowSurfaceType},
|
||||
input::{pointer::GrabStartData as PointerGrabStartData, Seat},
|
||||
reexports::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel::{self, ResizeEdge},
|
||||
wayland_server::DisplayHandle,
|
||||
},
|
||||
utils::IsAlive,
|
||||
wayland::{
|
||||
output::Output,
|
||||
seat::{PointerGrabStartData, Seat},
|
||||
Serial,
|
||||
wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
|
||||
},
|
||||
utils::{IsAlive, Serial},
|
||||
wayland::output::Output,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -81,35 +78,27 @@ impl Workspace {
|
|||
}
|
||||
|
||||
pub fn resize_request(
|
||||
&mut self,
|
||||
window: &Window,
|
||||
state: &mut State,
|
||||
surface: &WlSurface,
|
||||
seat: &Seat<State>,
|
||||
serial: Serial,
|
||||
start_data: PointerGrabStartData,
|
||||
start_data: PointerGrabStartData<State>,
|
||||
edges: ResizeEdge,
|
||||
) {
|
||||
if self.fullscreen.values().any(|w| w == window) {
|
||||
let workspace = state.common.shell.space_for_window_mut(surface).unwrap();
|
||||
let window = workspace
|
||||
.space
|
||||
.window_for_surface(surface, WindowSurfaceType::TOPLEVEL)
|
||||
.unwrap()
|
||||
.clone();
|
||||
|
||||
if workspace.fullscreen.values().any(|w| w == &window) {
|
||||
return;
|
||||
}
|
||||
if self.floating_layer.windows.contains(window) {
|
||||
self.floating_layer.resize_request(
|
||||
&mut self.space,
|
||||
window,
|
||||
seat,
|
||||
serial,
|
||||
start_data.clone(),
|
||||
edges,
|
||||
)
|
||||
}
|
||||
if self.tiling_layer.windows.contains(window) {
|
||||
self.tiling_layer.resize_request(
|
||||
&mut self.space,
|
||||
window,
|
||||
seat,
|
||||
serial,
|
||||
start_data,
|
||||
edges,
|
||||
)
|
||||
if workspace.floating_layer.windows.contains(&window) {
|
||||
FloatingLayout::resize_request(state, &window, seat, serial, start_data.clone(), edges)
|
||||
} else if workspace.tiling_layer.windows.contains(&window) {
|
||||
TilingLayout::resize_request(state, &window, seat, serial, start_data, edges)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue