From 9c46a9d8f780e3e670d283f4faf075888f398aaa Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 6 Mar 2020 10:23:39 +0200 Subject: [PATCH] Changed: Windows focus events on macOS --- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 +- .../3d/driver/opengl/mac/cocoa_window_delegate.h | 2 ++ .../3d/driver/opengl/mac/cocoa_window_delegate.mm | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 9bd19b14d..e1ee968a5 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -700,6 +700,7 @@ public: GfxMode _CurrentMode; sint32 _WindowX; sint32 _WindowY; + bool _WindowFocus; #ifdef NL_OS_MAC NLMISC::CCocoaEventEmitter _EventEmitter; @@ -723,7 +724,6 @@ private: bool _Maximized; uint _Interval; bool _Resizable; - bool _WindowFocus; sint32 _DecorationWidth; sint32 _DecorationHeight; diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h index 9736e2a27..1e9881b47 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.h @@ -40,5 +40,7 @@ using NL3D::CDriverGL; - (id)initWithDriver:(CDriverGL*)driver; - (void)windowDidMove:(NSNotification*)notification; +- (void)windowDidBecomeKey:(NSNotification *)notification; +- (void)windowDidResignKey:(NSNotification *)notification; @end diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.mm b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.mm index 2e5faf852..44031f7aa 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.mm +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_window_delegate.mm @@ -55,4 +55,19 @@ static void windowDidMove(NSWindow* window, CDriverGL* driver) windowDidMove([notification object], _driver); } +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + if (!_driver) + return; + + _driver->_WindowFocus = true; +} +- (void)windowDidResignKey:(NSNotification *)notification; +{ + if(!_driver) + return; + + _driver->_WindowFocus = false; +} + @end