From 4cfebf253b9bc0f7b0ffc35bfc153ec0c3781063 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 8 Aug 2011 20:52:43 +0200
Subject: [PATCH] vout_macosx: implemented support for resize, zoom, etc.
 events

---
 modules/video_output/macosx.m | 38 +++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 920f1ed47391..4034858cff60 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -289,17 +289,51 @@ static int Control (vout_display_t *vd, int query, va_list ap)
     {
         case VOUT_DISPLAY_CHANGE_FULLSCREEN:
         case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
+        {
+            /* todo */
+            return VLC_EGENERIC;
+        }
         case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
         case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
         case VOUT_DISPLAY_CHANGE_ZOOM:
         case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
         case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
         {
-            /* todo */
-            return VLC_EGENERIC;
+            NSPoint topleftbase;
+            NSPoint topleftscreen;
+            NSRect new_frame;
+            const vout_display_cfg_t *cfg;
+            topleftbase.x = 0;
+            topleftbase.y = [[sys->glView window] frame].size.height;
+            topleftscreen = [[sys->glView window] convertBaseToScreen: topleftbase];
+            cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
+            int i_width = cfg->display.width;
+            int i_height = cfg->display.height;
+
+            /* Calculate the window's new size, if it is larger than our minimal size */
+            if (i_width < [[sys->glView window] minSize].width)
+                i_width = [[sys->glView window] minSize].width;
+            if (i_height < [[sys->glView window] minSize].height)
+                i_height = [[sys->glView window] minSize].height;
+
+            if( i_height != [sys->glView frame].size.height || i_width != [sys->glView frame].size.width )
+            {
+                new_frame.size.width = [[sys->glView window] frame].size.width - [sys->glView frame].size.width + i_width;
+                new_frame.size.height = [[sys->glView window] frame].size.height - [sys->glView frame].size.height + i_height;
+
+                new_frame.origin.x = topleftscreen.x;
+                new_frame.origin.y = topleftscreen.y - new_frame.size.height;
+
+                [[sys->glView window] setFrame:new_frame display:YES animate:YES];
+            }
+            return VLC_SUCCESS;
         }
+
         case VOUT_DISPLAY_HIDE_MOUSE:
+        {
+            [NSCursor setHiddenUntilMouseMoves: YES];
             return VLC_SUCCESS;
+        }
 
         case VOUT_DISPLAY_GET_OPENGL:
         {
-- 
GitLab