Parcourir la source

Merge pull request #15 from AvaloniaUI/feature/position-changed

implement window position changed.
danwalmsley il y a 7 ans
Parent
commit
d9cbcd5e4d

+ 6 - 0
src/Avalonia.Native.OSX/window.mm

@@ -535,6 +535,12 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
     [super resignKeyWindow];
 }
 
+- (void)windowDidMove:(NSNotification *)notification
+{
+    AvnPoint position;
+    _parent->GetPosition(&position);
+    _parent->BaseEvents->PositionChanged(position);
+}
 @end
 
 class PopupImpl : public WindowBaseImpl, public IAvnPopup

+ 5 - 0
src/Avalonia.Native/WindowImplBase.cs

@@ -133,6 +133,11 @@ namespace Avalonia.Native
                 _parent.Resized?.Invoke(s);
             }
 
+            void IAvnWindowBaseEvents.PositionChanged(AvnPoint position)
+            {
+                _parent.PositionChanged?.Invoke(position.ToAvaloniaPoint());
+            }
+
             void IAvnWindowBaseEvents.RawMouseEvent(AvnRawMouseEventType type, uint timeStamp, AvnInputModifiers modifiers, AvnPoint point, AvnVector delta)
             {
                 _parent.RawMouseEvent(type, timeStamp, modifiers, point, delta);

+ 1 - 0
src/headers/avalonia-native.h

@@ -132,6 +132,7 @@ AVNCOM(IAvnWindowBaseEvents, 05) : IUnknown
     virtual void Activated() = 0;
     virtual void Deactivated() = 0;
     virtual void Resized(const AvnSize& size) = 0;
+    virtual void PositionChanged (AvnPoint position) = 0;
     virtual void RawMouseEvent (AvnRawMouseEventType type,
                                 unsigned int timeStamp,
                                 AvnInputModifiers modifiers,