X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Frubikblocks.c;h=71682fc3f738039e7cc6cfcc495320438e828b53;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=54c4134137361bd820bc615942b3d790697cd686;hpb=b81f521c5ad7022ac12db18ca8fcdd9fb063831e;p=xscreensaver diff --git a/hacks/glx/rubikblocks.c b/hacks/glx/rubikblocks.c index 54c41341..71682fc3 100644 --- a/hacks/glx/rubikblocks.c +++ b/hacks/glx/rubikblocks.c @@ -19,7 +19,8 @@ #define DEFAULTS "*delay: 20000 \n" \ "*showFPS: False \n" \ - "*wireframe: False \n" + "*wireframe: False \n" \ + "*suppressRotationAnimation: True\n" \ # define refresh_rubikblocks 0 #include "xlockmore.h" @@ -128,7 +129,6 @@ static const GLfloat lmodel_ambient[] = {0.1, 0.1, 0.1, 1.0}; static const GLfloat material_ambient[] = {0.7, 0.7, 0.7, 1.0}; static const GLfloat material_diffuse[] = {0.7, 0.7, 0.7, 1.0}; static const GLfloat material_specular[] = {0.2, 0.2, 0.2, 1.0}; -static const GLfloat zpos = -18.0; /*************************************************************************/ @@ -260,13 +260,11 @@ draw_main(ModeInfo *mi, rubikblocks_conf *cp) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); + get_position(cp->rot, &x, &y, &z, !cp->button_down); glTranslatef((x-0.5)*6, (y-0.5)*6, -20); - /* Do it twice because we don't track the device's orientation. */ - glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate(cp->trackball); - glRotatef(-current_device_rotation(), 0, 0, 1); get_rotation(cp->rot, &x, &y, &z, !cp->button_down); glRotatef(x*360, 1, 0, 0); @@ -274,6 +272,15 @@ draw_main(ModeInfo *mi, rubikblocks_conf *cp) glRotatef(z*360, 0, 0, 1); glScalef(size, size, size); +# 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 + if(cp->wire) glColor3f(0.7, 0.7, 0.7); if(!cp->pause) for(i = 0; i < 27; i++) @@ -523,7 +530,7 @@ init_cp(rubikblocks_conf *cp) cp->rot = make_rotator(spin?spinspeed:0, spin?spinspeed:0, spin?spinspeed:0, 0.1, wander?wspeed:0, True); - cp->trackball = gltrackball_init(); + cp->trackball = gltrackball_init(True); if(rndstart) randomize(cp); } @@ -627,32 +634,12 @@ ENTRYPOINT Bool rubikblocks_handle_event (ModeInfo *mi, XEvent *event) { rubikblocks_conf *cp = &rubikblocks[MI_SCREEN(mi)]; - if(event->xany.type == ButtonPress && event->xbutton.button == Button1) - { - cp->button_down = True; - gltrackball_start(cp->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) - { - cp->button_down = 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(cp->trackball, - event->xbutton.button, 5, !!event->xbutton.state); - return True; - } - else if(event->xany.type == MotionNotify && cp->button_down) - { - gltrackball_track(cp->trackball, event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); + + if (gltrackball_event_handler (event, cp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &cp->button_down)) return True; - } + return False; }