sgl
diff src/cb.c @ 4:648f8604d2b2
cont. x11 module
author | John Tsiombikas <nuclear@siggraph.org> |
---|---|
date | Thu, 12 May 2011 11:04:10 +0300 |
parents | 40491760d6e3 |
children | 0570e27e5ebc |
line diff
1.1 --- a/src/cb.c Wed May 11 09:09:43 2011 +0300 1.2 +++ b/src/cb.c Thu May 12 11:04:10 2011 +0300 1.3 @@ -1,12 +1,15 @@ 1.4 #include <stdlib.h> 1.5 #include <string.h> 1.6 #include "sgl.h" 1.7 +#include "wsys.h" 1.8 1.9 struct cbnode { 1.10 void (*func[SGL_NUM_CALLBACKS])(); 1.11 struct cbnode *next; 1.12 }; 1.13 1.14 +static void notify_wsys(void); 1.15 + 1.16 struct cbnode first_cbnode; 1.17 struct cbnode *cb = &first_cbnode; 1.18 1.19 @@ -34,17 +37,36 @@ 1.20 node = cb; 1.21 cb = cb->next; 1.22 free(node); 1.23 + 1.24 + notify_wsys(); 1.25 return 0; 1.26 } 1.27 1.28 void sgl_clear_callbacks(void) 1.29 { 1.30 memset(cb->func, 0, sizeof cb->func); 1.31 + notify_wsys(); 1.32 } 1.33 1.34 -void (*sgl_callback(int idx, void (*func)()))() 1.35 +void sgl_callback(int idx, void (*func)()) 1.36 { 1.37 - void (*prev)() = cb->func[idx]; 1.38 cb->func[idx] = func; 1.39 - return prev; 1.40 } 1.41 + 1.42 +void (*sgl_get_callback(int idx))() 1.43 +{ 1.44 + return cb->func[idx]; 1.45 +} 1.46 + 1.47 +/* notify the window system module as to which events are active */ 1.48 +static void notify_wsys(void) 1.49 +{ 1.50 + int i; 1.51 + struct wsys_module *ws; 1.52 + 1.53 + if((ws = sgl_wsys_module())) { 1.54 + for(i=0; i<SGL_NUM_CALLBACKS; i++) { 1.55 + ws->set_event(i, cb->func[i] != 0); 1.56 + } 1.57 + } 1.58 +}