toplevel-drag: correctly update surface positions
This commit is contained in:
parent
ac5a5ca949
commit
ac8b22f2bb
2 changed files with 29 additions and 2 deletions
|
|
@ -410,6 +410,16 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_pointer_cursor_position(&self, x: Fixed, y: Fixed) -> (Fixed, Fixed) {
|
||||||
|
let (x, y) = self.pointer_cursor.set_position(x, y);
|
||||||
|
if let Some(td) = self.pointer_owner.toplevel_drag() {
|
||||||
|
let x_int = x.round_down();
|
||||||
|
let y_int = y.round_down();
|
||||||
|
td.move_(x_int, y_int);
|
||||||
|
}
|
||||||
|
(x, y)
|
||||||
|
}
|
||||||
|
|
||||||
fn connector_position_event(
|
fn connector_position_event(
|
||||||
self: &Rc<Self>,
|
self: &Rc<Self>,
|
||||||
time_usec: u64,
|
time_usec: u64,
|
||||||
|
|
@ -424,7 +434,7 @@ impl WlSeatGlobal {
|
||||||
let pos = output.global.pos.get();
|
let pos = output.global.pos.get();
|
||||||
x += Fixed::from_int(pos.x1());
|
x += Fixed::from_int(pos.x1());
|
||||||
y += Fixed::from_int(pos.y1());
|
y += Fixed::from_int(pos.y1());
|
||||||
(x, y) = self.pointer_cursor.set_position(x, y);
|
(x, y) = self.set_pointer_cursor_position(x, y);
|
||||||
if let Some(c) = self.constraint.get() {
|
if let Some(c) = self.constraint.get() {
|
||||||
if c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()) {
|
if c.ty == ConstraintType::Lock || !c.contains(x.round_down(), y.round_down()) {
|
||||||
c.deactivate();
|
c.deactivate();
|
||||||
|
|
@ -484,7 +494,7 @@ impl WlSeatGlobal {
|
||||||
dy_unaccelerated,
|
dy_unaccelerated,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
self.pointer_cursor.set_position(x, y);
|
self.set_pointer_cursor_position(x, y);
|
||||||
self.cursor_moved(time_usec);
|
self.cursor_moved(time_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use {
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
rect::Rect,
|
rect::Rect,
|
||||||
renderer::Renderer,
|
renderer::Renderer,
|
||||||
|
tree::ToplevelNode,
|
||||||
utils::clonecell::CloneCell,
|
utils::clonecell::CloneCell,
|
||||||
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id},
|
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id},
|
||||||
},
|
},
|
||||||
|
|
@ -52,6 +53,18 @@ impl XdgToplevelDragV1 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn move2(&self, x: i32, y: i32) {
|
||||||
|
if let Some(tl) = self.toplevel.get() {
|
||||||
|
let extents = tl.xdg.absolute_desired_extents.get();
|
||||||
|
let extents = extents.at_point(x - self.x_off.get(), y - self.y_off.get());
|
||||||
|
tl.clone().tl_change_extents(&extents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn move_(&self, x: i32, y: i32) {
|
||||||
|
self.move2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render(&self, renderer: &mut Renderer<'_>, cursor_rect: &Rect, x: i32, y: i32) {
|
pub fn render(&self, renderer: &mut Renderer<'_>, cursor_rect: &Rect, x: i32, y: i32) {
|
||||||
if let Some(tl) = self.toplevel.get() {
|
if let Some(tl) = self.toplevel.get() {
|
||||||
if tl.xdg.surface.buffer.get().is_some() {
|
if tl.xdg.surface.buffer.get().is_some() {
|
||||||
|
|
@ -107,6 +120,10 @@ impl XdgToplevelDragV1 {
|
||||||
};
|
};
|
||||||
tl.prepare_toplevel_drag();
|
tl.prepare_toplevel_drag();
|
||||||
self.client.state.tree_changed();
|
self.client.state.tree_changed();
|
||||||
|
if let Some(seat) = self.source.data.seat.get() {
|
||||||
|
let (x, y) = seat.pointer_cursor().position_int();
|
||||||
|
self.move2(x, y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_drag(&self, seat: &Rc<WlSeatGlobal>) {
|
pub fn finish_drag(&self, seat: &Rc<WlSeatGlobal>) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue