Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions qxt/qxtglobalshortcut_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ namespace {
Q_DECLARE_LOGGING_CATEGORY(qxtCategory)
Q_LOGGING_CATEGORY(qxtCategory, "copyq.globalshortcut")

bool usePortal()
{
const bool usePortalFromEnv = qgetenv("COPYQ_USE_PORTAL") == "1";
return usePortalFromEnv || !X11Info::isPlatformX11();
}

} // namespace

class GlobalShortcutsPortal : public QObject
Expand Down Expand Up @@ -489,7 +495,7 @@ class QxtX11Data final {
QxtX11Data()
: m_display(nullptr)
{
if ( X11Info::isPlatformX11() ) {
if ( !usePortal() ) {
createFirstWindow();
m_display = X11Info::display();
}
Expand Down Expand Up @@ -616,19 +622,19 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(

void QxtGlobalShortcutPrivate::init()
{
if ( X11Info::isPlatformX11() )
if ( !usePortal() )
initFallback();
}

void QxtGlobalShortcutPrivate::destroy()
{
if ( X11Info::isPlatformX11() )
if ( !usePortal() )
destroyFallback();
}

bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
{
if ( X11Info::isPlatformX11() )
if ( !usePortal() )
return setShortcutFallback(shortcut);

auto portal = GlobalShortcutsPortal::instance();
Expand All @@ -643,7 +649,7 @@ bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)

bool QxtGlobalShortcutPrivate::unsetShortcut()
{
if ( X11Info::isPlatformX11() )
if ( !usePortal() )
return unsetShortcutFallback();

auto portal = GlobalShortcutsPortal::instance();
Expand All @@ -654,7 +660,7 @@ bool QxtGlobalShortcutPrivate::unsetShortcut()

quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers)
{
if ( !X11Info::isPlatformX11() )
if ( usePortal() )
return 0;

// ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask
Expand Down
Loading