Use wl_keyboard instead of toplevel state for focus
Rare TODO comment actually done. Fixes #64
This commit is contained in:
parent
8703e243eb
commit
dc1f8a753d
4 changed files with 80 additions and 29 deletions
|
|
@ -253,15 +253,6 @@ impl SurfaceData {
|
|||
states,
|
||||
} => {
|
||||
debug!("configuring toplevel {width}x{height}, {states:?}");
|
||||
let activated = states.contains(&(u32::from(xdg_toplevel::State::Activated) as u8));
|
||||
|
||||
if activated {
|
||||
// Technically this is wrong - activated doesn't necessarily mean focused
|
||||
// - but it works and no one's complained yet.
|
||||
// TODO: base focus on keyboard enter instead.
|
||||
state.to_focus = Some(self.window.unwrap());
|
||||
}
|
||||
|
||||
if let Some(SurfaceRole::Toplevel(Some(toplevel))) = &mut self.role {
|
||||
let prev_fs = toplevel.fullscreen;
|
||||
toplevel.fullscreen =
|
||||
|
|
@ -539,9 +530,11 @@ impl HandleEvent for Keyboard {
|
|||
surface,
|
||||
keys,
|
||||
} => {
|
||||
state.last_kb_serial = Some(serial);
|
||||
if let Some(surface_data) = state.get_server_surface_from_client(surface) {
|
||||
self.server.enter(serial, surface_data, keys);
|
||||
let key: ObjectKey = surface.data().copied().unwrap();
|
||||
if let Some(data) = state.objects.get(key).map(|o| <_ as AsRef<SurfaceData>>::as_ref(o)) {
|
||||
state.last_kb_serial = Some(serial);
|
||||
state.to_focus = Some(data.window.unwrap());
|
||||
self.server.enter(serial, &data.server, keys);
|
||||
}
|
||||
}
|
||||
_ => simple_event_shunt! {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct Compositor {
|
|||
compositor: TestObject<WlCompositor>,
|
||||
shm: TestObject<WlShm>,
|
||||
shell: TestObject<XwaylandShellV1>,
|
||||
seat: TestObject<WlSeat>
|
||||
seat: TestObject<WlSeat>,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -340,6 +340,12 @@ impl TestFixture {
|
|||
}
|
||||
}
|
||||
|
||||
// Activate keyboard for focus.
|
||||
TestObject::<WlKeyboard>::from_request(
|
||||
&ret.seat.as_ref().expect("Seat global missing").obj,
|
||||
wl_seat::Request::GetKeyboard {},
|
||||
);
|
||||
|
||||
ret.into()
|
||||
}
|
||||
|
||||
|
|
@ -566,6 +572,7 @@ impl TestFixture {
|
|||
|
||||
self.testwl
|
||||
.configure_toplevel(id, 100, 100, vec![xdg_toplevel::State::Activated]);
|
||||
self.testwl.focus_toplevel(id);
|
||||
self.run();
|
||||
|
||||
{
|
||||
|
|
@ -1087,7 +1094,6 @@ fn window_group_properties() {
|
|||
#[test]
|
||||
fn copy_from_x11() {
|
||||
let (mut f, comp) = TestFixture::new_with_compositor();
|
||||
TestObject::<WlKeyboard>::from_request(&comp.seat.obj, wl_seat::Request::GetKeyboard {});
|
||||
let win = unsafe { Window::new(1) };
|
||||
let (_surface, _id) = f.create_toplevel(&comp, win);
|
||||
|
||||
|
|
@ -1303,7 +1309,8 @@ fn output_offset() {
|
|||
);
|
||||
}
|
||||
f.testwl
|
||||
.configure_toplevel(t_id, 100, 100, vec![xdg_toplevel::State::Activated]);
|
||||
.configure_toplevel(t_id, 100, 100, vec![]);
|
||||
f.testwl.focus_toplevel(t_id);
|
||||
f.run();
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue