summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-13 16:15:33 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-13 16:15:33 (GMT)
commit8c78d2c26c365014a58cafd17acd9242a35311db (patch)
treea218dd09f03933ff102f90b45505fdd7a0b8de50 /meme/gui.c
parent079480506feafde34833f5768834f4aee490cb7e (diff)
downloadmisc-8c78d2c26c365014a58cafd17acd9242a35311db.zip
misc-8c78d2c26c365014a58cafd17acd9242a35311db.tar.gz
misc-8c78d2c26c365014a58cafd17acd9242a35311db.tar.bz2
meme/gui.c: make window resizable and reduce initial size to 640 x 480
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/meme/gui.c b/meme/gui.c
index c5f6e61..ed03133 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -23,8 +23,8 @@
#include "plane.h"
-#define XRES 1280
-#define YRES 1024
+#define XRES 640
+#define YRES 480
#define SDL_SURFACE SDL_HWSURFACE
@@ -759,8 +759,9 @@ static void delayed_motion(void *user)
}
-static bool event_loop(SDL_Surface *s)
+static bool event_loop(SDL_Surface **surf)
{
+ SDL_Surface *s = *surf;
SDL_Event event;
cancel_timer(&motion_timer);
@@ -781,6 +782,12 @@ static bool event_loop(SDL_Surface *s)
case SDL_MOUSEBUTTONDOWN:
button_event(&event.button);
return 0;
+ case SDL_VIDEORESIZE:
+ xres = event.resize.w;
+ yres = event.resize.h;
+ *surf = SDL_SetVideoMode(xres, yres, 0,
+ SDL_SURFACE | SDL_RESIZABLE);
+ return 0;
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_g:
@@ -814,7 +821,7 @@ void gui(void)
}
atexit(SDL_Quit);
- surf = SDL_SetVideoMode(XRES, YRES, 0, SDL_SURFACE);
+ surf = SDL_SetVideoMode(XRES, YRES, 0, SDL_SURFACE | SDL_RESIZABLE);
if (!surf) {
fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError());
exit(1);
@@ -850,7 +857,7 @@ fprintf(stderr, "%.3f s @ zoom %d\n", time_ms(&t)/1000.0, zoom);
}
apply_changes(surf);
- if (event_loop(surf))
+ if (event_loop(&surf))
break;
}
}