diff --git a/gb.sdl/src/Cwindow.cpp b/gb.sdl/src/Cwindow.cpp index 5caf76c52..d038335e6 100644 --- a/gb.sdl/src/Cwindow.cpp +++ b/gb.sdl/src/Cwindow.cpp @@ -215,6 +215,15 @@ BEGIN_PROPERTY(CWINDOW_id) END_PROPERTY +BEGIN_PROPERTY(Window_Grabbed) + + if (READ_PROPERTY) + GB.ReturnBoolean(WINDOWID->IsInputGrabbed()); + else + WINDOWID->GrabInput(VPROP(GB_BOOLEAN)); + +END_PROPERTY + /***************************************************************************/ GB_DESC CWindow[] = @@ -246,6 +255,7 @@ GB_DESC CWindow[] = GB_PROPERTY_READ("Handle", "i", CWINDOW_id), GB_PROPERTY_READ("Id", "i", CWINDOW_id), GB_PROPERTY_READ("Shown", "b", CWINDOW_shown), + GB_PROPERTY("Grabbed", "b", Window_Grabbed), GB_EVENT("Close", "b", NULL, &EVENT_Close), GB_EVENT("Resize", NULL, NULL, &EVENT_Resize), diff --git a/gb.sdl/src/SDLwindow.cpp b/gb.sdl/src/SDLwindow.cpp index 942cdd1c1..d44ff363c 100644 --- a/gb.sdl/src/SDLwindow.cpp +++ b/gb.sdl/src/SDLwindow.cpp @@ -98,6 +98,7 @@ void SDLwindow::Close() if (!hSurface) return; + GrabInput(false); SDLcore::RegisterWindow(NULL); hSurface = NULL; } @@ -256,3 +257,12 @@ bool SDLwindow::IsShown() return (false); } +void SDLwindow::GrabInput(bool grab) +{ + SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); +} + +bool SDLwindow::IsInputGrabbed(void) const +{ + return SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON; +} diff --git a/gb.sdl/src/SDLwindow.h b/gb.sdl/src/SDLwindow.h index 1f78154c6..8c87b92bb 100644 --- a/gb.sdl/src/SDLwindow.h +++ b/gb.sdl/src/SDLwindow.h @@ -66,6 +66,9 @@ public: bool IsResizable(void ) { return (hResizable); }; bool IsShown(void ); + void GrabInput(bool grab); + bool IsInputGrabbed(void) const; + // events :) virtual void Quit(void ) = 0; virtual void Resize(void ) = 0;