1 /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * xscreensaver, Copyright (c) 2016-2017 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.service.wallpaper.WallpaperService;
22 import android.view.GestureDetector;
23 import android.view.SurfaceHolder;
24 import android.util.Log;
25 import java.lang.RuntimeException;
26 import java.lang.Thread;
27 import org.jwz.xscreensaver.jwxyz;
29 public class XScreenSaverWallpaper extends WallpaperService
30 /*implements GestureDetector.OnGestureListener,
31 GestureDetector.OnDoubleTapListener, */ {
36 public Engine onCreateEngine() {
37 // Log.d("xscreensaver", "tid = " + Thread.currentThread().getId());
38 return new XScreenSaverGLEngine();
41 class XScreenSaverGLEngine extends Engine {
43 private boolean initTried = false;
44 private jwxyz jwxyz_obj;
47 public void onSurfaceCreated (SurfaceHolder holder) {
48 super.onSurfaceCreated(holder);
53 if (jwxyz_obj != null) {
61 public void onVisibilityChanged(final boolean visible) {
62 if (jwxyz_obj != null) {
71 public void onSurfaceChanged (SurfaceHolder holder, int format,
72 int width, int height) {
74 super.onSurfaceChanged(holder, format, width, height);
76 if (width == 0 || height == 0) {
81 Log.d ("xscreensaver",
82 String.format("surfaceChanged: %dx%d", width, height));
84 if (jwxyz_obj == null) {
85 jwxyz_obj = new jwxyz (jwxyz.saverNameOf(XScreenSaverWallpaper.this),
86 XScreenSaverWallpaper.this, null,
87 width, height, holder.getSurface(), null);
89 jwxyz_obj.resize (width, height);
96 public void onSurfaceDestroyed (SurfaceHolder holder) {
97 super.onSurfaceDestroyed (holder);
99 if (jwxyz_obj != null) {