X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fantspotlight.c;h=55bb80cd51158d03db785e586be717a6fef5bcf5;hb=39809ded547bdbb08207d3e514950425215b4410;hp=cec2676d9a33b20befbf845b283aeb3b536b45b0;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/hacks/glx/antspotlight.c b/hacks/glx/antspotlight.c index cec2676d..55bb80cd 100644 --- a/hacks/glx/antspotlight.c +++ b/hacks/glx/antspotlight.c @@ -19,13 +19,14 @@ "*showFPS: False \n" \ "*useSHM: True \n" -# define refresh_antspotlight 0 +# define free_antspotlight 0 +# define release_antspotlight 0 #include "xlockmore.h" #else #include "xlock.h" #endif -#ifdef HAVE_COCOA +#ifdef HAVE_JWXYZ # include "jwxyz.h" #else # include @@ -49,7 +50,7 @@ ENTRYPOINT ModeSpecOpt antspotlight_opts = { #ifdef USE_MODULES ModStruct antspotlight_description = { "antspotlight", "init_antspotlight", "draw_antspotlight", - "release_antspotlight", "draw_antspotlight", "change_antspotlight", + (char *) NULL, "draw_antspotlight", "change_antspotlight", (char *) NULL, &antspotlight_opts, 1000, 1, 1, 1, 4, 1.0, "", "draws an ant scoping the screen", 0, NULL }; @@ -551,8 +552,16 @@ static void draw_antspotlight_strip(ModeInfo *mi) ENTRYPOINT void reshape_antspotlight(ModeInfo * mi, int width, int height) { double h = (GLfloat) height / (GLfloat) width; + int y = 0; int size = 2; - glViewport(0, 0, width, height); + + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport(0, y, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -617,18 +626,6 @@ static void pinit(void) glEnable(GL_DEPTH_TEST); } -/* cleanup routine */ -ENTRYPOINT void release_antspotlight(ModeInfo * mi) -{ - - if(antspotlight) { - free((void *) antspotlight); - antspotlight = (antspotlightstruct *) NULL; - } - - FreeAllGL(mi); -} - #define MAX_MAGNIFICATION 10 #define max(a, b) a < b ? b : a #define min(a, b) a < b ? a : b @@ -638,51 +635,33 @@ ENTRYPOINT Bool antspotlight_handle_event(ModeInfo *mi, XEvent *event) { antspotlightstruct *mp = &antspotlight[MI_SCREEN(mi)]; - switch(event->xany.type) { - case ButtonPress: - - switch(event->xbutton.button) { - - case Button1: - mp->button_down_p = True; - gltrackball_start(mp->trackball, - event->xbutton.x, event->xbutton.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - break; + if (gltrackball_event_handler (event, mp->trackball, + MI_WIDTH (mi), MI_HEIGHT (mi), + &mp->button_down_p)) + return True; + + if (event->xany.type == ButtonPress) + { + switch(event->xbutton.button) { + + case Button1: + mp->button_down_p = True; + gltrackball_start(mp->trackball, + event->xbutton.x, event->xbutton.y, + MI_WIDTH (mi), MI_HEIGHT (mi)); + return True; - case Button4: - mp->mag = max(mp->mag-1, 1); - break; - - case Button5: - mp->mag = min(mp->mag+1, MAX_MAGNIFICATION); - break; + case Button4: + mp->mag = max(mp->mag-1, 1); + return True; + + case Button5: + mp->mag = min(mp->mag+1, MAX_MAGNIFICATION); + return True; + } } - break; - - case ButtonRelease: - - switch(event->xbutton.button) { - case Button1: - mp->button_down_p = False; - break; - } - - break; - - case MotionNotify: - if(mp->button_down_p) - gltrackball_track(mp->trackball, - event->xmotion.x, event->xmotion.y, - MI_WIDTH (mi), MI_HEIGHT (mi)); - break; - - default: - return False; - } - - return True; + return False; } static void @@ -726,14 +705,10 @@ ENTRYPOINT void init_antspotlight(ModeInfo *mi) antspotlightstruct *mp; - if(!antspotlight) { - if((antspotlight = (antspotlightstruct *) - calloc(MI_NUM_SCREENS(mi), sizeof (antspotlightstruct))) == NULL) - return; - } + MI_INIT(mi, antspotlight); mp = &antspotlight[MI_SCREEN(mi)]; mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True); - mp->trackball = gltrackball_init (); + mp->trackball = gltrackball_init (False); if((mp->glx_context = init_GL(mi)) != NULL) { reshape_antspotlight(mi, MI_WIDTH(mi), MI_HEIGHT(mi));