Skip to content

Commit

Permalink
Move prefs window event handling to global event context
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 1, 2016
1 parent d9cd1d7 commit a6f35e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/events.cpp
Expand Up @@ -448,12 +448,6 @@ void pump()
break;
}

// Hook into preferences event handling
// This probably isn't the right place for this but I really don't
// know where else to put it.
// - Vultraz, 12/28/2015
preferences::handle_event(event);

break;
#else
case SDL_ACTIVEEVENT: {
Expand Down
14 changes: 12 additions & 2 deletions src/preferences.cpp
Expand Up @@ -56,8 +56,18 @@ config prefs;

namespace preferences {

class prefs_event_handler : public events::sdl_handler {
public:
virtual void handle_event(const SDL_Event &event);
prefs_event_handler() : sdl_handler(false) {}
};

prefs_event_handler event_handler_;

base_manager::base_manager()
{
event_handler_.join_global();

try{
#ifdef DEFAULT_PREFS_PATH
filesystem::scoped_istream stream = filesystem::istream_file(filesystem::get_default_prefs_file(),false);
Expand Down Expand Up @@ -96,7 +106,7 @@ base_manager::~base_manager()
* events. Since there is no fullscreen window event, that setter is called
* from the CVideo function instead.
*/
void handle_event(const SDL_Event& event)
void prefs_event_handler::handle_event(const SDL_Event& event)
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
// Saftey check to make sure this is a window event
Expand All @@ -107,7 +117,7 @@ void handle_event(const SDL_Event& event)
case SDL_WINDOWEVENT_RESIZED:
_set_resolution(std::make_pair(event.window.data1,event.window.data2));

break;
break;

case SDL_WINDOWEVENT_MAXIMIZED:
_set_maximized(true);
Expand Down
2 changes: 0 additions & 2 deletions src/preferences.hpp
Expand Up @@ -39,8 +39,6 @@ namespace preferences {
~base_manager();
};

void handle_event(const SDL_Event& event);

void write_preferences();

void set(const std::string& key, const std::string &value);
Expand Down

0 comments on commit a6f35e5

Please sign in to comment.