Skip to content

Commit

Permalink
Reimplement preference flag event handling in member function hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jan 1, 2016
1 parent c425bd8 commit 02b9928
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/events.cpp
Expand Up @@ -445,12 +445,15 @@ void pump()
case SDL_WINDOWEVENT_RESIZED:
info.resize_dimensions.first = event.window.data1;
info.resize_dimensions.second = event.window.data2;

preferences::_set_resolution(
std::make_pair(event.window.data1,event.window.data2));
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
15 changes: 15 additions & 0 deletions src/preferences.cpp
Expand Up @@ -91,6 +91,21 @@ base_manager::~base_manager()
} catch (...) {}
}

/*
* Hook for setting window state variables on window resize and maximize
* events. Since there is no fullscreen window event, that setter is called
* from the CVideo function instead.
*/
void handle_event(const SDL_Event& event)
{
switch(event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
_set_resolution(std::make_pair(event.window.data1,event.window.data2));

break;
}
}

void write_preferences()
{
#ifndef _WIN32
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.hpp
Expand Up @@ -22,6 +22,8 @@ class display;

#include "terrain_translation.hpp"

#include "SDL.h"

#include <utility>

namespace hotkey {
Expand All @@ -37,6 +39,8 @@ 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 02b9928

Please sign in to comment.