Skip to content

Avalonia: Fix main window not draggable by touch#4869

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/4866-touchscreen-window-drag
Jun 3, 2026
Merged

Avalonia: Fix main window not draggable by touch#4869
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/4866-touchscreen-window-drag

Conversation

@GabrielDuf
Copy link
Copy Markdown
Contributor

This pull request enhances the window dragging experience for touch and pen users on Windows by implementing a custom, manual drag behavior for the title bar. This change addresses platform-specific limitations and ensures consistent behavior across pointer types. #4866

Title Bar Dragging Improvements:

  • Added event handlers (PointerMoved, PointerReleased, PointerCaptureLost) to the TitleBarDragArea in MainWindow.axaml to support manual drag logic for touch and pen input.
  • Introduced state variables (_titleBarDragPointer, _titleBarDragOrigin) and logic to track and manage manual drag operations in MainWindow.axaml.cs.
  • Updated TitleBar_PointerPressed to distinguish between mouse and touch/pen input, using manual drag only for touch/pen on Windows. Mouse input continues to use the native drag behavior.
  • Implemented TitleBar_PointerMoved, TitleBar_PointerReleased, and TitleBar_PointerCaptureLost methods to handle moving the window, releasing the drag, and cleaning up drag state for touch/pen scenarios.

These changes improve usability for touch and pen users, especially on Windows, by providing a smooth and reliable window dragging experience.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Avalonia main-window title bar dragging on Windows for touch/pen users by introducing a manual drag implementation (workaround for BeginMoveDrag limitations with non-mouse pointers), addressing issue #4866.

Changes:

  • Added manual drag state + pointer event handlers in MainWindow.axaml.cs for touch/pen on Windows.
  • Updated title bar pointer-press logic to keep native OS drag for mouse (preserving Aero Snap) while using manual dragging for touch/pen.
  • Wired up additional pointer events on the title bar drag area in XAML to support the new drag lifecycle.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs Adds touch/pen-specific manual window dragging logic and related pointer event handlers.
src/UniGetUI.Avalonia/Views/MainWindow.axaml Names the title bar drag area and hooks pointer moved/released/capture-lost events to drive manual dragging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs
Comment thread src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs
@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit acf111d into main Jun 3, 2026
3 checks passed
@GabrielDuf Gabriel Dufresne (GabrielDuf) deleted the fix/4866-touchscreen-window-drag branch June 3, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants