Edit

IABSD.fr/xenocara/app/xlockmore/modes/nose.c

Branch :

  • Show log

    Commit

  • Author : matthieu
    Date : 2006-11-26 11:07:42
    Hash : 110b2a92
    Message : Importing xlockmore 5.22

  • app/xlockmore/modes/nose.c
  • /* -*- Mode: C; tab-width: 4 -*- */
    /*-
     * nose --- a little guy with a big nose and a hat wanders around
     *          spewing out messages
     */
    
    #if !defined( lint ) && !defined( SABER )
    static const char sccsid[] = "@(#)nose.c	5.00 2000/11/01 xlockmore";
    
    #endif
    
    /*-
     * Permission to use, copy, modify, and distribute this software and its
     * documentation for any purpose and without fee is hereby granted,
     * provided that the above copyright notice appear in all copies and that
     * both that copyright notice and this permission notice appear in
     * supporting documentation.
     *
     * This file is provided AS IS with no warranties of any kind.  The author
     * shall have no liability with respect to the infringement of copyrights,
     * trade secrets or any patents by this file or any part thereof.  In no
     * event will the author be liable for any lost revenue or profits or
     * other special, indirect and consequential damages.
     *
     * Revision History:
     * 01-Nov-2000: Allocation checks
     * 06-Jun-1997: Compatible with xscreensaver and now colorized (idea from
     *              xscreensaver but colors are random).
     * 27-Feb-1996: Added new ModeInfo arg to init and callback hooks.  Removed
     *              references to onepause, now uses MI_PAUSE(mi) interface.
     *              Ron Hitchens <ron@idiom.com>
     * 10-Oct-1995: A better way of handling fortunes from a file, thanks to
     *              Jouk Jansen <joukj@hrem.stm.tudelft.nl>.
     * 21-Sep-1995: font option added, debugged for multiscreens
     * 12-Aug-1995: xlock version
     * 1992: xscreensaver version, noseguy (Jamie Zawinski <jwz@jwz.org>)
     * 1990: X11 version, xnlock (Dan Heller <argv@sun.com>)
     */
    
    /*-
     * xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
     *
     * Permission to use, copy, modify, distribute, and sell this software and its
     * documentation for any purpose is hereby granted without fee, provided that
     * the above copyright notice appear in all copies and that both that
     * copyright notice and this permission notice appear in supporting
     * documentation.  No representations are made about the suitability of this
     * software for any purpose.  It is provided "as is" without express or
     * implied warranty.
     */
    
    #ifdef STANDALONE
    #define MODE_nose
    #define PROGCLASS "Nose"
    #define HACK_INIT init_nose
    #define HACK_DRAW draw_nose
    #define nose_opts xlockmore_opts
    #define DEFAULTS "*delay: 100000 \n" \
     "*ncolors: 64 \n" \
     "*font: \n" \
     "*text: \n" \
     "*filename: \n" \
     "*fortunefile: \n" \
     "*program: \n"
    #define UNIFORM_COLORS
    #include "xlockmore.h"		/* in xscreensaver distribution */
    #else /* STANDALONE */
    #include "xlock.h"		/* in xlockmore distribution */
    #endif /* STANDALONE */
    #include "iostuff.h"
    
    #ifdef MODE_nose
    
    ModeSpecOpt nose_opts =
    {0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL};
    
    #ifdef USE_MODULES
    ModStruct   nose_description =
    {"nose", "init_nose", "draw_nose", "release_nose",
     "refresh_nose", "init_nose", (char *) NULL, &nose_opts,
     100000, 1, 1, 1, 64, 1.0, "",
     "Shows a man with a big nose runs around spewing out messages", 0, NULL};
    
    #endif
    
    #include "bitmaps/nose-hat.xbm"
    #include "bitmaps/nose-hatd.xbm"
    #include "bitmaps/nose-facef.xbm"
    #include "bitmaps/nose-faced.xbm"
    #include "bitmaps/nose-facel.xbm"
    #include "bitmaps/nose-facer.xbm"
    #include "bitmaps/nose-shoef.xbm"
    #include "bitmaps/nose-shoel.xbm"
    #include "bitmaps/nose-shoer.xbm"
    #include "bitmaps/nose-stepl.xbm"
    #include "bitmaps/nose-stepr.xbm"
    
    #define L 0
    #define R 1
    #define LSTEP 2
    #define RSTEP 3
    #define LF 4
    #define RF 5
    #define F 6
    #define D 7
    #define PIXMAPS 8
    #define PIXMAP_SIZE 64
    #define MOVE 0
    #define TALK 1
    #define FREEZE 2
    
    #ifndef USE_MB
    extern XFontStruct *getFont(Display * display);
    #else
    extern XFontSet getFontSet(Display * display);
    #endif
    extern char *getWords(int screen, int screens);
    extern int  isRibbon(void);
    
    typedef struct {
    	int         x, y, width, height;
    } window_rect;
    
    typedef struct {
    	int         xs, ys;
    	int         width, height;
    	GC          text_fg_gc, text_bg_gc, noseGC[PIXMAPS];
    	char       *words;
    	int         x, y;
    	int         tinymode;	/* walking or getting passwd */
    	int         length, dir, lastdir;
    	int         up;
    	int         busyLoop;
    	int         frames;
    	int         state;
    	Bool        talking;
    	window_rect s;
    	Pixmap      position[PIXMAPS];
    } nosestruct;
    
    static nosestruct *noses = (nosestruct *) NULL;
    
    #ifdef USE_MB
    static XFontSet mode_font = None;
    #else
    static XFontStruct *mode_font = None;
    #endif
    
    #ifdef USE_MB
    static int font_height(XFontSet f) {
      XRectangle ink, log;
      if (f == None) {
    	return 8;
      } else {
    	XmbTextExtents(mode_font, "M