X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fstonerview.c;h=e504709d7b7e0dcff8dd9583b86a4b8f1f10e4b7;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=dc578622d60f44a7008103397c53ce90e50249fd;hpb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;p=xscreensaver diff --git a/hacks/glx/stonerview.c b/hacks/glx/stonerview.c index dc578622..e504709d 100644 --- a/hacks/glx/stonerview.c +++ b/hacks/glx/stonerview.c @@ -35,6 +35,8 @@ #include "stonerview.h" #include "gltrackball.h" +#define DEF_TRANSPARENT "True" + typedef struct { GLXContext *glx_context; stonerview_state *st; @@ -44,7 +46,19 @@ typedef struct { static stonerview_configuration *bps = NULL; -ENTRYPOINT ModeSpecOpt stonerview_opts = {0, NULL, 0, NULL, NULL}; +static Bool transparent_p; + + +static XrmOptionDescRec opts[] = { + { "-transparent", ".transparent", XrmoptionNoArg, "True" }, + { "+transparent", ".transparent", XrmoptionNoArg, "False" }, +}; + +static argtype vars[] = { + {&transparent_p, "transparent", "Transparent", DEF_TRANSPARENT, t_Bool}, +}; + +ENTRYPOINT ModeSpecOpt stonerview_opts = {countof(opts), opts, countof(vars), vars, NULL}; ENTRYPOINT void @@ -74,19 +88,18 @@ init_stonerview (ModeInfo *mi) fprintf(stderr, "%s: out of memory\n", progname); exit(1); } - - bp = &bps[MI_SCREEN(mi)]; } bp = &bps[MI_SCREEN(mi)]; bp->glx_context = init_GL(mi); - bp->trackball = gltrackball_init (); - bp->st = init_view(MI_IS_WIREFRAME(mi)); - init_move(bp->st); + bp->trackball = gltrackball_init (False); + bp->st = stonerview_init_view(MI_IS_WIREFRAME(mi), transparent_p); + stonerview_init_move(bp->st); reshape_stonerview (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); + clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */ } @@ -98,10 +111,12 @@ draw_stonerview (ModeInfo *mi) glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context)); glPushMatrix (); + glRotatef( current_device_rotation(), 0, 0, 1); gltrackball_rotate (bp->trackball); - win_draw(bp->st); + + stonerview_win_draw(bp->st); if (! bp->button_down_p) - move_increment(bp->st); + stonerview_move_increment(bp->st); glPopMatrix (); mi->polygon_count = NUM_ELS; @@ -119,7 +134,7 @@ release_stonerview (ModeInfo *mi) for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { stonerview_configuration *bp = &bps[screen]; if (bp->st) - win_release (bp->st); + stonerview_win_release (bp->st); } free (bps); bps = 0; @@ -132,39 +147,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; }