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-dev-detect-report.gz
|
||||||
ckb-next-dev-detect-report.gz
|
ckb-next-dev-detect-report.gz
|
||||||
macos/pkgproj/build
|
macos/pkgproj/build
|
||||||
|
compile_commands.json
|
||||||
|
|||||||
@@ -398,6 +398,13 @@ elseif (LINUX)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_sources(
|
||||||
|
ckb-next
|
||||||
|
PRIVATE
|
||||||
|
wayland/waylandutils.cpp
|
||||||
|
wayland/waylandutils.h
|
||||||
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (MAC_LEGACY)
|
if (MAC_LEGACY)
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
#include "ckbsettings.h"
|
#include "ckbsettings.h"
|
||||||
#include "animdetailsdialog.h"
|
#include "animdetailsdialog.h"
|
||||||
#include "kbmanager.h"
|
#include "kbmanager.h"
|
||||||
#ifdef USE_XCB_SCREENSAVER
|
#include "wayland/waylandutils.h"
|
||||||
#include "idletimer.h"
|
|
||||||
#endif
|
|
||||||
// KbLight
|
// KbLight
|
||||||
static int lastSharedDimming = -2;
|
static int lastSharedDimming = -2;
|
||||||
|
|
||||||
@@ -79,7 +77,7 @@ ExtraSettingsWidget::ExtraSettingsWidget(QWidget *parent) :
|
|||||||
#endif
|
#endif
|
||||||
// We need to explicitly disable this if there's a wayland session.
|
// 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 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"));
|
QString notSupported(tr("This feature is not supported under Wayland"));
|
||||||
ui->timerBox->setToolTip(notSupported);
|
ui->timerBox->setToolTip(notSupported);
|
||||||
ui->timerMinBox->setToolTip(notSupported);
|
ui->timerMinBox->setToolTip(notSupported);
|
||||||
|
|||||||
@@ -54,13 +54,3 @@ int IdleTimer::getIdleTime(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#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:
|
public:
|
||||||
static int getIdleTime();
|
static int getIdleTime();
|
||||||
static bool isWayland();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IDLETIMER_H
|
#endif // IDLETIMER_H
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "kbmanager.h"
|
#include "kbmanager.h"
|
||||||
#include "idletimer.h"
|
#include "idletimer.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include "wayland/waylandutils.h"
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
QString devpath = "/dev/input/ckb%1";
|
QString devpath = "/dev/input/ckb%1";
|
||||||
@@ -74,7 +75,7 @@ void KbManager::init(const QString& guiVersion){
|
|||||||
return;
|
return;
|
||||||
_kbManager = new KbManager();
|
_kbManager = new KbManager();
|
||||||
#ifdef USE_XCB_SCREENSAVER
|
#ifdef USE_XCB_SCREENSAVER
|
||||||
if(!IdleTimer::isWayland() && CkbSettings::get("Program/IdleTimerEnable", true).toBool()){
|
if(!WaylandUtils::isWayland() && CkbSettings::get("Program/IdleTimerEnable", true).toBool()){
|
||||||
setIdleTimer(true);
|
setIdleTimer(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "kbwidget.h"
|
#include "kbwidget.h"
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include "idletimer.h"
|
#include "wayland/waylandutils.h"
|
||||||
#include "kbwindowinfomodel.h"
|
#include "kbwindowinfomodel.h"
|
||||||
|
|
||||||
KbModeEventMgr::KbModeEventMgr(QWidget* parent, KbMode* m) :
|
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::rowsInserted, this, &KbModeEventMgr::rowsChanged);
|
||||||
connect(model, &KbWindowInfoModel::rowsRemoved, this, &KbModeEventMgr::rowsChanged);
|
connect(model, &KbWindowInfoModel::rowsRemoved, this, &KbModeEventMgr::rowsChanged);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
if(!IdleTimer::isWayland())
|
if(!WaylandUtils::isWayland())
|
||||||
ui->waylandWarning->hide();
|
ui->waylandWarning->hide();
|
||||||
ui->modeLabel->setText(QString(tr("Switch to mode \"%1\" when:")).arg(m->name()));
|
ui->modeLabel->setText(QString(tr("Switch to mode \"%1\" when:")).arg(m->name()));
|
||||||
ui->tableView->setModel(model);
|
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