diff --git a/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs b/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs index 09aa7a165c..1697295198 100644 --- a/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs +++ b/src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs @@ -126,6 +126,11 @@ namespace Perspex.Android.Platform.SkiaPlatform this.Visibility = ViewStates.Visible; } + public void BeginMoveDrag() + { + //Not supported + } + public IDisposable ShowDialog() { throw new NotImplementedException(); diff --git a/src/Gtk/Perspex.Gtk/WindowImpl.cs b/src/Gtk/Perspex.Gtk/WindowImpl.cs index afeaaf9ff0..735150f9b2 100644 --- a/src/Gtk/Perspex.Gtk/WindowImpl.cs +++ b/src/Gtk/Perspex.Gtk/WindowImpl.cs @@ -162,6 +162,14 @@ namespace Perspex.Gtk GdkWindow.Cursor = cursor != null ? new Gdk.Cursor(cursor.Handle) : DefaultCursor; } + public void BeginMoveDrag() + { + int x, y; + ModifierType mod; + Screen.RootWindow.GetPointer(out x, out y, out mod); + BeginMoveDrag(0, x, y, 0); + } + public IDisposable ShowDialog() { Modal = true; diff --git a/src/Perspex.Controls/Platform/ITopLevelImpl.cs b/src/Perspex.Controls/Platform/ITopLevelImpl.cs index f826ec5990..ade7aab3bd 100644 --- a/src/Perspex.Controls/Platform/ITopLevelImpl.cs +++ b/src/Perspex.Controls/Platform/ITopLevelImpl.cs @@ -88,5 +88,10 @@ namespace Perspex.Platform /// Shows the toplevel. /// void Show(); + + /// + /// Starts moving a window with left button being held. Should be called from left mouse button press event handler + /// + void BeginMoveDrag(); } } diff --git a/src/Perspex.Controls/Platform/PlatformManager.cs b/src/Perspex.Controls/Platform/PlatformManager.cs index 735b810d91..1e7b5cc755 100644 --- a/src/Perspex.Controls/Platform/PlatformManager.cs +++ b/src/Perspex.Controls/Platform/PlatformManager.cs @@ -174,6 +174,7 @@ namespace Perspex.Controls.Platform public void SetTitle(string title) => _window.SetTitle(title); public void Show() => _tl.Show(); + public void BeginMoveDrag() => _tl.BeginMoveDrag(); public IDisposable ShowDialog() => _window.ShowDialog(); diff --git a/src/Perspex.Controls/TopLevel.cs b/src/Perspex.Controls/TopLevel.cs index ca84f67de1..dffedefbe2 100644 --- a/src/Perspex.Controls/TopLevel.cs +++ b/src/Perspex.Controls/TopLevel.cs @@ -364,5 +364,10 @@ namespace Perspex.Controls { _renderQueueManager?.InvalidateRender(this); } + + /// + /// Starts moving a window with left button being held. Should be called from left mouse button press event handler + /// + public void BeginMoveDrag() => PlatformImpl.BeginMoveDrag(); } } diff --git a/src/Windows/Perspex.Win32/WindowImpl.cs b/src/Windows/Perspex.Win32/WindowImpl.cs index 03fcd7cc6d..063be91873 100644 --- a/src/Windows/Perspex.Win32/WindowImpl.cs +++ b/src/Windows/Perspex.Win32/WindowImpl.cs @@ -223,6 +223,12 @@ namespace Perspex.Win32 UnmanagedMethods.ShowWindow(_hwnd, UnmanagedMethods.ShowWindowCommand.Normal); } + public void BeginMoveDrag() + { + UnmanagedMethods.DefWindowProc(_hwnd, (int) UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN, + new IntPtr(2), IntPtr.Zero); + } + public virtual IDisposable ShowDialog() { var disabled = s_instances.Where(x => x != this && x.IsEnabled).ToList(); diff --git a/src/iOS/Perspex.iOS/PerspexView.cs b/src/iOS/Perspex.iOS/PerspexView.cs index 52fe69d8d1..1ccf78330f 100644 --- a/src/iOS/Perspex.iOS/PerspexView.cs +++ b/src/iOS/Perspex.iOS/PerspexView.cs @@ -107,6 +107,11 @@ namespace Perspex.iOS _keyboardHelper.ActivateAutoShowKeybord(); } + public void BeginMoveDrag() + { + //Not supported + } + public Size MaxClientSize => Bounds.Size.ToPerspex(); public void SetTitle(string title) {