Add dragging window with cursor feature (#1840)
* X11 implementation. * Introduce example. * Wayland implementation. * Windows implementation. * Improve Wayland seat passing. * MacOS implementation. * Correct windows implementation per specification. * Update dependency smithay-client-toolkit from branch to master. * Fixed blocking thread in windows implementation. * Add multi-window example. * Move Wayland to a different PR. * Fix CHANGELOG. * Improve example. Co-authored-by: Markus Røyset <maroider@protonmail.com> * Rename `set_drag_window` to `begin_drag`. * Improve example. * Fix CHANGELOG. * Fix CHANGELOG. Co-authored-by: Markus Røyset <maroider@protonmail.com> * Rename to `drag_window`. * Fix typo. * Re-introduce Wayland implementation. * Fixing Wayland build. * Fixing Wayland build. * Move SCTK to 0.12.3. Co-authored-by: Markus Røyset <maroider@protonmail.com>
This commit is contained in:
parent
4192d04a53
commit
98470393d1
16 changed files with 233 additions and 5 deletions
|
|
@ -1276,6 +1276,46 @@ impl UnownedWindow {
|
|||
self.set_cursor_position_physical(x, y)
|
||||
}
|
||||
|
||||
pub fn drag_window(&self) -> Result<(), ExternalError> {
|
||||
let pointer = self
|
||||
.xconn
|
||||
.query_pointer(self.xwindow, util::VIRTUAL_CORE_POINTER)
|
||||
.map_err(|err| ExternalError::Os(os_error!(OsError::XError(err))))?;
|
||||
|
||||
let window = self.inner_position().map_err(ExternalError::NotSupported)?;
|
||||
|
||||
let message = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_MOVERESIZE\0") };
|
||||
|
||||
// we can't use `set_cursor_grab(false)` here because it doesn't run `XUngrabPointer`
|
||||
// if the cursor isn't currently grabbed
|
||||
let mut grabbed_lock = self.cursor_grabbed.lock();
|
||||
unsafe {
|
||||
(self.xconn.xlib.XUngrabPointer)(self.xconn.display, ffi::CurrentTime);
|
||||
}
|
||||
self.xconn
|
||||
.flush_requests()
|
||||
.map_err(|err| ExternalError::Os(os_error!(OsError::XError(err))))?;
|
||||
*grabbed_lock = false;
|
||||
|
||||
// we keep the lock until we are done
|
||||
self.xconn
|
||||
.send_client_msg(
|
||||
self.xwindow,
|
||||
self.root,
|
||||
message,
|
||||
Some(ffi::SubstructureRedirectMask | ffi::SubstructureNotifyMask),
|
||||
[
|
||||
(window.x as c_long + pointer.win_x as c_long),
|
||||
(window.y as c_long + pointer.win_y as c_long),
|
||||
8, // _NET_WM_MOVERESIZE_MOVE
|
||||
ffi::Button1 as c_long,
|
||||
1,
|
||||
],
|
||||
)
|
||||
.flush()
|
||||
.map_err(|err| ExternalError::Os(os_error!(OsError::XError(err))))
|
||||
}
|
||||
|
||||
pub(crate) fn set_ime_position_physical(&self, x: i32, y: i32) {
|
||||
let _ = self
|
||||
.ime_sender
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue