smaller bugfixes

This commit is contained in:
Victoria Brekenfeld 2022-04-05 23:53:01 +02:00
parent ec861fadd4
commit 1519942a63
2 changed files with 17 additions and 16 deletions

View file

@ -478,40 +478,40 @@ impl Common {
// change the keyboard focus unless the pointer is grabbed // change the keyboard focus unless the pointer is grabbed
if !seat.get_pointer().unwrap().is_grabbed() { if !seat.get_pointer().unwrap().is_grabbed() {
let output = active_output(seat, &self); let output = active_output(seat, &self);
let mut pos = seat.get_pointer().unwrap().current_location(); let pos = seat.get_pointer().unwrap().current_location();
let output_geo = self.shell.output_geometry(&output); let output_geo = self.shell.output_geometry(&output);
let relative_pos =
self.shell.space_relative_output_geometry(pos, &output);
let workspace = self.shell.active_space_mut(&output); let workspace = self.shell.active_space_mut(&output);
let layers = layer_map_for_output(&output); let layers = layer_map_for_output(&output);
pos -= output_geo.loc.to_f64();
let mut under = None; let mut under = None;
if let Some(layer) = layers if let Some(layer) = layers
.layer_under(WlrLayer::Overlay, pos) .layer_under(WlrLayer::Overlay, relative_pos)
.or_else(|| layers.layer_under(WlrLayer::Top, pos)) .or_else(|| layers.layer_under(WlrLayer::Top, relative_pos))
{ {
if layer.can_receive_keyboard_focus() { if layer.can_receive_keyboard_focus() {
let layer_loc = let layer_loc =
layers.layer_geometry(layer).unwrap().loc; layers.layer_geometry(layer).unwrap().loc;
under = layer under = layer
.surface_under( .surface_under(
pos - layer_loc.to_f64(), pos - output_geo.loc.to_f64() - layer_loc.to_f64(),
WindowSurfaceType::ALL, WindowSurfaceType::ALL,
) )
.map(|(s, _)| s); .map(|(s, _)| s);
} }
} else if let Some(window) = } else if let Some(window) =
workspace.space.window_under(pos).cloned() workspace.space.window_under(relative_pos).cloned()
{ {
let window_loc = let window_loc =
workspace.space.window_location(&window).unwrap(); workspace.space.window_location(&window).unwrap();
under = window under = window
.surface_under( .surface_under(
pos - window_loc.to_f64(), relative_pos - window_loc.to_f64(),
WindowSurfaceType::TOPLEVEL WindowSurfaceType::TOPLEVEL
| WindowSurfaceType::SUBSURFACE, | WindowSurfaceType::SUBSURFACE,
) )
.map(|(s, _)| s); .map(|(s, _)| s);
// space.raise_window(&window, true);
} else if let Some(layer) = layers } else if let Some(layer) = layers
.layer_under(WlrLayer::Bottom, pos) .layer_under(WlrLayer::Bottom, pos)
.or_else(|| layers.layer_under(WlrLayer::Background, pos)) .or_else(|| layers.layer_under(WlrLayer::Background, pos))
@ -521,14 +521,14 @@ impl Common {
layers.layer_geometry(layer).unwrap().loc; layers.layer_geometry(layer).unwrap().loc;
under = layer under = layer
.surface_under( .surface_under(
pos - layer_loc.to_f64(), pos - output_geo.loc.to_f64() - layer_loc.to_f64(),
WindowSurfaceType::ALL, WindowSurfaceType::ALL,
) )
.map(|(s, _)| s); .map(|(s, _)| s);
} }
}; };
self.set_focus(under.as_ref(), seat, None); self.set_focus(under.as_ref(), seat, Some(serial));
} }
wl_pointer::ButtonState::Pressed wl_pointer::ButtonState::Pressed
} }
@ -652,13 +652,13 @@ impl Common {
let layer_loc = layers.layer_geometry(layer).unwrap().loc; let layer_loc = layers.layer_geometry(layer).unwrap().loc;
layer layer
.surface_under( .surface_under(
relative_pos - output_geo.loc.to_f64() - layer_loc.to_f64(), global_pos - output_geo.loc.to_f64() - layer_loc.to_f64(),
WindowSurfaceType::ALL, WindowSurfaceType::ALL,
) )
.map(|(s, loc)| { .map(|(s, loc)| {
( (
s, s,
loc + layer_loc - (relative_pos - global_pos).to_i32_round(), loc + layer_loc + output_geo.loc,
) )
}) })
} else if let Some(window) = space.window_under(relative_pos) { } else if let Some(window) = space.window_under(relative_pos) {
@ -678,13 +678,13 @@ impl Common {
let layer_loc = layers.layer_geometry(layer).unwrap().loc; let layer_loc = layers.layer_geometry(layer).unwrap().loc;
layer layer
.surface_under( .surface_under(
relative_pos - output_geo.loc.to_f64() - layer_loc.to_f64(), global_pos - output_geo.loc.to_f64() - layer_loc.to_f64(),
WindowSurfaceType::ALL, WindowSurfaceType::ALL,
) )
.map(|(s, loc)| { .map(|(s, loc)| {
( (
s, s,
loc + layer_loc - (relative_pos - global_pos).to_i32_round(), loc + layer_loc + output_geo.loc,
) )
}) })
} else { } else {

View file

@ -26,6 +26,7 @@ use smithay::{
}, },
}, },
Serial, Serial,
SERIAL_COUNTER,
}, },
}; };
use std::{cell::Cell, sync::Mutex}; use std::{cell::Cell, sync::Mutex};
@ -242,7 +243,7 @@ pub fn init_shell(config: &Config, display: &mut Display) -> super::Shell {
with_states(surface, |states| { with_states(surface, |states| {
let state = states.cached_state.current::<LayerSurfaceCachedState>(); let state = states.cached_state.current::<LayerSurfaceCachedState>();
matches!(state.layer, Layer::Top | Layer::Overlay) matches!(state.layer, Layer::Top | Layer::Overlay)
&& state.keyboard_interactivity == KeyboardInteractivity::Exclusive && state.keyboard_interactivity != KeyboardInteractivity::None
}) })
.unwrap() .unwrap()
}) })
@ -253,7 +254,7 @@ pub fn init_shell(config: &Config, display: &mut Display) -> super::Shell {
.unwrap(); .unwrap();
if focus { if focus {
state.set_focus(surface.get_surface(), &seat, None); state.set_focus(surface.get_surface(), &seat, Some(SERIAL_COUNTER.next_serial()));
} }
} }
_ => {} _ => {}