-/* unknownpleasures, Copyright (c) 2013 Jamie Zawinski <jwz@jwz.org>
+/* unknownpleasures, Copyright (c) 2013-2014 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Interestingly, the original image is copyright-free:
* http://adamcap.com/2011/05/19/history-of-joy-division-unknown-pleasures-album-art/
- * http://en.wikipedia.org/wiki/Unknown_Pleasures
+ * https://en.wikipedia.org/wiki/Unknown_Pleasures
*
* TODO:
*
"*wireframe: False \n" \
"*geometry: =800x800" "\n" \
-# define refresh_unk 0
+# define free_unk 0
# define release_unk 0
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
{
unk_configuration *bp = &bps[MI_SCREEN(mi)];
GLfloat h = (GLfloat) height / (GLfloat) width;
+ int y = 0;
- glViewport (0, 0, (GLint) width, (GLint) height);
+ if (width > height * 5) { /* tiny window: show middle */
+ height = width*1.5;
+ y = -height/2;
+ h = height / (GLfloat) width;
+ }
+
+ glViewport (0, y, (GLint) width, (GLint) height);
if (bp->orthop)
{
unk_configuration *bp = &bps[MI_SCREEN(mi)];
if (event->xany.type == ButtonPress &&
- event->xbutton.button == Button1)
- {
- bp->button_down_p = True;
- gltrackball_start (bp->trackball,
- event->xbutton.x, event->xbutton.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
- return True;
- }
- else if (event->xany.type == ButtonRelease &&
- event->xbutton.button == Button1)
- {
- bp->button_down_p = False;
- return True;
- }
- else if (event->xany.type == ButtonPress &&
- (event->xbutton.button == Button4 ||
- event->xbutton.button == Button5 ||
- event->xbutton.button == Button6 ||
- event->xbutton.button == Button7))
+ (event->xbutton.button == Button4 ||
+ event->xbutton.button == Button5 ||
+ event->xbutton.button == Button6 ||
+ event->xbutton.button == Button7))
{
int b = event->xbutton.button;
int speed = 1;
gltrackball_mousewheel (bp->trackball, b, speed, !!event->xbutton.state);
return True;
}
- else if (event->xany.type == MotionNotify &&
- bp->button_down_p)
+ else if (gltrackball_event_handler (event, bp->trackball,
+ MI_WIDTH (mi), MI_HEIGHT (mi),
+ &bp->button_down_p))
+ return True;
+ else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
{
- gltrackball_track (bp->trackball,
- event->xmotion.x, event->xmotion.y,
- MI_WIDTH (mi), MI_HEIGHT (mi));
+ bp->orthop = !bp->orthop;
+ reshape_unk (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
return True;
}
- else if (event->xany.type == KeyPress)
- {
- KeySym keysym;
- char c = 0;
- XLookupString (&event->xkey, &c, 1, &keysym, 0);
- if (c == ' ')
- {
- bp->orthop = !bp->orthop;
- reshape_unk (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
- return True;
- }
- return False;
- }
return False;
}
{
unk_configuration *bp;
- if (!bps) {
- bps = (unk_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (unk_configuration));
- if (!bps) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT (mi, bps);
bp = &bps[MI_SCREEN(mi)];
bp->count = MI_COUNT(mi);
if (bp->count < 1) bp->count = 1;
- bp->trackball = gltrackball_init ();
+ bp->trackball = gltrackball_init (False);
if (MI_COUNT(mi) < 1) MI_COUNT(mi) = 1;
xinc *= 3;
}
-# ifdef USE_IPHONE
+# ifdef HAVE_MOBILE
/* Lower it even further for iPhone 3 */
if (mi->xgwa.width <= 480 || mi->xgwa.height <= 480)
{
xinc *= 2;
*/
-# endif /* USE_IPHONE */
+# endif /* HAVE_MOBILE */
/* Make the image fill the screen a little more fully */