Skip to content

Commit

Permalink
tree: force focus change after dnd drop
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Feb 15, 2024
1 parent dc554a7 commit 2abce40
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/ifs/wl_seat/pointer_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use {
ifs::{
ipc,
ipc::{wl_data_device::ClipboardIpc, wl_data_source::WlDataSource},
wl_seat::{wl_pointer::PendingScroll, Dnd, DroppedDnd, WlSeatError, WlSeatGlobal},
wl_seat::{
wl_pointer::PendingScroll, Dnd, DroppedDnd, WlSeatError, WlSeatGlobal,
CHANGE_CURSOR_MOVED,
},
wl_surface::WlSurface,
},
state::DeviceHandlerData,
Expand Down Expand Up @@ -132,6 +135,11 @@ impl PointerOwnerHolder {
pub fn clear(&self) {
self.owner.set(self.default.clone());
}

fn set_default_pointer_owner(&self, seat: &Rc<WlSeatGlobal>) {
seat.pointer_owner.owner.set(self.default.clone());
seat.changes.or_assign(CHANGE_CURSOR_MOVED);
}
}

trait PointerOwner {
Expand Down Expand Up @@ -300,10 +308,8 @@ impl PointerOwner for GrabPointerOwner {
if self.buttons.is_empty() {
self.node.node_seat_state().remove_pointer_grab(seat);
// log::info!("button");
seat.pointer_owner.set_default_pointer_owner(seat);
seat.tree_changed.trigger();
seat.pointer_owner
.owner
.set(seat.pointer_owner.default.clone());
}
}
KeyState::Pressed => {
Expand Down Expand Up @@ -394,9 +400,7 @@ impl PointerOwner for GrabPointerOwner {

fn revert_to_default(&self, seat: &Rc<WlSeatGlobal>) {
self.node.node_seat_state().remove_pointer_grab(seat);
seat.pointer_owner
.owner
.set(seat.pointer_owner.default.clone());
seat.pointer_owner.set_default_pointer_owner(seat);
}

fn dnd_target_removed(&self, seat: &Rc<WlSeatGlobal>) {
Expand Down Expand Up @@ -438,10 +442,7 @@ impl PointerOwner for DndPointerOwner {
if let Some(icon) = self.icon.get() {
icon.dnd_icons.remove(&seat.id());
}
seat.pointer_owner
.owner
.set(seat.pointer_owner.default.clone());
// log::info!("button2");
seat.pointer_owner.set_default_pointer_owner(seat);
seat.tree_changed.trigger();
}

Expand Down Expand Up @@ -511,10 +512,7 @@ impl PointerOwner for DndPointerOwner {
if let Some(icon) = self.icon.get() {
icon.dnd_icons.remove(&seat.id());
}
seat.pointer_owner
.owner
.set(seat.pointer_owner.default.clone());
// log::info!("cancel_dnd");
seat.pointer_owner.set_default_pointer_owner(seat);
seat.tree_changed.trigger();
}

Expand Down

0 comments on commit 2abce40

Please sign in to comment.