[vlc-commits] macosx: re-write the resize control used in the black window style to use the MouseDown event instead of the MouseDragged event which is ignored on Leopard (should fix #5822)

Felix Paul Kühne git at videolan.org
Sat Feb 11 15:25:41 CET 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Feb 11 15:25:34 2012 +0100| [f2a677c05602a0f7cf3fd31d93491126ad8fcd8f] | committer: Felix Paul Kühne

macosx: re-write the resize control used in the black window style to use the MouseDown event instead of the MouseDragged event which is ignored on Leopard (should fix #5822)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f2a677c05602a0f7cf3fd31d93491126ad8fcd8f
---

 modules/gui/macosx/MainWindowTitle.m |   64 +++++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/modules/gui/macosx/MainWindowTitle.m b/modules/gui/macosx/MainWindowTitle.m
index e01c6f1..b5bfa97 100644
--- a/modules/gui/macosx/MainWindowTitle.m
+++ b/modules/gui/macosx/MainWindowTitle.m
@@ -271,29 +271,51 @@
 
 @implementation VLCResizeControl
 
-- (void)mouseDragged:(NSEvent *)theEvent
-{
-    NSRect windowFrame = [[self window] frame];
-    CGFloat deltaX, deltaY, oldOriginY;
-    deltaX = [theEvent deltaX];
-    deltaY = [theEvent deltaY];
-    oldOriginY = windowFrame.origin.y;
-
-    windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
-    windowFrame.size.width += deltaX;
-    windowFrame.size.height += deltaY;
-
-    NSSize winMinSize = [self window].minSize;
-    if (windowFrame.size.width < winMinSize.width)
-        windowFrame.size.width = winMinSize.width;
+- (void)mouseDown:(NSEvent *)theEvent {
+    BOOL keepOn = YES;
+
+    while (keepOn) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |
+                    NSLeftMouseDraggedMask];
+
+        switch ([theEvent type]) {
+            case NSLeftMouseDragged:
+            {
+                NSRect windowFrame = [[self window] frame];
+                CGFloat deltaX, deltaY, oldOriginY;
+                deltaX = [theEvent deltaX];
+                deltaY = [theEvent deltaY];
+                oldOriginY = windowFrame.origin.y;
+
+                windowFrame.origin.y = (oldOriginY + windowFrame.size.height) - (windowFrame.size.height + deltaY);
+                windowFrame.size.width += deltaX;
+                windowFrame.size.height += deltaY;
+
+                NSSize winMinSize = [self window].minSize;
+                if (windowFrame.size.width < winMinSize.width)
+                    windowFrame.size.width = winMinSize.width;
+
+                if (windowFrame.size.height < winMinSize.height)
+                {
+                    windowFrame.size.height = winMinSize.height;
+                    windowFrame.origin.y = oldOriginY;
+                }
+
+                [[self window] setFrame: windowFrame display: YES animate: NO];
+                break;
+            }
+                break;
+            case NSLeftMouseUp:
+                keepOn = NO;
+                break;
+            default:
+                /* Ignore any other kind of event. */
+                break;
+        }
 
-    if (windowFrame.size.height < winMinSize.height)
-    {
-        windowFrame.size.height = winMinSize.height;
-        windowFrame.origin.y = oldOriginY;
-    }
+    };
 
-    [[self window] setFrame: windowFrame display: YES animate: NO];
+    return;
 }
 
 @end



More information about the vlc-commits mailing list