src/SDL_hints.c
changeset 5555 3ecad5e5dbe4
parent 5535 96594ac5fd1a
child 6138 4c64952a58fb
     1.1 --- a/src/SDL_hints.c	Fri Jun 10 14:23:24 2011 +0100
     1.2 +++ b/src/SDL_hints.c	Fri Jun 10 14:23:36 2011 +0100
     1.3 @@ -21,6 +21,7 @@
     1.4  #include "SDL_config.h"
     1.5  
     1.6  #include "SDL_hints.h"
     1.7 +#include "SDL_hints_c.h"
     1.8  
     1.9  
    1.10  /* Assuming there aren't many hints set and they aren't being queried in
    1.11 @@ -30,11 +31,26 @@
    1.12      char *name;
    1.13      char *value;
    1.14      SDL_HintPriority priority;
    1.15 +    SDL_HintChangedCb callback;
    1.16      struct SDL_Hint *next;
    1.17  } SDL_Hint;
    1.18  
    1.19  static SDL_Hint *SDL_hints;
    1.20  
    1.21 +SDL_bool
    1.22 +SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb)
    1.23 +{
    1.24 +    SDL_Hint *hint;
    1.25 +	
    1.26 +    for (hint = SDL_hints; hint; hint = hint->next) {
    1.27 +        if (SDL_strcmp(name, hint->name) == 0) {
    1.28 +            hint->callback = hintCb;
    1.29 +            return SDL_TRUE;
    1.30 +        }
    1.31 +    }
    1.32 +	
    1.33 +    return SDL_FALSE;
    1.34 +}
    1.35  
    1.36  SDL_bool
    1.37  SDL_SetHintWithPriority(const char *name, const char *value,
    1.38 @@ -59,6 +75,9 @@
    1.39                  return SDL_FALSE;
    1.40              }
    1.41              if (SDL_strcmp(hint->value, value) != 0) {
    1.42 +                if (hint->callback != NULL) {
    1.43 +                    (*hint->callback)(name, hint->value, value);
    1.44 +                }
    1.45                  SDL_free(hint->value);
    1.46                  hint->value = SDL_strdup(value);
    1.47              }
    1.48 @@ -75,6 +94,7 @@
    1.49      hint->name = SDL_strdup(name);
    1.50      hint->value = SDL_strdup(value);
    1.51      hint->priority = priority;
    1.52 +    hint->callback = NULL;
    1.53      hint->next = SDL_hints;
    1.54      SDL_hints = hint;
    1.55      return SDL_TRUE;