check if window is html or forced fullscreen
This commit is contained in:
parent
f2d91bc53c
commit
0dcf061dc1
6 changed files with 35 additions and 4 deletions
|
@ -221,6 +221,7 @@ void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
||||||
if (window) {
|
if (window) {
|
||||||
window->SetHtmlApiFullscreen(true);
|
window->SetHtmlApiFullscreen(true);
|
||||||
source->GetRenderViewHost()->WasResized();
|
source->GetRenderViewHost()->WasResized();
|
||||||
|
Emit("enter-html-full-screen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +230,7 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
|
||||||
if (window) {
|
if (window) {
|
||||||
window->SetHtmlApiFullscreen(false);
|
window->SetHtmlApiFullscreen(false);
|
||||||
source->GetRenderViewHost()->WasResized();
|
source->GetRenderViewHost()->WasResized();
|
||||||
|
Emit("leave-html-full-screen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ supportedWebViewEvents = [
|
||||||
'destroyed'
|
'destroyed'
|
||||||
'page-title-set'
|
'page-title-set'
|
||||||
'page-favicon-updated'
|
'page-favicon-updated'
|
||||||
|
'enter-html-full-screen'
|
||||||
|
'leave-html-full-screen'
|
||||||
]
|
]
|
||||||
|
|
||||||
nextInstanceId = 0
|
nextInstanceId = 0
|
||||||
|
|
|
@ -99,7 +99,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
is_closed_(false),
|
is_closed_(false),
|
||||||
node_integration_(true),
|
node_integration_(true),
|
||||||
has_dialog_attached_(false),
|
has_dialog_attached_(false),
|
||||||
fullscreen_(false),
|
html_fullscreen_(false),
|
||||||
zoom_factor_(1.0),
|
zoom_factor_(1.0),
|
||||||
weak_factory_(this),
|
weak_factory_(this),
|
||||||
inspectable_web_contents_(
|
inspectable_web_contents_(
|
||||||
|
@ -806,8 +806,22 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
void NativeWindow::SetHtmlApiFullscreen(bool enter_fullscreen) {
|
||||||
|
// Window is already in fullscreen mode, save the state.
|
||||||
|
if (enter_fullscreen && IsFullscreen()) {
|
||||||
|
forced_fullscreen_ = true;
|
||||||
|
html_fullscreen_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exit html fullscreen state but not window's fullscreen mode.
|
||||||
|
if (!enter_fullscreen && forced_fullscreen_) {
|
||||||
|
html_fullscreen_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetFullScreen(enter_fullscreen);
|
SetFullScreen(enter_fullscreen);
|
||||||
fullscreen_ = enter_fullscreen;
|
html_fullscreen_ = enter_fullscreen;
|
||||||
|
forced_fullscreen_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowUnresponsive() {
|
void NativeWindow::NotifyWindowUnresponsive() {
|
||||||
|
|
|
@ -220,7 +220,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
|
|
||||||
bool has_frame() const { return has_frame_; }
|
bool has_frame() const { return has_frame_; }
|
||||||
|
|
||||||
bool IsHtmlApiFullscreen() const { return fullscreen_; }
|
bool IsHtmlApiFullscreen() const { return html_fullscreen_; }
|
||||||
|
|
||||||
void set_has_dialog_attached(bool has_dialog_attached) {
|
void set_has_dialog_attached(bool has_dialog_attached) {
|
||||||
has_dialog_attached_ = has_dialog_attached;
|
has_dialog_attached_ = has_dialog_attached;
|
||||||
|
@ -349,7 +349,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
bool has_dialog_attached_;
|
bool has_dialog_attached_;
|
||||||
|
|
||||||
// Whether window is fullscreened by HTML5 api.
|
// Whether window is fullscreened by HTML5 api.
|
||||||
bool fullscreen_;
|
bool html_fullscreen_;
|
||||||
|
|
||||||
|
// Whether window is fullscreened by window api.
|
||||||
|
bool forced_fullscreen_;
|
||||||
|
|
||||||
// Closure that would be called when window is unresponsive when closing,
|
// Closure that would be called when window is unresponsive when closing,
|
||||||
// it should be cancelled when we can prove that the window is responsive.
|
// it should be cancelled when we can prove that the window is responsive.
|
||||||
|
|
|
@ -22,6 +22,8 @@ WEB_VIEW_EVENTS =
|
||||||
'destroyed': []
|
'destroyed': []
|
||||||
'page-title-set': ['title', 'explicitSet']
|
'page-title-set': ['title', 'explicitSet']
|
||||||
'page-favicon-updated': ['favicons']
|
'page-favicon-updated': ['favicons']
|
||||||
|
'enter-html-full-screen': []
|
||||||
|
'leave-html-full-screen': []
|
||||||
|
|
||||||
dispatchEvent = (webView, event, args...) ->
|
dispatchEvent = (webView, event, args...) ->
|
||||||
throw new Error("Unkown event #{event}") unless WEB_VIEW_EVENTS[event]?
|
throw new Error("Unkown event #{event}") unless WEB_VIEW_EVENTS[event]?
|
||||||
|
|
|
@ -361,6 +361,14 @@ url.
|
||||||
|
|
||||||
Fired when page receives favicon urls.
|
Fired when page receives favicon urls.
|
||||||
|
|
||||||
|
### enter-html-full-screen
|
||||||
|
|
||||||
|
Fired when page enters fullscreen triggered by html api.
|
||||||
|
|
||||||
|
### leave-html-full-screen
|
||||||
|
|
||||||
|
Fired when page leaves fullscreen triggered by html api.
|
||||||
|
|
||||||
### console-message
|
### console-message
|
||||||
|
|
||||||
* `level` Integer
|
* `level` Integer
|
||||||
|
|
Loading…
Reference in a new issue