Merge branch 'Ban3-visibility-api'

This commit is contained in:
Florian Bruhin 2016-09-11 16:25:37 +02:00
commit d59589cbff
3 changed files with 43 additions and 0 deletions

View File

@ -43,6 +43,8 @@ Added
- New `:debug-log-level` command to change the console loglevel on-the-fly.
- New `general -> yank-ignored-url-parameters` option to configure which URL
parameters (like `utm_source` etc.) to strip off when yanking an URL.
- Support for the
https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API[HTML5 page visibility API]
Changed
~~~~~~~

View File

@ -197,6 +197,7 @@ Contributors, sorted by the number of commits in descending order:
* Michał Góral
* Michael Ilsaas
* Martin Zimmermann
* Jussi Timperi
* Fritz Reichwald
* Brian Jackson
* sbinix

View File

@ -72,6 +72,14 @@ class WebView(QWebView):
page = webpage.BrowserPage(self.win_id, self._tab_id, tab.data,
parent=self)
try:
page.setVisibilityState(
QWebPage.VisibilityStateVisible if self.isVisible()
else QWebPage.VisibilityStateHidden)
except AttributeError:
pass
self.setPage(page)
mode_manager = objreg.get('mode-manager', scope='window',
@ -240,3 +248,35 @@ class WebView(QWebView):
self.shutting_down.connect(menu.close)
modeman.instance(self.win_id).entered.connect(menu.close)
menu.exec_(e.globalPos())
def showEvent(self, e):
"""Extend showEvent to set the page visibility state to visible.
Args:
e: The QShowEvent.
Return:
The superclass event return value.
"""
try:
self.page().setVisibilityState(QWebPage.VisibilityStateVisible)
except AttributeError:
pass
super().showEvent(e)
def hideEvent(self, e):
"""Extend hideEvent to set the page visibility state to hidden.
Args:
e: The QHideEvent.
Return:
The superclass event return value.
"""
try:
self.page().setVisibilityState(QWebPage.VisibilityStateHidden)
except AttributeError:
pass
super().hideEvent(e)