~ubuntu-branches/debian/sid/xscreensaver/sid

« back to all changes in this revision

Viewing changes to hacks/glx/fliptext.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Rivas, Tormod Volden, Jose Luis Rivas
  • Date: 2008-07-15 14:48:48 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080715144848-c6c6mhyxij0dk2p7
Tags: 5.05-3
[ Tormod Volden ]
* debian/patches/10_jwz-xscreensaver-randr-patch-3.patch:
  from upstream, addresses issues with xrandr/xinerama
  (Closes: #482385, #428797, #471920, #453708, #473681, #479715, #480231)
* fixed typo "screen < real_nscreens" in driver/lock:1527 from above patch
* drop 61_DualHead-nVidia_bug471920.patch (obsolete)
* drop 67_XineRama-mode_bug473681.patch (obsolete)
* fix m6502.o typo in hacks/Makefile.in
* refresh 53_XScreenSaver.ad.in.patch
* refresh (disabled) 60_add-ant-hack.patch

[ Jose Luis Rivas ]
* add xscreensaver-demo desktop file, thanks to Daniel Dickinson
  (Closes: #480592)
* update package descriptions (thanks jwz)
* fix categories in xscreensaver.menu
* change build-deps from xlibmesa-gl-dev to libgl1-mesa-dev,
  xutils to xutils-dev, x-dev to x11proto-core-dev.
* bump Standards-Version to 3.8.0
* add Vcs fields and Homepage to debian/control
* Flurry is not installed until the bug get fixed (Closes: #484112)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * fliptext, Copyright (c) 2005 Jamie Zawinski <jwz@jwz.org>
 
2
 * fliptext, Copyright (c) 2005-2007 Jamie Zawinski <jwz@jwz.org>
3
3
 *
4
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
5
 * documentation for any purpose is hereby granted without fee, provided that
10
10
 * implied warranty.
11
11
 */
12
12
 
13
 
#include <X11/Intrinsic.h>
14
 
 
15
 
extern XtAppContext app;
16
 
 
17
 
#define PROGCLASS       "FlipText"
18
 
#define HACK_INIT       init_fliptext
19
 
#define HACK_DRAW       draw_fliptext
20
 
#define HACK_RESHAPE    reshape_fliptext
21
 
#define fliptext_opts   xlockmore_opts
22
 
 
23
 
#define DEF_PROGRAM    "xscreensaver-text --cols 0"  /* don't wrap */
24
 
#define DEF_LINES      "8"
25
 
#define DEF_FONT_SIZE  "20"
26
 
#define DEF_COLUMNS    "80"
27
 
#define DEF_ALIGN      "random"
28
 
#define DEF_COLOR      "#00CCFF"
29
 
#define DEF_SPEED       "1.0"
 
13
#ifdef HAVE_CONFIG_H
 
14
# include "config.h"
 
15
#endif /* HAVE_CONFIG_H */
 
16
 
 
17
#include <ctype.h>
 
18
#include <sys/stat.h>
 
19
 
 
20
#ifndef HAVE_COCOA
 
21
# include <X11/Intrinsic.h>
 
22
#endif
 
23
 
 
24
#ifdef HAVE_UNISTD_H
 
25
# include <unistd.h>
 
26
#endif
 
27
 
 
28
#ifdef HAVE_UNAME
 
29
# include <sys/utsname.h>
 
30
#endif /* HAVE_UNAME */
 
31
 
30
32
 
31
33
/* Utopia 800 needs 64 512x512 textures (4096x4096 bitmap).
32
34
   Utopia 720 needs 16 512x512 textures (2048x2048 bitmap).
36
38
   Times  240 needs  1 512x512 texture.
37
39
 */
38
40
#define DEF_FONT       "-*-utopia-bold-r-normal-*-*-720-*-*-*-*-iso8859-1"
39
 
 
40
 
#define TAB_WIDTH        8
41
 
 
42
 
#define FONT_WEIGHT       14
43
 
#define KEEP_ASPECT
 
41
#define DEF_COLOR      "#00CCFF"
44
42
 
45
43
#define DEFAULTS "*delay:        10000      \n" \
46
44
                 "*showFPS:      False      \n" \
48
46
                 "*font:       " DEF_FONT  "\n" \
49
47
                 ".foreground: " DEF_COLOR "\n" \
50
48
 
 
49
# define refresh_fliptext 0
 
50
# define fliptext_handle_event 0
51
51
#undef countof
52
52
#define countof(x) (sizeof((x))/sizeof((*x)))
53
53
 
55
55
#define BELLRAND(n) ((frand((n)) + frand((n)) + frand((n))) / 3)
56
56
 
57
57
#include "xlockmore.h"
 
58
#include "texfont.h"
58
59
 
59
60
#ifdef USE_GL /* whole file */
60
61
 
61
 
#include <ctype.h>
62
 
#include <GL/glu.h>
63
 
#include <sys/stat.h>
64
 
#include "texfont.h"
65
 
 
66
 
#ifdef HAVE_UNAME
67
 
# include <sys/utsname.h>
68
 
#endif /* HAVE_UNAME */
 
62
/* Should be in <GL/glext.h> */
 
63
# ifndef  GL_TEXTURE_MAX_ANISOTROPY_EXT
 
64
#  define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
 
65
# endif
 
66
# ifndef  GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
 
67
#  define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
 
68
# endif
 
69
 
 
70
 
 
71
#define DEF_PROGRAM    "xscreensaver-text --cols 0"  /* don't wrap */
 
72
#define DEF_LINES      "8"
 
73
#define DEF_FONT_SIZE  "20"
 
74
#define DEF_COLUMNS    "80"
 
75
#define DEF_ALIGN      "random"
 
76
#define DEF_SPEED       "1.0"
 
77
#define TAB_WIDTH        8
 
78
 
 
79
#define FONT_WEIGHT       14
 
80
#define KEEP_ASPECT
69
81
 
70
82
typedef enum { NEW, HESITATE, IN, LINGER, OUT, DEAD } line_state;
71
83
typedef enum { SCROLL_BOTTOM, SCROLL_TOP, SPIN } line_anim_type;
89
101
 
90
102
 
91
103
typedef struct {
 
104
  Display *dpy;
92
105
  GLXContext *glx_context;
93
106
 
94
107
  texture_font_data *texfont;
95
108
 
96
109
  FILE *pipe;
97
110
  XtInputId pipe_id;
 
111
  XtIntervalId pipe_timer;
98
112
  Time subproc_relaunch_delay;
99
113
 
100
114
  char *buf;
139
153
  {"-columns",     ".columns",   XrmoptionSepArg, 0 },
140
154
  {"-speed",       ".speed",     XrmoptionSepArg, 0 },
141
155
/*{"-font",        ".font",      XrmoptionSepArg, 0 },*/
 
156
  {"-alignment",   ".alignment", XrmoptionSepArg, 0 },
142
157
  {"-left",        ".alignment", XrmoptionNoArg,  "Left"   },
143
158
  {"-right",       ".alignment", XrmoptionNoArg,  "Right"  },
144
159
  {"-center",      ".alignment", XrmoptionNoArg,  "Center" },
153
168
  {&speed,          "speed",     "Speed",      DEF_SPEED,     t_Float},
154
169
};
155
170
 
156
 
ModeSpecOpt fliptext_opts = {countof(opts), opts, countof(vars), vars, NULL};
 
171
ENTRYPOINT ModeSpecOpt fliptext_opts = {countof(opts), opts, countof(vars), vars, NULL};
157
172
 
158
173
 
159
174
 
236
251
static void
237
252
launch_text_generator (fliptext_configuration *sc)
238
253
{
239
 
  char *oprogram = get_string_resource ("program", "Program");
 
254
  XtAppContext app = XtDisplayToApplicationContext (sc->dpy);
 
255
  char *oprogram = get_string_resource (sc->dpy, "program", "Program");
240
256
  char *program = (char *) malloc (strlen (oprogram) + 10);
241
257
  strcpy (program, "( ");
242
258
  strcat (program, oprogram);
260
276
relaunch_generator_timer (XtPointer closure, XtIntervalId *id)
261
277
{
262
278
  fliptext_configuration *sc = (fliptext_configuration *) closure;
 
279
  if (!sc->pipe_timer) abort();
 
280
  sc->pipe_timer = 0;
263
281
  launch_text_generator (sc);
264
282
}
265
283
 
270
288
static void
271
289
drain_input (fliptext_configuration *sc)
272
290
{
 
291
  XtAppContext app = XtDisplayToApplicationContext (sc->dpy);
273
292
  if (sc->buf_tail < sc->buf_size - 2)
274
293
    {
275
294
      int target = sc->buf_size - sc->buf_tail - 2;
306
325
          sc->buf[sc->buf_tail] = 0;
307
326
 
308
327
          /* Set up a timer to re-launch the subproc in a bit. */
309
 
          XtAppAddTimeOut (app, sc->subproc_relaunch_delay,
310
 
                           relaunch_generator_timer,
311
 
                           (XtPointer) sc);
 
328
          sc->pipe_timer = XtAppAddTimeOut (app, sc->subproc_relaunch_delay,
 
329
                                            relaunch_generator_timer,
 
330
                                            (XtPointer) sc);
312
331
        }
313
332
    }
314
333
}
846
865
 
847
866
/* Window management, etc
848
867
 */
849
 
void
 
868
ENTRYPOINT void
850
869
reshape_fliptext (ModeInfo *mi, int width, int height)
851
870
{
852
871
  fliptext_configuration *sc = &scs[MI_SCREEN(mi)];
871
890
}
872
891
 
873
892
 
874
 
void 
 
893
ENTRYPOINT void 
875
894
init_fliptext (ModeInfo *mi)
876
895
{
877
896
  int wire = MI_IS_WIREFRAME(mi);
891
910
  }
892
911
 
893
912
  sc = &scs[MI_SCREEN(mi)];
 
913
  sc->dpy = MI_DISPLAY(mi);
894
914
 
895
915
  if ((sc->glx_context = init_GL(mi)) != NULL) {
896
916
    reshape_fliptext (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
897
917
  }
898
918
 
899
 
  program = get_string_resource ("program", "Program");
 
919
  program = get_string_resource (mi->dpy, "program", "Program");
900
920
 
901
921
  {
902
922
    int cw, lh;
914
934
      glEnable (GL_ALPHA_TEST);
915
935
      glEnable (GL_TEXTURE_2D);
916
936
 
917
 
# ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
918
937
      /* "Anistropic filtering helps for quadrilateral-angled textures.
919
938
         A sharper image is accomplished by interpolating and filtering
920
939
         multiple samples from one or more mipmaps to better approximate
921
940
         very distorted textures.  This is the next level of filtering
922
941
         after trilinear filtering." */
923
 
      glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
924
 
      clear_gl_error();
925
 
# endif
 
942
      if (strstr ((char *) glGetString(GL_EXTENSIONS),
 
943
                  "GL_EXT_texture_filter_anisotropic"))
 
944
      {
 
945
        GLfloat anisotropic = 0.0;
 
946
        glGetFloatv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic);
 
947
        if (anisotropic >= 1.0)
 
948
          glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 
 
949
                           anisotropic);
 
950
      }
926
951
    }
927
952
  
928
953
  /* The default font is (by fiat) "18 points".
977
1002
  if (min_lines < 1) min_lines = 1;
978
1003
 
979
1004
  parse_color (mi, "foreground",
980
 
               get_string_resource("foreground", "Foreground"),
 
1005
               get_string_resource(mi->dpy, "foreground", "Foreground"),
981
1006
               sc->color);
982
1007
 
983
1008
  sc->top_margin = (sc->char_width * 100);
986
1011
}
987
1012
 
988
1013
 
989
 
void
 
1014
ENTRYPOINT void
990
1015
draw_fliptext (ModeInfo *mi)
991
1016
{
992
1017
  fliptext_configuration *sc = &scs[MI_SCREEN(mi)];
 
1018
/*  XtAppContext app = XtDisplayToApplicationContext (sc->dpy);*/
993
1019
  Display *dpy = MI_DISPLAY(mi);
994
1020
  Window window = MI_WINDOW(mi);
995
1021
  int i;
997
1023
  if (!sc->glx_context)
998
1024
    return;
999
1025
 
 
1026
  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(sc->glx_context));
 
1027
 
 
1028
#if 0
1000
1029
  if (XtAppPending (app) & (XtIMTimer|XtIMAlternateInput))
1001
1030
    XtAppProcessEvent (app, XtIMTimer|XtIMAlternateInput);
 
1031
#endif
1002
1032
 
1003
1033
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1004
1034
 
1058
1088
  glXSwapBuffers(dpy, window);
1059
1089
}
1060
1090
 
 
1091
ENTRYPOINT void
 
1092
release_fliptext (ModeInfo *mi)
 
1093
{
 
1094
  if (scs) {
 
1095
    int screen;
 
1096
    for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
 
1097
      fliptext_configuration *sc = &scs[screen];
 
1098
      if (sc->pipe_id)
 
1099
        XtRemoveInput (sc->pipe_id);
 
1100
      if (sc->pipe)
 
1101
        pclose (sc->pipe);
 
1102
      if (sc->pipe_timer)
 
1103
        XtRemoveTimeOut (sc->pipe_timer);
 
1104
 
 
1105
      /* #### there's more to free here */
 
1106
    }
 
1107
    free (scs);
 
1108
    scs = 0;
 
1109
  }
 
1110
  FreeAllGL(mi);
 
1111
}
 
1112
 
 
1113
XSCREENSAVER_MODULE ("FlipText", fliptext)
 
1114
 
1061
1115
#endif /* USE_GL */