summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 39cbc3d..cb25e94 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -8,9 +8,19 @@ Window::Window( const char* title, int w, int h, int x, int y )
{
printf( "Window could not be created: %s\n", SDL_GetError() );
}
+
+ close = new WindowClose();
+ focus = new WindowFocus();
+ unfocus = new WindowUnFocus();
+ nop = new Nop();
+
}
Window::~Window(){
+ delete close;
+ delete focus;
+ delete unfocus;
+ delete nop;
SDL_DestroyWindow( window_ );
}
@@ -28,18 +38,16 @@ void Window::toggleFullscreen(){
fullscreen_ = !fullscreen_;
}
-void Window::handleEvent(SDL_Event e){
+Command* Window::handleEvent(SDL_Event e){
switch( e.window.event ){
case SDL_WINDOWEVENT_CLOSE:
- closed_ = true;
- printf("CLOSE!");
- break;
+ return close;
case SDL_WINDOWEVENT_FOCUS_GAINED:
- focused_ = true;
- break;
+ return focus;
case SDL_WINDOWEVENT_FOCUS_LOST:
- focused_ = false;
- break;
+ return unfocus;
+ default:
+ return nop;
}
}
@@ -48,11 +56,3 @@ Point Window::getSize(){
SDL_GetWindowSize(window_, &size.x, &size.y);
return size;
}
-
-bool Window::focused(){
- return focused_;
-}
-
-bool Window::closed(){
- return closed_;
-}