X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstonerview.c;h=880ef01b78cc1c9e48a197489ea3e4df621fd3b8;hb=39809ded547bdbb08207d3e514950425215b4410;hp=0e11395e2ace623c7c2b8c2603daddba80e4e598;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/glx/stonerview.c b/hacks/glx/stonerview.c index 0e11395e..880ef01b 100644 --- a/hacks/glx/stonerview.c +++ b/hacks/glx/stonerview.c @@ -24,7 +24,7 @@ "*showFPS: False \n" \ "*wireframe: False \n" -# define refresh_stonerview 0 +# define release_stonerview 0 #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -81,20 +81,13 @@ init_stonerview (ModeInfo *mi) { stonerview_configuration *bp; - if (!bps) { - bps = (stonerview_configuration *) - calloc (MI_NUM_SCREENS(mi), sizeof (stonerview_configuration)); - if (!bps) { - fprintf(stderr, "%s: out of memory\n", progname); - exit(1); - } - } + MI_INIT (mi, bps); bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); - bp->trackball = gltrackball_init (); + bp->trackball = gltrackball_init (False); bp->st = stonerview_init_view(MI_IS_WIREFRAME(mi), transparent_p); stonerview_init_move(bp->st); @@ -114,6 +107,15 @@ draw_stonerview (ModeInfo *mi) glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (bp->trackball); +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (h, h, h); + } +# endif + stonerview_win_draw(bp->st); if (! bp->button_down_p) stonerview_move_increment(bp->st); @@ -127,19 +129,11 @@ draw_stonerview (ModeInfo *mi) } ENTRYPOINT void -release_stonerview (ModeInfo *mi) +free_stonerview (ModeInfo *mi) { - if (bps) { - int screen; - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { - stonerview_configuration *bp = &bps[screen]; - if (bp->st) - stonerview_win_release (bp->st); - } - free (bps); - bps = 0; - } - FreeAllGL(mi); + stonerview_configuration *bp = &bps[MI_SCREEN(mi)]; + if (bp->st) + stonerview_win_release (bp->st); } ENTRYPOINT Bool @@ -147,39 +141,10 @@ stonerview_handle_event (ModeInfo *mi, XEvent *event) { stonerview_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)) - { - gltrackball_mousewheel (bp->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == MotionNotify && - bp->button_down_p) - { - gltrackball_track (bp->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; - } + if (gltrackball_event_handler (event, bp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &bp->button_down_p)) + return True; return False; }