# HG changeset patch # User Eris Caffee # Date 1289879746 21600 # Node ID 104dff305563e35d8e175d5883e19efc3f13ea57 # Parent 6fe9214af1515a86dece81e59365114756bebd9a Added App::on_InputFocus and app::on_InputBlur to make sure the program does not receive mouse clicks when not in foreground. Added option in CmakeLists.txt to support compiling for gprof. diff -r 6fe9214af151 -r 104dff305563 CMakeLists.txt --- a/CMakeLists.txt Sat Nov 13 00:39:47 2010 -0600 +++ b/CMakeLists.txt Mon Nov 15 21:55:46 2010 -0600 @@ -118,6 +118,15 @@ ################################################################################ + +option(Option_Profile_Program "Build for gprof profiling." OFF) +if (Option_Profile_Program) + add_definitions(-pg) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") +endif () + + +################################################################################ # The core project files file (GLOB SRCS src/*.c src/*.cpp) diff -r 6fe9214af151 -r 104dff305563 include/App.h --- a/include/App.h Sat Nov 13 00:39:47 2010 -0600 +++ b/include/App.h Mon Nov 15 21:55:46 2010 -0600 @@ -58,6 +58,8 @@ // Overrides of EventHandler: + void on_InputFocus(); + void on_InputBlur(); void on_KeyDown(SDL_KeyboardEvent key); void on_KeyUp(SDL_KeyboardEvent key); void on_MouseMove(SDL_MouseMotionEvent motion); diff -r 6fe9214af151 -r 104dff305563 include/EventHandler.h --- a/include/EventHandler.h Sat Nov 13 00:39:47 2010 -0600 +++ b/include/EventHandler.h Mon Nov 15 21:55:46 2010 -0600 @@ -38,9 +38,9 @@ public: EventHandler(); - virtual ~EventHandler(); + virtual ~EventHandler() = 0; - virtual void on_event(SDL_Event * event); + virtual void on_Event(SDL_Event * event); // Active events virtual void on_MouseFocus(); diff -r 6fe9214af151 -r 104dff305563 src/App.cpp --- a/src/App.cpp Sat Nov 13 00:39:47 2010 -0600 +++ b/src/App.cpp Mon Nov 15 21:55:46 2010 -0600 @@ -96,7 +96,7 @@ SDL_WaitEvent(&event); do { - on_event(&event); + on_Event(&event); } while (SDL_PollEvent(&event)); @@ -113,6 +113,7 @@ //////////////////////////////////////////////////////////////////////////////// + bool App::init() { if ((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) == -1) @@ -222,6 +223,26 @@ //////////////////////////////////////////////////////////////////////////////// +void App::on_InputFocus() + { + SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); + SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_ENABLE); + SDL_EventState(SDL_MOUSEBUTTONUP, SDL_ENABLE); + } + + +//////////////////////////////////////////////////////////////////////////////// + +void App::on_InputBlur() + { + SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); + SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); + SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); + } + + +//////////////////////////////////////////////////////////////////////////////// + void App::on_KeyDown(SDL_KeyboardEvent key) { switch (key.keysym.sym) diff -r 6fe9214af151 -r 104dff305563 src/EventHandler.cpp --- a/src/EventHandler.cpp Sat Nov 13 00:39:47 2010 -0600 +++ b/src/EventHandler.cpp Mon Nov 15 21:55:46 2010 -0600 @@ -41,7 +41,7 @@ //////////////////////////////////////////////////////////////////////////////// -void EventHandler::on_event(SDL_Event * event) +void EventHandler::on_Event(SDL_Event * event) { switch(event->type) {