Fix screen/window size change events.

Window size was being treated as equivalent to screen size, which it isn't.
Make sure to send the size-changed event when either the window size or the
screen size change, and to properly differentiate between the two.
This commit is contained in:
Chris Lord 2012-02-17 17:25:52 +00:00
Родитель 8d009ca309
Коммит acb4083161
2 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@ -68,6 +68,7 @@ public abstract class GeckoLayerClient implements GeckoEventListener,
protected LayerRenderer mLayerRenderer;
protected IntSize mScreenSize;
protected IntSize mWindowSize;
protected IntSize mBufferSize;
protected Layer mTileLayer;
@ -263,19 +264,36 @@ public abstract class GeckoLayerClient implements GeckoEventListener,
/* Informs Gecko that the screen size has changed. */
protected void sendResizeEventIfNecessary(boolean force) {
Log.e(LOGTAG, "### sendResizeEventIfNecessary " + force);
Log.d(LOGTAG, "### sendResizeEventIfNecessary " + force);
IntSize newSize = getBufferSize();
if (!force && mScreenSize != null && mScreenSize.equals(newSize)) {
DisplayMetrics metrics = new DisplayMetrics();
GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
IntSize newWindowSize = getBufferSize();
boolean screenSizeChanged = mScreenSize == null || !mScreenSize.equals(newScreenSize);
boolean windowSizeChanged = mWindowSize == null || !mWindowSize.equals(newWindowSize);
if (!force && !screenSizeChanged && !windowSizeChanged) {
return;
}
mScreenSize = newSize;
mScreenSize = newScreenSize;
mWindowSize = newWindowSize;
Log.e(LOGTAG, "### Screen-size changed to " + mScreenSize);
GeckoEvent event = GeckoEvent.createSizeChangedEvent(mScreenSize.width, mScreenSize.height,
mScreenSize.width, mScreenSize.height,
mScreenSize.width, mScreenSize.height);
if (screenSizeChanged) {
Log.i(LOGTAG, "### Screen-size changed to " + mScreenSize);
}
if (windowSizeChanged) {
Log.i(LOGTAG, "### Window-size changed to " + mWindowSize);
}
IntSize bufferSize = getBufferSize();
GeckoEvent event = GeckoEvent.createSizeChangedEvent(mWindowSize.width, mWindowSize.height, // Window (buffer) size
mScreenSize.width, mScreenSize.height, // Screen size
0, 0); // Tile-size (unused)
GeckoAppShell.sendEventToGecko(event);
}

Просмотреть файл

@ -930,14 +930,8 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
nsTArray<nsIntPoint> points = ae->Points();
NS_ASSERTION(points.Length() == 3, "Size changed does not have enough coordinates");
#ifdef MOZ_JAVA_COMPOSITOR
int nw = points[1].x;
int nh = points[1].y;
#else
int nw = points[0].x;
int nh = points[0].y;
#endif
if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width ||
nh != gAndroidBounds.height) {