Added isWindowFocused and isWindowMinimized methods.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1383 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7d6f77dd91
commit
966db1eac4
|
@ -151,6 +151,14 @@ namespace irr
|
|||
\return True if window is active. */
|
||||
virtual bool isWindowActive() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window has focus
|
||||
/** \return True if window has focus. */
|
||||
virtual bool isWindowFocused() const = 0;
|
||||
|
||||
//! Checks if the Irrlicht window is minimized
|
||||
/** \return True if window is minimized. */
|
||||
virtual bool isWindowMinimized() const = 0;
|
||||
|
||||
//! Notifies the device that it should close itself.
|
||||
/** IrrlichtDevice::run() will always return false after closeDevice() was called. */
|
||||
virtual void closeDevice() = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@ CIrrDeviceLinux::CIrrDeviceLinux(const SIrrlichtCreationParameters& param)
|
|||
display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0),
|
||||
#endif
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
||||
Close(false), WindowActive(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), AutorepeatSupport(0)
|
||||
Close(false), WindowHasFocus(false), WindowMinimized(false), UseXVidMode(false), UseXRandR(false), UseGLXWindow(false), AutorepeatSupport(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceLinux");
|
||||
|
@ -529,7 +529,7 @@ bool CIrrDeviceLinux::createWindow()
|
|||
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||
XMapRaised(display, window);
|
||||
}
|
||||
WindowActive=true;
|
||||
WindowMinimized=false;
|
||||
XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport);
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
|
@ -668,7 +668,6 @@ void CIrrDeviceLinux::createDriver()
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! runs the device. Returns false if device wants to be deleted
|
||||
bool CIrrDeviceLinux::run()
|
||||
{
|
||||
|
@ -722,11 +721,11 @@ bool CIrrDeviceLinux::run()
|
|||
break;
|
||||
|
||||
case FocusIn:
|
||||
WindowActive=true;
|
||||
WindowHasFocus=true;
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
WindowActive=false;
|
||||
WindowHasFocus=false;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
|
@ -859,7 +858,7 @@ void CIrrDeviceLinux::yield()
|
|||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
|
||||
{
|
||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
|
||||
struct timespec ts;
|
||||
ts.tv_sec = (time_t) (timeMs / 1000);
|
||||
|
@ -1011,7 +1010,21 @@ void CIrrDeviceLinux::closeDevice()
|
|||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceLinux::isWindowActive() const
|
||||
{
|
||||
return WindowActive;
|
||||
return (WindowHasFocus && !WindowMinimized);
|
||||
}
|
||||
|
||||
|
||||
//! returns if window has focus.
|
||||
bool CIrrDeviceLinux::isWindowFocused() const
|
||||
{
|
||||
return WindowHasFocus;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is minimized.
|
||||
bool CIrrDeviceLinux::isWindowMinimized() const
|
||||
{
|
||||
return WindowMinimized;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,12 @@ namespace irr
|
|||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus.
|
||||
virtual bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized.
|
||||
virtual bool isWindowMinimized() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual void present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 );
|
||||
|
||||
|
@ -305,7 +311,7 @@ namespace irr
|
|||
#endif
|
||||
u32 Width, Height;
|
||||
bool Close;
|
||||
bool WindowActive;
|
||||
bool WindowHasFocus;
|
||||
bool WindowMinimized;
|
||||
bool UseXVidMode;
|
||||
bool UseXRandR;
|
||||
|
|
|
@ -38,10 +38,12 @@ const char* wmDeleteWindow = "WM_DELETE_WINDOW";
|
|||
|
||||
//! constructor
|
||||
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param), Resizeable(false),
|
||||
: CIrrDeviceStub(param),
|
||||
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_HWSURFACE|SDL_ANYFORMAT),
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Close(0),
|
||||
WindowActive(false)
|
||||
MouseX(0), MouseY(0),
|
||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
||||
Close(0), Resizeable(false),
|
||||
WindowHasFocus(false), WindowMinimized(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceSDL");
|
||||
|
@ -197,6 +199,7 @@ bool CIrrDeviceSDL::run()
|
|||
os::Timer::tick();
|
||||
|
||||
SEvent irrevent;
|
||||
SDL_Event SDL_event;
|
||||
|
||||
while ( !Close && SDL_PollEvent( &SDL_event ) )
|
||||
{
|
||||
|
@ -269,8 +272,12 @@ bool CIrrDeviceSDL::run()
|
|||
break;
|
||||
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (SDL_event.active.state == SDL_APPMOUSEFOCUS)
|
||||
WindowActive = (SDL_event.active.gain==1);
|
||||
if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) ||
|
||||
(SDL_event.active.state == SDL_APPINPUTFOCUS))
|
||||
WindowHasFocus = (SDL_event.active.gain==1);
|
||||
else
|
||||
if (SDL_event.active.state == SDL_APPACTIVE)
|
||||
WindowMinimized = (SDL_event.active.gain!=1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -293,7 +300,7 @@ void CIrrDeviceSDL::yield()
|
|||
//! pause execution for a specified time
|
||||
void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
|
||||
{
|
||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->stop();
|
||||
|
||||
|
@ -387,11 +394,24 @@ void CIrrDeviceSDL::setResizeAble(bool resize)
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceSDL::isWindowActive() const
|
||||
{
|
||||
return WindowActive;
|
||||
return (WindowHasFocus && !WindowMinimized);
|
||||
}
|
||||
|
||||
|
||||
//! returns if window has focus.
|
||||
bool CIrrDeviceSDL::isWindowFocused() const
|
||||
{
|
||||
return WindowHasFocus;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is minimized.
|
||||
bool CIrrDeviceSDL::isWindowMinimized() const
|
||||
{
|
||||
return WindowMinimized;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -158,16 +158,17 @@ namespace irr
|
|||
|
||||
void createKeyMap();
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
bool Resizeable;
|
||||
|
||||
SDL_Surface* Screen;
|
||||
SDL_Event SDL_event;
|
||||
int SDL_Flags;
|
||||
|
||||
s32 MouseX, MouseY;
|
||||
|
||||
u32 Width, Height;
|
||||
|
||||
bool Close;
|
||||
bool WindowActive;
|
||||
bool Resizeable;
|
||||
bool WindowHasFocus;
|
||||
bool WindowMinimized;
|
||||
|
||||
struct SKeyMap
|
||||
{
|
||||
|
|
|
@ -554,7 +554,7 @@ void CIrrDeviceWin32::yield()
|
|||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer)
|
||||
{
|
||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->stop();
|
||||
|
||||
|
@ -668,8 +668,7 @@ void CIrrDeviceWin32::closeDevice()
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
//! returns if window is active. if not, nothing needs to be drawn
|
||||
bool CIrrDeviceWin32::isWindowActive() const
|
||||
{
|
||||
bool ret = (GetActiveWindow() == HWnd);
|
||||
|
@ -678,6 +677,27 @@ bool CIrrDeviceWin32::isWindowActive() const
|
|||
}
|
||||
|
||||
|
||||
//! returns if window has focus
|
||||
bool CIrrDeviceWin32::isWindowFocused() const
|
||||
{
|
||||
bool ret = (GetFocus() == HWnd);
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is minimized
|
||||
bool CIrrDeviceWin32::isWindowMinimized() const
|
||||
{
|
||||
WINDOWPLACEMENT plc;
|
||||
plc.length=sizeof(WINDOWPLACEMENT);
|
||||
bool ret=false;
|
||||
if (GetWindowPlacement(HWnd,&plc))
|
||||
ret=(plc.showCmd & SW_SHOWMINIMIZED);
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! switches to fullscreen
|
||||
bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits)
|
||||
|
|
|
@ -43,6 +43,12 @@ namespace irr
|
|||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus
|
||||
virtual bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized
|
||||
virtual bool isWindowMinimized() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual void present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ void CIrrDeviceWinCE::yield()
|
|||
//! Pause execution and let other processes to run for a specified amount of time.
|
||||
void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
|
||||
{
|
||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||
if (pauseTimer && !wasStopped)
|
||||
Timer->stop();
|
||||
|
||||
|
@ -657,7 +657,6 @@ void CIrrDeviceWinCE::closeDevice()
|
|||
}
|
||||
|
||||
|
||||
|
||||
//! returns if window is active. if not, nothing need to be drawn
|
||||
bool CIrrDeviceWinCE::isWindowActive() const
|
||||
{
|
||||
|
@ -667,6 +666,27 @@ bool CIrrDeviceWinCE::isWindowActive() const
|
|||
}
|
||||
|
||||
|
||||
//! returns if window has focus
|
||||
bool CIrrDeviceWinCE::isWindowFocused() const
|
||||
{
|
||||
bool ret = (GetFocus() == HWnd);
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! returns if window is minimized
|
||||
bool CIrrDeviceWinCE::isWindowMinimized() const
|
||||
{
|
||||
WINDOWPLACEMENT plc;
|
||||
plc.length=sizeof(WINDOWPLACEMENT);
|
||||
bool ret=false;
|
||||
if (GetWindowPlacement(HWnd,&plc))
|
||||
ret=(plc.showCmd & SW_SHOWMINIMIZED);
|
||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! switches to fullscreen
|
||||
bool CIrrDeviceWinCE::switchToFullScreen()
|
||||
|
|
|
@ -49,6 +49,12 @@ namespace irr
|
|||
//! returns if window is active. if not, nothing need to be drawn
|
||||
virtual bool isWindowActive() const;
|
||||
|
||||
//! returns if window has focus
|
||||
virtual bool isWindowFocused() const;
|
||||
|
||||
//! returns if window is minimized
|
||||
virtual bool isWindowMinimized() const;
|
||||
|
||||
//! presents a surface in the client area
|
||||
virtual void present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue