fix event with fullscreen mode
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1730 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
9ce6a2aa2a
commit
e2ff29ecda
@ -60,6 +60,8 @@ else() # MACOSX
|
|||||||
${SRCROOT}/OSX/SFContext.mm
|
${SRCROOT}/OSX/SFContext.mm
|
||||||
${SRCROOT}/OSX/SFOpenGLView.h
|
${SRCROOT}/OSX/SFOpenGLView.h
|
||||||
${SRCROOT}/OSX/SFOpenGLView.mm
|
${SRCROOT}/OSX/SFOpenGLView.mm
|
||||||
|
${SRCROOT}/OSX/SFWindow.h
|
||||||
|
${SRCROOT}/OSX/SFWindow.m
|
||||||
${SRCROOT}/OSX/SFWindowController.h
|
${SRCROOT}/OSX/SFWindowController.h
|
||||||
${SRCROOT}/OSX/SFWindowController.mm
|
${SRCROOT}/OSX/SFWindowController.mm
|
||||||
${SRCROOT}/OSX/VideoModeImpl.cpp
|
${SRCROOT}/OSX/VideoModeImpl.cpp
|
||||||
|
46
src/SFML/Window/OSX/SFWindow.h
Normal file
46
src/SFML/Window/OSX/SFWindow.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SFML - Simple and Fast Multimedia Library
|
||||||
|
// Copyright (C) 2007-2010 Marco Antognini (antognini.marco@gmail.com),
|
||||||
|
// Laurent Gomila (laurent.gom@gmail.com),
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
// subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented;
|
||||||
|
// you must not claim that you wrote the original software.
|
||||||
|
// If you use this software in a product, an acknowledgment
|
||||||
|
// in the product documentation would be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such,
|
||||||
|
// and must not be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Headers
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Here we redefine some methods to allow grabing fullscreen events.
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
@interface SFWindow : NSWindow {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
These two methods must return YES to grab fullscreen events.
|
||||||
|
See http://stackoverflow.com/questions/999464/fullscreen-key-down-actions
|
||||||
|
for more informations
|
||||||
|
*/
|
||||||
|
-(BOOL)acceptsFirstResponder;
|
||||||
|
-(BOOL)canBecomeKeyWindow;
|
||||||
|
|
||||||
|
@end
|
45
src/SFML/Window/OSX/SFWindow.m
Normal file
45
src/SFML/Window/OSX/SFWindow.m
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SFML - Simple and Fast Multimedia Library
|
||||||
|
// Copyright (C) 2007-2010 Marco Antognini (antognini.marco@gmail.com),
|
||||||
|
// Laurent Gomila (laurent.gom@gmail.com),
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
// subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented;
|
||||||
|
// you must not claim that you wrote the original software.
|
||||||
|
// If you use this software in a product, an acknowledgment
|
||||||
|
// in the product documentation would be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such,
|
||||||
|
// and must not be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Headers
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#import "SFWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation SFWindow
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
-(BOOL)acceptsFirstResponder {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
-(BOOL)canBecomeKeyWindow {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -28,6 +28,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#import <SFML/Window/OSX/WindowImplDelegateProtocol.h>
|
#import <SFML/Window/OSX/WindowImplDelegateProtocol.h>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Predefine some classes
|
/// Predefine some classes
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#import <SFML/Window/OSX/SFWindowController.h>
|
#import <SFML/Window/OSX/SFWindowController.h>
|
||||||
#import <SFML/Window/OSX/SFApplication.h>
|
#import <SFML/Window/OSX/SFApplication.h>
|
||||||
#import <SFML/Window/OSX/SFOpenGLView.h>
|
#import <SFML/Window/OSX/SFOpenGLView.h>
|
||||||
|
#import <SFML/Window/OSX/SFWindow.h>
|
||||||
|
|
||||||
@implementation SFWindowController
|
@implementation SFWindowController
|
||||||
|
|
||||||
@ -103,7 +104,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the window.
|
// Create the window.
|
||||||
myWindow = [[NSWindow alloc] initWithContentRect:rect
|
myWindow = [[SFWindow alloc] initWithContentRect:rect
|
||||||
styleMask:nsStyle
|
styleMask:nsStyle
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
@ -127,6 +128,26 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply special feature for fullscreen window.
|
||||||
|
if (style & sf::Style::Fullscreen) {
|
||||||
|
// We place the window above everything else.
|
||||||
|
[myWindow setLevel:NSMainMenuWindowLevel+1];
|
||||||
|
[myWindow setOpaque:YES];
|
||||||
|
[myWindow setHidesOnDeactivate:YES];
|
||||||
|
|
||||||
|
/* ---------------------------
|
||||||
|
* | Note for future version |
|
||||||
|
* ---------------------------
|
||||||
|
*
|
||||||
|
* starting with OS 10.5 NSView provides
|
||||||
|
* a new method -enterFullScreenMode:withOptions:
|
||||||
|
* which could be a good alternative.
|
||||||
|
*/
|
||||||
|
} else {
|
||||||
|
// Center the window to be cool =)
|
||||||
|
[myWindow center];
|
||||||
|
}
|
||||||
|
|
||||||
// Create the view.
|
// Create the view.
|
||||||
myOGLView = [[SFOpenGLView alloc] initWithFrame:[[myWindow contentView] frame]];
|
myOGLView = [[SFOpenGLView alloc] initWithFrame:[[myWindow contentView] frame]];
|
||||||
|
|
||||||
@ -151,28 +172,6 @@
|
|||||||
// And some other things...
|
// And some other things...
|
||||||
[myWindow setAutodisplay:YES];
|
[myWindow setAutodisplay:YES];
|
||||||
[myWindow setReleasedWhenClosed:NO];
|
[myWindow setReleasedWhenClosed:NO];
|
||||||
|
|
||||||
// Apply special feature for fullscreen window.
|
|
||||||
if (style & sf::Style::Fullscreen) {
|
|
||||||
|
|
||||||
// We place the window above everything else.
|
|
||||||
[myWindow setLevel:NSMainMenuWindowLevel+1];
|
|
||||||
[myWindow setOpaque:YES];
|
|
||||||
[myWindow setHidesOnDeactivate:YES];
|
|
||||||
|
|
||||||
/* ---------------------------
|
|
||||||
* | Note for future version |
|
|
||||||
* ---------------------------
|
|
||||||
*
|
|
||||||
* starting with OS 10.5 NSView provides
|
|
||||||
* a new method -enterFullScreenMode:withOptions:
|
|
||||||
* which could be a good alternative.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// Center the window to be cool =)
|
|
||||||
[myWindow center];
|
|
||||||
|
|
||||||
} // if super init ok
|
} // if super init ok
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
Loading…
Reference in New Issue
Block a user