projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.36.tar.gz
[xscreensaver]
/
hacks
/
decayscreen.c
diff --git
a/hacks/decayscreen.c
b/hacks/decayscreen.c
index fc74672c7180c3a7cf5c0290e62a9f09269ecb57..832b7ca7d3a71b72dead0b42db8623add01f7461 100644
(file)
--- a/
hacks/decayscreen.c
+++ b/
hacks/decayscreen.c
@@
-1,4
+1,4
@@
-/* xscreensaver, Copyright (c) 1992-20
08
Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-20
14
Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@
-36,10
+36,14
@@
*/
#include "screenhack.h"
*/
#include "screenhack.h"
+#include <time.h>
struct state {
Display *dpy;
Window window;
struct state {
Display *dpy;
Window window;
+ XWindowAttributes xgwa;
+ Pixmap saved;
+ int saved_w, saved_h;
int sizex, sizey;
int delay;
int sizex, sizey;
int delay;
@@
-79,6
+83,7
@@
decayscreen_load_image (struct state *st)
st->sizex = xgwa.width;
st->sizey = xgwa.height;
if (st->img_loader) abort();
st->sizex = xgwa.width;
st->sizey = xgwa.height;
if (st->img_loader) abort();
+
st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
st->window, 0, 0);
}
st->img_loader = load_image_async_simple (0, xgwa.screen, st->window,
st->window, 0, 0);
}
@@
-88,7
+93,6
@@
decayscreen_init (Display *dpy, Window window)
{
struct state *st = (struct state *) calloc (1, sizeof(*st));
XGCValues gcv;
{
struct state *st = (struct state *) calloc (1, sizeof(*st));
XGCValues gcv;
- XWindowAttributes xgwa;
long gcflags;
unsigned long bg;
char *s;
long gcflags;
unsigned long bg;
char *s;
@@
-125,19
+129,19
@@
decayscreen_init (Display *dpy, Window window)
st->duration = get_integer_resource (st->dpy, "duration", "Seconds");
if (st->duration < 1) st->duration = 1;
st->duration = get_integer_resource (st->dpy, "duration", "Seconds");
if (st->duration < 1) st->duration = 1;
- XGetWindowAttributes (st->dpy, st->window, &xgwa);
+ XGetWindowAttributes (st->dpy, st->window, &
st->
xgwa);
gcv.function = GXcopy;
gcv.subwindow_mode = IncludeInferiors;
gcv.function = GXcopy;
gcv.subwindow_mode = IncludeInferiors;
- bg = get_pixel_resource (st->dpy, xgwa.colormap, "background", "Background");
+ bg = get_pixel_resource (st->dpy,
st->
xgwa.colormap, "background", "Background");
gcv.foreground = bg;
gcflags = GCForeground | GCFunction;
gcv.foreground = bg;
gcflags = GCForeground | GCFunction;
- if (use_subwindow_mode_p(xgwa.screen, st->window)) /* see grabscreen.c */
+ if (use_subwindow_mode_p(
st->
xgwa.screen, st->window)) /* see grabscreen.c */
gcflags |= GCSubwindowMode;
st->gc = XCreateGC (st->dpy, st->window, gcflags, &gcv);
gcflags |= GCSubwindowMode;
st->gc = XCreateGC (st->dpy, st->window, gcflags, &gcv);
- st->start_time = time ((time_t) 0);
+ st->start_time = time ((time_t
*
) 0);
decayscreen_load_image (st);
return st;
decayscreen_load_image (st);
return st;
@@
-174,19
+178,29
@@
decayscreen_draw (Display *dpy, Window window, void *closure)
0, 0, 0, 0, 0);
if (! st->img_loader) { /* just finished */
0, 0, 0, 0, 0);
if (! st->img_loader) { /* just finished */
- st->start_time = time ((time_t) 0);
+ st->start_time = time ((time_t
*
) 0);
if (st->random_p)
st->mode = random() % (FUZZ+1);
if (st->mode == MELT || st->mode == STRETCH)
/* make sure screen eventually turns background color */
XDrawLine (st->dpy, st->window, st->gc, 0, 0, st->sizex, 0);
if (st->random_p)
st->mode = random() % (FUZZ+1);
if (st->mode == MELT || st->mode == STRETCH)
/* make sure screen eventually turns background color */
XDrawLine (st->dpy, st->window, st->gc, 0, 0, st->sizex, 0);
+
+ if (!st->saved) {
+ st->saved = XCreatePixmap (st->dpy, st->window,
+ st->sizex, st->sizey,
+ st->xgwa.depth);
+ st->saved_w = st->sizex;
+ st->saved_h = st->sizey;
+ }
+ XCopyArea (st->dpy, st->window, st->saved, st->gc, 0, 0,
+ st->sizex, st->sizey, 0, 0);
}
return st->delay;
}
if (!st->img_loader &&
}
return st->delay;
}
if (!st->img_loader &&
- st->start_time + st->duration < time ((time_t) 0)) {
+ st->start_time + st->duration < time ((time_t
*
) 0)) {
decayscreen_load_image (st);
}
decayscreen_load_image (st);
}
@@
-316,6
+330,12
@@
decayscreen_reshape (Display *dpy, Window window, void *closure,
unsigned int w, unsigned int h)
{
struct state *st = (struct state *) closure;
unsigned int w, unsigned int h)
{
struct state *st = (struct state *) closure;
+ if (! st->saved) return; /* Image might not be loaded yet */
+ XClearWindow (st->dpy, st->window);
+ XCopyArea (st->dpy, st->saved, st->window, st->gc,
+ 0, 0, st->saved_w, st->saved_h,
+ ((int)w - st->saved_w) / 2,
+ ((int)h - st->saved_h) / 2);
st->sizex = w;
st->sizey = h;
}
st->sizex = w;
st->sizey = h;
}
@@
-323,6
+343,12
@@
decayscreen_reshape (Display *dpy, Window window, void *closure,
static Bool
decayscreen_event (Display *dpy, Window window, void *closure, XEvent *event)
{
static Bool
decayscreen_event (Display *dpy, Window window, void *closure, XEvent *event)
{
+ struct state *st = (struct state *) closure;
+ if (screenhack_event_helper (dpy, window, event))
+ {
+ st->start_time = 0;
+ return True;
+ }
return False;
}
return False;
}
@@
-339,6
+365,7
@@
static const char *decayscreen_defaults [] = {
".background: Black",
".foreground: Yellow",
"*dontClearRoot: True",
".background: Black",
".foreground: Yellow",
"*dontClearRoot: True",
+ "*fpsSolid: True",
#ifdef __sgi /* really, HAVE_READ_DISPLAY_EXTENSION */
"*visualID: Best",
#ifdef __sgi /* really, HAVE_READ_DISPLAY_EXTENSION */
"*visualID: Best",
@@
-347,6
+374,10
@@
static const char *decayscreen_defaults [] = {
"*delay: 10000",
"*mode: random",
"*duration: 120",
"*delay: 10000",
"*mode: random",
"*duration: 120",
+#ifdef HAVE_MOBILE
+ "*ignoreRotation: True",
+ "*rotateImages: True",
+#endif
0
};
0
};