mirror of
https://github.com/ckb-next/ckb-next.git
synced 2026-10-10 12:27:21 -04:00
Add Wayland utils
This commit is contained in:
@@ -20,3 +20,4 @@ qrc_*
|
||||
ckb-dev-detect-report.gz
|
||||
ckb-next-dev-detect-report.gz
|
||||
macos/pkgproj/build
|
||||
compile_commands.json
|
||||
|
||||
@@ -398,6 +398,13 @@ elseif (LINUX)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_sources(
|
||||
ckb-next
|
||||
PRIVATE
|
||||
wayland/waylandutils.cpp
|
||||
wayland/waylandutils.h
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (MAC_LEGACY)
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
#include "ckbsettings.h"
|
||||
#include "animdetailsdialog.h"
|
||||
#include "kbmanager.h"
|
||||
#ifdef USE_XCB_SCREENSAVER
|
||||
#include "idletimer.h"
|
||||
#endif
|
||||
#include "wayland/waylandutils.h"
|
||||
// KbLight
|
||||
static int lastSharedDimming = -2;
|
||||
|
||||
@@ -79,7 +77,7 @@ ExtraSettingsWidget::ExtraSettingsWidget(QWidget *parent) :
|
||||
#endif
|
||||
// We need to explicitly disable this if there's a wayland session.
|
||||
// If not, the idle timer will only count when there's activity inside XWayland windows.
|
||||
if(IdleTimer::isWayland()){
|
||||
if(WaylandUtils::isWayland()){
|
||||
QString notSupported(tr("This feature is not supported under Wayland"));
|
||||
ui->timerBox->setToolTip(notSupported);
|
||||
ui->timerMinBox->setToolTip(notSupported);
|
||||
|
||||
@@ -54,13 +54,3 @@ int IdleTimer::getIdleTime(){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool IdleTimer::isWayland(){
|
||||
QByteArray wdesktop = qgetenv("WAYLAND_DESKTOP");
|
||||
if(!wdesktop.isEmpty())
|
||||
return true;
|
||||
QString stype(qgetenv("XDG_SESSION_TYPE"));
|
||||
if(stype == "wayland")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ class IdleTimer
|
||||
{
|
||||
public:
|
||||
static int getIdleTime();
|
||||
static bool isWayland();
|
||||
};
|
||||
|
||||
#endif // IDLETIMER_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "kbmanager.h"
|
||||
#include "idletimer.h"
|
||||
#include <limits>
|
||||
#include "wayland/waylandutils.h"
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
QString devpath = "/dev/input/ckb%1";
|
||||
@@ -74,7 +75,7 @@ void KbManager::init(const QString& guiVersion){
|
||||
return;
|
||||
_kbManager = new KbManager();
|
||||
#ifdef USE_XCB_SCREENSAVER
|
||||
if(!IdleTimer::isWayland() && CkbSettings::get("Program/IdleTimerEnable", true).toBool()){
|
||||
if(!WaylandUtils::isWayland() && CkbSettings::get("Program/IdleTimerEnable", true).toBool()){
|
||||
setIdleTimer(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include "kbwidget.h"
|
||||
#include <QCloseEvent>
|
||||
#include "idletimer.h"
|
||||
#include "wayland/waylandutils.h"
|
||||
#include "kbwindowinfomodel.h"
|
||||
|
||||
KbModeEventMgr::KbModeEventMgr(QWidget* parent, KbMode* m) :
|
||||
@@ -15,7 +15,7 @@ KbModeEventMgr::KbModeEventMgr(QWidget* parent, KbMode* m) :
|
||||
connect(model, &KbWindowInfoModel::rowsInserted, this, &KbModeEventMgr::rowsChanged);
|
||||
connect(model, &KbWindowInfoModel::rowsRemoved, this, &KbModeEventMgr::rowsChanged);
|
||||
ui->setupUi(this);
|
||||
if(!IdleTimer::isWayland())
|
||||
if(!WaylandUtils::isWayland())
|
||||
ui->waylandWarning->hide();
|
||||
ui->modeLabel->setText(QString(tr("Switch to mode \"%1\" when:")).arg(m->name()));
|
||||
ui->tableView->setModel(model);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "waylandutils.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace WaylandUtils
|
||||
{
|
||||
|
||||
bool isWayland()
|
||||
{
|
||||
if (qGuiApp->platformName() == "wayland") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!qEnvironmentVariableIsEmpty("WAYLAND_DESKTOP")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(qEnvironmentVariable("XDG_SESSION_TYPE") == "wayland") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // WaylandUtils
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef WAYLANDUTILS_HPP
|
||||
#define WAYLANDUTILS_HPP
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace WaylandUtils
|
||||
{
|
||||
|
||||
bool isWayland();
|
||||
|
||||
} // WaylandUtils
|
||||
|
||||
#endif // WAYLANDUTILS_HPP
|
||||
Reference in New Issue
Block a user