cargo fmt
This commit is contained in:
parent
43062c1754
commit
39de286d51
40 changed files with 1557 additions and 1080 deletions
|
|
@ -1,10 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::{
|
||||
reexports::wayland_server::protocol::wl_buffer::WlBuffer,
|
||||
wayland::buffer::BufferHandler,
|
||||
};
|
||||
use crate::utils::prelude::*;
|
||||
use smithay::{
|
||||
reexports::wayland_server::protocol::wl_buffer::WlBuffer, wayland::buffer::BufferHandler,
|
||||
};
|
||||
|
||||
impl BufferHandler for State {
|
||||
fn buffer_destroyed(&mut self, _buffer: &WlBuffer) {}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,22 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::{
|
||||
sync::Mutex,
|
||||
};
|
||||
use crate::{state::BackendData, utils::prelude::*};
|
||||
use smithay::{
|
||||
backend::renderer::utils::{
|
||||
on_commit_buffer_handler,
|
||||
},
|
||||
desktop::{
|
||||
LayerSurface,
|
||||
PopupKind,
|
||||
Kind,
|
||||
WindowSurfaceType,
|
||||
},
|
||||
reexports::wayland_server::{
|
||||
DisplayHandle,
|
||||
protocol::wl_surface::WlSurface,
|
||||
},
|
||||
wayland::{
|
||||
compositor::{
|
||||
CompositorHandler,
|
||||
CompositorState,
|
||||
with_states,
|
||||
},
|
||||
shell::{
|
||||
xdg::{
|
||||
ToplevelSurface,
|
||||
XdgToplevelSurfaceRoleAttributes,
|
||||
XdgPopupSurfaceRoleAttributes,
|
||||
},
|
||||
wlr_layer::LayerSurfaceAttributes,
|
||||
},
|
||||
},
|
||||
backend::renderer::utils::on_commit_buffer_handler,
|
||||
delegate_compositor,
|
||||
desktop::{Kind, LayerSurface, PopupKind, WindowSurfaceType},
|
||||
reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
|
||||
wayland::{
|
||||
compositor::{with_states, CompositorHandler, CompositorState},
|
||||
shell::{
|
||||
wlr_layer::LayerSurfaceAttributes,
|
||||
xdg::{
|
||||
ToplevelSurface, XdgPopupSurfaceRoleAttributes, XdgToplevelSurfaceRoleAttributes,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
use crate::{
|
||||
state::BackendData,
|
||||
utils::prelude::*,
|
||||
};
|
||||
use std::sync::Mutex;
|
||||
|
||||
impl State {
|
||||
fn early_import_surface(&mut self, dh: &DisplayHandle, surface: &WlSurface) {
|
||||
|
|
@ -46,12 +25,17 @@ impl State {
|
|||
if let BackendData::Kms(ref mut kms_state) = &mut self.backend {
|
||||
if let Some(target) = kms_state.target_node_for_output(&output) {
|
||||
if import_nodes.insert(target) {
|
||||
kms_state.try_early_import(dh, surface, &output, target, &self.common.shell);
|
||||
kms_state.try_early_import(
|
||||
dh,
|
||||
surface,
|
||||
&output,
|
||||
target,
|
||||
&self.common.shell,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
self
|
||||
.backend
|
||||
self.backend
|
||||
.schedule_render(&self.common.event_loop_handle, &output);
|
||||
}
|
||||
}
|
||||
|
|
@ -119,9 +103,14 @@ impl CompositorHandler for State {
|
|||
|
||||
fn commit(&mut self, dh: &DisplayHandle, surface: &WlSurface) {
|
||||
// initial configure
|
||||
if let Some((window, seat)) = self.common.shell.pending_windows.iter().find(|(window, _)| {
|
||||
window.toplevel().wl_surface() == surface
|
||||
}).cloned() {
|
||||
if let Some((window, seat)) = self
|
||||
.common
|
||||
.shell
|
||||
.pending_windows
|
||||
.iter()
|
||||
.find(|(window, _)| window.toplevel().wl_surface() == surface)
|
||||
.cloned()
|
||||
{
|
||||
match window.toplevel() {
|
||||
Kind::Xdg(toplevel) => {
|
||||
if self.toplevel_ensure_initial_configure(&toplevel) {
|
||||
|
|
@ -134,9 +123,14 @@ impl CompositorHandler for State {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some((layer_surface, _, _)) = self.common.shell.pending_layers.iter().find(|(layer_surface, _, _)| {
|
||||
layer_surface.wl_surface() == surface
|
||||
}).cloned() {
|
||||
if let Some((layer_surface, _, _)) = self
|
||||
.common
|
||||
.shell
|
||||
.pending_layers
|
||||
.iter()
|
||||
.find(|(layer_surface, _, _)| layer_surface.wl_surface() == surface)
|
||||
.cloned()
|
||||
{
|
||||
if self.layer_surface_ensure_inital_configure(&layer_surface) {
|
||||
self.common.shell.map_layer(&layer_surface, dh);
|
||||
} else {
|
||||
|
|
@ -163,16 +157,17 @@ impl CompositorHandler for State {
|
|||
.map(|window| (&mut workspace.space, window))
|
||||
})
|
||||
{
|
||||
let new_location = crate::shell::layout::floating::ResizeSurfaceGrab::apply_resize_state(
|
||||
&window,
|
||||
space.window_location(&window).unwrap(),
|
||||
window.geometry().size,
|
||||
);
|
||||
let new_location =
|
||||
crate::shell::layout::floating::ResizeSurfaceGrab::apply_resize_state(
|
||||
&window,
|
||||
space.window_location(&window).unwrap(),
|
||||
window.geometry().size,
|
||||
);
|
||||
if let Some(location) = new_location {
|
||||
space.map_window(&window, location, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
on_commit_buffer_handler(surface);
|
||||
self.early_import_surface(dh, surface);
|
||||
self.common.shell.popups.commit(surface);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,17 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::cell::RefCell;
|
||||
use crate::state::State;
|
||||
use smithay::{
|
||||
reexports::wayland_server::protocol::{
|
||||
wl_data_source::WlDataSource,
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
delegate_data_device,
|
||||
reexports::wayland_server::protocol::{wl_data_source::WlDataSource, wl_surface::WlSurface},
|
||||
wayland::{
|
||||
data_device::{
|
||||
DataDeviceState,
|
||||
DataDeviceHandler,
|
||||
ClientDndGrabHandler,
|
||||
ServerDndGrabHandler,
|
||||
ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler,
|
||||
},
|
||||
seat::Seat,
|
||||
},
|
||||
delegate_data_device,
|
||||
};
|
||||
use crate::state::State;
|
||||
use std::cell::RefCell;
|
||||
|
||||
pub struct DnDIcon {
|
||||
surface: RefCell<Option<WlSurface>>,
|
||||
|
|
@ -32,10 +26,10 @@ pub fn get_dnd_icon(seat: &Seat<State>) -> Option<WlSurface> {
|
|||
|
||||
impl ClientDndGrabHandler for State {
|
||||
fn started(
|
||||
&mut self,
|
||||
_source: Option<WlDataSource>,
|
||||
icon: Option<WlSurface>,
|
||||
seat: Seat<Self>
|
||||
&mut self,
|
||||
_source: Option<WlDataSource>,
|
||||
icon: Option<WlSurface>,
|
||||
seat: Seat<Self>,
|
||||
) {
|
||||
let user_data = seat.user_data();
|
||||
user_data.insert_if_missing(|| DnDIcon {
|
||||
|
|
|
|||
|
|
@ -1,32 +1,36 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::state::{BackendData, State};
|
||||
use smithay::{
|
||||
backend::{
|
||||
allocator::dmabuf::Dmabuf,
|
||||
renderer::ImportDma,
|
||||
},
|
||||
backend::{allocator::dmabuf::Dmabuf, renderer::ImportDma},
|
||||
delegate_dmabuf,
|
||||
reexports::wayland_server::DisplayHandle,
|
||||
wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError},
|
||||
delegate_dmabuf,
|
||||
};
|
||||
use crate::state::{BackendData, State};
|
||||
|
||||
impl DmabufHandler for State {
|
||||
fn dmabuf_state(&mut self) -> &mut DmabufState {
|
||||
&mut self.common.dmabuf_state
|
||||
}
|
||||
|
||||
fn dmabuf_imported(&mut self, dh: &DisplayHandle, global: &DmabufGlobal, dmabuf: Dmabuf) -> Result<(), ImportError> {
|
||||
fn dmabuf_imported(
|
||||
&mut self,
|
||||
dh: &DisplayHandle,
|
||||
global: &DmabufGlobal,
|
||||
dmabuf: Dmabuf,
|
||||
) -> Result<(), ImportError> {
|
||||
match &mut self.backend {
|
||||
BackendData::Kms(ref mut state) => state
|
||||
.dmabuf_imported(dh, global, dmabuf)
|
||||
.map_err(|_| ImportError::Failed),
|
||||
BackendData::Winit(ref mut state) => state.backend
|
||||
BackendData::Winit(ref mut state) => state
|
||||
.backend
|
||||
.renderer()
|
||||
.import_dmabuf(&dmabuf, None)
|
||||
.map(|_| ())
|
||||
.map_err(|_| ImportError::Failed),
|
||||
BackendData::X11(ref mut state) => state.renderer
|
||||
BackendData::X11(ref mut state) => state
|
||||
.renderer
|
||||
.import_dmabuf(&dmabuf, None)
|
||||
.map(|_| ())
|
||||
.map_err(|_| ImportError::Failed),
|
||||
|
|
|
|||
|
|
@ -1,23 +1,17 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::utils::prelude::*;
|
||||
use smithay::{
|
||||
delegate_layer_shell,
|
||||
desktop::LayerSurface,
|
||||
reexports::wayland_server::{
|
||||
DisplayHandle,
|
||||
protocol::wl_output::WlOutput,
|
||||
},
|
||||
reexports::wayland_server::{protocol::wl_output::WlOutput, DisplayHandle},
|
||||
wayland::{
|
||||
output::Output,
|
||||
shell::wlr_layer::{
|
||||
WlrLayerShellHandler,
|
||||
WlrLayerShellState,
|
||||
LayerSurface as WlrLayerSurface,
|
||||
Layer,
|
||||
Layer, LayerSurface as WlrLayerSurface, WlrLayerShellHandler, WlrLayerShellState,
|
||||
},
|
||||
},
|
||||
delegate_layer_shell,
|
||||
};
|
||||
use crate::utils::prelude::*;
|
||||
|
||||
impl WlrLayerShellHandler for State {
|
||||
fn shell_state(&mut self) -> &mut WlrLayerShellState {
|
||||
|
|
@ -25,12 +19,12 @@ impl WlrLayerShellHandler for State {
|
|||
}
|
||||
|
||||
fn new_layer_surface(
|
||||
&mut self,
|
||||
_dh: &DisplayHandle,
|
||||
surface: WlrLayerSurface,
|
||||
wl_output: Option<WlOutput>,
|
||||
_layer: Layer,
|
||||
namespace: String
|
||||
&mut self,
|
||||
_dh: &DisplayHandle,
|
||||
surface: WlrLayerSurface,
|
||||
wl_output: Option<WlOutput>,
|
||||
_layer: Layer,
|
||||
namespace: String,
|
||||
) {
|
||||
super::mark_dirty_on_drop(&self.common, surface.wl_surface());
|
||||
let seat = self.common.last_active_seat.clone();
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ use smithay::{
|
|||
|
||||
fn mark_dirty_on_drop(state: &Common, wl_surface: &WlSurface) {
|
||||
use std::sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
|
||||
let dirty = state.dirty_flag.clone();
|
||||
|
|
@ -33,7 +33,9 @@ fn mark_dirty_on_drop(state: &Common, wl_surface: &WlSurface) {
|
|||
with_states(wl_surface, |data| {
|
||||
data.data_map.insert_if_missing(|| DirtyFlag(dirty));
|
||||
});
|
||||
add_destruction_hook(wl_surface, |data| if let Some(DirtyFlag(dirty)) = data.data_map.get::<DirtyFlag>() {
|
||||
dirty.store(true, Ordering::SeqCst);
|
||||
add_destruction_hook(wl_surface, |data| {
|
||||
if let Some(DirtyFlag(dirty)) = data.data_map.get::<DirtyFlag>() {
|
||||
dirty.store(true, Ordering::SeqCst);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::delegate_output;
|
||||
use crate::state::State;
|
||||
use smithay::delegate_output;
|
||||
|
||||
delegate_output!(State);
|
||||
|
|
|
|||
|
|
@ -6,11 +6,8 @@ use crate::{
|
|||
config::OutputConfig,
|
||||
state::State,
|
||||
wayland::protocols::output_configuration::{
|
||||
OutputConfigurationState,
|
||||
OutputConfigurationHandler,
|
||||
OutputConfiguration,
|
||||
ModeConfiguration,
|
||||
delegate_output_configuration,
|
||||
delegate_output_configuration, ModeConfiguration, OutputConfiguration,
|
||||
OutputConfigurationHandler, OutputConfigurationState,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -30,8 +27,15 @@ impl OutputConfigurationHandler for State {
|
|||
}
|
||||
|
||||
impl State {
|
||||
fn output_configuration(&mut self, test_only: bool, conf: Vec<(Output, OutputConfiguration)>) -> bool {
|
||||
if conf.iter().all(|(_, conf)| matches!(conf, OutputConfiguration::Disabled)) {
|
||||
fn output_configuration(
|
||||
&mut self,
|
||||
test_only: bool,
|
||||
conf: Vec<(Output, OutputConfiguration)>,
|
||||
) -> bool {
|
||||
if conf
|
||||
.iter()
|
||||
.all(|(_, conf)| matches!(conf, OutputConfiguration::Disabled))
|
||||
{
|
||||
return false; // we don't allow the user to accidentally disable all their outputs
|
||||
}
|
||||
|
||||
|
|
@ -50,15 +54,15 @@ impl State {
|
|||
scale,
|
||||
transform,
|
||||
position,
|
||||
} = conf {
|
||||
} = conf
|
||||
{
|
||||
match mode {
|
||||
Some(ModeConfiguration::Mode(mode)) => {
|
||||
current_config.mode =
|
||||
((mode.size.w, mode.size.h), Some(mode.refresh as u32));
|
||||
}
|
||||
Some(ModeConfiguration::Custom { size, refresh }) => {
|
||||
current_config.mode =
|
||||
((size.w, size.h), refresh.map(|x| x as u32));
|
||||
current_config.mode = ((size.w, size.h), refresh.map(|x| x as u32));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -116,22 +120,25 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
for output in conf.iter().filter(|(_, c)| matches!(c, OutputConfiguration::Enabled { .. })).map(|(o, _)| o) {
|
||||
for output in conf
|
||||
.iter()
|
||||
.filter(|(_, c)| matches!(c, OutputConfiguration::Enabled { .. }))
|
||||
.map(|(o, _)| o)
|
||||
{
|
||||
self.common.output_configuration_state.enable_head(output);
|
||||
}
|
||||
for output in conf.iter().filter(|(_, c)| matches!(c, OutputConfiguration::Disabled)).map(|(o, _)| o) {
|
||||
for output in conf
|
||||
.iter()
|
||||
.filter(|(_, c)| matches!(c, OutputConfiguration::Disabled))
|
||||
.map(|(o, _)| o)
|
||||
{
|
||||
self.common.output_configuration_state.disable_head(output);
|
||||
}
|
||||
self
|
||||
.common
|
||||
self.common
|
||||
.config
|
||||
.write_outputs(self.common.output_configuration_state.outputs());
|
||||
self.common.event_loop_handle.insert_idle(move |data| {
|
||||
data
|
||||
.state
|
||||
.common
|
||||
.output_configuration_state
|
||||
.update();
|
||||
data.state.common.output_configuration_state.update();
|
||||
});
|
||||
|
||||
true
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::{
|
||||
wayland::seat::{SeatHandler, SeatState},
|
||||
delegate_seat,
|
||||
};
|
||||
use crate::state::State;
|
||||
use smithay::{
|
||||
delegate_seat,
|
||||
wayland::seat::{SeatHandler, SeatState},
|
||||
};
|
||||
|
||||
impl SeatHandler for State {
|
||||
fn seat_state(&mut self) -> &mut SeatState<Self> {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::{
|
||||
wayland::shm::{ShmHandler, ShmState},
|
||||
delegate_shm,
|
||||
};
|
||||
use crate::state::State;
|
||||
use smithay::{
|
||||
delegate_shm,
|
||||
wayland::shm::{ShmHandler, ShmState},
|
||||
};
|
||||
|
||||
impl ShmHandler for State {
|
||||
fn shm_state(&self) -> &ShmState {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
use crate::{
|
||||
state::State,
|
||||
wayland::protocols::toplevel_info::{
|
||||
ToplevelInfoHandler,
|
||||
ToplevelInfoState,
|
||||
delegate_toplevel_info,
|
||||
delegate_toplevel_info, ToplevelInfoHandler, ToplevelInfoState,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::delegate_viewporter;
|
||||
use crate::state::State;
|
||||
use smithay::delegate_viewporter;
|
||||
|
||||
delegate_viewporter!(State);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
state::State,
|
||||
wayland::protocols::drm::delegate_wl_drm,
|
||||
};
|
||||
use crate::{state::State, wayland::protocols::drm::delegate_wl_drm};
|
||||
|
||||
delegate_wl_drm!(State);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,14 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use smithay::reexports::wayland_server::DisplayHandle;
|
||||
use crate::{
|
||||
state::ClientState,
|
||||
wayland::protocols::workspace::{
|
||||
Request,
|
||||
WorkspaceHandler,
|
||||
WorkspaceState,
|
||||
WorkspaceClientHandler,
|
||||
WorkspaceClientState,
|
||||
delegate_workspace,
|
||||
},
|
||||
utils::prelude::*,
|
||||
wayland::protocols::workspace::{
|
||||
delegate_workspace, Request, WorkspaceClientHandler, WorkspaceClientState,
|
||||
WorkspaceHandler, WorkspaceState,
|
||||
},
|
||||
};
|
||||
use smithay::reexports::wayland_server::DisplayHandle;
|
||||
|
||||
impl WorkspaceClientHandler for ClientState {
|
||||
fn workspace_state(&self) -> &WorkspaceClientState {
|
||||
|
|
@ -28,18 +24,24 @@ impl WorkspaceHandler for State {
|
|||
fn workspace_state_mut(&mut self) -> &mut WorkspaceState<Self> {
|
||||
&mut self.common.shell.workspace_state
|
||||
}
|
||||
|
||||
|
||||
fn commit_requests(&mut self, _dh: &DisplayHandle, requests: Vec<Request>) {
|
||||
for request in requests.into_iter() {
|
||||
match request {
|
||||
Request::Activate(handle) => {
|
||||
if let Some(idx) = self.common.shell.spaces.iter().position(|w| w.handle == handle) {
|
||||
if let Some(idx) = self
|
||||
.common
|
||||
.shell
|
||||
.spaces
|
||||
.iter()
|
||||
.position(|w| w.handle == handle)
|
||||
{
|
||||
let seat = &self.common.last_active_seat;
|
||||
let output = active_output(seat, &self.common);
|
||||
self.common.shell.activate(seat, &output, idx);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,36 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::utils::prelude::*;
|
||||
use smithay::{
|
||||
delegate_xdg_shell,
|
||||
desktop::{
|
||||
Kind,
|
||||
PopupKind,
|
||||
PopupUngrabStrategy,
|
||||
PopupKeyboardGrab,
|
||||
PopupPointerGrab,
|
||||
PopupGrab,
|
||||
Window,
|
||||
WindowSurfaceType,
|
||||
Kind, PopupGrab, PopupKeyboardGrab, PopupKind, PopupPointerGrab, PopupUngrabStrategy,
|
||||
Window, WindowSurfaceType,
|
||||
},
|
||||
reexports::{
|
||||
wayland_server::{
|
||||
DisplayHandle,
|
||||
protocol::{
|
||||
wl_seat::WlSeat,
|
||||
wl_surface::WlSurface,
|
||||
wl_output::WlOutput,
|
||||
},
|
||||
},
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel,
|
||||
wayland_server::{
|
||||
protocol::{wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface},
|
||||
DisplayHandle,
|
||||
},
|
||||
},
|
||||
wayland::{
|
||||
shell::xdg::{
|
||||
XdgShellHandler,
|
||||
XdgShellState,
|
||||
ToplevelSurface,
|
||||
PopupSurface,
|
||||
PositionerState,
|
||||
Configure,
|
||||
},
|
||||
seat::{
|
||||
Seat,
|
||||
PointerGrabStartData,
|
||||
},
|
||||
output::Output,
|
||||
seat::{PointerGrabStartData, Seat},
|
||||
shell::xdg::{
|
||||
Configure, PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler,
|
||||
XdgShellState,
|
||||
},
|
||||
Serial,
|
||||
},
|
||||
delegate_xdg_shell,
|
||||
};
|
||||
use std::cell::Cell;
|
||||
use crate::utils::prelude::*;
|
||||
|
||||
pub type PopupGrabData = Cell<Option<PopupGrab>>;
|
||||
|
||||
impl XdgShellHandler for State {
|
||||
fn xdg_shell_state(&mut self) -> &mut XdgShellState {
|
||||
&mut self.common.shell.xdg_shell_state
|
||||
&mut self.common.shell.xdg_shell_state
|
||||
}
|
||||
|
||||
fn new_toplevel(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
|
||||
|
|
@ -56,7 +39,10 @@ impl XdgShellHandler for State {
|
|||
let seat = &self.common.last_active_seat;
|
||||
let window = Window::new(Kind::Xdg(surface));
|
||||
self.common.shell.toplevel_info_state.new_toplevel(&window);
|
||||
self.common.shell.pending_windows.push((window, seat.clone()));
|
||||
self.common
|
||||
.shell
|
||||
.pending_windows
|
||||
.push((window, seat.clone()));
|
||||
// We will position the window after the first commit, when we know its size hints
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +53,7 @@ impl XdgShellHandler for State {
|
|||
_positioner: PositionerState,
|
||||
) {
|
||||
super::mark_dirty_on_drop(&self.common, surface.wl_surface());
|
||||
|
||||
|
||||
self.common
|
||||
.shell
|
||||
.popups
|
||||
|
|
@ -75,37 +61,33 @@ impl XdgShellHandler for State {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
fn ack_configure(
|
||||
&mut self,
|
||||
_dh: &DisplayHandle,
|
||||
surface: WlSurface,
|
||||
configure: Configure
|
||||
) {
|
||||
fn ack_configure(&mut self, _dh: &DisplayHandle, surface: WlSurface, configure: Configure) {
|
||||
if let Configure::Toplevel(configure) = configure {
|
||||
// If we would re-position the window inside the grab we would get a weird jittery animation.
|
||||
// We only want to resize once the client has acknoledged & commited the new size,
|
||||
// so we need to carefully track the state through different handlers.
|
||||
if let Some(window) = self.common
|
||||
.shell
|
||||
.space_for_surface(&surface)
|
||||
.and_then(|workspace| workspace.space.window_for_surface(&surface, WindowSurfaceType::TOPLEVEL))
|
||||
if let Some(window) =
|
||||
self.common
|
||||
.shell
|
||||
.space_for_surface(&surface)
|
||||
.and_then(|workspace| {
|
||||
workspace
|
||||
.space
|
||||
.window_for_surface(&surface, WindowSurfaceType::TOPLEVEL)
|
||||
})
|
||||
{
|
||||
crate::shell::layout::floating::ResizeSurfaceGrab::ack_configure(
|
||||
window, configure,
|
||||
)
|
||||
crate::shell::layout::floating::ResizeSurfaceGrab::ack_configure(window, configure)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn grab(
|
||||
&mut self,
|
||||
dh: &DisplayHandle,
|
||||
surface: PopupSurface,
|
||||
seat: WlSeat,
|
||||
serial: Serial,
|
||||
) {
|
||||
fn grab(&mut self, dh: &DisplayHandle, surface: PopupSurface, seat: WlSeat, serial: Serial) {
|
||||
let seat = Seat::from_resource(&seat).unwrap();
|
||||
let ret = self.common.shell.popups.grab_popup(dh, surface.into(), &seat, serial);
|
||||
let ret = self
|
||||
.common
|
||||
.shell
|
||||
.popups
|
||||
.grab_popup(dh, surface.into(), &seat, serial);
|
||||
|
||||
if let Ok(mut grab) = ret {
|
||||
if let Some(keyboard) = seat.get_keyboard() {
|
||||
|
|
@ -116,16 +98,16 @@ impl XdgShellHandler for State {
|
|||
grab.ungrab(dh, PopupUngrabStrategy::All);
|
||||
return;
|
||||
}
|
||||
self.common.set_focus(dh, grab.current_grab().as_ref(), &seat, Some(serial));
|
||||
self.common
|
||||
.set_focus(dh, grab.current_grab().as_ref(), &seat, Some(serial));
|
||||
keyboard.set_grab(PopupKeyboardGrab::new(&grab), serial);
|
||||
}
|
||||
|
||||
if let Some(pointer) = seat.get_pointer() {
|
||||
if pointer.is_grabbed()
|
||||
&& !(pointer.has_grab(serial)
|
||||
|| pointer.has_grab(
|
||||
grab.previous_serial().unwrap_or_else(|| grab.serial()),
|
||||
))
|
||||
|| pointer
|
||||
.has_grab(grab.previous_serial().unwrap_or_else(|| grab.serial())))
|
||||
{
|
||||
grab.ungrab(dh, PopupUngrabStrategy::All);
|
||||
return;
|
||||
|
|
@ -147,7 +129,7 @@ impl XdgShellHandler for State {
|
|||
_dh: &DisplayHandle,
|
||||
surface: PopupSurface,
|
||||
positioner: PositionerState,
|
||||
token: u32
|
||||
token: u32,
|
||||
) {
|
||||
surface.with_pending_state(|state| {
|
||||
// TODO: This is a simplification, a proper compositor would
|
||||
|
|
@ -166,12 +148,10 @@ impl XdgShellHandler for State {
|
|||
_dh: &DisplayHandle,
|
||||
surface: ToplevelSurface,
|
||||
seat: WlSeat,
|
||||
serial: Serial
|
||||
serial: Serial,
|
||||
) {
|
||||
let seat = Seat::from_resource(&seat).unwrap();
|
||||
if let Some(start_data) =
|
||||
check_grab_preconditions(&seat, surface.wl_surface(), serial)
|
||||
{
|
||||
if let Some(start_data) = check_grab_preconditions(&seat, surface.wl_surface(), serial) {
|
||||
let workspace = self
|
||||
.common
|
||||
.shell
|
||||
|
|
@ -184,7 +164,7 @@ impl XdgShellHandler for State {
|
|||
.clone();
|
||||
|
||||
workspace.move_request(&window, &seat, serial, start_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resize_request(
|
||||
|
|
@ -193,12 +173,10 @@ impl XdgShellHandler for State {
|
|||
surface: ToplevelSurface,
|
||||
seat: WlSeat,
|
||||
serial: Serial,
|
||||
edges: xdg_toplevel::ResizeEdge
|
||||
edges: xdg_toplevel::ResizeEdge,
|
||||
) {
|
||||
let seat = Seat::from_resource(&seat).unwrap();
|
||||
if let Some(start_data) =
|
||||
check_grab_preconditions(&seat, surface.wl_surface(), serial)
|
||||
{
|
||||
if let Some(start_data) = check_grab_preconditions(&seat, surface.wl_surface(), serial) {
|
||||
let workspace = self
|
||||
.common
|
||||
.shell
|
||||
|
|
@ -220,8 +198,11 @@ impl XdgShellHandler for State {
|
|||
let output = active_output(seat, &self.common);
|
||||
|
||||
if let Some(workspace) = self.common.shell.space_for_surface_mut(surface) {
|
||||
let window =
|
||||
workspace.space.window_for_surface(surface, WindowSurfaceType::TOPLEVEL).unwrap().clone();
|
||||
let window = workspace
|
||||
.space
|
||||
.window_for_surface(surface, WindowSurfaceType::TOPLEVEL)
|
||||
.unwrap()
|
||||
.clone();
|
||||
workspace.maximize_request(&window, &output)
|
||||
}
|
||||
}
|
||||
|
|
@ -234,7 +215,12 @@ impl XdgShellHandler for State {
|
|||
surface.send_configure();
|
||||
}
|
||||
|
||||
fn fullscreen_request(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface, output: Option<WlOutput>) {
|
||||
fn fullscreen_request(
|
||||
&mut self,
|
||||
_dh: &DisplayHandle,
|
||||
surface: ToplevelSurface,
|
||||
output: Option<WlOutput>,
|
||||
) {
|
||||
let output = output
|
||||
.as_ref()
|
||||
.and_then(Output::from_resource)
|
||||
|
|
@ -245,8 +231,11 @@ impl XdgShellHandler for State {
|
|||
|
||||
let surface = surface.wl_surface();
|
||||
if let Some(workspace) = self.common.shell.space_for_surface_mut(surface) {
|
||||
let window =
|
||||
workspace.space.window_for_surface(surface, WindowSurfaceType::TOPLEVEL).unwrap().clone();
|
||||
let window = workspace
|
||||
.space
|
||||
.window_for_surface(surface, WindowSurfaceType::TOPLEVEL)
|
||||
.unwrap()
|
||||
.clone();
|
||||
workspace.fullscreen_request(&window, &output)
|
||||
}
|
||||
}
|
||||
|
|
@ -254,8 +243,11 @@ impl XdgShellHandler for State {
|
|||
fn unfullscreen_request(&mut self, _dh: &DisplayHandle, surface: ToplevelSurface) {
|
||||
let surface = surface.wl_surface();
|
||||
if let Some(workspace) = self.common.shell.space_for_surface_mut(surface) {
|
||||
let window =
|
||||
workspace.space.window_for_surface(surface, WindowSurfaceType::TOPLEVEL).unwrap().clone();
|
||||
let window = workspace
|
||||
.space
|
||||
.window_for_surface(surface, WindowSurfaceType::TOPLEVEL)
|
||||
.unwrap()
|
||||
.clone();
|
||||
workspace.unfullscreen_request(&window)
|
||||
}
|
||||
}
|
||||
|
|
@ -294,5 +286,4 @@ fn check_grab_preconditions(
|
|||
Some(start_data)
|
||||
}
|
||||
|
||||
|
||||
delegate_xdg_shell!(State);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue