#include "library.h" #include void slow() { printf("slow\n"); int s=0; for (int j=0; j<20; j+=1) for (int i=0; i<100000000; i+=1) s+=i*j; } /* First sample. Just click about with the mouse and keyboard while it is running, and you'll see how everything works. If you un-comment lines B and/or C you will see even more events, but they may be more than you want to handle to start with. */ void main() { make_window(600, 400); set_interesting_events(all_normal_events); // add_to_interesting_events(mouse_being_dragged); // Line B // add_to_interesting_events(mouse_movement); // Line C while (true) { event e = wait_for_interesting_event(); cout << e.kind << ": " << e.description() << " " << e.code << " '" << e.c << "' " << "(" << e.x << ", " << e.y << ") " << "(" << e.x0 << ", " << e.y0 << ") " << e.files << "\n"; if (e.kind==event::key_typed && e.c=='s') slow(); } } /* Second sample uses a thread for background processing struct threaddd: public thread { void main() { while (true) { event e = wait_for_interesting_event(); cout << e.kind << ": " << e.description() << " " << e.code << " '" << e.c << "' " << "(" << e.x << ", " << e.y << ") " << "(" << e.x0 << ", " << e.y0 << ") " << e.files << "\n"; } } }; void main() { make_window(600, 400); set_interesting_events(all_normal_events); // add_to_interesting_events(mouse_being_dragged); // add_to_interesting_events(mouse_movement); threaddd watcher; watcher.start(); while (true) { cout << "****\n"; slow(); } } */