void game_handle_sdl_events (void) { const size_t max_events = 256; size_t event; SDL_Event ev; for (event = 0; event < max_events; event++) { if (SDL_PollEvent (&ev) == 0) break; switch (ev.type) { case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: mouse_handle_event (&ev); break; case SDL_KEYUP: case SDL_KEYDOWN: keyboard_handle_event (&ev); break; case SDL_QUIT: game_quit (); } } }
void buttonpress(XEvent* event) { XButtonEvent* be = &(event->xbutton); HSDebug("name is: ButtonPress on sub %lx, win %lx\n", be->subwindow, be->window); if (mouse_binding_find(be->state, be->button)) { mouse_handle_event(event); } else { HSClient* client = get_client_from_window(be->window); if (client) { focus_client(client, false, true); if (*g_raise_on_click) { client_raise(client); } } } XAllowEvents(g_display, ReplayPointer, be->time); }
static void handle_events () { SDL_Event event; while (1 == SDL_PollEvent (&event)) { switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: if (keyboard_isr_is_installed) { keyboard_handle_event (&event.key); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_MOUSEMOTION: if (mouse_isr_is_installed) { mouse_handle_event (&event); } break; case SDL_QUIT: { enum { EXIT_STATUS = 10 }; exit_write (EXIT_STATUS); game_quit (); exit (EXIT_STATUS); } default: break; } } }