Fix minor bugs and do minor cleanup

This commit is contained in:
Ottatop 2024-03-21 16:40:08 -05:00
parent 2880792d9f
commit 5fd8c60f21
7 changed files with 111 additions and 123 deletions

View file

@ -38,7 +38,7 @@ use tokio::{
};
use tokio_stream::{Stream, StreamExt};
use tonic::{Request, Response, Status, Streaming};
use tracing::{error, warn};
use tracing::{debug, error, warn};
use crate::{
config::ConnectorSavedState,
@ -230,19 +230,19 @@ impl input_service_server::InputService for InputService {
use pinnacle_api_defs::pinnacle::input::v0alpha1::set_keybind_request::Key;
let keysym = match key {
Key::RawCode(num) => {
tracing::info!("set keybind: {:?}, raw {}", modifiers, num);
debug!("Set keybind: {:?}, raw {}", modifiers, num);
xkbcommon::xkb::Keysym::new(num)
}
Key::XkbName(s) => {
if s.chars().count() == 1 {
let Some(ch) = s.chars().next() else { unreachable!() };
let keysym = xkbcommon::xkb::Keysym::from_char(ch);
tracing::info!("set keybind: {:?}, {:?}", modifiers, keysym);
debug!("Set keybind: {:?}, {:?}", modifiers, keysym);
keysym
} else {
let keysym =
xkbcommon::xkb::keysym_from_name(&s, xkbcommon::xkb::KEYSYM_NO_FLAGS);
tracing::info!("set keybind: {:?}, {:?}", modifiers, keysym);
debug!("Set keybind: {:?}, {:?}", modifiers, keysym);
keysym
}
}
@ -262,7 +262,7 @@ impl input_service_server::InputService for InputService {
) -> Result<Response<Self::SetMousebindStream>, Status> {
let request = request.into_inner();
tracing::debug!(request = ?request);
debug!(request = ?request);
let modifiers = request
.modifiers()
@ -508,7 +508,7 @@ impl process_service_server::ProcessService for ProcessService {
&self,
request: Request<SpawnRequest>,
) -> Result<Response<Self::SpawnStream>, Status> {
tracing::debug!("ProcessService.spawn");
debug!("ProcessService.spawn");
let request = request.into_inner();
let once = request.once();
@ -780,7 +780,7 @@ impl tag_service_server::TagService for TagService {
{
output.with_state_mut(|state| {
state.tags.extend(new_tags.clone());
tracing::debug!("tags added, are now {:?}", state.tags);
debug!("tags added, are now {:?}", state.tags);
});
}
@ -938,7 +938,7 @@ impl output_service_server::OutputService for OutputService {
}
output.change_current_state(None, None, None, Some(loc));
state.space.map_output(&output, loc);
tracing::debug!("Mapping output {} to {loc:?}", output.name());
debug!("Mapping output {} to {loc:?}", output.name());
state.request_layout(&output);
})
.await

View file

@ -92,10 +92,7 @@ impl window_service_server::WindowService for WindowService {
let Some(window) = window_id.window(state) else { return };
// TODO: with no x or y, defaults unmapped windows to 0, 0
let mut window_loc = state
.space
.element_location(&window)
.unwrap_or((x.unwrap_or_default(), y.unwrap_or_default()).into());
let mut window_loc = state.space.element_location(&window).unwrap_or_default();
window_loc.x = x.unwrap_or(window_loc.x);
window_loc.y = y.unwrap_or(window_loc.y);
@ -104,7 +101,7 @@ impl window_service_server::WindowService for WindowService {
window_size.h = height.unwrap_or(window_size.h);
let rect = Rectangle::from_loc_and_size(window_loc, window_size);
// window.change_geometry(rect);
window.with_state_mut(|state| {
use crate::window::window_state::FloatingOrTiled;
state.floating_or_tiled = match state.floating_or_tiled {
@ -349,7 +346,6 @@ impl window_service_server::WindowService for WindowService {
}
}
state.request_layout(&output);
state.schedule_render(&output);
})
.await

View file

@ -267,7 +267,7 @@ impl State {
let mut pointer_element = PointerElement::<GlesTexture>::new();
pointer_element.set_status(self.cursor_status.clone());
// The z-index of these is determined by `state.fixup_focus()`, which is called at the end
// The z-index of these is determined by `state.fixup_z_layering()`, which is called at the end
// of every event loop cycle
let windows = self.space.elements().cloned().collect::<Vec<_>>();
@ -304,7 +304,7 @@ impl State {
.render_output(renderer, age, &output_render_elements, [0.6, 0.6, 0.6, 1.0])
.map_err(|err| match err {
damage::Error::Rendering(err) => err.into(),
damage::Error::OutputNoMode(_) => todo!(),
damage::Error::OutputNoMode(_) => panic!("winit output has no mode set"),
})
});
@ -312,7 +312,6 @@ impl State {
Ok(render_output_result) => {
let has_rendered = render_output_result.damage.is_some();
if let Some(damage) = render_output_result.damage {
// tracing::debug!("damage rects are {damage:?}");
if let Err(err) = winit.backend.submit(Some(&damage)) {
tracing::warn!("{}", err);
}

View file

@ -6,14 +6,17 @@ use smithay::{
// | input::keyboard
input::{
pointer::{
AxisFrame, ButtonEvent, Focus, GrabStartData, MotionEvent, PointerGrab,
PointerInnerHandle, RelativeMotionEvent,
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData,
MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
},
Seat, SeatHandler,
},
reexports::wayland_server::protocol::wl_surface::WlSurface,
utils::{IsAlive, Logical, Point, Rectangle, Serial},
};
use tracing::{debug, warn};
use crate::{
state::{State, WithState},
@ -26,8 +29,6 @@ pub struct MoveSurfaceGrab {
/// The window being moved
pub window: WindowElement,
pub initial_window_loc: Point<i32, Logical>,
/// Which button initiated the grab
pub button_used: u32,
}
impl PointerGrab<State> for MoveSurfaceGrab {
@ -103,22 +104,13 @@ impl PointerGrab<State> for MoveSurfaceGrab {
return;
}
let is_floating =
window_under.with_state(|state| state.floating_or_tiled.is_floating());
if is_floating {
if window_under.with_state(|state| {
state.floating_or_tiled.is_floating() || state.target_loc.is_some()
}) {
return;
}
// let has_pending_resize = window_under.with_state(|state| {
// !matches!(state.loc_request_state, LocationRequestState::Idle)
// });
//
// if has_pending_resize {
// return;
// }
tracing::debug!("Swapping window positions");
debug!("Swapping window positions");
state.swap_window_positions(&self.window, &window_under);
}
} else {
@ -174,7 +166,7 @@ impl PointerGrab<State> for MoveSurfaceGrab {
) {
handle.button(data, event);
if !handle.current_pressed().contains(&self.button_used) {
if !handle.current_pressed().contains(&self.start_data.button) {
handle.unset_grab(data, event.serial, event.time, true);
}
}
@ -194,74 +186,74 @@ impl PointerGrab<State> for MoveSurfaceGrab {
fn gesture_swipe_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeBeginEvent,
) {
todo!()
handle.gesture_swipe_begin(data, event);
}
fn gesture_swipe_update(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeUpdateEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeUpdateEvent,
) {
todo!()
handle.gesture_swipe_update(data, event);
}
fn gesture_swipe_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeEndEvent,
) {
todo!()
handle.gesture_swipe_end(data, event);
}
fn gesture_pinch_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchBeginEvent,
) {
todo!()
handle.gesture_pinch_begin(data, event);
}
fn gesture_pinch_update(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchUpdateEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchUpdateEvent,
) {
todo!()
handle.gesture_pinch_update(data, event);
}
fn gesture_pinch_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchEndEvent,
) {
todo!()
handle.gesture_pinch_end(data, event);
}
fn gesture_hold_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureHoldBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldBeginEvent,
) {
todo!()
handle.gesture_hold_begin(data, event);
}
fn gesture_hold_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureHoldEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldEndEvent,
) {
todo!()
handle.gesture_hold_end(data, event);
}
}
@ -271,12 +263,11 @@ pub fn move_request_client(
surface: &WlSurface,
seat: &Seat<State>,
serial: Serial,
button_used: u32,
) {
let pointer = seat.get_pointer().expect("seat had no pointer");
if let Some(start_data) = crate::grab::pointer_grab_start_data(&pointer, surface, serial) {
let Some(window) = state.window_for_surface(surface) else {
tracing::error!("Surface had no window, cancelling move request");
warn!("Surface had no window, cancelling move request");
return;
};
@ -289,12 +280,11 @@ pub fn move_request_client(
start_data,
window,
initial_window_loc,
button_used,
};
pointer.set_grab(state, grab, serial, Focus::Clear);
} else {
tracing::warn!("no grab start data");
debug!("No grab start data for grab, cancelling");
}
}
@ -308,7 +298,7 @@ pub fn move_request_server(
) {
let pointer = seat.get_pointer().expect("seat had no pointer");
let Some(window) = state.window_for_surface(surface) else {
tracing::error!("Surface had no window, cancelling move request");
warn!("Surface had no window, cancelling move request");
return;
};
@ -329,7 +319,6 @@ pub fn move_request_server(
start_data,
window,
initial_window_loc,
button_used,
};
pointer.set_grab(state, grab, serial, Focus::Clear);

View file

@ -3,7 +3,12 @@
use smithay::{
desktop::{space::SpaceElement, WindowSurface},
input::{
pointer::{AxisFrame, ButtonEvent, Focus, GrabStartData, PointerGrab, PointerInnerHandle},
pointer::{
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData,
PointerGrab, PointerInnerHandle,
},
Seat, SeatHandler,
},
reexports::{
@ -136,19 +141,11 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
let data = states.cached_state.current::<SurfaceCachedState>();
(data.min_size, data.max_size)
}),
None => ((0, 0).into(), (0, 0).into()),
None => (Size::default(), Size::default()),
};
// HACK: Here I set the min height to be self.window.geometry().loc.y.abs() because if it's
// | lower then the compositor crashes trying to create a size with height -1 if you make the
// | window height too small.
// | However I don't know if the loc.y from window.geometry will always be the negative
// | of the csd height.
let min_width = i32::max(1, min_size.w);
let min_height = i32::max(
i32::max(0, self.window.geometry().loc.y.abs()) + 1,
min_size.h,
);
let min_height = i32::max(1, min_size.h);
let max_width = if max_size.w != 0 { max_size.w } else { i32::MAX };
let max_height = if max_size.h != 0 { max_size.h } else { i32::MAX };
@ -254,74 +251,74 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
fn gesture_swipe_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeBeginEvent,
) {
todo!()
handle.gesture_swipe_begin(data, event);
}
fn gesture_swipe_update(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeUpdateEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeUpdateEvent,
) {
todo!()
handle.gesture_swipe_update(data, event);
}
fn gesture_swipe_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureSwipeEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureSwipeEndEvent,
) {
todo!()
handle.gesture_swipe_end(data, event);
}
fn gesture_pinch_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchBeginEvent,
) {
todo!()
handle.gesture_pinch_begin(data, event);
}
fn gesture_pinch_update(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchUpdateEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchUpdateEvent,
) {
todo!()
handle.gesture_pinch_update(data, event);
}
fn gesture_pinch_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GesturePinchEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GesturePinchEndEvent,
) {
todo!()
handle.gesture_pinch_end(data, event);
}
fn gesture_hold_begin(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureHoldBeginEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldBeginEvent,
) {
todo!()
handle.gesture_hold_begin(data, event);
}
fn gesture_hold_end(
&mut self,
_data: &mut State,
_handle: &mut PointerInnerHandle<'_, State>,
_event: &smithay::input::pointer::GestureHoldEndEvent,
data: &mut State,
handle: &mut PointerInnerHandle<'_, State>,
event: &GestureHoldEndEvent,
) {
todo!()
handle.gesture_hold_end(data, event);
}
}

View file

@ -589,13 +589,11 @@ impl XdgShellHandler for State {
fn move_request(&mut self, surface: ToplevelSurface, seat: WlSeat, serial: Serial) {
tracing::debug!("move_request_client");
const BUTTON_LEFT: u32 = 0x110; // We assume the left mouse button is used
crate::grab::move_grab::move_request_client(
self,
surface.wl_surface(),
&Seat::from_resource(&seat).expect("couldn't get seat from WlSeat"),
serial,
BUTTON_LEFT,
);
}

View file

@ -11,7 +11,7 @@ use smithay::{
};
use tokio::sync::mpsc::UnboundedSender;
use tonic::Status;
use tracing::error;
use tracing::warn;
use crate::{
output::OutputName,
@ -23,7 +23,7 @@ use crate::{
};
impl State {
pub fn update_windows_with_geometries(
fn update_windows_with_geometries(
&mut self,
output: &Output,
geometries: Vec<Rectangle<i32, Logical>>,
@ -56,13 +56,22 @@ impl State {
map.non_exclusive_zone()
};
for (win, geo) in tiled_windows.zip(geometries.into_iter().map(|mut geo| {
let mut zipped = tiled_windows.zip(geometries.into_iter().map(|mut geo| {
geo.loc += output_geo.loc + non_exclusive_geo.loc;
geo
})) {
}));
for (win, geo) in zipped.by_ref() {
win.change_geometry(geo);
}
let (remaining_wins, _remaining_geos) = zipped.unzip::<_, _, Vec<_>, Vec<_>>();
for win in remaining_wins {
assert!(win.with_state(|state| state.floating_or_tiled.is_floating()));
win.toggle_floating();
}
for window in windows_on_foc_tags.iter() {
match window.with_state(|state| state.fullscreen_or_maximized) {
FullscreenOrMaximized::Fullscreen => {
@ -156,7 +165,7 @@ pub struct LayoutState {
impl State {
pub fn request_layout(&mut self, output: &Output) {
let Some(sender) = self.layout_state.layout_request_sender.as_ref() else {
error!("Layout requested but no client has connected to the layout service");
warn!("Layout requested but no client has connected to the layout service");
return;
};