Skip to content

Commit

Permalink
UI: Disable and ignore Always On Top on Wayland platforms
Browse files Browse the repository at this point in the history
This is a dangerous operation on Wayland, and is crashing not only
OBS Studio but also the whole compositor. Let's disable it for now
when running as a native Wayland client.

Some compositors (GNOME Shell, Plasma) still allow setting this
option on the window menu.
  • Loading branch information
GeorgesStavracas committed Feb 9, 2021
1 parent fb49fd4 commit 89693f1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@

#include <json11.hpp>

#ifdef ENABLE_WAYLAND
#include <obs-nix-platform.h>
#endif

using namespace json11;
using namespace std;

Expand Down Expand Up @@ -1865,9 +1869,22 @@ void OBSBasic::OBSInit()

bool alwaysOnTop = config_get_bool(App()->GlobalConfig(), "BasicWindow",
"AlwaysOnTop");
if (alwaysOnTop || opt_always_on_top) {

#ifdef ENABLE_WAYLAND
bool isWayland = obs_get_nix_platform() == OBS_NIX_PLATFORM_WAYLAND;
#else
bool isWayland = false;
#endif

if (!isWayland && (alwaysOnTop || opt_always_on_top)) {
SetAlwaysOnTop(this, true);
ui->actionAlwaysOnTop->setChecked(true);
} else if (isWayland) {
if (opt_always_on_top)
blog(LOG_INFO,
"Always On Top not available on Wayland, ignoring…");
ui->actionAlwaysOnTop->setEnabled(false);
ui->actionAlwaysOnTop->setVisible(false);
}

#ifndef _WIN32
Expand Down

0 comments on commit 89693f1

Please sign in to comment.