diff options
Diffstat (limited to 'src/menu')
-rw-r--r-- | src/menu/application.cpp | 14 | ||||
-rw-r--r-- | src/menu/application.hpp | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/menu/application.cpp b/src/menu/application.cpp index f9be797f..55edd69c 100644 --- a/src/menu/application.cpp +++ b/src/menu/application.cpp @@ -102,7 +102,7 @@ namespace usdx SDL_Event event; EventManager event_manager; MouseManager mouse_manager(event_manager); - boost::thread event_thread(boost::bind(&EventManager::handle_events, &event_manager)); + event_thread = boost::thread(boost::bind(&EventManager::handle_events, &event_manager)); SoftwareMousePointer pointer(this, &event_manager); LoadingFrame frame(this); @@ -121,14 +121,12 @@ namespace usdx while (event_manager.available() && SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: - running = false; - event_thread.interrupt(); + quit(); break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_q) { - running = false; - event_thread.interrupt(); + quit(); break; } @@ -214,6 +212,12 @@ namespace usdx SDL_ShowCursor(SDL_ENABLE); } + void Application::quit(void) + { + running = false; + event_thread.interrupt(); + } + const int Application::get_frames_per_second(void) const { return frames_per_second; diff --git a/src/menu/application.hpp b/src/menu/application.hpp index c6eea5c8..a0c82107 100644 --- a/src/menu/application.hpp +++ b/src/menu/application.hpp @@ -57,6 +57,7 @@ namespace usdx */ void main_loop(SDL_Surface* display); boost::thread::id gl_thread; + boost::thread event_thread; void init_fps_manager(void); @@ -73,6 +74,7 @@ namespace usdx static bool is_gl_thread(void); void run(void); + void quit(void); const int get_frames_per_second(void) const; void set_frames_per_second(int fps); |