X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fgflux.c;h=1e6daed2578b16b090439049423b2659e0710ab3;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=f3829b59c707efa6960344dd2da98bf92fbf92d5;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/glx/gflux.c b/hacks/glx/gflux.c index f3829b59..1e6daed2 100644 --- a/hacks/glx/gflux.c +++ b/hacks/glx/gflux.c @@ -42,9 +42,9 @@ #ifdef STANDALONE #define DEFAULTS "*delay: 20000\n" \ "*showFPS: False\n" \ - "*mode: light\n" \ - "*useSHM: True \n" - + "*mode: grab\n" \ + "*useSHM: True \n" \ + "*suppressRotationAnimation: True\n" \ # define refresh_gflux 0 # include "xlockmore.h" /* from the xscreensaver distribution */ @@ -240,38 +240,16 @@ gflux_handle_event (ModeInfo *mi, XEvent *event) { gfluxstruct *gp = &gfluxes[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && - event->xbutton.button == Button1) - { - gp->button_down_p = True; - gltrackball_start (gp->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) - { - gp->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)) + if (gltrackball_event_handler (event, gp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &gp->button_down_p)) + return True; + else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) { - gltrackball_mousewheel (gp->trackball, event->xbutton.button, 10, - !!event->xbutton.state); - return True; - } - else if (event->xany.type == MotionNotify && - gp->button_down_p) - { - gltrackball_track (gp->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - return True; + if (_draw == grab) { + grabTexture(gp); + return True; + } } return False; @@ -281,10 +259,7 @@ gflux_handle_event (ModeInfo *mi, XEvent *event) static void userRot(gfluxstruct *gp) { - /* Do it twice because we don't track the device's orientation. */ - glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (gp->trackball); - glRotatef(-current_device_rotation(), 0, 0, 1); } /* draw the gflux once */ @@ -308,23 +283,26 @@ ENTRYPOINT void draw_gflux(ModeInfo * mi) } -/* reset the projection matrix */ -static void resetProjection(void) +/* Standard reshape function */ +ENTRYPOINT void +reshape_gflux(ModeInfo *mi, int width, int height) { + glViewport( 0, 0, width, height ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-_zoom,_zoom,-0.8*_zoom,0.8*_zoom,2,6); glTranslatef(0.0,0.0,-4.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); -} -/* Standard reshape function */ -ENTRYPOINT void -reshape_gflux(ModeInfo *mi, int width, int height) -{ - glViewport( 0, 0, width, height ); - resetProjection(); +# 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 (1/h, 1/h, 1/h); + } +# endif } @@ -387,13 +365,13 @@ ENTRYPOINT void init_gflux(ModeInfo * mi) } gp = &gfluxes[screen]; - gp->trackball = gltrackball_init (); + gp->trackball = gltrackball_init (True); gp->time = frand(1000.0); /* don't run two screens in lockstep */ { char *s = get_string_resource (mi->dpy, "mode", "Mode"); - if (!s || !*s) _draw = wire; + if (!s || !*s) _draw = grab; else if (!strcasecmp (s, "wire")) _draw = wire; else if (!strcasecmp (s, "solid")) _draw = solid; else if (!strcasecmp (s, "light")) _draw = light;