mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Improved mouse events on OS X regarding fullscreen mode
This commit is contained in:
parent
71f34600bc
commit
eca4502424
@ -41,7 +41,10 @@ namespace sf {
|
||||
///
|
||||
/// Handle event and send them back to the requester.
|
||||
///
|
||||
/// NSTrackingArea is used to keep track of mouse events.
|
||||
/// NSTrackingArea is used to keep track of mouse events. We also
|
||||
/// need to be able to ignore mouse event when exiting fullscreen.
|
||||
/// The SFWindowController should call -[SFOpenGLView exitFullscreen]
|
||||
/// and -[SFOpenGLView enterFullscreen] when appropriate.
|
||||
///
|
||||
/// In order to send correct mouse coordonate to the requester when
|
||||
/// the window is in fullscreen we use m_realSize to represent the
|
||||
@ -72,6 +75,13 @@ namespace sf {
|
||||
////////////////////////////////////////////////////////////
|
||||
-(id)initWithFrame:(NSRect)frameRect;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Handle going in and out of fullscreen mode.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
-(void)enterFullscreen;
|
||||
-(void)exitFullscreen;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Apply the given resquester to the view.
|
||||
///
|
||||
|
@ -128,6 +128,39 @@ BOOL isValidTextUnicode(NSEvent* event);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)enterFullscreen
|
||||
{
|
||||
// Remove the tracking area first,
|
||||
// just to be sure we don't add it twice!
|
||||
[self removeTrackingArea:m_trackingArea];
|
||||
[self addTrackingArea:m_trackingArea];
|
||||
|
||||
// Fire an mouse entered event if needed
|
||||
if (!m_mouseIsIn && m_requester != 0) {
|
||||
m_requester->mouseMovedIn();
|
||||
}
|
||||
|
||||
// Update status
|
||||
m_mouseIsIn = YES;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)exitFullscreen
|
||||
{
|
||||
[self removeTrackingArea:m_trackingArea];
|
||||
|
||||
// Fire an mouse left event if needed
|
||||
if (m_mouseIsIn && m_requester != 0) {
|
||||
m_requester->mouseMovedOut();
|
||||
}
|
||||
|
||||
// Update status
|
||||
m_mouseIsIn = NO;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
-(void)setRequesterTo:(sf::priv::WindowImplCocoa *)requester
|
||||
{
|
||||
|
@ -211,9 +211,15 @@
|
||||
}
|
||||
|
||||
// If a fullscreen window was requested...
|
||||
if (style & sf::Style::Fullscreen && mode != sf::VideoMode::getDesktopMode()) {
|
||||
/// ... we set the "real size" of the view (that is the back buffer size).
|
||||
[m_oglView setRealSize:NSMakeSize(m_fullscreenMode->width, m_fullscreenMode->height)];
|
||||
if (style & sf::Style::Fullscreen) {
|
||||
/// ... we tell the OpenGL view
|
||||
[m_oglView enterFullscreen];
|
||||
|
||||
// ... and if the resolution is not the default one...
|
||||
if (mode != sf::VideoMode::getDesktopMode()) {
|
||||
// ... we set the "real size" of the view (that is the back buffer size).
|
||||
[m_oglView setRealSize:NSMakeSize(m_fullscreenMode->width, m_fullscreenMode->height)];
|
||||
}
|
||||
}
|
||||
|
||||
// Set the view to the window as its content view.
|
||||
@ -496,6 +502,10 @@
|
||||
if (m_requester == 0) return;
|
||||
|
||||
m_requester->windowGainedFocus();
|
||||
|
||||
if (*m_fullscreenMode != sf::VideoMode()) {
|
||||
[m_oglView enterFullscreen];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -506,6 +516,10 @@
|
||||
if (m_requester == 0) return;
|
||||
|
||||
m_requester->windowLostFocus();
|
||||
|
||||
if (*m_fullscreenMode != sf::VideoMode()) {
|
||||
[m_oglView exitFullscreen];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user