Merge change Ie211adae into eclair

* changes:
  Add a way for wallpapers to know the delta between virtual screens.
This commit is contained in:
Android (Google) Code Review
2009-11-09 19:31:02 -08:00
11 changed files with 108 additions and 18 deletions

View File

@ -25097,6 +25097,21 @@
<exception name="IOException" type="java.io.IOException"> <exception name="IOException" type="java.io.IOException">
</exception> </exception>
</method> </method>
<method name="setWallpaperOffsetSteps"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="xStep" type="float">
</parameter>
<parameter name="yStep" type="float">
</parameter>
</method>
<method name="setWallpaperOffsets" <method name="setWallpaperOffsets"
return="void" return="void"
abstract="false" abstract="false"
@ -123675,6 +123690,10 @@
</parameter> </parameter>
<parameter name="yOffset" type="float"> <parameter name="yOffset" type="float">
</parameter> </parameter>
<parameter name="xOffsetStep" type="float">
</parameter>
<parameter name="yOffsetStep" type="float">
</parameter>
<parameter name="xPixelOffset" type="int"> <parameter name="xPixelOffset" type="int">
</parameter> </parameter>
<parameter name="yPixelOffset" type="int"> <parameter name="yPixelOffset" type="int">

View File

@ -25097,6 +25097,21 @@
<exception name="IOException" type="java.io.IOException"> <exception name="IOException" type="java.io.IOException">
</exception> </exception>
</method> </method>
<method name="setWallpaperOffsetSteps"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="xStep" type="float">
</parameter>
<parameter name="yStep" type="float">
</parameter>
</method>
<method name="setWallpaperOffsets" <method name="setWallpaperOffsets"
return="void" return="void"
abstract="false" abstract="false"
@ -123675,6 +123690,10 @@
</parameter> </parameter>
<parameter name="yOffset" type="float"> <parameter name="yOffset" type="float">
</parameter> </parameter>
<parameter name="xOffsetStep" type="float">
</parameter>
<parameter name="yOffsetStep" type="float">
</parameter>
<parameter name="xPixelOffset" type="int"> <parameter name="xPixelOffset" type="int">
</parameter> </parameter>
<parameter name="yPixelOffset" type="int"> <parameter name="yPixelOffset" type="int">

View File

@ -53,6 +53,8 @@ import java.io.InputStream;
public class WallpaperManager { public class WallpaperManager {
private static String TAG = "WallpaperManager"; private static String TAG = "WallpaperManager";
private static boolean DEBUG = false; private static boolean DEBUG = false;
private float mWallpaperXStep = -1;
private float mWallpaperYStep = -1;
/** /**
* Launch an activity for the user to pick the current global live * Launch an activity for the user to pick the current global live
@ -575,20 +577,33 @@ public class WallpaperManager {
* @param windowToken The window who these offsets should be associated * @param windowToken The window who these offsets should be associated
* with, as returned by {@link android.view.View#getWindowToken() * with, as returned by {@link android.view.View#getWindowToken()
* View.getWindowToken()}. * View.getWindowToken()}.
* @param xOffset The offset olong the X dimension, from 0 to 1. * @param xOffset The offset along the X dimension, from 0 to 1.
* @param yOffset The offset along the Y dimension, from 0 to 1. * @param yOffset The offset along the Y dimension, from 0 to 1.
*/ */
public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) { public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) {
try { try {
//Log.v(TAG, "Sending new wallpaper offsets from app..."); //Log.v(TAG, "Sending new wallpaper offsets from app...");
ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
windowToken, xOffset, yOffset); windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep);
//Log.v(TAG, "...app returning after sending offsets!"); //Log.v(TAG, "...app returning after sending offsets!");
} catch (RemoteException e) { } catch (RemoteException e) {
// Ignore. // Ignore.
} }
} }
/**
* For applications that use multiple virtual screens showing a wallpaper,
* specify the step size between virtual screens. For example, if the
* launcher has 5 virtual screens, it would specify an xStep of 0.5,
* since the X offset for those screens are 0.0, 0.5 and 1.0
* @param xStep The X offset delta from one screen to the next one
* @param yStep The Y offset delta from one screen to the next one
*/
public void setWallpaperOffsetSteps(float xStep, float yStep) {
mWallpaperXStep = xStep;
mWallpaperYStep = yStep;
}
/** /**
* Send an arbitrary command to the current active wallpaper. * Send an arbitrary command to the current active wallpaper.
* *
@ -627,7 +642,7 @@ public class WallpaperManager {
public void clearWallpaperOffsets(IBinder windowToken) { public void clearWallpaperOffsets(IBinder windowToken) {
try { try {
ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( ViewRoot.getWindowSession(mContext.getMainLooper()).setWallpaperPosition(
windowToken, -1, -1); windowToken, -1, -1, -1, -1);
} catch (RemoteException e) { } catch (RemoteException e) {
// Ignore. // Ignore.
} }

View File

@ -134,6 +134,8 @@ public abstract class WallpaperService extends Service {
boolean mOffsetMessageEnqueued; boolean mOffsetMessageEnqueued;
float mPendingXOffset; float mPendingXOffset;
float mPendingYOffset; float mPendingYOffset;
float mPendingXOffsetStep;
float mPendingYOffsetStep;
boolean mPendingSync; boolean mPendingSync;
MotionEvent mPendingMove; MotionEvent mPendingMove;
@ -227,11 +229,14 @@ public abstract class WallpaperService extends Service {
} }
@Override @Override
public void dispatchWallpaperOffsets(float x, float y, boolean sync) { public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
boolean sync) {
synchronized (mLock) { synchronized (mLock) {
if (DEBUG) Log.v(TAG, "Dispatch wallpaper offsets: " + x + ", " + y); if (DEBUG) Log.v(TAG, "Dispatch wallpaper offsets: " + x + ", " + y);
mPendingXOffset = x; mPendingXOffset = x;
mPendingYOffset = y; mPendingYOffset = y;
mPendingXOffsetStep = xStep;
mPendingYOffsetStep = yStep;
if (sync) { if (sync) {
mPendingSync = true; mPendingSync = true;
} }
@ -360,6 +365,7 @@ public abstract class WallpaperService extends Service {
* WallpaperManager.setWallpaperOffsets()}. * WallpaperManager.setWallpaperOffsets()}.
*/ */
public void onOffsetsChanged(float xOffset, float yOffset, public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep,
int xPixelOffset, int yPixelOffset) { int xPixelOffset, int yPixelOffset) {
} }
@ -608,10 +614,14 @@ public abstract class WallpaperService extends Service {
float xOffset; float xOffset;
float yOffset; float yOffset;
float xOffsetStep;
float yOffsetStep;
boolean sync; boolean sync;
synchronized (mLock) { synchronized (mLock) {
xOffset = mPendingXOffset; xOffset = mPendingXOffset;
yOffset = mPendingYOffset; yOffset = mPendingYOffset;
xOffsetStep = mPendingXOffsetStep;
yOffsetStep = mPendingYOffsetStep;
sync = mPendingSync; sync = mPendingSync;
mPendingSync = false; mPendingSync = false;
mOffsetMessageEnqueued = false; mOffsetMessageEnqueued = false;
@ -622,7 +632,7 @@ public abstract class WallpaperService extends Service {
final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0; final int xPixels = availw > 0 ? -(int)(availw*xOffset+.5f) : 0;
final int availh = mIWallpaperEngine.mReqHeight-mCurHeight; final int availh = mIWallpaperEngine.mReqHeight-mCurHeight;
final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0; final int yPixels = availh > 0 ? -(int)(availh*yOffset+.5f) : 0;
onOffsetsChanged(xOffset, yOffset, xPixels, yPixels); onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixels, yPixels);
if (sync) { if (sync) {
try { try {

View File

@ -62,7 +62,7 @@ oneway interface IWindow {
/** /**
* Called for wallpaper windows when their offsets change. * Called for wallpaper windows when their offsets change.
*/ */
void dispatchWallpaperOffsets(float x, float y, boolean sync); void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync);
void dispatchWallpaperCommand(String action, int x, int y, void dispatchWallpaperCommand(String action, int x, int y,
int z, in Bundle extras, boolean sync); int z, in Bundle extras, boolean sync);

View File

@ -113,8 +113,10 @@ interface IWindowSession {
/** /**
* For windows with the wallpaper behind them, and the wallpaper is * For windows with the wallpaper behind them, and the wallpaper is
* larger than the screen, set the offset within the screen. * larger than the screen, set the offset within the screen.
* For multi screen launcher type applications, xstep and ystep indicate
* how big the increment is from one screen to another.
*/ */
void setWallpaperPosition(IBinder windowToken, float x, float y); void setWallpaperPosition(IBinder windowToken, float x, float y, float xstep, float ystep);
void wallpaperOffsetsComplete(IBinder window); void wallpaperOffsetsComplete(IBinder window);

View File

@ -2895,7 +2895,8 @@ public final class ViewRoot extends Handler implements ViewParent,
} }
} }
public void dispatchWallpaperOffsets(float x, float y, boolean sync) { public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
boolean sync) {
if (sync) { if (sync) {
try { try {
sWindowSession.wallpaperOffsetsComplete(asBinder()); sWindowSession.wallpaperOffsetsComplete(asBinder());

View File

@ -102,6 +102,7 @@ public class ImageWallpaper extends WallpaperService {
@Override @Override
public void onOffsetsChanged(float xOffset, float yOffset, public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep,
int xPixels, int yPixels) { int xPixels, int yPixels) {
mXOffset = xOffset; mXOffset = xOffset;
mYOffset = yOffset; mYOffset = yOffset;

View File

@ -94,7 +94,7 @@ public class BaseIWindow extends IWindow.Stub {
public void closeSystemDialogs(String reason) { public void closeSystemDialogs(String reason) {
} }
public void dispatchWallpaperOffsets(float x, float y, boolean sync) { public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync) {
if (sync) { if (sync) {
try { try {
mSession.wallpaperOffsetsComplete(asBinder()); mSession.wallpaperOffsetsComplete(asBinder());

View File

@ -433,6 +433,8 @@ public class WindowManagerService extends IWindowManager.Stub
int mWallpaperAnimLayerAdjustment; int mWallpaperAnimLayerAdjustment;
float mLastWallpaperX = -1; float mLastWallpaperX = -1;
float mLastWallpaperY = -1; float mLastWallpaperY = -1;
float mLastWallpaperXStep = -1;
float mLastWallpaperYStep = -1;
// This is set when we are waiting for a wallpaper to tell us it is done // This is set when we are waiting for a wallpaper to tell us it is done
// changing its scroll position. // changing its scroll position.
WindowState mWaitingOnWallpaper; WindowState mWaitingOnWallpaper;
@ -1465,9 +1467,11 @@ public class WindowManagerService extends IWindowManager.Stub
if (visible) { if (visible) {
if (mWallpaperTarget.mWallpaperX >= 0) { if (mWallpaperTarget.mWallpaperX >= 0) {
mLastWallpaperX = mWallpaperTarget.mWallpaperX; mLastWallpaperX = mWallpaperTarget.mWallpaperX;
mLastWallpaperXStep = mWallpaperTarget.mWallpaperXStep;
} }
if (mWallpaperTarget.mWallpaperY >= 0) { if (mWallpaperTarget.mWallpaperY >= 0) {
mLastWallpaperY = mWallpaperTarget.mWallpaperY; mLastWallpaperY = mWallpaperTarget.mWallpaperY;
mLastWallpaperYStep = mWallpaperTarget.mWallpaperYStep;
} }
} }
@ -1570,6 +1574,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean changed = false; boolean changed = false;
boolean rawChanged = false; boolean rawChanged = false;
float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f; float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f;
float wpxs = mLastWallpaperXStep >= 0 ? mLastWallpaperXStep : -1.0f;
int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw; int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw;
int offset = availw > 0 ? -(int)(availw*wpx+.5f) : 0; int offset = availw > 0 ? -(int)(availw*wpx+.5f) : 0;
changed = wallpaperWin.mXOffset != offset; changed = wallpaperWin.mXOffset != offset;
@ -1578,12 +1583,14 @@ public class WindowManagerService extends IWindowManager.Stub
+ wallpaperWin + " x: " + offset); + wallpaperWin + " x: " + offset);
wallpaperWin.mXOffset = offset; wallpaperWin.mXOffset = offset;
} }
if (wallpaperWin.mWallpaperX != wpx) { if (wallpaperWin.mWallpaperX != wpx || wallpaperWin.mWallpaperXStep != wpxs) {
wallpaperWin.mWallpaperX = wpx; wallpaperWin.mWallpaperX = wpx;
wallpaperWin.mWallpaperXStep = wpxs;
rawChanged = true; rawChanged = true;
} }
float wpy = mLastWallpaperY >= 0 ? mLastWallpaperY : 0.5f; float wpy = mLastWallpaperY >= 0 ? mLastWallpaperY : 0.5f;
float wpys = mLastWallpaperYStep >= 0 ? mLastWallpaperYStep : -1.0f;
int availh = wallpaperWin.mFrame.bottom-wallpaperWin.mFrame.top-dh; int availh = wallpaperWin.mFrame.bottom-wallpaperWin.mFrame.top-dh;
offset = availh > 0 ? -(int)(availh*wpy+.5f) : 0; offset = availh > 0 ? -(int)(availh*wpy+.5f) : 0;
if (wallpaperWin.mYOffset != offset) { if (wallpaperWin.mYOffset != offset) {
@ -1592,8 +1599,9 @@ public class WindowManagerService extends IWindowManager.Stub
changed = true; changed = true;
wallpaperWin.mYOffset = offset; wallpaperWin.mYOffset = offset;
} }
if (wallpaperWin.mWallpaperY != wpy) { if (wallpaperWin.mWallpaperY != wpy || wallpaperWin.mWallpaperYStep != wpys) {
wallpaperWin.mWallpaperY = wpy; wallpaperWin.mWallpaperY = wpy;
wallpaperWin.mWallpaperYStep = wpys;
rawChanged = true; rawChanged = true;
} }
@ -1606,7 +1614,8 @@ public class WindowManagerService extends IWindowManager.Stub
mWaitingOnWallpaper = wallpaperWin; mWaitingOnWallpaper = wallpaperWin;
} }
wallpaperWin.mClient.dispatchWallpaperOffsets( wallpaperWin.mClient.dispatchWallpaperOffsets(
wallpaperWin.mWallpaperX, wallpaperWin.mWallpaperY, sync); wallpaperWin.mWallpaperX, wallpaperWin.mWallpaperY,
wallpaperWin.mWallpaperXStep, wallpaperWin.mWallpaperYStep, sync);
if (sync) { if (sync) {
if (mWaitingOnWallpaper != null) { if (mWaitingOnWallpaper != null) {
long start = SystemClock.uptimeMillis(); long start = SystemClock.uptimeMillis();
@ -2181,10 +2190,13 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
public void setWindowWallpaperPositionLocked(WindowState window, float x, float y) { public void setWindowWallpaperPositionLocked(WindowState window, float x, float y,
float xStep, float yStep) {
if (window.mWallpaperX != x || window.mWallpaperY != y) { if (window.mWallpaperX != x || window.mWallpaperY != y) {
window.mWallpaperX = x; window.mWallpaperX = x;
window.mWallpaperY = y; window.mWallpaperY = y;
window.mWallpaperXStep = xStep;
window.mWallpaperYStep = yStep;
if (updateWallpaperOffsetLocked(window, true)) { if (updateWallpaperOffsetLocked(window, true)) {
performLayoutAndPlaceSurfacesLocked(); performLayoutAndPlaceSurfacesLocked();
} }
@ -6585,12 +6597,12 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
public void setWallpaperPosition(IBinder window, float x, float y) { public void setWallpaperPosition(IBinder window, float x, float y, float xStep, float yStep) {
synchronized(mWindowMap) { synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
try { try {
setWindowWallpaperPositionLocked(windowForClientLocked(this, window), setWindowWallpaperPositionLocked(windowForClientLocked(this, window),
x, y); x, y, xStep, yStep);
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
@ -6805,6 +6817,11 @@ public class WindowManagerService extends IWindowManager.Stub
float mWallpaperX = -1; float mWallpaperX = -1;
float mWallpaperY = -1; float mWallpaperY = -1;
// If a window showing a wallpaper: what fraction of the offset
// range corresponds to a full virtual screen.
float mWallpaperXStep = -1;
float mWallpaperYStep = -1;
// Wallpaper windows: pixels offset based on above variables. // Wallpaper windows: pixels offset based on above variables.
int mXOffset; int mXOffset;
int mYOffset; int mYOffset;
@ -8037,6 +8054,10 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX); pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
pw.print(" mWallpaperY="); pw.println(mWallpaperY); pw.print(" mWallpaperY="); pw.println(mWallpaperY);
} }
if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
}
} }
@Override @Override

View File

@ -1060,7 +1060,8 @@ public final class Bridge implements ILayoutBridge {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void setWallpaperPosition(IBinder window, float x, float y) { public void setWallpaperPosition(IBinder window, float x, float y,
float xStep, float yStep) {
// pass for now. // pass for now.
} }
@ -1140,7 +1141,8 @@ public final class Bridge implements ILayoutBridge {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void dispatchWallpaperOffsets(float x, float y, boolean sync) { public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
boolean sync) {
// pass for now. // pass for now.
} }