Skip to content

Commit

Permalink
qt: add preference qt-backdrop-blur
Browse files Browse the repository at this point in the history
This setting makes it possible to disable the
backdrop blur filter for the main window.

Apart from accessibility reasons, having this
setting enabled makes text being rendered in
worse quality since Qt's sub-pixel rendering
is impaired by translucency, which is a
requirement for exposing backdrop effects in
the UI layer.

In order to align with the proposed design,
this setting is enabled by default.
  • Loading branch information
fuzun authored and robUx4 committed Jul 20, 2024
1 parent 7dc7847 commit d33cfe3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
8 changes: 8 additions & 0 deletions modules/gui/qt/maininterface/compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ bool CompositorVideo::setBlurBehind(QWindow *window, const bool enable)
assert(window);
assert(m_intf);

if (enable)
{
if (!var_InheritBool(m_intf, "qt-backdrop-blur"))
{
return false;
}
}

if (m_failedToLoadWindowEffectsModule)
return false;

Expand Down
19 changes: 11 additions & 8 deletions modules/gui/qt/maininterface/compositor_dcomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,18 @@ void CompositorDirectComposition::setup()

if (!m_blurBehind)
{
try
if (var_InheritBool(m_intf, "qt-backdrop-blur"))
{
m_acrylicSurface = new CompositorDCompositionAcrylicSurface(m_intf, this, m_mainCtx, m_dcompDevice);
}
catch (const std::exception& exception)
{
if (const auto what = exception.what())
msg_Warn(m_intf, "%s", what);
delete m_acrylicSurface.data();
try
{
m_acrylicSurface = new CompositorDCompositionAcrylicSurface(m_intf, this, m_mainCtx, m_dcompDevice);
}
catch (const std::exception& exception)
{
if (const auto what = exception.what())
msg_Warn(m_intf, "%s", what);
delete m_acrylicSurface.data();
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/gui/qt/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define HIDE_WINDOW_ON_CLOSE_TEXT N_( "Hide the window on close" )
#define HIDE_WINDOW_ON_CLOSE_LONGTEXT N_( "Instead of closing the application, hide the window. This setting is only applicable when system tray icon is enabled." )

#define BACKDROP_BLUR_FILTER_TEXT N_( "Enable backdrop blur filter for the main window if possible" )
#define BACKDROP_BLUR_FILTER_LONGTEXT N_( "If backdrop blur filter is available, use translucency in the backgrounds of certain parts of the user interface " \
"instead of a solid color. This setting impairs readibility of text." )

static const int initial_prefs_view_list[] = { 0, 1, 2 };
static const char *const initial_prefs_view_list_texts[] =
{ N_("Simple"), N_("Advanced"), N_("Expert") };
Expand Down Expand Up @@ -435,6 +439,8 @@ vlc_module_begin ()

add_bool( "qt-close-to-system-tray", false, HIDE_WINDOW_ON_CLOSE_TEXT, HIDE_WINDOW_ON_CLOSE_LONGTEXT )

add_bool( "qt-backdrop-blur", true, BACKDROP_BLUR_FILTER_TEXT, BACKDROP_BLUR_FILTER_LONGTEXT )

add_float_with_range( "qt-safe-area", 0, 0, 100.0, SAFE_AREA_TEXT, SAFE_AREA_LONGTEXT )

cannot_unload_broken_library()
Expand Down

0 comments on commit d33cfe3

Please sign in to comment.