summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-04-20 18:18:51 -0700
committerDianne Hackborn <hackbod@google.com>2011-04-21 15:17:52 -0700
commit44bc17c6b517aef35a390c81b5aa79c4f284f744 (patch)
treeb4dabc94a8974f81cf7ea855a93e307205c5b8d7 /services
parent52c03d2cb9a782366e804d1910a7c8f072b05353 (diff)
downloadframeworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.zip
frameworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.tar.gz
frameworks_base-44bc17c6b517aef35a390c81b5aa79c4f284f744.tar.bz2
Rework display size access.
Applications now get the display size from the window manager. No behavior should be changed yet, this is just prep for some real changes. Change-Id: I2958a6660895c1cba2b670509600014e55ee9273
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/WallpaperManagerService.java12
-rw-r--r--services/java/com/android/server/wm/InputMonitor.java4
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java60
-rw-r--r--services/java/com/android/server/wm/WindowState.java4
4 files changed, 57 insertions, 23 deletions
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index b1a6a9a..c129b97 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -49,6 +49,7 @@ import android.service.wallpaper.IWallpaperService;
import android.service.wallpaper.WallpaperService;
import android.util.Slog;
import android.util.Xml;
+import android.view.Display;
import android.view.IWindowManager;
import android.view.WindowManager;
@@ -726,6 +727,17 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
mHeight = -1;
mName = "";
}
+
+ // We always want to have some reasonable width hint.
+ WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
+ Display d = wm.getDefaultDisplay();
+ int baseSize = d.getMaximumSizeDimension();
+ if (mWidth < baseSize) {
+ mWidth = baseSize;
+ }
+ if (mHeight < baseSize) {
+ mHeight = baseSize;
+ }
}
// Called by SystemBackupAgent after files are restored to disk.
diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java
index 45a78af..4f157fe 100644
--- a/services/java/com/android/server/wm/InputMonitor.java
+++ b/services/java/com/android/server/wm/InputMonitor.java
@@ -132,8 +132,8 @@ final class InputMonitor {
// The drag window covers the entire display
inputWindow.frameLeft = 0;
inputWindow.frameTop = 0;
- inputWindow.frameRight = mService.mDisplay.getWidth();
- inputWindow.frameBottom = mService.mDisplay.getHeight();
+ inputWindow.frameRight = mService.mDisplay.getRealWidth();
+ inputWindow.frameBottom = mService.mDisplay.getRealHeight();
// The drag window cannot receive new touches.
inputWindow.touchableRegion.setEmpty();
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index e2874f8..b2e78f1 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -64,6 +64,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.BatteryStats;
@@ -392,6 +393,8 @@ public class WindowManagerService extends IWindowManager.Stub
boolean mSystemBooted = false;
int mInitialDisplayWidth = 0;
int mInitialDisplayHeight = 0;
+ int mCurDisplayWidth = 0;
+ int mCurDisplayHeight = 0;
int mRotation = 0;
int mRequestedRotation = 0;
int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -1419,8 +1422,8 @@ public class WindowManagerService extends IWindowManager.Stub
int adjustWallpaperWindowsLocked() {
int changed = 0;
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
// First find top-most window that has asked to be on top of the
// wallpaper; all wallpapers go behind it.
@@ -1838,8 +1841,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
boolean changed = false;
@@ -1879,8 +1882,8 @@ public class WindowManagerService extends IWindowManager.Stub
void updateWallpaperVisibilityLocked() {
final boolean visible = isWallpaperVisible(mWallpaperTarget);
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
int curTokenIndex = mWallpaperTokens.size();
while (curTokenIndex > 0) {
@@ -2682,8 +2685,7 @@ public class WindowManagerService extends IWindowManager.Stub
configChanged = updateOrientationFromAppTokensLocked(false);
performLayoutAndPlaceSurfacesLocked();
if (displayed && win.mIsWallpaper) {
- updateWallpaperOffsetLocked(win, mDisplay.getWidth(),
- mDisplay.getHeight(), false);
+ updateWallpaperOffsetLocked(win, mCurDisplayWidth, mCurDisplayHeight, false);
}
if (win.mAppToken != null) {
win.mAppToken.updateReportedVisibilityLocked();
@@ -4757,8 +4759,8 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) {
long ident = Binder.clearCallingIdentity();
- dw = mDisplay.getWidth();
- dh = mDisplay.getHeight();
+ dw = mCurDisplayWidth;
+ dh = mCurDisplayHeight;
int aboveAppLayer = mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER
@@ -5848,9 +5850,9 @@ public class WindowManagerService extends IWindowManager.Stub
}
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mDisplay = wm.getDefaultDisplay();
- mInitialDisplayWidth = mDisplay.getWidth();
- mInitialDisplayHeight = mDisplay.getHeight();
- mInputManager.setDisplaySize(0, mDisplay.getRealWidth(), mDisplay.getRealHeight());
+ mInitialDisplayWidth = mCurDisplayWidth = mDisplay.getRealWidth();
+ mInitialDisplayHeight = mCurDisplayHeight = mDisplay.getRealHeight();
+ mInputManager.setDisplaySize(0, mDisplay.getRawWidth(), mDisplay.getRawHeight());
}
try {
@@ -6344,6 +6346,21 @@ public class WindowManagerService extends IWindowManager.Stub
return false;
}
+ public void getDisplaySize(Point size) {
+ synchronized(mWindowMap) {
+ size.x = mCurDisplayWidth;
+ size.y = mCurDisplayHeight;
+ }
+ }
+
+ public int getMaximumSizeDimension() {
+ synchronized(mWindowMap) {
+ // Do this based on the raw screen size, until we are smarter.
+ return mInitialDisplayWidth > mInitialDisplayHeight
+ ? mInitialDisplayWidth : mInitialDisplayHeight;
+ }
+ }
+
// -------------------------------------------------------------
// Internals
// -------------------------------------------------------------
@@ -6586,8 +6603,8 @@ public class WindowManagerService extends IWindowManager.Stub
mLayoutNeeded = false;
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth;
+ final int dh = mCurDisplayHeight;
final int N = mWindows.size();
int i;
@@ -6704,8 +6721,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
final long currentTime = SystemClock.uptimeMillis();
- final int dw = mDisplay.getWidth();
- final int dh = mDisplay.getHeight();
+ final int dw = mCurDisplayWidth = mDisplay.getRealWidth();
+ final int dh = mCurDisplayHeight = mDisplay.getRealHeight();
int i;
@@ -8726,8 +8743,13 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(" mToBottomApps="); pw.println(mToBottomApps);
}
if (mDisplay != null) {
- pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth());
- pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight());
+ pw.print(" Display: init="); pw.print(mInitialDisplayWidth); pw.print("x");
+ pw.print(mInitialDisplayHeight); pw.print(" cur=");
+ pw.print(mCurDisplayWidth); pw.print("x"); pw.print(mCurDisplayHeight);
+ pw.print(" real="); pw.print(mDisplay.getRealWidth());
+ pw.print("x"); pw.print(mDisplay.getRealHeight());
+ pw.print(" raw="); pw.print(mDisplay.getRawWidth());
+ pw.print("x"); pw.println(mDisplay.getRawHeight());
} else {
pw.println(" NO DISPLAY");
}
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index f8ff5f8..c05186a 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -440,8 +440,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
visibleInsets.bottom = frame.bottom-visible.bottom;
if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
- mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getWidth(),
- mService.mDisplay.getHeight(), false);
+ mService.updateWallpaperOffsetLocked(this, mService.mDisplay.getRealWidth(),
+ mService.mDisplay.getRealHeight(), false);
}
if (WindowManagerService.localLOGV) {