- // fetch all songs
- pqxx::result res( t.exec("SELECT * FROM songs") );
- for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
- std::fprintf(stderr, "%s\n", i["title"].c_str());
+ if (mainscreen && mainscreen->check_invalidated()) {
+ if (screen->pitch == screen_width * 4) {
+ SDL_LockSurface(screen);
+ mainscreen->draw((unsigned char *)screen->pixels, screen_width, screen_height);
+ SDL_UnlockSurface(screen);
+ } else {
+ mainscreen->draw(framebuf, screen_width, screen_height);
+ SDL_LockSurface(screen);
+ for (unsigned y = 0; y < screen_height; ++y) {
+ unsigned char *sptr = framebuf + y * screen_width * 4;
+ unsigned char *dptr = (unsigned char *)screen->pixels + y * screen->pitch;
+ memcpy(dptr, sptr, screen_width * 4);
+ }
+ SDL_UnlockSurface(screen);
+ }
+ SDL_Flip(screen);
+ conn.await_notification(0, 10000);
+ } else {
+ SDL_Flip(screen);
+ conn.await_notification(0, 200000);
+ }
+}
+
+void handle_events()
+{
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+ if (event.type == SDL_QUIT) {
+ quit_requested = true;
+ }
+ if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_ESCAPE) {
+ quit_requested = true;
+ }