toplevel-drag: move render logic into toplevel drag
This commit is contained in:
parent
50b6999b0c
commit
ac5a5ca949
3 changed files with 19 additions and 11 deletions
|
|
@ -352,6 +352,11 @@ impl CursorUser {
|
||||||
self.pos.get()
|
self.pos.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn position_int(&self) -> (i32, i32) {
|
||||||
|
let (x, y) = self.pos.get();
|
||||||
|
(x.round_down(), y.round_down())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_position(&self, mut x: Fixed, mut y: Fixed) -> (Fixed, Fixed) {
|
pub fn set_position(&self, mut x: Fixed, mut y: Fixed) -> (Fixed, Fixed) {
|
||||||
let x_int = x.round_down();
|
let x_int = x.round_down();
|
||||||
let y_int = y.round_down();
|
let y_int = y.round_down();
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ impl dyn GfxFramebuffer {
|
||||||
if let Some(rect) = cursor_rect {
|
if let Some(rect) = cursor_rect {
|
||||||
let seats = state.globals.lock_seats();
|
let seats = state.globals.lock_seats();
|
||||||
for seat in seats.values() {
|
for seat in seats.values() {
|
||||||
let (x, y) = seat.pointer_cursor().position();
|
let (x, y) = seat.pointer_cursor().position_int();
|
||||||
if let Some(im) = seat.input_method() {
|
if let Some(im) = seat.input_method() {
|
||||||
for (_, popup) in &im.popups {
|
for (_, popup) in &im.popups {
|
||||||
if popup.surface.node_visible() {
|
if popup.surface.node_visible() {
|
||||||
|
|
@ -359,18 +359,10 @@ impl dyn GfxFramebuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(drag) = seat.toplevel_drag() {
|
if let Some(drag) = seat.toplevel_drag() {
|
||||||
if let Some(tl) = drag.toplevel.get() {
|
drag.render(&mut renderer, &rect, x, y);
|
||||||
if tl.xdg.surface.buffer.get().is_some() {
|
|
||||||
let (x, y) = rect.translate(
|
|
||||||
x.round_down() - drag.x_off.get(),
|
|
||||||
y.round_down() - drag.y_off.get(),
|
|
||||||
);
|
|
||||||
renderer.render_xdg_surface(&tl.xdg, x, y, None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let Some(dnd_icon) = seat.dnd_icon() {
|
if let Some(dnd_icon) = seat.dnd_icon() {
|
||||||
dnd_icon.render(&mut renderer, &rect, x.round_down(), y.round_down());
|
dnd_icon.render(&mut renderer, &rect, x, y);
|
||||||
}
|
}
|
||||||
if render_cursor {
|
if render_cursor {
|
||||||
let cursor_user_group = seat.cursor_group();
|
let cursor_user_group = seat.cursor_group();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ use {
|
||||||
},
|
},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
|
rect::Rect,
|
||||||
|
renderer::Renderer,
|
||||||
utils::clonecell::CloneCell,
|
utils::clonecell::CloneCell,
|
||||||
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id},
|
wire::{xdg_toplevel_drag_v1::*, XdgToplevelDragV1Id},
|
||||||
},
|
},
|
||||||
|
|
@ -49,6 +51,15 @@ impl XdgToplevelDragV1 {
|
||||||
tl.drag.take();
|
tl.drag.take();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn render(&self, renderer: &mut Renderer<'_>, cursor_rect: &Rect, x: i32, y: i32) {
|
||||||
|
if let Some(tl) = self.toplevel.get() {
|
||||||
|
if tl.xdg.surface.buffer.get().is_some() {
|
||||||
|
let (x, y) = cursor_rect.translate(x - self.x_off.get(), y - self.y_off.get());
|
||||||
|
renderer.render_xdg_surface(&tl.xdg, x, y, None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XdgToplevelDragV1RequestHandler for XdgToplevelDragV1 {
|
impl XdgToplevelDragV1RequestHandler for XdgToplevelDragV1 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue