Skip to content

Commit

Permalink
fix: add fix for overlay appearing on top of other windows (Linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Jul 15, 2022
1 parent 542a6fb commit 748e79d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gridplayer/dialogs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self, parent):
"logging/log_limit_size": self.logLimitSize,
"logging/log_limit_backups": self.logLimitBackups,
"internal/opaque_hw_overlay": self.miscOpaqueHWOverlay,
"internal/fake_overlay_invisibility": self.miscFakeOverlayInvisibility,
"streaming/hls_via_streamlink": self.streamingHLSVIAStreamlink,
"streaming/resolver_priority": self.streamingResolverPriority,
"streaming/resolver_priority_patterns": self.streamingResolverPriorityPatterns, # noqa: E501
Expand All @@ -128,6 +129,7 @@ def ui_customize(self): # noqa: WPS213
if not env.IS_LINUX:
self.section_misc.hide()
self.miscOpaqueHWOverlay.hide()
self.miscFakeOverlayInvisibility.hide()

def ui_customize_section_index(self):
font = self.section_index.font()
Expand Down
9 changes: 9 additions & 0 deletions gridplayer/dialogs/settings_dialog_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ def setupUi(self, SettingsDialog):
self.miscOpaqueHWOverlay = QtWidgets.QCheckBox(self.page_misc_advanced)
self.miscOpaqueHWOverlay.setObjectName("miscOpaqueHWOverlay")
self.lay_page_misc_advanced.addWidget(self.miscOpaqueHWOverlay)
self.miscFakeOverlayInvisibility = QtWidgets.QCheckBox(self.page_misc_advanced)
self.miscFakeOverlayInvisibility.setObjectName("miscFakeOverlayInvisibility")
self.lay_page_misc_advanced.addWidget(self.miscFakeOverlayInvisibility)
spacerItem3 = QtWidgets.QSpacerItem(
0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding
)
Expand Down Expand Up @@ -668,6 +671,12 @@ def retranslateUi(self, SettingsDialog):
self.miscOpaqueHWOverlay.setText(
_translate("SettingsDialog", "Opaque overlay (fix black screen)")
)
self.miscFakeOverlayInvisibility.setText(
_translate(
"SettingsDialog",
"Fake overlay invisibility (fix overlay on top of other windows)",
)
)
self.logLimit.setText(_translate("SettingsDialog", "Limit log file size"))
self.logLimitSizeLabel.setText(_translate("SettingsDialog", "Log file size"))
self.label_5.setText(_translate("SettingsDialog", "MB"))
Expand Down
1 change: 1 addition & 0 deletions gridplayer/player/managers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _is_reload_needed(self, previous_settings):
"player/video_driver",
"player/video_driver_players",
"internal/opaque_hw_overlay",
"internal/fake_overlay_invisibility",
"misc/vlc_options",
}

Expand Down
1 change: 1 addition & 0 deletions gridplayer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def default_language():
"logging/log_limit_size": 10,
"logging/log_limit_backups": 1,
"internal/opaque_hw_overlay": False,
"internal/fake_overlay_invisibility": False,
"streaming/hls_via_streamlink": True,
"streaming/resolver_priority": URLResolver.STREAMLINK,
"streaming/resolver_priority_patterns": ResolverPatterns(__root__=[]),
Expand Down
11 changes: 9 additions & 2 deletions gridplayer/widgets/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
from gridplayer.utils.url_resolve.url_resolve import VideoURLResolver
from gridplayer.vlc_player.static import MediaInput
from gridplayer.widgets.video_frame_vlc_base import VideoFrameVLC
from gridplayer.widgets.video_overlay import OverlayBlock, OverlayBlockFloating
from gridplayer.widgets.video_overlay import (
OverlayBlock,
OverlayBlockFloating,
OverlayFakeInvisible,
)
from gridplayer.widgets.video_status import VideoStatus

IN_PROGRESS_THRESHOLD_MS = 500
Expand Down Expand Up @@ -239,7 +243,10 @@ def reset(self):

def init_overlay(self):
if self.video_driver.is_opengl:
overlay = OverlayBlockFloating(self)
if Settings().get("internal/fake_overlay_invisibility"):
overlay = OverlayFakeInvisible(self)
else:
overlay = OverlayBlockFloating(self)
self.installEventFilter(overlay)
else:
overlay = OverlayBlock(self)
Expand Down
34 changes: 34 additions & 0 deletions gridplayer/widgets/video_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,37 @@ def event(self, event):
self.parent().window().filter_event(event)

return super().event(event)


class OverlayFakeInvisible(OverlayBlockFloating):
def __init__(self, parent=None):
super().__init__(parent)

self._is_visible = False

def show(self):
if not self.isVisible():
super().show()

self._is_visible = True

self.setAttribute(Qt.WA_TransparentForMouseEvents, False)
self.update()

def hide(self):
self._is_visible = False

self.setAttribute(Qt.WA_TransparentForMouseEvents)
self.update()

def paintEvent(self, event):
if not self._is_visible and self.windowOpacity() != 0:
self.setMask(QRegion(0, 0, 1, 1))
self.setWindowOpacity(0)
return

if self.windowOpacity() == 0:
self.clearMask()
self.setWindowOpacity(1)

super().paintEvent(event)
7 changes: 7 additions & 0 deletions resources/ui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="miscFakeOverlayInvisibility">
<property name="text">
<string>Fake overlay invisibility (fix overlay on top of other windows)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down

0 comments on commit 748e79d

Please sign in to comment.