am a8f1a805: am 61462b43: Merge change I1864d098 into eclair

Merge commit 'a8f1a805c8b6dff5becbd95122462d91c1d1b254' into eclair-mr2-plus-aosp

* commit 'a8f1a805c8b6dff5becbd95122462d91c1d1b254':
  Improve wallpaper offset handling.
This commit is contained in:
Dianne Hackborn
2009-10-20 12:18:46 -07:00
committed by Android Git Automerger

View File

@@ -430,8 +430,8 @@ public class WindowManagerService extends IWindowManager.Stub
// to another, and this is the higher one in Z-order. // to another, and this is the higher one in Z-order.
WindowState mUpperWallpaperTarget = null; WindowState mUpperWallpaperTarget = null;
int mWallpaperAnimLayerAdjustment; int mWallpaperAnimLayerAdjustment;
float mLastWallpaperX; float mLastWallpaperX = -1;
float mLastWallpaperY; float mLastWallpaperY = -1;
// Lock for waiting for the wallpaper. // Lock for waiting for the wallpaper.
final Object mWaitingOnWallpaperLock = new Object(); final Object mWaitingOnWallpaperLock = new Object();
// 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
@@ -1464,9 +1464,13 @@ public class WindowManagerService extends IWindowManager.Stub
} }
if (visible) { if (visible) {
if (mWallpaperTarget.mWallpaperX >= 0) {
mLastWallpaperX = mWallpaperTarget.mWallpaperX; mLastWallpaperX = mWallpaperTarget.mWallpaperX;
}
if (mWallpaperTarget.mWallpaperY >= 0) {
mLastWallpaperY = mWallpaperTarget.mWallpaperY; mLastWallpaperY = mWallpaperTarget.mWallpaperY;
} }
}
// Start stepping backwards from here, ensuring that our wallpaper windows // Start stepping backwards from here, ensuring that our wallpaper windows
// are correctly placed. // are correctly placed.
@@ -1566,35 +1570,33 @@ public class WindowManagerService extends IWindowManager.Stub
boolean sync) { boolean sync) {
boolean changed = false; boolean changed = false;
boolean rawChanged = false; boolean rawChanged = false;
if (mLastWallpaperX >= 0) { float wpx = mLastWallpaperX >= 0 ? mLastWallpaperX : 0.5f;
int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw; int availw = wallpaperWin.mFrame.right-wallpaperWin.mFrame.left-dw;
int offset = availw > 0 ? -(int)(availw*mLastWallpaperX+.5f) : 0; int offset = availw > 0 ? -(int)(availw*wpx+.5f) : 0;
changed = wallpaperWin.mXOffset != offset; changed = wallpaperWin.mXOffset != offset;
if (changed) { if (changed) {
if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper " if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper "
+ wallpaperWin + " x: " + offset); + wallpaperWin + " x: " + offset);
wallpaperWin.mXOffset = offset; wallpaperWin.mXOffset = offset;
} }
if (wallpaperWin.mWallpaperX != mLastWallpaperX) { if (wallpaperWin.mWallpaperX != wpx) {
wallpaperWin.mWallpaperX = mLastWallpaperX; wallpaperWin.mWallpaperX = wpx;
rawChanged = true; rawChanged = true;
} }
}
if (mLastWallpaperY >= 0) { float wpy = mLastWallpaperY >= 0 ? mLastWallpaperY : 0.5f;
int availh = wallpaperWin.mFrame.bottom-wallpaperWin.mFrame.top-dh; int availh = wallpaperWin.mFrame.bottom-wallpaperWin.mFrame.top-dh;
int offset = availh > 0 ? -(int)(availh*mLastWallpaperY+.5f) : 0; offset = availh > 0 ? -(int)(availh*wpy+.5f) : 0;
if (wallpaperWin.mYOffset != offset) { if (wallpaperWin.mYOffset != offset) {
if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper " if (DEBUG_WALLPAPER) Log.v(TAG, "Update wallpaper "
+ wallpaperWin + " y: " + offset); + wallpaperWin + " y: " + offset);
changed = true; changed = true;
wallpaperWin.mYOffset = offset; wallpaperWin.mYOffset = offset;
} }
if (wallpaperWin.mWallpaperY != mLastWallpaperY) { if (wallpaperWin.mWallpaperY != wpy) {
wallpaperWin.mWallpaperY = mLastWallpaperY; wallpaperWin.mWallpaperY = wpy;
rawChanged = true; rawChanged = true;
} }
}
if (rawChanged) { if (rawChanged) {
try { try {
@@ -1649,7 +1651,7 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
boolean updateWallpaperOffsetLocked(boolean sync) { boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
final int dw = mDisplay.getWidth(); final int dw = mDisplay.getWidth();
final int dh = mDisplay.getHeight(); final int dh = mDisplay.getHeight();
@@ -1657,8 +1659,18 @@ public class WindowManagerService extends IWindowManager.Stub
WindowState target = mWallpaperTarget; WindowState target = mWallpaperTarget;
if (target != null) { if (target != null) {
if (target.mWallpaperX >= 0) {
mLastWallpaperX = target.mWallpaperX; mLastWallpaperX = target.mWallpaperX;
} else if (changingTarget.mWallpaperX >= 0) {
mLastWallpaperX = changingTarget.mWallpaperX;
}
if (target.mWallpaperY >= 0) {
mLastWallpaperY = target.mWallpaperY; mLastWallpaperY = target.mWallpaperY;
} else if (changingTarget.mWallpaperY >= 0) {
mLastWallpaperY = changingTarget.mWallpaperY;
}
}
int curTokenIndex = mWallpaperTokens.size(); int curTokenIndex = mWallpaperTokens.size();
while (curTokenIndex > 0) { while (curTokenIndex > 0) {
curTokenIndex--; curTokenIndex--;
@@ -1675,7 +1687,6 @@ public class WindowManagerService extends IWindowManager.Stub
} }
} }
} }
}
return changed; return changed;
} }
@@ -2179,14 +2190,11 @@ public class WindowManagerService extends IWindowManager.Stub
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;
if (updateWallpaperOffsetLocked(window, true)) {
if (mWallpaperTarget == window) {
if (updateWallpaperOffsetLocked(true)) {
performLayoutAndPlaceSurfacesLocked(); performLayoutAndPlaceSurfacesLocked();
} }
} }
} }
}
public int relayoutWindow(Session session, IWindow client, public int relayoutWindow(Session session, IWindow client,
WindowManager.LayoutParams attrs, int requestedWidth, WindowManager.LayoutParams attrs, int requestedWidth,