~ubuntu-branches/ubuntu/breezy/xscreensaver/breezy

« back to all changes in this revision

Viewing changes to hacks/flag.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2005-10-11 21:00:42 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051011210042-u7q6zslgevdxspr3
Tags: 4.21-4ubuntu17
updated pt_BR again, fixed to UTF-8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 4 -*-
2
2
 * flag --- a waving flag
3
3
 */
4
 
#if !defined( lint ) && !defined( SABER )
 
4
#if 0
5
5
static const char sccsid[] = "@(#)flag.c        4.02 97/04/01 xlockmore";
6
6
#endif
7
7
 
48
48
# define DEF_TEXT                                       ""
49
49
# include "xlockmore.h"                         /* from the xscreensaver distribution */
50
50
 
51
 
# ifdef HAVE_XPM
52
 
#  include <X11/xpm.h>
53
 
#  ifndef PIXEL_ALREADY_TYPEDEFED
54
 
#   define PIXEL_ALREADY_TYPEDEFED /* Sigh, Xmu/Drawing.h needs this... */
55
 
#  endif
56
 
# endif
57
 
 
58
 
#ifdef HAVE_XMU
59
 
# ifndef VMS
60
 
#  include <X11/Xmu/Drawing.h>
61
 
# else  /* VMS */
62
 
#  include <Xmu/Drawing.h>
63
 
# endif /* VMS */
64
 
#endif /* HAVE_XMU */
 
51
#include "xpm-pixmap.h"
65
52
 
66
53
#include "images/bob.xbm"
67
54
 
219
206
          *bitmap_name &&
220
207
          !!strcmp(bitmap_name, "(default)"))
221
208
        {
222
 
#ifdef HAVE_XPM
223
 
          Window window = MI_WINDOW(mi);
224
 
          XWindowAttributes xgwa;
225
 
          XpmAttributes xpmattrs;
226
 
          int result;
227
209
          Pixmap bitmap = 0;
228
 
          int width = 0, height = 0;
229
 
          xpmattrs.valuemask = 0;
230
 
 
231
 
          XGetWindowAttributes (dpy, window, &xgwa);
232
 
 
233
 
# ifdef XpmCloseness
234
 
          xpmattrs.valuemask |= XpmCloseness;
235
 
          xpmattrs.closeness = 40000;
236
 
# endif
237
 
# ifdef XpmVisual
238
 
          xpmattrs.valuemask |= XpmVisual;
239
 
          xpmattrs.visual = xgwa.visual;
240
 
# endif
241
 
# ifdef XpmDepth
242
 
          xpmattrs.valuemask |= XpmDepth;
243
 
          xpmattrs.depth = xgwa.depth;
244
 
# endif
245
 
# ifdef XpmColormap
246
 
          xpmattrs.valuemask |= XpmColormap;
247
 
          xpmattrs.colormap = xgwa.colormap;
248
 
# endif
249
 
 
250
 
          /* Uh, we don't need these now.  We use the colors from the xpm.
251
 
                 It kinda sucks that we already allocated them. */
252
 
          XFreeColors(dpy, xgwa.colormap, mi->pixels, mi->npixels, 0L);
253
 
 
254
 
          result = XpmReadFileToPixmap (dpy, window, bitmap_name, &bitmap, 0,
255
 
                                                                        &xpmattrs);
256
 
          switch (result)
257
 
                {
258
 
                case XpmColorError:
259
 
                  fprintf (stderr, "%s: warning: xpm color substitution performed\n",
260
 
                                   progname);
261
 
                  /* fall through */
262
 
                case XpmSuccess:
263
 
                  width = xpmattrs.width;
264
 
                  height = xpmattrs.height;
265
 
                  break;
266
 
                case XpmFileInvalid:
267
 
                case XpmOpenFailed:
268
 
                  bitmap = 0;
269
 
                  break;
270
 
                case XpmColorFailed:
271
 
                  fprintf (stderr, "%s: xpm: color allocation failed\n", progname);
272
 
                  exit (-1);
273
 
                case XpmNoMemory:
274
 
                  fprintf (stderr, "%s: xpm: out of memory\n", progname);
275
 
                  exit (-1);
276
 
                default:
277
 
                  fprintf (stderr, "%s: xpm: unknown error code %d\n", progname,
278
 
                                   result);
279
 
                  exit (-1);
280
 
                }
281
 
 
 
210
      int width = 0;
 
211
      int height = 0;
 
212
 
 
213
      bitmap = xpm_file_to_pixmap (dpy, MI_WINDOW (mi), bitmap_name,
 
214
                                   &width, &height, 0);
282
215
          if (bitmap)
283
216
                {
284
217
                  fp->image = XGetImage(dpy, bitmap, 0, 0, width, height, ~0L,
285
218
                                                                ZPixmap);
286
219
                  XFreePixmap(dpy, bitmap);
287
220
                }
288
 
          else
289
 
#endif /* HAVE_XPM */
290
 
 
291
 
#ifdef HAVE_XMU
292
 
                {
293
 
                  int width, height, xh, yh;
294
 
                  Pixmap bitmap =
295
 
                        XmuLocateBitmapFile (DefaultScreenOfDisplay (dpy),
296
 
                                                                 bitmap_name, 0, 0, &width, &height, &xh, &yh);
297
 
                  if (!bitmap)
298
 
                        {
299
 
                          fprintf(stderr, "%s: unable to load bitmap file %s\n",
300
 
                                          progname, bitmap_name);
301
 
                          exit (1);
302
 
                        }
303
 
                  fp->image = XGetImage(dpy, bitmap, 0, 0, width, height,
304
 
                                                                1L, XYPixmap);
305
 
                  XFreePixmap(dpy, bitmap);
306
 
                }
307
 
 
308
 
#else  /* !XMU */
309
 
      fprintf (stderr,
310
 
                           "%s: your vendor doesn't ship the standard Xmu library.\n",
311
 
                           progname);
312
 
      fprintf (stderr, "\tWe can't load XBM files without it.\n");
313
 
      exit (1);
314
 
#endif /* !XMU */
315
 
 
316
221
        }
317
222
  else if (text && *text)
318
223
        {