Bug 1362195 - 3. Call onFullScreen for full screen changes; r=snorp

Send an event from nsWindow to GeckoView when we enter/exit full screen
mode, and call ContentListener.onFullScreen to notify the implementer.
This commit is contained in:
Jim Chen 2017-05-11 16:40:17 -04:00
parent 1137640d64
commit 044b6b9b8c
2 changed files with 17 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import org.mozilla.gecko.annotation.ReflectionTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.mozglue.JNIObject;
import org.mozilla.gecko.util.ActivityUtils;
import org.mozilla.gecko.util.BundleEventListener;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.GeckoBundle;
@ -196,6 +197,8 @@ public class GeckoView extends LayerView
/* package */ void registerListeners() {
getEventDispatcher().registerUiThreadListener(this,
"GeckoView:DOMTitleChanged",
"GeckoView:FullScreenEnter",
"GeckoView:FullScreenExit",
"GeckoView:LocationChange",
"GeckoView:PageStart",
"GeckoView:PageStop",
@ -215,6 +218,14 @@ public class GeckoView extends LayerView
if (mContentListener != null) {
mContentListener.onTitleChange(GeckoView.this, message.getString("title"));
}
} else if ("GeckoView:FullScreenEnter".equals(event)) {
if (mContentListener != null) {
mContentListener.onFullScreen(GeckoView.this, true);
}
} else if ("GeckoView:FullScreenExit".equals(event)) {
if (mContentListener != null) {
mContentListener.onFullScreen(GeckoView.this, false);
}
} else if ("GeckoView:LocationChange".equals(event)) {
if (mNavigationListener == null) {
// We shouldn't be getting this event.

View File

@ -1920,9 +1920,14 @@ nsWindow::DispatchEvent(WidgetGUIEvent* aEvent)
nsresult
nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*)
{
if (!mAndroidView) {
return NS_ERROR_NOT_AVAILABLE;
}
mIsFullScreen = aFullScreen;
mAwaitingFullScreen = true;
GeckoAppShell::SetFullScreen(aFullScreen);
mAndroidView->mEventDispatcher->Dispatch(aFullScreen ?
u"GeckoView:FullScreenEnter" : u"GeckoView:FullScreenExit");
return NS_OK;
}