Re: [AD] Resizable windows on Mac OS X |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Actually you don't need to keep willResize:toSize: because there's a
setMinSize: for windows. Patch attached, see what you think. I
enforced it for manual setting via al_resize_display too, dunno if
this is right or not.
Pete
On Tue, Sep 23, 2008 at 2:04 PM, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:
> On 23 Sep 2008, at 08:31, Peter Hull wrote:
>> Have you had a look at this?
>> http://developer.apple.com/documentation/Cocoa/Conceptual/
>> CocoaPerformance/Articles/CocoaLiveResize.html
>> I wonder if any of that stuff can help.
>
> I did, but I somehow missed the bit about viewEndLiveResize. That
> makes things a whole lot better than they were, so I changed the code
> to use that instead (see log message though).
>
> Evert
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
>
Index: src/macosx/osxgl.m
===================================================================
--- src/macosx/osxgl.m (revision 10969)
+++ src/macosx/osxgl.m (working copy)
@@ -32,6 +32,10 @@
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
+/* Defines */
+#define MINIMUM_WIDTH 48
+#define MINIMUM_HEIGHT 48
+
/* Module Variables */
static BOOL _osx_mouse_installed = NO, _osx_keyboard_installed = NO;
static NSPoint last_window_pos;
@@ -99,7 +103,6 @@
/* Window delegate methods */
-(void) windowDidBecomeMain:(NSNotification*) notification;
-(void) windowDidResignMain:(NSNotification*) notification;
--(NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
@end
/* ALWindow:
@@ -348,16 +351,6 @@
_al_event_source_emit_event(src, evt);
_al_event_source_unlock(src);
}
-
--(NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
-{
- /* Make sure the content doesn't get resized to 0, since that would
- * really suck.
- */
- proposedFrameSize.height = MAX(48, proposedFrameSize.height);
-
- return proposedFrameSize;
-}
/* End of ALOpenGLView implementation */
@end
@@ -486,6 +479,7 @@
[win setReleasedWhenClosed: YES];
[win setAcceptsMouseMovedEvents: _osx_mouse_installed];
[win setTitle: @"Allegro"];
+ [win setMinSize: NSMakeSize(MINIMUM_WIDTH, MINIMUM_HEIGHT)];
if (NSEqualPoints(last_window_pos, NSZeroPoint)) {
/* We haven't positioned a window before */
[win center];
@@ -891,6 +885,8 @@
ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) d;
NSWindow* window = dpy->win;
NSRect current = [window frame];
+ w = MAX(w, MINIMUM_WIDTH);
+ h = MAX(h, MINIMUM_HEIGHT);
NSRect rc = [window frameRectForContentRect: NSMakeRect(0.0f, 0.0f, (float) w, (float) h)];
rc.origin = current.origin;
[window setFrame:rc display:YES animate:YES];