1 /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * xscreensaver, Copyright (c) 2016 Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
12 * The superclass of every saver's Wallpaper.
14 * Each Wallpaper needs a distinct subclass in order to show up in the list.
15 * We know which saver we are running by the subclass name; we know which
16 * API to use by how the subclass calls super().
19 package org.jwz.xscreensaver;
21 import android.opengl.GLSurfaceView;
22 import android.os.Handler;
23 import android.os.Message;
24 import android.service.wallpaper.WallpaperService;
25 import android.view.GestureDetector;
26 import android.view.SurfaceHolder;
27 import android.util.Log;
28 import java.lang.RuntimeException;
29 import java.lang.Thread;
31 public class XScreenSaverWallpaper extends WallpaperService
32 /*implements GestureDetector.OnGestureListener,
33 GestureDetector.OnDoubleTapListener, */ {
38 public Engine onCreateEngine() {
39 return new XScreenSaverGLEngine();
42 class XScreenSaverGLEngine extends Engine
43 implements Handler.Callback {
48 public void onSurfaceCreated (SurfaceHolder holder) {
49 /* Old GLWallpaperService warns against working with a GLSurfaceView
50 in the Engine constructor.
52 glview = new GLSurfaceView (XScreenSaverWallpaper.this) {
54 public SurfaceHolder getHolder() {
55 return XScreenSaverGLEngine.this.getSurfaceHolder();
59 new XScreenSaverRenderer (
60 XScreenSaverRenderer.saverNameOf (XScreenSaverWallpaper.this),
61 XScreenSaverWallpaper.this, null, this, glview);
62 // super.onSurfaceCreated(holder);
63 glview.surfaceCreated(holder);
64 // glview.requestRender();
68 public void onVisibilityChanged(final boolean visible) {
77 /* These aren't necessary...maybe? */
80 public void onSurfaceChanged (SurfaceHolder holder, int format,
81 int width, int height) {
83 glview.surfaceChanged(holder, format, width, height);
84 // super.onSurfaceChanged(holder, format, width, height);
88 public void onSurfaceDestroyed (SurfaceHolder holder) {
89 glview.surfaceDestroyed(holder);
94 public boolean handleMessage (Message msg) {
95 Log.d ("xscreensaver", msg.obj.toString());
96 throw (RuntimeException)msg.obj;