Skip to content

Commit 7720107

Browse files
committed
Implement Window::StartDragging() on Linux
It was an empty stub, so a custom title bar (DragToMoveArea in the Flutter binding) did nothing on Linux. Hand the move to the window manager with gdk_window_begin_move_drag_for_device(), the same way StartResizing() already does for the edges.
1 parent 99c5f3c commit 7720107

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎src/platform/linux/window_linux.cpp‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,25 @@ bool Window::IsFocusable() const {
723723
}
724724

725725
void Window::StartDragging() {
726-
// Window dragging would typically involve listening to mouse events
727-
// Provide stub implementation
726+
if (!pimpl_->gdk_window_) {
727+
return;
728+
}
729+
730+
GdkDisplay* display = gdk_window_get_display(pimpl_->gdk_window_);
731+
GdkSeat* seat = display ? gdk_display_get_default_seat(display) : nullptr;
732+
GdkDevice* pointer = seat ? gdk_seat_get_pointer(seat) : nullptr;
733+
if (!pointer) {
734+
return;
735+
}
736+
737+
gint root_x = 0, root_y = 0;
738+
gdk_device_get_position(pointer, nullptr, &root_x, &root_y);
739+
// The window manager moves the window from here on, so this works on Wayland too,
740+
// where the position above is meaningless and ignored — what matters is the
741+
// timestamp of the mouse-down we are called from, which is what the compositor
742+
// matches against the press it delivered.
743+
gdk_window_begin_move_drag_for_device(pimpl_->gdk_window_, pointer, GDK_BUTTON_PRIMARY,
744+
root_x, root_y, gtk_get_current_event_time());
728745
}
729746

730747
void Window::StartResizing(ResizeEdge edge) {

0 commit comments

Comments
 (0)