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. */
|
\return True if window is active. */
|
||||||
virtual bool isWindowActive() const = 0;
|
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.
|
//! Notifies the device that it should close itself.
|
||||||
/** IrrlichtDevice::run() will always return false after closeDevice() was called. */
|
/** IrrlichtDevice::run() will always return false after closeDevice() was called. */
|
||||||
virtual void closeDevice() = 0;
|
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),
|
display(0), visual(0), screennr(0), window(0), StdHints(0), SoftwareImage(0),
|
||||||
#endif
|
#endif
|
||||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
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
|
#ifdef _DEBUG
|
||||||
setDebugName("CIrrDeviceLinux");
|
setDebugName("CIrrDeviceLinux");
|
||||||
|
@ -529,7 +529,7 @@ bool CIrrDeviceLinux::createWindow()
|
||||||
XSetWMProtocols(display, window, &wmDelete, 1);
|
XSetWMProtocols(display, window, &wmDelete, 1);
|
||||||
XMapRaised(display, window);
|
XMapRaised(display, window);
|
||||||
}
|
}
|
||||||
WindowActive=true;
|
WindowMinimized=false;
|
||||||
XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport);
|
XkbSetDetectableAutoRepeat(display, True, &AutorepeatSupport);
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||||
|
@ -668,7 +668,6 @@ void CIrrDeviceLinux::createDriver()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! runs the device. Returns false if device wants to be deleted
|
//! runs the device. Returns false if device wants to be deleted
|
||||||
bool CIrrDeviceLinux::run()
|
bool CIrrDeviceLinux::run()
|
||||||
{
|
{
|
||||||
|
@ -722,11 +721,11 @@ bool CIrrDeviceLinux::run()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
WindowActive=true;
|
WindowHasFocus=true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
WindowActive=false;
|
WindowHasFocus=false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
@ -859,7 +858,7 @@ void CIrrDeviceLinux::yield()
|
||||||
//! Pause execution and let other processes to run for a specified amount of time.
|
//! Pause execution and let other processes to run for a specified amount of time.
|
||||||
void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
|
void CIrrDeviceLinux::sleep(u32 timeMs, bool pauseTimer=false)
|
||||||
{
|
{
|
||||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||||
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
ts.tv_sec = (time_t) (timeMs / 1000);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
bool CIrrDeviceLinux::isWindowActive() const
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
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
|
//! presents a surface in the client area
|
||||||
virtual void present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 );
|
virtual void present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 );
|
||||||
|
|
||||||
|
@ -305,7 +311,7 @@ namespace irr
|
||||||
#endif
|
#endif
|
||||||
u32 Width, Height;
|
u32 Width, Height;
|
||||||
bool Close;
|
bool Close;
|
||||||
bool WindowActive;
|
bool WindowHasFocus;
|
||||||
bool WindowMinimized;
|
bool WindowMinimized;
|
||||||
bool UseXVidMode;
|
bool UseXVidMode;
|
||||||
bool UseXRandR;
|
bool UseXRandR;
|
||||||
|
|
|
@ -38,10 +38,12 @@ const char* wmDeleteWindow = "WM_DELETE_WINDOW";
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
||||||
: CIrrDeviceStub(param), Resizeable(false),
|
: CIrrDeviceStub(param),
|
||||||
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_HWSURFACE|SDL_ANYFORMAT),
|
Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_HWSURFACE|SDL_ANYFORMAT),
|
||||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height), Close(0),
|
MouseX(0), MouseY(0),
|
||||||
WindowActive(false)
|
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
||||||
|
Close(0), Resizeable(false),
|
||||||
|
WindowHasFocus(false), WindowMinimized(false)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CIrrDeviceSDL");
|
setDebugName("CIrrDeviceSDL");
|
||||||
|
@ -197,6 +199,7 @@ bool CIrrDeviceSDL::run()
|
||||||
os::Timer::tick();
|
os::Timer::tick();
|
||||||
|
|
||||||
SEvent irrevent;
|
SEvent irrevent;
|
||||||
|
SDL_Event SDL_event;
|
||||||
|
|
||||||
while ( !Close && SDL_PollEvent( &SDL_event ) )
|
while ( !Close && SDL_PollEvent( &SDL_event ) )
|
||||||
{
|
{
|
||||||
|
@ -269,8 +272,12 @@ bool CIrrDeviceSDL::run()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_ACTIVEEVENT:
|
case SDL_ACTIVEEVENT:
|
||||||
if (SDL_event.active.state == SDL_APPMOUSEFOCUS)
|
if ((SDL_event.active.state == SDL_APPMOUSEFOCUS) ||
|
||||||
WindowActive = (SDL_event.active.gain==1);
|
(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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -293,7 +300,7 @@ void CIrrDeviceSDL::yield()
|
||||||
//! pause execution for a specified time
|
//! pause execution for a specified time
|
||||||
void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
|
void CIrrDeviceSDL::sleep(u32 timeMs, bool pauseTimer)
|
||||||
{
|
{
|
||||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||||
if (pauseTimer && !wasStopped)
|
if (pauseTimer && !wasStopped)
|
||||||
Timer->stop();
|
Timer->stop();
|
||||||
|
|
||||||
|
@ -387,11 +394,24 @@ void CIrrDeviceSDL::setResizeAble(bool resize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! returns if window is active. if not, nothing need to be drawn
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
bool CIrrDeviceSDL::isWindowActive() const
|
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();
|
void createKeyMap();
|
||||||
|
|
||||||
s32 MouseX, MouseY;
|
|
||||||
bool Resizeable;
|
|
||||||
|
|
||||||
SDL_Surface* Screen;
|
SDL_Surface* Screen;
|
||||||
SDL_Event SDL_event;
|
|
||||||
int SDL_Flags;
|
int SDL_Flags;
|
||||||
|
|
||||||
|
s32 MouseX, MouseY;
|
||||||
|
|
||||||
u32 Width, Height;
|
u32 Width, Height;
|
||||||
|
|
||||||
bool Close;
|
bool Close;
|
||||||
bool WindowActive;
|
bool Resizeable;
|
||||||
|
bool WindowHasFocus;
|
||||||
|
bool WindowMinimized;
|
||||||
|
|
||||||
struct SKeyMap
|
struct SKeyMap
|
||||||
{
|
{
|
||||||
|
|
|
@ -554,7 +554,7 @@ void CIrrDeviceWin32::yield()
|
||||||
//! Pause execution and let other processes to run for a specified amount of time.
|
//! Pause execution and let other processes to run for a specified amount of time.
|
||||||
void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer)
|
void CIrrDeviceWin32::sleep(u32 timeMs, bool pauseTimer)
|
||||||
{
|
{
|
||||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||||
if (pauseTimer && !wasStopped)
|
if (pauseTimer && !wasStopped)
|
||||||
Timer->stop();
|
Timer->stop();
|
||||||
|
|
||||||
|
@ -668,8 +668,7 @@ void CIrrDeviceWin32::closeDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! returns if window is active. if not, nothing needs to be drawn
|
||||||
//! returns if window is active. if not, nothing need to be drawn
|
|
||||||
bool CIrrDeviceWin32::isWindowActive() const
|
bool CIrrDeviceWin32::isWindowActive() const
|
||||||
{
|
{
|
||||||
bool ret = (GetActiveWindow() == HWnd);
|
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
|
//! switches to fullscreen
|
||||||
bool CIrrDeviceWin32::switchToFullScreen(s32 width, s32 height, s32 bits)
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
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
|
//! presents a surface in the client area
|
||||||
virtual void present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0);
|
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.
|
//! Pause execution and let other processes to run for a specified amount of time.
|
||||||
void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
|
void CIrrDeviceWinCE::sleep(u32 timeMs, bool pauseTimer)
|
||||||
{
|
{
|
||||||
bool wasStopped = Timer ? Timer->isStopped() : true;
|
const bool wasStopped = Timer ? Timer->isStopped() : true;
|
||||||
if (pauseTimer && !wasStopped)
|
if (pauseTimer && !wasStopped)
|
||||||
Timer->stop();
|
Timer->stop();
|
||||||
|
|
||||||
|
@ -657,7 +657,6 @@ void CIrrDeviceWinCE::closeDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! returns if window is active. if not, nothing need to be drawn
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
bool CIrrDeviceWinCE::isWindowActive() const
|
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
|
//! switches to fullscreen
|
||||||
bool CIrrDeviceWinCE::switchToFullScreen()
|
bool CIrrDeviceWinCE::switchToFullScreen()
|
||||||
|
|
|
@ -49,6 +49,12 @@ namespace irr
|
||||||
//! returns if window is active. if not, nothing need to be drawn
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
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
|
//! presents a surface in the client area
|
||||||
virtual void present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 );
|
virtual void present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue