diff --git a/api/lua/test_config.lua b/api/lua/test_config.lua index b6ff096..28a27ff 100644 --- a/api/lua/test_config.lua +++ b/api/lua/test_config.lua @@ -66,16 +66,21 @@ require("pinnacle").setup(function(pinnacle) -- Just testing stuff input.keybind({ mod_key }, keys.h, function() - local wins = window.get_all() - for _, win in pairs(wins) do - print("loc: " .. (win:loc() and win:loc().x or "nil") .. ", " .. (win:loc() and win:loc().y or "nil")) - print("size: " .. (win:size() and win:size().w or "nil") .. ", " .. (win:size() and win:size().h or "nil")) - print("class: " .. (win:class() or "nil")) - print("title: " .. (win:title() or "nil")) - print("float: " .. tostring(win:floating())) + local win = window.get_focused() + if win ~= nil then + win:set_size({ w = 500, h = 500 }) end - print("----------------------") + -- local wins = window.get_all() + -- for _, win in pairs(wins) do + -- print("loc: " .. (win:loc() and win:loc().x or "nil") .. ", " .. (win:loc() and win:loc().y or "nil")) + -- print("size: " .. (win:size() and win:size().w or "nil") .. ", " .. (win:size() and win:size().h or "nil")) + -- print("class: " .. (win:class() or "nil")) + -- print("title: " .. (win:title() or "nil")) + -- print("float: " .. tostring(win:floating())) + -- end + -- + -- print("----------------------") -- -- local op = output.get_focused() --[[@as Output]] -- print("res: " .. (op:res() and (op:res().w .. ", " .. op:res().h) or "nil")) diff --git a/src/focus.rs b/src/focus.rs index 8e8c2b2..9521c80 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -61,9 +61,11 @@ impl IsAlive for FocusTarget { } } -impl From for WlSurface { - fn from(value: FocusTarget) -> Self { - value.wl_surface().expect("no wl_surface") +impl TryFrom for WlSurface { + type Error = (); + + fn try_from(value: FocusTarget) -> Result { + value.wl_surface().ok_or(()) } } diff --git a/src/handlers.rs b/src/handlers.rs index f29bdc2..f2e9b0c 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -393,6 +393,7 @@ impl XdgShellHandler for State { } fn move_request(&mut self, surface: ToplevelSurface, seat: WlSeat, serial: Serial) { + tracing::debug!("move_request_client"); crate::grab::move_grab::move_request_client( self, surface.wl_surface(), diff --git a/src/input.rs b/src/input.rs index 6ee161a..5e47fe5 100644 --- a/src/input.rs +++ b/src/input.rs @@ -12,14 +12,14 @@ use smithay::{ AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, }, - desktop::{space::SpaceElement, WindowSurfaceType}, + desktop::space::SpaceElement, input::{ keyboard::{keysyms, FilterResult}, pointer::{AxisFrame, ButtonEvent, MotionEvent}, }, reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge, utils::{Logical, Point, SERIAL_COUNTER}, - wayland::compositor, + wayland::{compositor, seat::WaylandFocus}, }; use crate::{ @@ -42,14 +42,14 @@ impl InputState { } impl State { - pub fn surface_under

(&self, point: P) -> Option<(WindowElement, Point)> + pub fn surface_under

(&self, point: P) -> Option<(FocusTarget, Point)> where P: Into>, { // TODO: layer map, popups, fullscreen self.space .element_under(point) - .map(|(window, loc)| (window.clone(), loc)) + .map(|(window, loc)| (window.clone().into(), loc)) } fn pointer_button(&mut self, event: I::PointerButtonEvent) { @@ -88,6 +88,7 @@ impl State { } return; // TODO: kinda ugly return here } else if event.button_code() == BUTTON_RIGHT { + let FocusTarget::Window(window) = window else { return }; let window_geometry = window.geometry(); let window_x = window_loc.x as f64; let window_y = window_loc.y as f64; @@ -139,6 +140,7 @@ impl State { } } else { // Move window to top of stack. + let FocusTarget::Window(window) = window else { return }; self.space.raise_element(&window, true); if let WindowElement::X11(surface) = &window { self.xwm @@ -380,15 +382,17 @@ impl State { } } - let surface_under_pointer = - self.space - .element_under(pointer_loc) - .and_then(|(window, location)| { - window - .surface_under(pointer_loc - location.to_f64(), WindowSurfaceType::ALL) - .map(|(_s, p)| (FocusTarget::Window(window.clone()), p + location)) - }); + let surface_under_pointer = self + .space + .element_under(pointer_loc) + .map(|(window, loc)| (FocusTarget::Window(window.clone()), loc)); + // .and_then(|(window, location)| { + // window + // .surface_under(pointer_loc - location.to_f64(), WindowSurfaceType::ALL) + // .map(|(_s, p)| (FocusTarget::Window(window.clone()), p + location)) + // }); + tracing::debug!("surface_under_pointer: {surface_under_pointer:?}"); pointer.motion( self, surface_under_pointer, @@ -441,9 +445,7 @@ impl State { } } - let surface_under = self - .surface_under(self.pointer_location) - .map(|(window, loc)| (FocusTarget::Window(window), loc)); + let surface_under = self.surface_under(self.pointer_location); // tracing::info!("{:?}", self.pointer_location); if let Some(ptr) = self.seat.get_pointer() { @@ -508,9 +510,7 @@ impl State { self.pointer_location = self.clamp_coords(self.pointer_location); - let surface_under = self - .surface_under(self.pointer_location) - .map(|(window, loc)| (FocusTarget::Window(window), loc)); + let surface_under = self.surface_under(self.pointer_location); if let Some(ptr) = self.seat.get_pointer() { ptr.motion(