Skip to content

Commit cf4acd2

Browse files
committed
X11: Use Portal optionally with COPYQ_USE_PORTAL env variable
1 parent 69656de commit cf4acd2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

qxt/qxtglobalshortcut_x11.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ namespace {
5656
Q_DECLARE_LOGGING_CATEGORY(qxtCategory)
5757
Q_LOGGING_CATEGORY(qxtCategory, "copyq.globalshortcut")
5858

59+
bool usePortal()
60+
{
61+
const bool usePortalFromEnv = qgetenv("COPYQ_USE_PORTAL") == "1";
62+
return usePortalFromEnv || !X11Info::isPlatformX11();
63+
}
64+
5965
} // namespace
6066

6167
class GlobalShortcutsPortal : public QObject
@@ -489,7 +495,7 @@ class QxtX11Data final {
489495
QxtX11Data()
490496
: m_display(nullptr)
491497
{
492-
if ( X11Info::isPlatformX11() ) {
498+
if ( !usePortal() ) {
493499
createFirstWindow();
494500
m_display = X11Info::display();
495501
}
@@ -616,19 +622,19 @@ bool QxtGlobalShortcutPrivate::nativeEventFilter(
616622

617623
void QxtGlobalShortcutPrivate::init()
618624
{
619-
if ( X11Info::isPlatformX11() )
625+
if ( !usePortal() )
620626
initFallback();
621627
}
622628

623629
void QxtGlobalShortcutPrivate::destroy()
624630
{
625-
if ( X11Info::isPlatformX11() )
631+
if ( !usePortal() )
626632
destroyFallback();
627633
}
628634

629635
bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
630636
{
631-
if ( X11Info::isPlatformX11() )
637+
if ( !usePortal() )
632638
return setShortcutFallback(shortcut);
633639

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

644650
bool QxtGlobalShortcutPrivate::unsetShortcut()
645651
{
646-
if ( X11Info::isPlatformX11() )
652+
if ( !usePortal() )
647653
return unsetShortcutFallback();
648654

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

655661
quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers)
656662
{
657-
if ( !X11Info::isPlatformX11() )
663+
if ( usePortal() )
658664
return 0;
659665

660666
// ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask

0 commit comments

Comments
 (0)