-int reshape_called = 0, key_called = 0, special_called = 0, visibility_called = 0,
- keyup_called = 0, specialup_called = 0, joystick_called = 0, mouse_called = 0,
- mousewheel_called = 0, motion_called = 0, passivemotion_called = 0, entry_called = 0,
- close_called = 0, overlaydisplay_called = 0, windowstatus_called = 0,
- spacemotion_called = 0, spacerotation_called = 0, spacebutton_called = 0,
- buttonbox_called = 0, dials_called = 0, tabletmotion_called = 0, tabletbutton_called = 0,
- menudestroy_called = 0, menustatus_called = 0 ;
-int reshape_width = -1, reshape_height = -1, reshape_seq = -1 ;
-int key_key = -1, key_x = -1, key_y = -1, key_seq = -1 ;
-int special_key = -1, special_x = -1, special_y = -1, special_seq = -1 ;
-int visibility_vis = -1, visibility_seq = -1 ;
-int keyup_key = -1, keyup_x = -1, keyup_y = -1, keyup_seq = -1 ;
-int specialup_key = -1, specialup_x = -1, specialup_y = -1, specialup_seq = -1 ;
-int joystick_a = -1, joystick_b = -1, joystick_c = -1, joystick_d = -1, joystick_seq = -1 ; /* Need meaningful names */
-int mouse_button = -1, mouse_updown = -1, mouse_x = -1, mouse_y = -1, mouse_seq = -1 ;
-int mousewheel_number = -1, mousewheel_direction = -1, mousewheel_x = -1, mousewheel_y = -1, mousewheel_seq = -1 ;
-int motion_x = -1, motion_y = -1, motion_seq = -1 ;
-int passivemotion_x = -1, passivemotion_y = -1, passivemotion_seq = -1 ;
+int windows[2] = {0};
+
+/* define status vars showing whether given callback has been called for given window */
+#define CALLBACK_CALLED_VAR(name) int name##_called[2] = {0};
+#define CALLBACK_0V(name) int name##_seq[2] = {-1}; CALLBACK_CALLED_VAR(name);
+#define CALLBACK_1V(name,field) int name##_##field[2] = {-1}; CALLBACK_0V(name);
+#define CALLBACK_2V(name,field1,field2) int name##_##field2[2] = {-1}; CALLBACK_1V(name,field1);
+#define CALLBACK_3V(name,field1,field2,field3) int name##_##field3[2] = {-1}; CALLBACK_2V(name,field1,field2);
+#define CALLBACK_4V(name,field1,field2,field3,field4) int name##_##field4[2] = {-1}; CALLBACK_3V(name,field1,field2,field3);
+CALLBACK_2V(reshape,width,height);
+CALLBACK_2V(position,top,left);
+CALLBACK_3V(key,key,x,y);
+CALLBACK_3V(keyup,key,x,y);
+CALLBACK_3V(special,key,x,y);
+CALLBACK_3V(specialup,key,x,y);
+CALLBACK_1V(visibility,vis);
+CALLBACK_4V(joystick,a,b,c,d);
+CALLBACK_4V(mouse,button,updown,x,y);
+CALLBACK_4V(mousewheel,number,direction,x,y);
+CALLBACK_2V(motion,x,y);
+CALLBACK_2V(passivemotion,x,y);
+CALLBACK_0V(entry);
+CALLBACK_0V(close);
+/* menudestroy is registered on each menu, not a window */
+int menudestroy_called = 0 ;
+/* menustatus and menustate are global callbacks, set for all menus at the same time */
+int menustatus_called = 0;
+int menustate_called = 0;
+
+#define STRING_LENGTH 10