libkysdk-applications-2.2.1.1/ 0000775 0001750 0001750 00000000000 14474244170 015126 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/ 0000775 0001750 0001750 00000000000 14474244170 017401 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/kysdk-ukenv.pro 0000664 0001750 0001750 00000000761 14474244170 022402 0 ustar admin admin QT += core dbus
TARGET = kysdk-ukenv
TEMPLATE = lib
CONFIG += c++11 console link_pkgconfig
PKGCONFIG += gsettings-qt
HEADERS += src/usermanual.h \
src/currency.h \
src/gsettingmonitor.h
SOURCES += src/usermanual.cpp \
src/currency.cpp \
src/gsettingmonitor.cpp
# Default rules for deployment.
headers.files = $${HEADERS}
headers.path = /usr/include/kysdk/applications/
target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu
INSTALLS += target headers
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/ 0000775 0001750 0001750 00000000000 14474244170 020170 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/src/usermanual.cpp 0000664 0001750 0001750 00000003645 14474244170 023060 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include
#include
#include
#include
#include
#include "usermanual.h"
namespace kdk
{
namespace
{
constexpr char dbusObjectPath[] = "/";
constexpr char dbusInterfaceName[] = "com.guide.hotel";
constexpr char dbusCallUserManualMethod[] = "showGuide";
} // namespace
UserManual::UserManual() = default;
UserManual::~UserManual() = default;
bool UserManual::callUserManual(QString appName)
{
if (appName.isEmpty()) {
return false;
}
const QString dbusServiceName = QString("com.kylinUserGuide.hotel") + QString("_") + QString::number(getuid());
QDBusMessage message =
QDBusMessage::createMethodCall(dbusServiceName, dbusObjectPath, dbusInterfaceName, dbusCallUserManualMethod);
QList args;
args << appName;
message.setArguments(args);
QDBusMessage ret = QDBusConnection::sessionBus().call(message);
if (ret.type() == QDBusMessage::InvalidMessage || ret.type() == QDBusMessage::ErrorMessage) {
qCritical() << "kdk : user manual d-bus call fail!";
return false;
}
return true;
}
} // namespace kdk
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/currency.h 0000664 0001750 0001750 00000003523 14474244170 022176 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#ifndef KYSDK_UKENV_CURRENCY_H_
#define KYSDK_UKENV_CURRENCY_H_
#include
namespace kdk
{
enum AppName {
KylinIpmsg = 0, /* 传书 */
KylinFontViewer, /* 字体管理器 */
KylinCalculator, /* 麒麟计算器 */
KylinGpuController, /* 显卡控制器 */
KylinMusic, /* 音乐 */
KylinWeather, /* 天气 */
KylinPhotoViewer, /* 看图 */
KylinServiceSupport, /* 服务与支持 */
KylinPrinter, /* 麒麟打印 */
KylinCalendar, /* 日历 */
KylinRecorder, /* 录音 */
KylinCamera, /* 摄像头 */
KylinNotebook, /* 便签 */
KylinOsManager, /* 麒麟管家 */
KylinNetworkCheck, /* 网络检测工具 */
KylinGallery, /* 相册 */
KylinScanner, /* 扫描 */
KylinMobileAssistant, /* 多端协同 */
KylinTest /* 测试预留 */
};
class Currency
{
public:
Currency();
~Currency();
static QString getAppName(AppName appName);
};
} // namespace kdk
#endif
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/currency.cpp 0000664 0001750 0001750 00000004652 14474244170 022535 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include "currency.h"
namespace kdk
{
Currency::Currency() = default;
Currency::~Currency() = default;
QString Currency::getAppName(AppName appName)
{
switch (appName) {
case AppName::KylinCalculator:
return QString("kylin-calaulator");
case AppName::KylinCalendar:
return QString("kylin-calendar");
case AppName::KylinCamera:
return QString("kylin-camera");
case AppName::KylinFontViewer:
return QString("kylin-font-viewer");
case AppName::KylinGpuController:
return QString("kylin-gpu-controller");
case AppName::KylinIpmsg:
return QString("kylin-ipmsg");
case AppName::KylinMusic:
return QString("kylin-music");
case AppName::KylinPhotoViewer:
return QString("kylin-photo-viewer");
case AppName::KylinPrinter:
return QString("kylin-printer");
case AppName::KylinRecorder:
return QString("kylin-recorder");
case AppName::KylinServiceSupport:
return QString("kylin-service-support");
case AppName::KylinWeather:
return QString("kylin-weather");
case AppName::KylinNotebook:
return QString("kylin-notebook");
case AppName::KylinOsManager:
return QString("kylin-os-manager");
case AppName::KylinNetworkCheck:
return QString("kylin-network-check-tools");
case AppName::KylinGallery:
return QString("kylin-gallery");
case AppName::KylinScanner:
return QString("kylin-scanner");
case AppName::KylinMobileAssistant:
return QString("kylin-mobile-assistant");
default:
return QString("");
}
/* 不应该被执行 */
return "";
}
}
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/usermanual.h 0000664 0001750 0001750 00000002252 14474244170 022516 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#ifndef KYSDK_UKENV_USERMANUAL_H_
#define KYSDK_UKENV_USERMANUAL_H_
#include
namespace kdk
{
class UserManual
{
public:
UserManual();
~UserManual();
/**
* @brief 调用用户手册
*
* @param appName 应用名
*
* @retval true 成功
* @retval false 失败
*/
bool callUserManual(QString appName);
};
} // namespace kdk
#endif
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/gsettingmonitor.cpp 0000664 0001750 0001750 00000011303 14474244170 024126 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include
#include
#include
#include "gsettingmonitor.h"
namespace kdk
{
namespace
{
constexpr char themeSchemasId[] = "org.ukui.style";
constexpr char controlCenterPersonaliseSchemasId[] = "org.ukui.control-center.personalise";
constexpr char systemFontSizeKey[] = "systemFontSize";
constexpr char systemTransparencyKey[] = "transparency";
constexpr char systemThemeKey[] = "styleName";
constexpr char themeFlag[] = "__themeFlag";
constexpr char controlCenterPersonaliseFlag[] = "__controlCenterPersonaliseFlag";
QHash g_gsettings;
} // namespace
GsettingMonitor GsettingMonitor::m_gsettingMonitor;
GsettingMonitor::GsettingMonitor()
{
if (!GsettingMonitor::registerGsetting(themeFlag, themeSchemasId)) {
qCritical() << "kdk : register org.ukui.style gsetting fail!";
}
if (!GsettingMonitor::registerGsetting(controlCenterPersonaliseFlag, controlCenterPersonaliseSchemasId)) {
qCritical() << "kdk : register org.ukui.control-center.personalise gsetting fail!";
}
conn();
}
GsettingMonitor::~GsettingMonitor()
{
for (QHash::iterator it = g_gsettings.begin(); it != g_gsettings.end(); it++) {
QGSettings *s = it.value();
if (s != nullptr) {
delete s;
s = nullptr;
}
}
g_gsettings.clear();
}
GsettingMonitor *GsettingMonitor::getInstance(void)
{
return &m_gsettingMonitor;
}
bool GsettingMonitor::registerGsetting(QString flag, QByteArray schemasId)
{
QGSettings *s = nullptr;
if (g_gsettings.contains(flag)) {
qCritical() << "kdk : gsettings flag repeat!";
return false;
}
if (QGSettings::isSchemaInstalled(schemasId)) {
s = new QGSettings(schemasId);
} else {
qCritical() << "kdk : gsettings schemasId not fount!";
return false;
}
g_gsettings.insert(flag, s);
return true;
}
QVariant GsettingMonitor::getSystemFontSize(void)
{
QGSettings *s = nullptr;
if (g_gsettings.contains(themeFlag)) {
s = g_gsettings.value(themeFlag);
}
if (s != nullptr && s->keys().contains(systemFontSizeKey)) {
return s->get(systemFontSizeKey);
}
return QVariant();
}
QVariant GsettingMonitor::getSystemTransparency(void)
{
QGSettings *s = nullptr;
if (g_gsettings.contains(controlCenterPersonaliseFlag)) {
s = g_gsettings.value(controlCenterPersonaliseFlag);
}
if (s != nullptr && s->keys().contains(systemTransparencyKey)) {
return s->get(systemTransparencyKey);
}
return QVariant();
}
QVariant GsettingMonitor::getSystemTheme(void)
{
QGSettings *s = nullptr;
if (g_gsettings.contains(themeFlag)) {
s = g_gsettings.value(themeFlag);
}
if (s != nullptr && s->keys().contains(systemThemeKey)) {
return s->get(systemThemeKey);
}
return QVariant();
}
void GsettingMonitor::conn(void)
{
QGSettings *theme = nullptr;
QGSettings *control = nullptr;
if (g_gsettings.contains(themeFlag)) {
theme = g_gsettings.value(themeFlag);
}
if (g_gsettings.contains(controlCenterPersonaliseFlag)) {
control = g_gsettings.value(controlCenterPersonaliseFlag);
}
if (theme != nullptr) {
QObject::connect(theme, &QGSettings::changed, this, &GsettingMonitor::themeChange);
}
if (control != nullptr) {
QObject::connect(control, &QGSettings::changed, this, &GsettingMonitor::controlCenterPersonaliseChange);
}
return;
}
void GsettingMonitor::themeChange(QString key)
{
if (key == QString(systemThemeKey)) {
Q_EMIT systemThemeChange();
} else if (key == QString(systemFontSizeKey)) {
Q_EMIT systemFontSizeChange();
}
return;
}
void GsettingMonitor::controlCenterPersonaliseChange(QString key)
{
if (key == QString(systemTransparencyKey)) {
Q_EMIT systemTransparencyChange();
}
return;
}
} // namespace kdk
libkysdk-applications-2.2.1.1/kysdk-ukenv/src/gsettingmonitor.h 0000664 0001750 0001750 00000004162 14474244170 023600 0 ustar admin admin /*
* libkysdk-ukenv's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#ifndef KYSDK_UKENV_GSETTINGMONITOR_H_
#define KYSDK_UKENV_GSETTINGMONITOR_H_
#include
#include
#include
#include
namespace kdk
{
class GsettingMonitor : public QObject
{
Q_OBJECT
public:
~GsettingMonitor();
/**
* @brief 获取单例指针
*
* @param 无
*
* @return 获取到的单例指针
*/
static GsettingMonitor *getInstance(void);
/**
* @brief 获取系统字号
*
* @param 无
*
* @return 获取到的系统字号
*/
static QVariant getSystemFontSize(void);
/**
* @brief 获取系统透明度
*
* @param 无
*
* @return 获取到的系统透明度
*/
static QVariant getSystemTransparency(void);
/**
* @brief 获取系统主题
*
* @param 无
*
* @return 获取到的系统主题
*/
static QVariant getSystemTheme(void);
Q_SIGNALS:
void systemFontSizeChange();
void systemTransparencyChange();
void systemThemeChange();
private Q_SLOTS:
void themeChange(QString key);
void controlCenterPersonaliseChange(QString key);
private:
GsettingMonitor();
void conn(void);
static bool registerGsetting(QString flag, QByteArray schemasId);
static GsettingMonitor m_gsettingMonitor;
};
} // namespace kdk
#endif
libkysdk-applications-2.2.1.1/kysdk-ukenv/test/ 0000775 0001750 0001750 00000000000 14474244076 020365 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/ 0000775 0001750 0001750 00000000000 14474244170 023434 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/testusermanual.pro 0000664 0001750 0001750 00000000204 14474244076 027233 0 ustar admin admin QT += widgets
TARGET = testusermanual
TEMPLATE = app
CONFIG += c++11 link_pkgconfig
PKGCONFIG += kysdk-ukenv
SOURCES += main.cpp libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testusermanual/main.cpp 0000664 0001750 0001750 00000002154 14474244170 025066 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include
#include
#include "usermanual.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
/* 调用用户手册 */
kdk::UserManual userManual;
if (!userManual.callUserManual("messages")) {
qCritical() << "call user manual fail!";
return -1;
}
return app.exec();
}
libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/ 0000775 0001750 0001750 00000000000 14474244170 023112 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/main.cpp 0000664 0001750 0001750 00000001757 14474244170 024554 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include
#include
#include "currency.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
qDebug() << kdk::Currency::getAppName(kdk::AppName::KylinIpmsg);
app.exec();
}
libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testcurrency/testcurrency.pro 0000664 0001750 0001750 00000000206 14474244076 026371 0 ustar admin admin QT += core
TARGET = testcurrency
TEMPLATE = app
CONFIG += c++11 console link_pkgconfig
PKGCONFIG += kysdk-ukenv
SOURCES += main.cpp libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/ 0000775 0001750 0001750 00000000000 14474244170 024514 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/testgsettingmonitor.pro 0000664 0001750 0001750 00000000232 14474244076 031374 0 ustar admin admin QT += core
TARGET = testgsettingmonitor
TEMPLATE = app
CONFIG += c++11 console link_pkgconfig
PKGCONFIG += gsettings-qt kysdk-ukenv
SOURCES += main.cpp libkysdk-applications-2.2.1.1/kysdk-ukenv/test/testgsettingmonitor/main.cpp 0000664 0001750 0001750 00000003467 14474244170 026156 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Shengjie Ji
*
*/
#include
#include
#include
#include "gsettingmonitor.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
qDebug() << "系统字号 : " << kdk::GsettingMonitor::getSystemFontSize();
qDebug() << "系统透明度 : " << kdk::GsettingMonitor::getSystemTransparency();
qDebug() << "系统主题" << kdk::GsettingMonitor::getSystemTheme();
QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemFontSizeChange, [=]() {
qDebug() << "系统字号改变 : " << kdk::GsettingMonitor::getSystemFontSize();
});
QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemThemeChange, [=]() {
qDebug() << "系统主题改变 : " << kdk::GsettingMonitor::getSystemTheme();
});
QObject::connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemTransparencyChange, [=]() {
qDebug() << "系统透明度改变 : " << kdk::GsettingMonitor::getSystemTransparency();
});
return app.exec();
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/ 0000775 0001750 0001750 00000000000 14474244170 021110 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/readme.md 0000664 0001750 0001750 00000000000 14474244076 022662 0 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/kysdk-waylandhelper.pro 0000664 0001750 0001750 00000005704 14474244170 025622 0 ustar admin admin QT += KWaylandClient KWaylandServer gui widgets x11extras KWindowSystem KIconThemes
TEMPLATE = lib
DEFINES += KYSDKWAYLANDHELPER_LIBRARY
CONFIG += c++11 link_pkgconfig
PKGCONFIG += wayland-client x11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
src/ukuistylehelper/ukui-decoration-core.c \
src/ukuistylehelper/ukui-decoration-manager.cpp \
src/ukuistylehelper/ukuistylehelper.cpp \
src/ukuistylehelper/xatom-helper.cpp \
src/waylandhelper.cpp \
src/windowmanager/abstractinterface.cpp \
src/windowmanager/waylandinterface.cpp \
src/windowmanager/wmregister.cpp \
src/windowmanager/xcbinterface.cpp \
src/windowmanager/windowmanager.cpp
HEADERS += \
src/ukuistylehelper/ukui-decoration-client.h \
src/ukuistylehelper/ukui-decoration-manager.h \
src/ukuistylehelper/ukuistylehelper.h \
src/ukuistylehelper/xatom-helper.h \
src/waylandhelper.h \
src/windowmanager/abstractinterface.h \
src/windowmanager/waylandinterface.h \
src/windowmanager/windowinfo.h \
src/windowmanager/wmregister.h \
src/windowmanager/xcbinterface.h \
src/windowmanager/windowmanager.h \
src/kysdk-waylandhelper_global.h
#kysdk-waylandhelper/src/*.h usr/include/kysdk/applications/
#kysdk-waylandhelper/src/ukuistylehelper/*.h usr/include/kysdk/applications/ukuistylehelper/
#kysdk-waylandhelper/src/windowmanager/*.h usr/include/kysdk/applications/windowmanager/
# Default rules for deployment.
headers.files = src/kysdk-waylandhelper_global.h \
src/waylandhelper.h
headers.path = /usr/include/kysdk/applications/
wm_headers.files = src/windowmanager/abstractinterface.h \
src/windowmanager/waylandinterface.h \
src/windowmanager/windowinfo.h \
src/windowmanager/wmregister.h \
src/windowmanager/xcbinterface.h \
src/windowmanager/windowmanager.h
wm_headers.path = /usr/include/kysdk/applications/windowmanager/
sty_headers.files = src/ukuistylehelper/ukui-decoration-client.h \
src/ukuistylehelper/ukui-decoration-manager.h \
src/ukuistylehelper/ukuistylehelper.h \
src/ukuistylehelper/xatom-helper.h
sty_headers.path = /usr/include/kysdk/applications/ukuistylehelper/
target.path = /usr/lib/$$QMAKE_HOST.arch-linux-gnu
INSTALLS += target headers wm_headers sty_headers
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ 0000775 0001750 0001750 00000000000 14474244170 021677 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/ 0000775 0001750 0001750 00000000000 14474244170 024541 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowmanager.cpp 0000664 0001750 0001750 00000014217 14474244170 030114 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "windowmanager.h"
#include
#include
#include
using namespace kdk;
static WindowManager* g_windowmanger = nullptr;
static WmRegister* m_wm =nullptr;
kdk::WindowManager::WindowManager(QObject *parent)
:QObject(parent)
{
m_wm = new WmRegister(this);
connect(m_wm->winInterface(),&AbstractInterface::windowAdded,this,&WindowManager::windowAdded);
connect(m_wm->winInterface(),&AbstractInterface::windowRemoved,this,&WindowManager::windowRemoved);
connect(m_wm->winInterface(),&AbstractInterface::activeWindowChanged,this,&WindowManager::activeWindowChanged);
connect(m_wm->winInterface(),&AbstractInterface::windowChanged,this,&WindowManager::windowChanged);
connect(m_wm->winInterface(),&AbstractInterface::currentDesktopChanged,this,&WindowManager::currentDesktopChanged);
connect(m_wm->winInterface(),&AbstractInterface::isShowingDesktopChanged,this,&WindowManager::isShowingDesktopChanged);
}
WindowId WindowManager::currentActiveWindow()
{
self();
if(!m_wm)
return QVariant();
return m_wm->winInterface()->activeWindow();
}
void WindowManager::keepWindowAbove(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->requestToggleKeepAbove(windowId);
}
QString WindowManager::getWindowTitle(const WindowId &windowId)
{
self();
if(!m_wm)
return QString();
return m_wm->winInterface()->titleFor(windowId);
}
QIcon WindowManager::getWindowIcon(const WindowId &windowId)
{
self();
if(!m_wm)
return QIcon();
return m_wm->winInterface()->iconFor(windowId);
}
QString WindowManager::getWindowGroup(const WindowId &windowId)
{
if(!m_wm)
return QString();
self();
return m_wm->winInterface()->windowGroupFor(windowId);
}
void WindowManager::closeWindow(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->requestClose(windowId);
}
void WindowManager::activateWindow(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->requestActivate(windowId);
}
void WindowManager::maximizeWindow(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->requestToggleMaximized(windowId);
}
void WindowManager::minimizeWindow(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->requestToggleMinimized(windowId);
}
quint32 WindowManager::getPid(const WindowId &windowId)
{
self();
quint32 pid = 0;
if(!m_wm)
return pid;
pid = m_wm->winInterface()->pid(windowId);
return pid;
}
WindowManager *WindowManager::self()
{
if(g_windowmanger)
return g_windowmanger;
g_windowmanger = new WindowManager();
return g_windowmanger;
}
WindowInfo WindowManager::getwindowInfo(const WindowId &windowId)
{
self();
if(!m_wm)
return WindowInfo();
return m_wm->winInterface()->requestInfo(windowId);
}
void WindowManager::showDesktop()
{
self();
if(!m_wm)
return;
m_wm->winInterface()->showCurrentDesktop();
}
void WindowManager::hideDesktop()
{
self();
if(!m_wm)
return;
m_wm->winInterface()->hideCurrentDesktop();
}
QString WindowManager::currentDesktop()
{
self();
if(!m_wm)
return 0;
return m_wm->winInterface()->currentDesktop();
}
QList WindowManager::windows()
{
self();
if(!m_wm)
return QList();
return m_wm->winInterface()->windows();
}
NET::WindowType WindowManager::getWindowType(const WindowId &windowId)
{
self();
if(!m_wm)
return NET::WindowType::Unknown;
return m_wm->winInterface()->windowType(windowId);
}
void WindowManager::setGeometry(QWindow *window, const QRect &rect)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->setGeometry(window,rect);
}
void WindowManager::setSkipTaskBar(QWindow *window, bool skip)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->setSkipTaskBar(window,skip);
}
void WindowManager::setSkipSwitcher(QWindow *window, bool skip)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->setSkipSwitcher(window,skip);
}
bool WindowManager::skipTaskBar(const WindowId &windowId)
{
self();
if(!m_wm)
return false;
return m_wm->winInterface()->skipTaskBar(windowId);
}
bool WindowManager::skipSwitcher(const WindowId &windowId)
{
self();
if(!m_wm)
return false;
return m_wm->winInterface()->skipSwitcher(windowId);
}
bool WindowManager::isShowingDesktop()
{
self();
if(!m_wm)
return false;
return m_wm->winInterface()->isShowingDesktop();
}
void WindowManager::setOnAllDesktops(const WindowId &windowId)
{
self();
if(!m_wm)
return;
m_wm->winInterface()->setOnAllDesktops(windowId);
}
bool WindowManager::isOnAllDesktops(const WindowId &windowId)
{
kdk::WindowInfo windowInfo = WindowManager::getwindowInfo(windowId);
return windowInfo.isOnAllDesktops();
}
bool WindowManager::isOnCurrentDesktop(const WindowId &windowId)
{
kdk::WindowInfo windowinfo = WindowManager::getwindowInfo(windowId);
return windowinfo.isOnDesktop(currentDesktop());
}
bool WindowManager::isOnDesktop(const WindowId &windowId, int desktop)
{
kdk::WindowInfo windowinfo = WindowManager::getwindowInfo(windowId);
return windowinfo.isOnDesktop(QString::number(desktop));
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/wmregister.h 0000664 0001750 0001750 00000002275 14474244170 027110 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WMREGISTER_H
#define WMREGISTER_H
#include
#include "../kysdk-waylandhelper_global.h"
#include "abstractinterface.h"
namespace kdk
{
class KYSDKWAYLANDHELPER_EXPORT WmRegister:public QObject
{
public:
WmRegister(QObject*parent = nullptr);
~WmRegister();
AbstractInterface* winInterface();
private:
AbstractInterface *m_winInterface{nullptr};
};
}
#endif // WMREGISTER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/abstractinterface.h 0000664 0001750 0001750 00000006027 14474244170 030403 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef ABSTRACTINTERFACE_H
#define ABSTRACTINTERFACE_H
#include
#include
#include
#include "windowinfo.h"
#include "netwm.h"
namespace kdk
{
using WindowId = QVariant;
class KWindows;
class AbstractInterface:public QObject
{
Q_OBJECT
public:
AbstractInterface(QObject* parent=nullptr);
virtual ~AbstractInterface();
virtual WindowInfo requestInfo(WindowId wid) = 0;
virtual void requestActivate(WindowId wid) = 0;
virtual void requestClose(WindowId wid) = 0;
virtual void requestToggleKeepAbove(WindowId wid) = 0;
virtual void requestToggleMinimized(WindowId wid) = 0;
virtual void requestToggleMaximized(WindowId wid) = 0;
virtual WindowId activeWindow() = 0;
virtual QIcon iconFor(WindowId wid) = 0;
virtual QString titleFor(WindowId wid) = 0;
virtual QString windowGroupFor(WindowId wid) = 0;
virtual bool windowCanBeDragged(WindowId wid) = 0;
virtual bool windowCanBeMaximized(WindowId wid) = 0;
virtual void showCurrentDesktop() = 0;
virtual void hideCurrentDesktop() = 0;
virtual quint32 pid(WindowId wid) = 0;
virtual void setGeometry(QWindow *window, const QRect &rect) = 0;
virtual NET::WindowType windowType(WindowId wid) = 0;
virtual void setSkipTaskBar(QWindow* window,bool skip) = 0;
virtual void setSkipSwitcher(QWindow* window,bool skip) = 0;
virtual bool skipTaskBar(const WindowId &wid) = 0;
virtual bool skipSwitcher(const WindowId &wid) = 0;
virtual bool isShowingDesktop() = 0;
virtual void setOnAllDesktops(const WindowId &wid) = 0;
bool inCurrentDesktopActivity(const WindowInfo &winfo) ;
bool isPlasmaDesktop(const QRect &wGeometry);
QString currentDesktop() ;
QString currentActivity() ;
void setPlasmaDesktop(WindowId wid);
bool isValidFor(const WindowId &wid) ;
QList windows();
Q_SIGNALS:
void activeWindowChanged(WindowId wid);
void windowChanged(WindowId winfo);
void windowAdded(WindowId wid);
void windowRemoved(WindowId wid);
void currentDesktopChanged();
void isShowingDesktopChanged();
public:
QMap m_windows;
QString m_currentDesktop;
QString m_currentActivity;
};
}
#endif // ABSTRACTINTERFACE_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/abstractinterface.cpp 0000664 0001750 0001750 00000004331 14474244170 030732 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "abstractinterface.h"
#include
#include
#include
using namespace kdk;
AbstractInterface::AbstractInterface(QObject *parent)
:QObject(parent)
{
}
AbstractInterface::~AbstractInterface()
{
}
bool AbstractInterface::inCurrentDesktopActivity(const WindowInfo &winfo)
{
if(winfo.isValid() && winfo.isOnDesktop(currentDesktop()))
return (winfo.isValid() && winfo.isOnDesktop(currentDesktop()) /*&& winfo.isOnActivity(currentActivity())*/);
}
bool AbstractInterface::isPlasmaDesktop(const QRect &wGeometry)
{
if (wGeometry.isEmpty()) {
return false;
}
for (const auto scr : qGuiApp->screens()) {
if (wGeometry == scr->geometry()) {
return true;
}
}
return false;
}
QString AbstractInterface::currentDesktop()
{
return m_currentDesktop;
}
QString AbstractInterface::currentActivity()
{
return m_currentActivity;
}
void AbstractInterface::setPlasmaDesktop(WindowId wid)
{
if (!m_windows.contains(wid)) {
return;
}
if (!m_windows[wid].isPlasmaDesktop()) {
m_windows[wid].setIsPlasmaDesktop(true);
//updateAllHints();
}
}
bool AbstractInterface::isValidFor(const WindowId &wid)
{
if (!m_windows.contains(wid)) {
return false;
}
return m_windows[wid].isValid() && !m_windows[wid].isPlasmaDesktop();
}
QList AbstractInterface::windows()
{
return m_windows.keys();
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowmanager.h 0000664 0001750 0001750 00000013110 14474244170 027550 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WINDOWMANAGER_H
#define WINDOWMANAGER_H
#include
#include
#include
#include "windowinfo.h"
#include "wmregister.h"
namespace kdk
{
using WindowId = QVariant;
class WindowManager : public QObject
{
Q_OBJECT
public:
/**
* @brief self
* @return
*/
static WindowManager* self();
/**
* @brief 获取窗口信息
* @param windowId
* @return
*/
static WindowInfo getwindowInfo(const WindowId& windowId);
/**
* @brief 获取当前活动窗口
* @return
*/
static WindowId currentActiveWindow();
/**
* @brief 置顶窗口
* @param windowId
*/
static void keepWindowAbove(const WindowId& windowId);
/**
* @brief 获取窗口标题
* @param windowId
* @return
*/
static QString getWindowTitle(const WindowId& windowId);
/**
* @brief 获取窗口图标
* @param windowId
* @return
*/
static QIcon getWindowIcon(const WindowId& windowId);
/**
* @brief 获取窗口所在组的组名
* @param windowId
* @return
*/
static QString getWindowGroup(const WindowId& windowId);
/**
* @brief 关闭窗口
* @param windowId
*/
static void closeWindow(const WindowId& windowId);
/**
* @brief 激活窗口
* @param windowId
*/
static void activateWindow(const WindowId& windowId);
/**
* @brief 最大化窗口
* @param windowId
*/
static void maximizeWindow(const WindowId& windowId);
/**
* @brief 最小化窗口
* @param windowId
*/
static void minimizeWindow(const WindowId& windowId);
/**
* @brief 获取窗口进程pid
* @return
*/
static quint32 getPid(const WindowId& windowId);
/**
* @brief 显示当前桌面
*/
static void showDesktop();
/**
* @brief 取消显示当前桌面
*/
static void hideDesktop();
/**
* @brief 获取当前桌面的名称
* @return
*/
static QString currentDesktop();
/**
* @brief 获取当前窗口列表
* @return
*/
static QList windows();
/**
* @brief 获取窗口类型,仅适用于X环境下,wayland下统一返回normal
* @param windowId
* @return
*/
static NET::WindowType getWindowType(const WindowId& windowId);
/**
* @brief 设置窗口位置
* @param window
* @param rect
*/
static void setGeometry(QWindow *window,const QRect &rect);
/**
* @brief 设置是否跳过任务栏,since 2.0
* @param window
* @param skip
*/
static void setSkipTaskBar(QWindow *window,bool skip);
/**
* @brief 设置是否跳过窗口选择,,since 2.0
* @param window
* @param skip
*/
static void setSkipSwitcher(QWindow *window,bool skip);
/**
* @brief 判断窗体是否跳过任务栏,since 2.0
* @param windowId
* @return
*/
static bool skipTaskBar(const WindowId& windowId);
/**
* @brief 判断窗体是否跳过窗口选择,since 2.0
* @param windowId
* @return
*/
static bool skipSwitcher(const WindowId& windowId);
/**
* @brief 判断桌面是否处于显示状态,,since 2.0
* @return
*/
static bool isShowingDesktop();
/**
* @brief 设置窗口在所有桌面中显示,since 2.0
* @param wid
*/
static void setOnAllDesktops(const WindowId &windowId);
/**
* @brief 判断窗口在所有桌面中显示,since 2.0
* @param windowId
* @return
*/
static bool isOnAllDesktops(const WindowId &windowId);
/**
* @brief 判断窗口是否在当前桌面
* @param 窗口id
* @return
*/
static bool isOnCurrentDesktop(const WindowId& id);
/**
* @brief 判断窗口是否在指定桌面
* @param 窗口id
* @param 桌面id
* @return
*/
static bool isOnDesktop(const WindowId &id, int desktop);
Q_SIGNALS:
/**
* @brief 窗口添加信号
* @param windowId
*/
void windowAdded(const WindowId& windowId);
/**
* @brief 窗口删除信号
* @param windowId
*/
void windowRemoved(const WindowId& windowId);
/**
* @brief 活动窗口改变信号
* @param wid
*/
void activeWindowChanged(const WindowId& wid);
/**
* @brief 窗口改变信号
* @param wid
*/
void windowChanged(const WindowId& wid);
/**
* @brief 当前桌面改变信号
* @param wid
*/
void currentDesktopChanged();
/**
* @brief 桌面显示状态变化信号
*/
void isShowingDesktopChanged();
private:
WindowManager(QObject *parent = nullptr);
};
}
#endif // WINDOWMANAGER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/netwm.h 0000664 0001750 0001750 00000152603 14474244170 026053 0 ustar admin admin /*
Copyright (c) 2000 Troll Tech AS
Copyright (c) 2003 Lubos Lunak
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef netwm_h
#define netwm_h
#include
#include
#include
#if KWINDOWSYSTEM_HAVE_X11
#include
#include
#include "netwm_def.h"
#define KDE_ALL_ACTIVITIES_UUID "00000000-0000-0000-0000-000000000000"
// forward declaration
struct NETRootInfoPrivate;
struct NETWinInfoPrivate;
template class NETRArray;
/**
Common API for root window properties/protocols.
The NETRootInfo class provides a common API for clients and window managers
to set/read/change properties on the root window as defined by the NET Window
Manager Specification..
@author Bradley T. Hughes
@see NET
@see NETWinInfo
**/
class KWINDOWSYSTEM_EXPORT NETRootInfo : public NET
{
public:
/**
Indexes for the properties array.
**/
// update also NETRootInfoPrivate::properties[] size when extending this
enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS,
PROPERTIES_SIZE
};
/**
Window Managers should use this constructor to create a NETRootInfo object,
which will be used to set/update information stored on the rootWindow.
The application role is automatically set to WindowManager
when using this constructor.
@param connection XCB connection
@param supportWindow The Window id of the supportWindow. The supportWindow
must be created by the window manager as a child of the rootWindow. The
supportWindow must not be destroyed until the Window Manager exits.
@param wmName A string which should be the window manager's name (ie. "KWin"
or "Blackbox").
@param properties The properties the window manager supports
@param windowTypes The window types the window manager supports
@param states The states the window manager supports
@param properties2 The properties2 the window manager supports
@param actions The actions the window manager supports
@param screen For Window Managers that support multiple screen (ie.
"multiheaded") displays, the screen number may be explicitly defined. If
this argument is omitted, the default screen will be used.
@param doActivate true to activate the window
**/
NETRootInfo(xcb_connection_t *connection, xcb_window_t supportWindow, const char *wmName,
NET::Properties properties, NET::WindowTypes windowTypes, NET::States states,
NET::Properties2 properties2, NET::Actions actions,
int screen = -1, bool doActivate = true);
/**
Clients should use this constructor to create a NETRootInfo object, which
will be used to query information set on the root window. The application
role is automatically set to Client when using this constructor.
@param connection XCB connection
@param properties The properties the client is interested in.
@param properties2 The properties2 the client is interested in.
@param properties_size The number of elements in the properties array.
@param screen For Clients that support multiple screen (ie. "multiheaded")
displays, the screen number may be explicitly defined. If this argument is
omitted, the default screen will be used.
@param doActivate true to call activate() to do an initial data read/update
of the query information.
**/
NETRootInfo(xcb_connection_t *connection, NET::Properties properties, NET::Properties2 properties2 = NET::Properties2(),
int screen = -1, bool doActivate = true);
/**
Creates a shared copy of the specified NETRootInfo object.
@param rootinfo the NETRootInfo object to copy
**/
NETRootInfo(const NETRootInfo &rootinfo);
/**
Destroys the NETRootInfo object.
**/
virtual ~NETRootInfo();
/**
Returns the xcb connection used.
@return the XCB connection
**/
xcb_connection_t *xcbConnection() const;
/**
Returns the Window id of the rootWindow.
@return the id of the root window
**/
xcb_window_t rootWindow() const;
/**
Returns the Window id of the supportWindow.
@return the id of the support window
**/
xcb_window_t supportWindow() const;
/**
Returns the name of the Window Manager.
@return the name of the window manager
**/
const char *wmName() const;
/**
Sets the given property if on is true, and clears the property otherwise.
In WindowManager mode this function updates _NET_SUPPORTED.
In Client mode this function does nothing.
@since 4.4
**/
void setSupported(NET::Property property, bool on = true);
/**
@overload
@since 4.4
**/
void setSupported(NET::Property2 property, bool on = true);
/**
@overload
@since 4.4
**/
void setSupported(NET::WindowTypeMask property, bool on = true);
/**
@overload
@since 4.4
**/
void setSupported(NET::State property, bool on = true);
/**
@overload
@since 4.4
**/
void setSupported(NET::Action property, bool on = true);
/**
Returns true if the given property is supported by the window
manager. Note that for Client mode, NET::Supported needs
to be passed in the properties argument for this to work.
**/
bool isSupported(NET::Property property) const;
/**
@overload
**/
bool isSupported(NET::Property2 property) const;
/**
@overload
**/
bool isSupported(NET::WindowTypeMask type) const;
/**
@overload
**/
bool isSupported(NET::State state) const;
/**
@overload
**/
bool isSupported(NET::Action action) const;
/**
In the Window Manager mode, this is equivalent to the properties
argument passed to the constructor. In the Client mode, if
NET::Supported was passed in the properties argument, the returned
value are all properties supported by the Window Manager. Other supported
protocols and properties are returned by the specific methods.
@see supportedProperties2()
@see supportedStates()
@see supportedWindowTypes()
@see supportedActions()
**/
NET::Properties supportedProperties() const;
/**
* In the Window Manager mode, this is equivalent to the properties2
* argument passed to the constructor. In the Client mode, if
* NET::Supported was passed in the properties argument, the returned
* value are all properties2 supported by the Window Manager. Other supported
* protocols and properties are returned by the specific methods.
* @see supportedProperties()
* @see supportedStates()
* @see supportedWindowTypes()
* @see supportedActions()
* @since 5.0
**/
NET::Properties2 supportedProperties2() const;
/**
* In the Window Manager mode, this is equivalent to the states
* argument passed to the constructor. In the Client mode, if
* NET::Supported was passed in the properties argument, the returned
* value are all states supported by the Window Manager. Other supported
* protocols and properties are returned by the specific methods.
* @see supportedProperties()
@see supportedProperties2()
* @see supportedWindowTypes()
* @see supportedActions()
* @since 5.0
**/
NET::States supportedStates() const;
/**
* In the Window Manager mode, this is equivalent to the windowTypes
* argument passed to the constructor. In the Client mode, if
* NET::Supported was passed in the properties argument, the returned
* value are all window types supported by the Window Manager. Other supported
* protocols and properties are returned by the specific methods.
* @see supportedProperties()
@see supportedProperties2()
* @see supportedStates()
* @see supportedActions()
* @since 5.0
**/
NET::WindowTypes supportedWindowTypes() const;
/**
* In the Window Manager mode, this is equivalent to the actions
* argument passed to the constructor. In the Client mode, if
* NET::Supported was passed in the properties argument, the returned
* value are all actions supported by the Window Manager. Other supported
* protocols and properties are returned by the specific methods.
* @see supportedProperties()
@see supportedProperties2()
* @see supportedStates()
* @see supportedWindowTypes()
* @since 5.0
**/
NET::Actions supportedActions() const;
/**
* @returns the properties argument passed to the constructor.
* @see passedProperties2()
* @see passedStates()
* @see passedWindowTypes()
* @see passedActions()
**/
NET::Properties passedProperties() const;
/**
* @returns the properties2 argument passed to the constructor.
* @see passedProperties()
* @see passedStates()
* @see passedWindowTypes()
* @see passedActions()
* @since 5.0
**/
NET::Properties2 passedProperties2() const;
/**
* @returns the states argument passed to the constructor.
* @see passedProperties()
* @see passedProperties2()
* @see passedWindowTypes()
* @see passedActions()
* @since 5.0
**/
NET::States passedStates() const;
/**
* @returns the windowTypes argument passed to the constructor.
* @see passedProperties()
* @see passedProperties2()
* @see passedStates()
* @see passedActions()
* @since 5.0
**/
NET::WindowTypes passedWindowTypes() const;
/**
* @returns the actions argument passed to the constructor.
* @see passedProperties()
* @see passedProperties2()
* @see passedStates()
* @see passedWindowTypes()
* @since 5.0
**/
NET::Actions passedActions() const;
/**
Returns an array of Window id's, which contain all managed windows.
@return the array of Window id's
@see clientListCount()
**/
const xcb_window_t *clientList() const;
/**
Returns the number of managed windows in clientList array.
@return the number of managed windows in the clientList array
@see clientList()
**/
int clientListCount() const;
/**
Returns an array of Window id's, which contain all managed windows in
stacking order.
@return the array of Window id's in stacking order
@see clientListStackingCount()
**/
const xcb_window_t *clientListStacking() const;
/**
Returns the number of managed windows in the clientListStacking array.
@return the number of Window id's in the client list
@see clientListStacking()
**/
int clientListStackingCount() const;
/**
Returns the desktop geometry size.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. You should use calls for virtual desktops,
viewport is mapped to them if needed.
@return the size of the desktop
**/
NETSize desktopGeometry() const;
/**
Returns the viewport of the specified desktop.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. You should use calls for virtual desktops,
viewport is mapped to them if needed.
@param desktop the number of the desktop
@return the position of the desktop's viewport
**/
NETPoint desktopViewport(int desktop) const;
/**
Returns the workArea for the specified desktop.
@param desktop the number of the desktop
@return the size of the work area
**/
NETRect workArea(int desktop) const;
/**
Returns the name for the specified desktop.
@param desktop the number of the desktop
@return the name of the desktop
**/
const char *desktopName(int desktop) const;
/**
Returns an array of Window id's, which contain the virtual root windows.
@return the array of Window id's
@see virtualRootsCount()
**/
const xcb_window_t *virtualRoots() const;
/**
Returns the number of window in the virtualRoots array.
@return the number of Window id's in the virtual root array
@see virtualRoots()
**/
int virtualRootsCount() const;
/**
Returns the desktop layout orientation.
**/
NET::Orientation desktopLayoutOrientation() const;
/**
Returns the desktop layout number of columns and rows. Note that
either may be 0 (see _NET_DESKTOP_LAYOUT).
**/
QSize desktopLayoutColumnsRows() const;
/**
Returns the desktop layout starting corner.
**/
NET::DesktopLayoutCorner desktopLayoutCorner() const;
/**
Returns the number of desktops.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. They are however mapped to virtual desktops
if needed.
@param ignore_viewport if false, viewport is mapped to virtual desktops
@return the number of desktops
**/
int numberOfDesktops(bool ignore_viewport = false) const;
/**
Returns the current desktop.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. They are however mapped to virtual desktops
if needed.
@param ignore_viewport if false, viewport is mapped to virtual desktops
@return the number of the current desktop
**/
int currentDesktop(bool ignore_viewport = false) const;
/**
Returns the active (focused) window.
@return the id of the active window
**/
xcb_window_t activeWindow() const;
/**
Window Managers must call this after creating the NETRootInfo object, and
before using any other method in the class. This method sets initial data
on the root window and does other post-construction duties.
Clients must also call this after creating the object to do an initial
data read/update.
**/
void activate();
/**
Sets the list of managed windows on the Root/Desktop window.
@param windows The array of Window id's
@param count The number of windows in the array
**/
void setClientList(const xcb_window_t *windows, unsigned int count);
/**
Sets the list of managed windows in stacking order on the Root/Desktop
window.
@param windows The array of Window id's
@param count The number of windows in the array.
**/
void setClientListStacking(const xcb_window_t *windows, unsigned int count);
/**
Sets the current desktop to the specified desktop.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. It is however mapped to virtual desktops
if needed.
@param desktop the number of the desktop
@param ignore_viewport if false, viewport is mapped to virtual desktops
**/
void setCurrentDesktop(int desktop, bool ignore_viewport = false);
/**
Sets the desktop geometry to the specified geometry.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. You should use calls for virtual desktops,
viewport is mapped to them if needed.
@param geometry the new size of the desktop
**/
void setDesktopGeometry(const NETSize &geometry);
/**
Sets the viewport for the current desktop to the specified point.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. You should use calls for virtual desktops,
viewport is mapped to them if needed.
@param desktop the number of the desktop
@param viewport the new position of the desktop's viewport
**/
void setDesktopViewport(int desktop, const NETPoint &viewport);
/**
Sets the number of desktops to the specified number.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. Viewport is mapped to virtual desktops
if needed, but not for this call.
@param numberOfDesktops the number of desktops
**/
void setNumberOfDesktops(int numberOfDesktops);
/**
Sets the name of the specified desktop.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. Viewport is mapped to virtual desktops
if needed, but not for this call.
@param desktop the number of the desktop
@param desktopName the new name of the desktop
**/
void setDesktopName(int desktop, const char *desktopName);
/**
Requests that the specified window becomes the active (focused) one.
@param window the id of the new active window
@param src whether the request comes from normal application
or from a pager or similar tool
@param timestamp X server timestamp of the user action that
caused the request
@param active_window active window of the requesting application, if any
**/
void setActiveWindow(xcb_window_t window, NET::RequestSource src,
xcb_timestamp_t timestamp, xcb_window_t active_window);
/**
Sets the active (focused) window the specified window. This should
be used only in the window manager mode.
@param window the if of the new active window
**/
void setActiveWindow(xcb_window_t window);
/**
Sets the workarea for the specified desktop
@param desktop the number of the desktop
@param workArea the new work area of the desktop
**/
void setWorkArea(int desktop, const NETRect &workArea);
/**
Sets the list of virtual root windows on the root window.
@param windows The array of Window id's
@param count The number of windows in the array.
**/
void setVirtualRoots(const xcb_window_t *windows, unsigned int count);
/**
Sets the desktop layout. This is set by the pager. When setting, the pager must
own the _NET_DESKTOP_LAYOUT_Sn manager selection. See _NET_DESKTOP_LAYOUT for details.
**/
void setDesktopLayout(NET::Orientation orientation, int columns, int rows,
NET::DesktopLayoutCorner corner);
/**
* Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown).
*/
void setShowingDesktop(bool showing);
/**
* Returns the status of _NET_SHOWING_DESKTOP.
*/
bool showingDesktop() const;
/**
Assignment operator. Ensures that the shared data reference counts are
correct.
**/
const NETRootInfo &operator=(const NETRootInfo &rootinfo);
/**
Clients (such as pagers/taskbars) that wish to close a window should call
this function. This will send a request to the Window Manager, which
usually can usually decide how to react to such requests.
@param window the id of the window to close
**/
void closeWindowRequest(xcb_window_t window);
/**
Clients (such as pagers/taskbars) that wish to start a WMMoveResize
(where the window manager controls the resize/movement,
i.e. _NET_WM_MOVERESIZE) should call this function.
This will send a request to the Window Manager.
@param window The client window that would be resized/moved.
@param x_root X position of the cursor relative to the root window.
@param y_root Y position of the cursor relative to the root window.
@param direction One of NET::Direction (see base class documentation for
a description of the different directions).
**/
void moveResizeRequest(xcb_window_t window, int x_root, int y_root,
Direction direction);
/**
Clients (such as pagers/taskbars) that wish to move/resize a window
using WM2MoveResizeWindow (_NET_MOVERESIZE_WINDOW) should call this function.
This will send a request to the Window Manager. See _NET_MOVERESIZE_WINDOW
description for details.
@param window The client window that would be resized/moved.
@param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
@param x Requested X position for the window
@param y Requested Y position for the window
@param width Requested width for the window
@param height Requested height for the window
**/
void moveResizeWindowRequest(xcb_window_t window, int flags, int x, int y, int width, int height);
/**
Sends the _NET_RESTACK_WINDOW request.
**/
void restackRequest(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp);
/**
Sends a ping with the given timestamp to the window, using
the _NET_WM_PING protocol.
*/
void sendPing(xcb_window_t window, xcb_timestamp_t timestamp);
#if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
/**
This function takes the passed XEvent and returns an OR'ed list of
NETRootInfo properties that have changed in the properties argument.
The new information will be read immediately by the class.
The elements of the properties argument are as they would be passed
to the constructor, if the array is not large enough,
changed properties that don't fit in it won't be listed there
(they'll be updated in the class though).
@param event the event
@param properties properties that changed
@param properties_size size of the passed properties array
@deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)
**/
KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETRootInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
#endif
/**
* This function takes the passed xcb_generic_event_t and returns the updated properties in the passed in arguments.
*
* The new information will be read immediately by the class. It is possible to pass in a
* null pointer in the arguments. In that case the passed in argument will obviously not
* be updated, but the class will process the information nevertheless.
*
* @param event the event
* @param properties The NET::Properties that changed
* @param properties2 The NET::Properties2 that changed
* @since 5.0
**/
void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
/**
This function takes the passed XEvent and returns an OR'ed list of
NETRootInfo properties that have changed. The new information will be
read immediately by the class. This overloaded version returns
only a single mask, and therefore cannot check state of all properties
like the other variant.
@param event the event
@return the properties
**/
NET::Properties event(xcb_generic_event_t *event);
protected:
/**
A Client should subclass NETRootInfo and reimplement this function when
it wants to know when a window has been added.
@param window the id of the window to add
**/
virtual void addClient(xcb_window_t window)
{
Q_UNUSED(window);
}
/**
A Client should subclass NETRootInfo and reimplement this function when
it wants to know when a window has been removed.
@param window the id of the window to remove
**/
virtual void removeClient(xcb_window_t window)
{
Q_UNUSED(window);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to change the number
of desktops.
@param numberOfDesktops the new number of desktops
**/
virtual void changeNumberOfDesktops(int numberOfDesktops)
{
Q_UNUSED(numberOfDesktops);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to change the specified
desktop geometry.
@param desktop the number of the desktop
@param geom the new size
**/
virtual void changeDesktopGeometry(int desktop, const NETSize &geom)
{
Q_UNUSED(desktop);
Q_UNUSED(geom);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to change the specified
desktop viewport.
@param desktop the number of the desktop
@param viewport the new position of the viewport
**/
virtual void changeDesktopViewport(int desktop, const NETPoint &viewport)
{
Q_UNUSED(desktop);
Q_UNUSED(viewport);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to change the current
desktop.
@param desktop the number of the desktop
**/
virtual void changeCurrentDesktop(int desktop)
{
Q_UNUSED(desktop);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to close a window.
@param window the id of the window to close
**/
virtual void closeWindow(xcb_window_t window)
{
Q_UNUSED(window);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to start a move/resize.
@param window The window that wants to move/resize
@param x_root X position of the cursor relative to the root window.
@param y_root Y position of the cursor relative to the root window.
@param direction One of NET::Direction (see base class documentation for
a description of the different directions).
**/
virtual void moveResize(xcb_window_t window, int x_root, int y_root,
unsigned long direction)
{
Q_UNUSED(window);
Q_UNUSED(x_root);
Q_UNUSED(y_root);
Q_UNUSED(direction);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to receive replies to the _NET_WM_PING protocol.
@param window the window from which the reply came
@param timestamp timestamp of the ping
*/
virtual void gotPing(xcb_window_t window, xcb_timestamp_t timestamp)
{
Q_UNUSED(window);
Q_UNUSED(timestamp);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to change the active
(focused) window.
@param window the id of the window to activate
@param src the source from which the request came
@param timestamp the timestamp of the user action causing this request
@param active_window active window of the requesting application, if any
**/
virtual void changeActiveWindow(xcb_window_t window, NET::RequestSource src,
xcb_timestamp_t timestamp, xcb_window_t active_window)
{
Q_UNUSED(window);
Q_UNUSED(src);
Q_UNUSED(timestamp);
Q_UNUSED(active_window);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a pager made a request to move/resize a window.
See _NET_MOVERESIZE_WINDOW for details.
@param window the id of the window to more/resize
@param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
@param x Requested X position for the window
@param y Requested Y position for the window
@param width Requested width for the window
@param height Requested height for the window
**/
virtual void moveResizeWindow(xcb_window_t window, int flags, int x, int y, int width, int height)
{
Q_UNUSED(window);
Q_UNUSED(flags);
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(width);
Q_UNUSED(height);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a Client made a request to restack a window.
See _NET_RESTACK_WINDOW for details.
@param window the id of the window to restack
@param source the source of the request
@param above other window in the restack request
@param detail restack detail
@param timestamp the timestamp of the request
**/
virtual void restackWindow(xcb_window_t window, RequestSource source,
xcb_window_t above, int detail, xcb_timestamp_t timestamp)
{
Q_UNUSED(window);
Q_UNUSED(source);
Q_UNUSED(above);
Q_UNUSED(detail);
Q_UNUSED(timestamp);
}
/**
A Window Manager should subclass NETRootInfo and reimplement this function
when it wants to know when a pager made a request to change showing the desktop.
See _NET_SHOWING_DESKTOP for details.
@param showing whether to activate the showing desktop mode
**/
virtual void changeShowingDesktop(bool showing)
{
Q_UNUSED(showing);
}
private:
void update(NET::Properties properties, NET::Properties2 properties2);
void setSupported();
void setDefaultProperties();
void updateSupportedProperties(xcb_atom_t atom);
protected:
/** Virtual hook, used to add new "virtual" functions while maintaining
binary compatibility. Unused in this class.
*/
virtual void virtual_hook(int id, void *data);
private:
NETRootInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
};
/**
Common API for application window properties/protocols.
The NETWinInfo class provides a common API for clients and window managers to
set/read/change properties on an application window as defined by the NET
Window Manager Specification.
@author Bradley T. Hughes
@see NET
@see NETRootInfo
@see http://www.freedesktop.org/standards/wm-spec/
**/
class KWINDOWSYSTEM_EXPORT NETWinInfo : public NET
{
public:
/**
Indexes for the properties array.
**/
// update also NETWinInfoPrivate::properties[] size when extending this
enum { PROTOCOLS, PROTOCOLS2,
PROPERTIES_SIZE
};
/**
Create a NETWinInfo object, which will be used to set/read/change
information stored on an application window.
@param connection XCB connection
@param window The Window id of the application window.
@param rootWindow The Window id of the root window.
@param properties The NET::Properties flags
@param properties2 The NET::Properties2 flags
@param role Select the application role. If this argument is omitted,
the role will default to Client.
**/
NETWinInfo(xcb_connection_t *connection, xcb_window_t window, xcb_window_t rootWindow,
NET::Properties properties, NET::Properties2 properties2,
Role role = Client);
#if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
/**
This constructor differs from the above one only in the way it accepts
the list of properties the client is interested in.
@deprecated since 5.0 use above ctor
**/
KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo(xcb_connection_t *, xcb_window_t, xcb_window_t, NET::Properties, NET::Properties2, Role")
NETWinInfo(xcb_connection_t *connection, xcb_window_t window,
xcb_window_t rootWindow, NET::Properties properties,
Role role = Client);
#endif
/**
Creates a shared copy of the specified NETWinInfo object.
@param wininfo the NETWinInfo to copy
**/
NETWinInfo(const NETWinInfo &wininfo);
/**
Destroys the NETWinInfo object.
**/
virtual ~NETWinInfo();
/**
Assignment operator. Ensures that the shared data reference counts are
correct.
**/
const NETWinInfo &operator=(const NETWinInfo &wintinfo);
/**
Returns the xcb connection used.
@return the XCB connection
**/
xcb_connection_t *xcbConnection() const;
/**
Returns true if the window has any window type set, even if the type
itself is not known to this implementation. Presence of a window type
as specified by the NETWM spec is considered as the window supporting
this specification.
@return true if the window has support for the NETWM spec
**/
bool hasNETSupport() const;
/**
@returns the properties argument passed to the constructor.
@see passedProperties2()
**/
NET::Properties passedProperties() const;
/**
* @returns the properties2 argument passed to the constructor.
* @see passedProperties()
* @since 5.0
**/
NET::Properties2 passedProperties2() const;
/**
Returns the icon geometry.
@return the geometry of the icon
**/
NETRect iconGeometry() const;
/**
Returns the state of the window (see the NET base class documentation for a
description of the various states).
@return the state of the window
**/
NET::States state() const;
/**
Returns the extended (partial) strut specified by this client.
See _NET_WM_STRUT_PARTIAL in the spec.
**/
NETExtendedStrut extendedStrut() const;
// Still used internally, e.g. by KWindowSystem::strutChanged() logic
/**
@deprecated use strutPartial()
Returns the strut specified by this client.
@return the strut of the window
**/
NETStrut strut() const;
/**
Returns the window type for this client (see the NET base class
documentation for a description of the various window types).
Since clients may specify several windows types for a window
in order to support backwards compatibility and extensions
not available in the NETWM spec, you should specify all
window types you application supports (see the NET::WindowTypeMask
mask values for various window types). This method will
return the first window type that is listed in the supported types,
or NET::Unknown if none of the window types is supported.
@return the type of the window
**/
WindowType windowType(WindowTypes supported_types) const;
/**
This function returns false if the window has not window type
specified at all. Used by KWindowInfo::windowType() to return either
NET::Normal or NET::Dialog as appropriate as a fallback.
**/
bool hasWindowType() const;
/**
Returns the name of the window in UTF-8 format.
@return the name of the window
**/
const char *name() const;
/**
Returns the visible name as set by the window manager in UTF-8 format.
@return the visible name of the window
**/
const char *visibleName() const;
/**
Returns the iconic name of the window in UTF-8 format. Note that this has
nothing to do with icons, but it's for "iconic"
representations of the window (taskbars etc.), that should be shown
when the window is in iconic state. See description of _NET_WM_ICON_NAME
for details.
@return the iconic name
**/
const char *iconName() const;
/**
Returns the visible iconic name as set by the window manager in UTF-8 format.
Note that this has nothing to do with icons, but it's for "iconic"
representations of the window (taskbars etc.), that should be shown
when the window is in iconic state. See description of _NET_WM_VISIBLE_ICON_NAME
for details.
@return the visible iconic name
**/
const char *visibleIconName() const;
/**
Returns the desktop where the window is residing.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. It is however mapped to virtual desktops
if needed.
@param ignore_viewport if false, viewport is mapped to virtual desktops
@return the number of the window's desktop
@see OnAllDesktops()
**/
int desktop(bool ignore_viewport = false) const;
/**
Returns the process id for the client window.
@return the process id of the window
**/
int pid() const;
/**
Returns whether or not this client handles icons.
@return true if this client handles icons, false otherwise
**/
bool handledIcons() const;
/**
Returns the mapping state for the window (see the NET base class
documentation for a description of mapping state).
@return the mapping state
**/
MappingState mappingState() const;
/**
Set icons for the application window. If replace is True, then
the specified icon is defined to be the only icon. If replace is False,
then the specified icon is added to a list of icons.
@param icon the new icon
@param replace true to replace, false to append to the list of icons
**/
void setIcon(NETIcon icon, bool replace = true);
/**
Set the icon geometry for the application window.
@param geometry the new icon geometry
**/
void setIconGeometry(NETRect geometry);
/**
Set the extended (partial) strut for the application window.
@param extended_strut the new strut
**/
void setExtendedStrut(const NETExtendedStrut &extended_strut);
// Still used internally, e.g. by KWindowSystem::strutChanged() logic
/**
@deprecated use setExtendedStrut()
Set the strut for the application window.
@param strut the new strut
**/
void setStrut(NETStrut strut);
/**
Set the state for the application window (see the NET base class documentation
for a description of window state).
@param state the name state
@param mask the mask for the state
**/
void setState(NET::States state, NET::States mask);
/**
Sets the window type for this client (see the NET base class
documentation for a description of the various window types).
@param type the window type
**/
void setWindowType(WindowType type);
/**
Sets the name for the application window.
@param name the new name of the window
**/
void setName(const char *name);
/**
For Window Managers only: set the visible name ( i.e. xterm, xterm <2>,
xterm <3>, ... )
@param visibleName the new visible name
**/
void setVisibleName(const char *visibleName);
/**
Sets the iconic name for the application window.
@param name the new iconic name
**/
void setIconName(const char *name);
/**
For Window Managers only: set the visible iconic name ( i.e. xterm, xterm <2>,
xterm <3>, ... )
@param name the new visible iconic name
**/
void setVisibleIconName(const char *name);
/**
Set which window the desktop is (should be) on.
NOTE: KDE uses virtual desktops and does not directly support
viewport in any way. It is however mapped to virtual desktops
if needed.
@param desktop the number of the new desktop
@param ignore_viewport if false, viewport is mapped to virtual desktops
@see OnAllDesktops()
**/
void setDesktop(int desktop, bool ignore_viewport = false);
/**
Set the application window's process id.
@param pid the window's process id
**/
void setPid(int pid);
/**
Set whether this application window handles icons.
@param handled true if the window handles icons, false otherwise
**/
void setHandledIcons(bool handled);
/**
Set the frame decoration strut, i.e. the width of the decoration borders.
@param strut the new strut
**/
void setFrameExtents(NETStrut strut);
/**
Returns the frame decoration strut, i.e. the width of the decoration borders.
@since 4.3
**/
NETStrut frameExtents() const;
/**
Sets the window frame overlap strut, i.e. how far the window frame extends
behind the client area on each side.
Set the strut values to -1 if you want the window frame to cover the whole
client area.
The default values are 0.
@since 4.4
**/
void setFrameOverlap(NETStrut strut);
/**
Returns the frame overlap strut, i.e. how far the window frame extends
behind the client area on each side.
@since 4.4
**/
NETStrut frameOverlap() const;
/**
Sets the extents of the drop-shadow drawn by the client.
@since 5.65
**/
void setGtkFrameExtents(NETStrut strut);
/**
Returns the extents of the drop-shadow drawn by a GTK client.
@since 5.65
**/
NETStrut gtkFrameExtents() const;
/**
Returns an icon. If width and height are passed, the icon returned will be
the closest it can find (the next biggest). If width and height are omitted,
then the largest icon in the list is returned.
@param width the preferred width for the icon, -1 to ignore
@param height the preferred height for the icon, -1 to ignore
@return the icon
**/
NETIcon icon(int width = -1, int height = -1) const;
/**
Returns a list of provided icon sizes. Each size is pair width,height, terminated
with pair 0,0.
@since 4.3
**/
const int *iconSizes() const;
/**
* Sets user timestamp @p time on the window (property _NET_WM_USER_TIME).
* The timestamp is expressed as XServer time. If a window
* is shown with user timestamp older than the time of the last
* user action, it won't be activated after being shown, with the special
* value 0 meaning not to activate the window after being shown.
*/
void setUserTime(xcb_timestamp_t time);
/**
* Returns the time of last user action on the window, or -1 if not set.
*/
xcb_timestamp_t userTime() const;
/**
* Sets the startup notification id @p id on the window.
*/
void setStartupId(const char *startup_id);
/**
* Returns the startup notification id of the window.
*/
const char *startupId() const;
/**
* Sets opacity (0 = transparent, 0xffffffff = opaque ) on the window.
*/
void setOpacity(unsigned long opacity);
/**
* Returns the opacity of the window.
*/
unsigned long opacity() const;
/**
* Sets actions that the window manager allows for the window.
*/
void setAllowedActions(NET::Actions actions);
/**
* Returns actions that the window manager allows for the window.
*/
NET::Actions allowedActions() const;
/**
* Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow
* for this window.
*/
xcb_window_t transientFor() const;
/**
* Returns the leader window for the group the window is in, if any.
*/
xcb_window_t groupLeader() const;
/**
* Returns whether the UrgencyHint is set in the WM_HINTS.flags.
* See ICCCM 4.1.2.4.
*
* @since 5.3
**/
bool urgency() const;
/**
* Returns whether the Input flag is set in WM_HINTS.
* See ICCCM 4.1.2.4 and 4.1.7.
*
* The default value is @c true in case the Client is mapped without a WM_HINTS property.
*
* @since 5.3
**/
bool input() const;
/**
* Returns the initial mapping state as set in WM_HINTS.
* See ICCCM 4.1.2.4 and 4.1.4.
*
* The default value if @c Withdrawn in case the Client is mapped without
* a WM_HINTS property or without the initial state hint set.
*
* @since 5.5
**/
MappingState initialMappingState() const;
/**
* Returns the icon pixmap as set in WM_HINTS.
* See ICCCM 4.1.2.4.
*
* The default value is @c XCB_PIXMAP_NONE.
*
* Using the ICCCM variant for the icon is deprecated and only
* offers a limited functionality compared to {@link icon}.
* Only use this variant as a fallback.
*
* @see icccmIconPixmapMask
* @see icon
* @since 5.7
**/
xcb_pixmap_t icccmIconPixmap() const;
/**
* Returns the mask for the icon pixmap as set in WM_HINTS.
* See ICCCM 4.1.2.4.
*
* The default value is @c XCB_PIXMAP_NONE.
*
* @see icccmIconPixmap
* @since 5.7
**/
xcb_pixmap_t icccmIconPixmapMask() const;
/**
* Returns the class component of the window class for the window
* (i.e. WM_CLASS property).
*/
const char *windowClassClass() const;
/**
* Returns the name component of the window class for the window
* (i.e. WM_CLASS property).
*/
const char *windowClassName() const;
/**
* Returns the window role for the window (i.e. WM_WINDOW_ROLE property).
*/
const char *windowRole() const;
/**
* Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property).
*/
const char *clientMachine() const;
/**
* returns a comma-separated list of the activities the window is associated with.
* FIXME this might be better as a NETRArray ?
* @since 4.6
*/
const char *activities() const;
/**
* Sets the comma-separated list of activities the window is associated with.
* @since 5.1
*/
void setActivities(const char *activities);
/**
* Sets whether the client wishes to block compositing (for better performance)
* @since 4.7
*/
void setBlockingCompositing(bool active);
/**
* Returns whether the client wishes to block compositing (for better performance)
* @since 4.7
*/
bool isBlockingCompositing() const;
/**
Places the window frame geometry in frame, and the application window
geometry in window. Both geometries are relative to the root window.
@param frame the geometry for the frame
@param window the geometry for the window
**/
void kdeGeometry(NETRect &frame, NETRect &window);
/**
Sets the desired multiple-monitor topology (4 monitor indices indicating
the top, bottom, left, and right edges of the window) when the fullscreen
state is enabled. The indices are from the set returned by the Xinerama
extension.
See _NET_WM_FULLSCREEN_MONITORS for details.
@param topology A struct that models the desired monitor topology, namely:
top is the monitor whose top edge defines the top edge of the
fullscreen window, bottom is the monitor whose bottom edge defines
the bottom edge of the fullscreen window, left is the monitor whose
left edge defines the left edge of the fullscreen window, and right
is the monitor whose right edge defines the right edge of the fullscreen
window.
**/
void setFullscreenMonitors(NETFullscreenMonitors topology);
/**
Returns the desired fullscreen monitor topology for this client, should
it be in fullscreen state.
See _NET_WM_FULLSCREEN_MONITORS in the spec.
**/
NETFullscreenMonitors fullscreenMonitors() const;
#if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
/**
This function takes the passed XEvent and returns an OR'ed list of
NETWinInfo properties that have changed in the properties argument.
The new information will be read immediately by the class.
The elements of the properties argument are as they would be passed
to the constructor, if the array is not large enough,
changed properties that don't fit in it won't be listed there
(they'll be updated in the class though).
@param event the event
@param properties properties that changed
@param properties_size size of the passed properties array
@deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)
**/
KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
#endif
/**
* This function takes the passed in xcb_generic_event_t and returns the updated properties
* in the passed in arguments.
*
* The new information will be read immediately by the class. It is possible to pass in a
* null pointer in the arguments. In that case the passed in
* argument will obviously not be updated, but the class will process the information
* nevertheless.
*
* @param event the event
* @param properties The NET::Properties that changed
* @param properties2 The NET::Properties2 that changed
* @since 5.0
**/
void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
/**
This function takes the pass XEvent and returns an OR'ed list of NETWinInfo
properties that have changed. The new information will be read
immediately by the class. This overloaded version returns
only a single mask, and therefore cannot check state of all properties
like the other variant.
@param event the event
@return the properties
**/
NET::Properties event(xcb_generic_event_t *event);
/**
* @returns The window manager protocols this Client supports.
* @since 5.3
**/
NET::Protocols protocols() const;
/**
* @returns @c true if the Client supports the @p protocol.
* @param protocol The window manager protocol to test for
* @since 5.3
**/
bool supportsProtocol(NET::Protocol protocol) const;
/**
* @returns The opaque region as specified by the Client.
* @since 5.7
**/
std::vector opaqueRegion() const;
/**
* Sets the @p name as the desktop file name.
*
* This is either the base name without full path and without file extension of the
* desktop file for the window's application (e.g. "org.kde.foo").
*
* If the application's desktop file name is not at a standard location it should be
* the full path to the desktop file name (e.g. "/opt/kde/share/org.kde.foo.desktop").
*
* If the window does not know the desktop file name, it should not set the name at all.
*
* @since 5.28
**/
void setDesktopFileName(const char *name);
/**
* @returns The desktop file name of the window's application if present.
* @since 5.28
* @see setDesktopFileName
**/
const char *desktopFileName() const;
/**
Sentinel value to indicate that the client wishes to be visible on
all desktops.
@return the value to be on all desktops
**/
static const int OnAllDesktops;
protected:
/**
A Window Manager should subclass NETWinInfo and reimplement this function when
it wants to know when a Client made a request to change desktops (ie. move to
another desktop).
@param desktop the number of the desktop
**/
virtual void changeDesktop(int desktop)
{
Q_UNUSED(desktop);
}
/**
A Window Manager should subclass NETWinInfo and reimplement this function when
it wants to know when a Client made a request to change state (ie. to
Shade / Unshade).
@param state the new state
@param mask the mask for the state
**/
virtual void changeState(NET::States state, NET::States mask)
{
Q_UNUSED(state);
Q_UNUSED(mask);
}
/**
A Window Manager should subclass NETWinInfo2 and reimplement this function
when it wants to know when a Client made a request to change the
fullscreen monitor topology for its fullscreen state.
@param topology A structure (top, bottom, left, right) representing the
fullscreen monitor topology.
**/
virtual void changeFullscreenMonitors(NETFullscreenMonitors topology)
{
Q_UNUSED(topology);
}
private:
void update(NET::Properties dirtyProperties, NET::Properties2 dirtyProperties2 = NET::Properties2());
void updateWMState();
void setIconInternal(NETRArray &icons, int &icon_count, xcb_atom_t property, NETIcon icon, bool replace);
NETIcon iconInternal(NETRArray &icons, int icon_count, int width, int height) const;
protected:
/** Virtual hook, used to add new "virtual" functions while maintaining
binary compatibility. Unused in this class.
*/
virtual void virtual_hook(int id, void *data);
private:
NETWinInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
};
//#define KWIN_FOCUS
#endif
#endif // netwm_h
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/xcbinterface.h 0000664 0001750 0001750 00000004670 14474244170 027356 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef XCBINTERFACE_H
#define XCBINTERFACE_H
#include "abstractinterface.h"
#include
#include
using namespace kdk;
class Q_DECL_HIDDEN XcbInterface:public AbstractInterface
{
public:
XcbInterface(QObject* parent=nullptr);
~XcbInterface();
WindowInfo requestInfo(WindowId wid) override;
void requestActivate(WindowId wid) override;
void requestClose(WindowId wid) ;
void requestToggleKeepAbove(WindowId wid) override;
void requestToggleMinimized(WindowId wid) override;
void requestToggleMaximized(WindowId wid) override;
QIcon iconFor(WindowId wid) override;
QString titleFor(WindowId wid) override;
QString windowGroupFor(WindowId wid) override;
void showCurrentDesktop() override;
void hideCurrentDesktop() override;
quint32 pid(WindowId wid) override;
WindowId activeWindow() override;
bool windowCanBeDragged(WindowId wid) override;
bool windowCanBeMaximized(WindowId wid) override;
void setGeometry(QWindow *window, const QRect &rect) override;
void setSkipTaskBar(QWindow* window,bool skip) override;
void setSkipSwitcher(QWindow* window,bool skip) override;
bool skipTaskBar(const WindowId &wid) override;
bool skipSwitcher(const WindowId &wid) override;
bool isShowingDesktop();
void setOnAllDesktops(const WindowId &wid);
NET::WindowType windowType(WindowId wid) override;
private:
bool isValidWindow(WindowId wid) ;
bool isValidWindow(const KWindowInfo &winfo) ;
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
private:
WindowId m_desktopId{-1};
};
#endif // XCBINTERFACE_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/waylandinterface.h 0000664 0001750 0001750 00000007127 14474244170 030241 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WAYLANDINTERFACE_H
#define WAYLANDINTERFACE_H
#include "abstractinterface.h"
#include
#include
#include
#include
#include
#include
#include
using namespace kdk;
using namespace KWayland::Client;
class Q_DECL_HIDDEN WaylandInterface:public AbstractInterface
{
public:
WaylandInterface(QObject* parent=nullptr);
~WaylandInterface();
WindowInfo requestInfo(WindowId wid) override;
void requestActivate(WindowId wid) override;
void requestClose(WindowId wid) override;
void requestToggleKeepAbove(WindowId wid) override;
void requestToggleMinimized(WindowId wid) override;
void requestToggleMaximized(WindowId wid) override;
QIcon iconFor(WindowId wid) override;
QString titleFor(WindowId wid) override;
QString windowGroupFor(WindowId wid) override;
quint32 pid(WindowId wid) override;
void showCurrentDesktop() override;
void hideCurrentDesktop() override;
bool windowCanBeDragged(WindowId wid) override;
bool windowCanBeMaximized(WindowId wid) override;
WindowId activeWindow() override;
void setGeometry(QWindow *window, const QRect &rect) override;
void setSkipTaskBar(QWindow* window,bool skip) override;
void setSkipSwitcher(QWindow* window,bool skip) override;
bool skipTaskBar(const WindowId &wid) override;
bool skipSwitcher(const WindowId &wid) override;
bool isShowingDesktop();
void setOnAllDesktops(const WindowId &wid);
NET::WindowType windowType(WindowId wid) override;
protected:
bool eventFilter(QObject *obj, QEvent *ev) override;
private slots:
void updateWindow();
void windowUnmapped();
private:
PlasmaWindow *windowFor(WindowId wid) ;
bool isValidWindow(const KWayland::Client::PlasmaWindow *w) ;
bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) ;
bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) ;
void windowCreatedProxy(KWayland::Client::PlasmaWindow *w);
void trackWindow(KWayland::Client::PlasmaWindow *w);
void untrackWindow(KWayland::Client::PlasmaWindow *w);
void setCurrentDesktop(QString desktop);
void addDesktop(const QString &id, quint32 position);
private:
ConnectionThread *m_connection=nullptr;
PlasmaShell *m_plasmaShell = nullptr;
Shell *m_shell = nullptr;
PlasmaWindowManagement *m_windowManager = nullptr;
PlasmaWindow *m_appWindow = nullptr;
PlasmaVirtualDesktopManagement *m_virtualDesktopManagement{nullptr};
QStringList m_desktops;
QMapm_surfaces;
QMapm_plasmaShellSurfaces;
};
#endif // WAYLANDINTERFACE_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/waylandinterface.cpp 0000664 0001750 0001750 00000045117 14474244170 030575 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "waylandinterface.h"
#include
#include
#include
#include
#include
#include
WaylandInterface::WaylandInterface(QObject *parent)
:AbstractInterface(parent)
{
m_connection = KWayland::Client::ConnectionThread::fromApplication(qApp);
auto registry = new Registry(this);
registry->create(m_connection->display());
connect(registry, &KWayland::Client::Registry::plasmaShellAnnounced, this, [=](){
const auto interface = registry->interface(KWayland::Client::Registry::Interface::PlasmaShell);
if (interface.name != 0) {
m_plasmaShell = registry->createPlasmaShell(interface.name, interface.version, this);
}
});
connect(registry, &Registry::plasmaWindowManagementAnnounced, this, [=](){
const auto interface = registry->interface(Registry::Interface::PlasmaWindowManagement);
if (interface.name != 0) {
m_windowManager = registry->createPlasmaWindowManagement(interface.name, interface.version, this);
}
if(m_windowManager)
{
connect(m_windowManager, &PlasmaWindowManagement::showingDesktopChanged,this,&AbstractInterface::isShowingDesktopChanged);
connect(m_windowManager, &PlasmaWindowManagement::windowCreated, this, &WaylandInterface::windowCreatedProxy);
connect(m_windowManager, &PlasmaWindowManagement::activeWindowChanged, this, [&]() noexcept {
auto w = m_windowManager->activeWindow();
if(w)
{
emit activeWindowChanged(w ? w->internalId() : 0);
}
}, Qt::QueuedConnection);
connect(m_windowManager, &PlasmaWindowManagement::windowCreated,this,
[this](PlasmaWindow *window)
{
if (!m_windows.contains(window->internalId())) {
m_windows.insert(window->internalId(), this->requestInfo(window->internalId()));
}
emit windowAdded(window->internalId());
});
}
});
connect(registry, &KWayland::Client::Registry::plasmaVirtualDesktopManagementAnnounced,
[this, registry] (quint32 name, quint32 version) {
m_virtualDesktopManagement = registry->createPlasmaVirtualDesktopManagement(name, version, this);
if(m_virtualDesktopManagement)
{
connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopCreated, this,
[this](const QString &id, quint32 position) {
addDesktop(id, position);
});
connect(m_virtualDesktopManagement, &KWayland::Client::PlasmaVirtualDesktopManagement::desktopRemoved, this,
[this](const QString &id) {
m_desktops.removeAll(id);
if (m_currentDesktop == id) {
setCurrentDesktop(QString());
}
});
}
});
connect(registry, &KWayland::Client::Registry::shellAnnounced, this, [=](){
const auto interface = registry->interface(KWayland::Client::Registry::Interface::Shell);
if (interface.name != 0) {
m_shell = registry->createShell(interface.name, interface.version, this);
}
});
registry->setup();
m_connection->roundtrip();
}
WaylandInterface::~WaylandInterface()
{
}
WindowInfo WaylandInterface::requestInfo(WindowId wid)
{
WindowInfo windowInfo;
auto w = windowFor(wid);
if (w) {
if (isPlasmaDesktop(w)) {
windowInfo.setIsValid(true);
windowInfo.setIsPlasmaDesktop(true);
windowInfo.setWid(wid);
//! Window Abilities
windowInfo.setIsClosable(false);
windowInfo.setIsFullScreenable(false);
windowInfo.setIsGroupable(false);
windowInfo.setIsMaximizable(false);
windowInfo.setIsMinimizable(false);
windowInfo.setIsMovable(false);
windowInfo.setIsResizable(false);
windowInfo.setIsShadeable(false);
windowInfo.setIsVirtualDesktopsChangeable(false);
//! Window Abilities
} else if (isValidWindow(w)) {
windowInfo.setIsValid(true);
windowInfo.setWid(wid);
windowInfo.setIsActive(w->isActive());
windowInfo.setIsMinimized(w->isMinimized());
windowInfo.setIsMaxVert(w->isMaximized());
windowInfo.setIsMaxHoriz(w->isMaximized());
windowInfo.setIsFullscreen(w->isFullscreen());
windowInfo.setIsShaded(w->isShaded());
windowInfo.setIsOnAllDesktops(w->isOnAllDesktops());
windowInfo.setIsOnAllActivities(true);
windowInfo.setHasSkipTaskbar(w->skipTaskbar());
windowInfo.setHasSkipSwitcher(w->skipSwitcher());
windowInfo.setIsKeepAbove(w->isKeepAbove());
//! Window Abilities
windowInfo.setIsClosable(w->isCloseable());
windowInfo.setIsFullScreenable(w->isFullscreenable());
windowInfo.setIsMaximizable(w->isMaximizeable());
windowInfo.setIsMinimizable(w->isMinimizeable());
windowInfo.setIsMovable(w->isMovable());
windowInfo.setIsResizable(w->isResizable());
windowInfo.setIsShadeable(w->isShadeable());
windowInfo.setIsVirtualDesktopsChangeable(w->isVirtualDesktopChangeable());
//! Window Abilities
windowInfo.setDesktops(w->plasmaVirtualDesktops());
}
} else {
windowInfo.setIsValid(false);
}
return windowInfo;
}
void WaylandInterface::requestActivate(WindowId wid)
{
auto w = windowFor(wid);
if (w) {
w->requestActivate();
m_connection->roundtrip();
emit windowChanged(w->internalId());
}
}
void WaylandInterface::requestClose(WindowId wid)
{
auto w = windowFor(wid);
if (w) {
w->requestClose();
m_connection->roundtrip();
}
}
void WaylandInterface::requestToggleKeepAbove(WindowId wid)
{
auto w = windowFor(wid);
if (w) {
w->requestToggleKeepAbove();
m_connection->roundtrip();
emit windowChanged(w->internalId());
}
}
void WaylandInterface::requestToggleMinimized(WindowId wid)
{
auto w = windowFor(wid);
if (w) {
w->requestToggleMinimized();
m_connection->roundtrip();
}
}
void WaylandInterface::requestToggleMaximized(WindowId wid)
{
auto w = windowFor(wid);
if (w) {
w->requestToggleMaximized();
m_connection->roundtrip();
}
}
QIcon WaylandInterface::iconFor(WindowId wid)
{
auto window = windowFor(wid);
if (window) {
return window->icon();
}
return QIcon();
}
QString WaylandInterface::titleFor(WindowId wid)
{
auto window = windowFor(wid);
if (window) {
return window->title();
}
return QString();
}
QString WaylandInterface::windowGroupFor(WindowId wid)
{
auto window = windowFor(wid);
if (window)
{
m_connection->roundtrip();
return window->appId();
}
else
return QString();
}
quint32 WaylandInterface::pid(WindowId wid)
{
quint32 pid = 0;
auto window = windowFor(wid);
if (window)
{
m_connection->roundtrip();
return window->pid();
}
else
return pid;
}
void WaylandInterface::showCurrentDesktop()
{
if(m_windowManager)
{
m_windowManager->showDesktop();
m_connection->roundtrip();
}
}
void WaylandInterface::hideCurrentDesktop()
{
if(m_windowManager)
{
m_windowManager->hideDesktop();
m_connection->roundtrip();
}
}
bool WaylandInterface::windowCanBeDragged(WindowId wid)
{
auto w = windowFor(wid);
if (w && isValidWindow(w)) {
WindowInfo winfo = requestInfo(wid);
return (winfo.isValid()
&& w->isMovable()
&& !winfo.isMinimized()
&& inCurrentDesktopActivity(winfo)
&& !winfo.isPlasmaDesktop());
}
return false;
}
bool WaylandInterface::windowCanBeMaximized(WindowId wid)
{
auto w = windowFor(wid);
if (w && isValidWindow(w)) {
WindowInfo winfo = requestInfo(wid);
return (winfo.isValid()
&& w->isMaximizeable()
&& !winfo.isMinimized()
&& inCurrentDesktopActivity(winfo)
&& !winfo.isPlasmaDesktop());
}
return false;
}
WindowId WaylandInterface::activeWindow()
{
if (!m_windowManager) {
return 0;
}
m_connection->roundtrip();
auto wid = m_windowManager->activeWindow();
return wid ? QVariant(wid->internalId()) : 0;
}
void WaylandInterface::setGeometry(QWindow *window, const QRect &rect)
{
if(!window)
return;
if (!m_plasmaShell)
return;
auto surface = KWayland::Client::Surface::fromWindow(window);
if (!surface)
return;
if(!m_surfaces.contains(window))
{
m_surfaces.insert(window,surface);
}
auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window);
if (!plasmaShellSurface)
return;
if(!m_plasmaShellSurfaces.contains(window))
{
m_plasmaShellSurfaces.insert(window,plasmaShellSurface);
}
plasmaShellSurface->setPosition(rect.topLeft());
window->resize(rect.size());
window->installEventFilter(this);
}
void WaylandInterface::setSkipTaskBar(QWindow *window, bool skip)
{
if(!window)
return;
if (!m_plasmaShell)
return;
auto surface = KWayland::Client::Surface::fromWindow(window);
if (!surface)
return;
if(!m_surfaces.contains(window))
m_surfaces.insert(window,surface);
auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window);
if (!plasmaShellSurface)
return;
if(!m_plasmaShellSurfaces.contains(window))
m_plasmaShellSurfaces.insert(window,plasmaShellSurface);
plasmaShellSurface->setSkipTaskbar(skip);
window->installEventFilter(this);
}
void WaylandInterface::setSkipSwitcher(QWindow *window, bool skip)
{
if(!window)
return;
if (!m_plasmaShell)
return;
auto surface = KWayland::Client::Surface::fromWindow(window);
if (!surface)
return;
if(!m_surfaces.contains(window))
m_surfaces.insert(window,surface);
auto plasmaShellSurface = m_plasmaShell->createSurface(surface, window);
if (!plasmaShellSurface)
return;
if(!m_plasmaShellSurfaces.contains(window))
m_plasmaShellSurfaces.insert(window,plasmaShellSurface);
plasmaShellSurface->setSkipSwitcher(skip);
window->installEventFilter(this);
}
bool WaylandInterface::skipTaskBar(const WindowId &wid)
{
auto window = windowFor(wid);
return window ? window->skipTaskbar() : false;
}
bool WaylandInterface::skipSwitcher(const WindowId &wid)
{
auto window = windowFor(wid);
return window ? window->skipSwitcher() : false;
}
bool WaylandInterface::isShowingDesktop()
{
bool flag = false;
if(m_windowManager)
{
flag = m_windowManager->isShowingDesktop();
m_connection->roundtrip();
}
return flag;
}
void WaylandInterface::setOnAllDesktops(const WindowId &wid)
{
auto w = windowFor(wid);
if (w && isValidWindow(w) && m_desktops.count() > 1) {
if (w->isOnAllDesktops()) {
w->requestEnterVirtualDesktop(m_currentDesktop);
} else {
const QStringList &now = w->plasmaVirtualDesktops();
foreach (const QString &desktop, now) {
w->requestLeaveVirtualDesktop(desktop);
}
}
}
}
NET::WindowType WaylandInterface::windowType(WindowId wid)
{
return NET::WindowType::Normal;
}
bool WaylandInterface::eventFilter(QObject *obj, QEvent *ev)
{
auto window = qobject_cast(obj);
if(window && ev->type() == QEvent::Hide)
{
if(m_plasmaShellSurfaces.contains(window))
{
auto plasmaShellSurface = m_plasmaShellSurfaces.value(window);
if(plasmaShellSurface)
{
plasmaShellSurface->release();
plasmaShellSurface->destroy();
}
m_plasmaShellSurfaces.remove(window);
}
if(m_surfaces.contains(window))
{
auto surface = m_surfaces.value(window);
if(surface)
{
surface->release();
surface->destroy();
}
m_surfaces.remove(window);
}
}
return QObject::eventFilter(obj,ev);
}
void WaylandInterface::updateWindow()
{
PlasmaWindow* w = qobject_cast(QObject::sender());
if(w && !isPlasmaPanel(w))
{
m_connection->roundtrip();
emit windowChanged(w->internalId());
}
}
void WaylandInterface::windowUnmapped()
{
PlasmaWindow *pW = qobject_cast(QObject::sender());
if (pW) {
untrackWindow(pW);
if (!m_windows.contains(pW->internalId())) {
m_windows.remove(pW->internalId());
}
emit windowRemoved(pW->internalId());
}
}
PlasmaWindow *WaylandInterface::windowFor(WindowId wid)
{
auto it = std::find_if(m_windowManager->windows().constBegin(), m_windowManager->windows().constEnd(), [&wid](PlasmaWindow * w) noexcept {
return w->isValid() && w->internalId() == wid;
});
if (it == m_windowManager->windows().constEnd()) {
return nullptr;
}
return *it;
}
bool WaylandInterface::isValidWindow(const PlasmaWindow *w)
{
return w->isValid();
}
bool WaylandInterface::isPlasmaDesktop(const PlasmaWindow *w)
{
if (!w || (w->appId() != QLatin1String("org.kde.plasmashell"))) {
return false;
}
return AbstractInterface::isPlasmaDesktop(w->geometry());
}
bool WaylandInterface::isPlasmaPanel(const PlasmaWindow *w)
{
if(w && w->appId() == QLatin1String("ukui-panel"))
return true;
else
return false;
}
void WaylandInterface::windowCreatedProxy(PlasmaWindow *w)
{
if (!isValidWindow(w)) {
return;
}
if ((w->appId() == QLatin1String("org.kde.plasmashell")) && isPlasmaPanel(w))
{
//registerPlasmaPanel(w->internalId());
}
else
{
trackWindow(w);
}
}
void WaylandInterface::trackWindow(PlasmaWindow *w)
{
if (!w) {
return;
}
//监控activeChanged会导致最小化状态获取不准确的问题
//connect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::iconChanged, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow);
connect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped);
}
void WaylandInterface::untrackWindow(PlasmaWindow *w)
{
if (!w) {
return;
}
disconnect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow);
disconnect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped);
}
void WaylandInterface::setCurrentDesktop(QString desktop)
{
if (m_currentDesktop == desktop) {
return;
}
m_currentDesktop = desktop;
emit currentDesktopChanged();
}
void WaylandInterface::addDesktop(const QString &id, quint32 position)
{
if (m_desktops.contains(id)) {
return;
}
m_desktops.append(id);
const KWayland::Client::PlasmaVirtualDesktop *desktop = m_virtualDesktopManagement->getVirtualDesktop(id);
QObject::connect(desktop, &KWayland::Client::PlasmaVirtualDesktop::activated, this,
[desktop, this]() {
setCurrentDesktop(desktop->id());
}
);
if (desktop->isActive()) {
setCurrentDesktop(id);
}
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/xcbinterface.cpp 0000664 0001750 0001750 00000033252 14474244170 027707 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "xcbinterface.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "kwindowinfo.h"
#include
XcbInterface::XcbInterface(QObject *parent)
:AbstractInterface(parent)
{
m_currentDesktop = QString::number(KWindowSystem::self()->currentDesktop());
connect(KWindowSystem::self(),&KWindowSystem::showingDesktopChanged,this,&AbstractInterface::isShowingDesktopChanged);
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &AbstractInterface::activeWindowChanged);
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, [=](WindowId wid){
if (!m_windows.contains(wid)) {
m_windows.insert(wid, this->requestInfo(wid));
}
emit windowAdded(wid);});
connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, this, [=](WindowId wid){
m_windows.remove(wid);
emit windowRemoved(wid);
});
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [&](int desktop) {
m_currentDesktop = QString::number(desktop);
emit currentDesktopChanged();
});
connect(KWindowSystem::self()
, static_cast
(&KWindowSystem::windowChanged)
, this, &XcbInterface::windowChangedProxy);
for(auto wid : KWindowSystem::self()->windows()) {
emit windowAdded(wid);
windowChangedProxy(wid,0,0);
}
}
XcbInterface::~XcbInterface()
{
}
WindowInfo XcbInterface::requestInfo(WindowId wid)
{
const KWindowInfo winfo{wid.value(), NET::WMFrameExtents
| NET::WMWindowType
| NET::WMGeometry
| NET::WMDesktop
| NET::WMState
| NET::WMName
| NET::WMVisibleName,
NET::WM2WindowClass
| NET::WM2Activities
| NET::WM2AllowedActions
| NET::WM2TransientFor};
bool isDesktop{false};
if (winfo.windowClassName() == "plasmashell" && isPlasmaDesktop(winfo.geometry())) {
isDesktop = true;
this->setPlasmaDesktop(wid);
}
WindowInfo windowInfo;
if (!winfo.valid())
{
windowInfo.setIsValid(false);
}
else if (isValidWindow(winfo) && !isDesktop)
{
windowInfo.setIsValid(true);
windowInfo.setWid(wid);
windowInfo.setIsPlasmaDesktop(false);
//windowInfo.setParentId(winfo.transientFor());
windowInfo.setIsActive(KWindowSystem::activeWindow() == wid.value());
windowInfo.setIsMinimized(winfo.hasState(NET::Hidden));
windowInfo.setIsMaxVert(winfo.hasState(NET::MaxVert));
windowInfo.setIsMaxHoriz(winfo.hasState(NET::MaxHoriz));
windowInfo.setIsFullscreen(winfo.hasState(NET::FullScreen));
windowInfo.setIsShaded(winfo.hasState(NET::Shaded));
windowInfo.setIsOnAllDesktops(winfo.onAllDesktops());
windowInfo.setIsOnAllActivities(winfo.activities().empty());
//windowInfo.setGeometry(winfo.frameGeometry());
windowInfo.setIsKeepAbove(winfo.hasState(NET::KeepAbove));
windowInfo.setHasSkipTaskbar(winfo.hasState(NET::SkipTaskbar));
//! Window Abilities
windowInfo.setIsClosable(winfo.actionSupported(NET::ActionClose));
windowInfo.setIsFullScreenable(winfo.actionSupported(NET::ActionFullScreen));
windowInfo.setIsMaximizable(winfo.actionSupported(NET::ActionMax));
windowInfo.setIsMinimizable(winfo.actionSupported(NET::ActionMinimize));
windowInfo.setIsMovable(winfo.actionSupported(NET::ActionMove));
windowInfo.setIsResizable(winfo.actionSupported(NET::ActionResize));
windowInfo.setIsShadeable(winfo.actionSupported(NET::ActionShade));
windowInfo.setIsVirtualDesktopsChangeable(winfo.actionSupported(NET::ActionChangeDesktop));
//! Window Abilities
//windowInfo.setDisplay(winfo.visibleName());
windowInfo.setDesktops({QString::number(winfo.desktop())});
//windowInfo.setActivities(winfo.activities());
}
else if (m_desktopId == wid)
{
windowInfo.setIsValid(true);
windowInfo.setIsPlasmaDesktop(true);
windowInfo.setWid(wid);
//windowInfo.setParentId(0);
windowInfo.setHasSkipTaskbar(true);
//! Window Abilities
windowInfo.setIsClosable(false);
windowInfo.setIsFullScreenable(false);
windowInfo.setIsGroupable(false);
windowInfo.setIsMaximizable(false);
windowInfo.setIsMinimizable(false);
windowInfo.setIsMovable(false);
windowInfo.setIsResizable(false);
windowInfo.setIsShadeable(false);
windowInfo.setIsVirtualDesktopsChangeable(false);
//! Window Abilities
}
return windowInfo;
}
void XcbInterface::requestActivate(WindowId wid)
{
KWindowSystem::activateWindow(wid.toInt());
}
void XcbInterface::requestClose(WindowId wid)
{
WindowInfo wInfo = requestInfo(wid);
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
return;
}
NETRootInfo ri(QX11Info::connection(), NET::CloseWindow);
ri.closeWindowRequest(wInfo.wid().toUInt());
}
void XcbInterface::requestToggleKeepAbove(WindowId wid)
{
WindowInfo wInfo = requestInfo(wid);
if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) {
return;
}
NETWinInfo ni(QX11Info::connection(), wid.toUInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2());
if (wInfo.isKeepAbove()) {
ni.setState(NET::States(), NET::StaysOnTop);
} else {
ni.setState(NET::StaysOnTop, NET::StaysOnTop);
}
}
void XcbInterface::requestToggleMinimized(WindowId wid)
{
WindowInfo wInfo = requestInfo(wid);
if (!wInfo.isValid() || wInfo.isPlasmaDesktop() || !inCurrentDesktopActivity(wInfo)) {
return;
}
if (wInfo.isMinimized()) {
bool onCurrent = wInfo.isOnDesktop(m_currentDesktop);
KWindowSystem::unminimizeWindow(wid.toUInt());
if (onCurrent) {
KWindowSystem::forceActiveWindow(wid.toUInt());
}
} else {
KWindowSystem::minimizeWindow(wid.toUInt());
}
}
void XcbInterface::requestToggleMaximized(WindowId wid)
{
WindowInfo wInfo = requestInfo(wid);
if (!windowCanBeMaximized(wid) || !inCurrentDesktopActivity(wInfo)) {
return;
}
bool restore = wInfo.isMaxHoriz() && wInfo.isMaxVert();
if (wInfo.isMinimized()) {
KWindowSystem::unminimizeWindow(wid.toUInt());
}
NETWinInfo ni(QX11Info::connection(), wid.toInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2());
if (restore) {
ni.setState(NET::States(), NET::Max);
} else {
ni.setState(NET::Max, NET::Max);
}
}
QIcon XcbInterface::iconFor(WindowId wid)
{
QIcon icon;
icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmall, KIconLoader::SizeSmall, false));
icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium, false));
icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeMedium, KIconLoader::SizeMedium, false));
icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeLarge, KIconLoader::SizeLarge, false));
return icon;
}
QString XcbInterface::titleFor(WindowId wid)
{
const KWindowInfo winfo{wid.value(), NET::WMName};
if(winfo.valid())
return winfo.name();
else
return QString();
}
QString XcbInterface::windowGroupFor(WindowId wid)
{
KWindowInfo winfo(wid.toULongLong(), NET::WMName, NET::WM2WindowClass);
if(winfo.valid())
return winfo.windowClassClass();
else
return QString();
}
void XcbInterface::showCurrentDesktop()
{
KWindowSystem::setShowingDesktop(true);
}
void XcbInterface::hideCurrentDesktop()
{
KWindowSystem::setShowingDesktop(false);
}
quint32 XcbInterface::pid(WindowId wid)
{
quint64 pid = 0;
const KWindowInfo winfo{wid.value(), NET::WMName};
if(!winfo.valid())
return pid;
else
{
pid = winfo.pid();
}
return pid;
}
WindowId XcbInterface::activeWindow()
{
WId wid = KWindowSystem::self()->activeWindow();
return QVariant::fromValue(wid);
}
bool XcbInterface::windowCanBeDragged(WindowId wid)
{
WindowInfo winfo = requestInfo(wid);
return (winfo.isValid()
&& !winfo.isMinimized()
&& winfo.isMovable()
&& inCurrentDesktopActivity(winfo)
&& !winfo.isPlasmaDesktop());
}
bool XcbInterface::windowCanBeMaximized(WindowId wid)
{
WindowInfo winfo = requestInfo(wid);
return (winfo.isValid()
&& !winfo.isMinimized()
&& winfo.isMaximizable()
&& inCurrentDesktopActivity(winfo)
&& !winfo.isPlasmaDesktop());
}
void XcbInterface::setGeometry(QWindow *window, const QRect &rect)
{
if(window)
window->setGeometry(rect);
}
void XcbInterface::setSkipTaskBar(QWindow *window, bool skip)
{
if(skip)
KWindowSystem::setState(window->winId(),NET::SkipTaskbar);
else
KWindowSystem::clearState(window->winId(),NET::SkipTaskbar);
}
void XcbInterface::setSkipSwitcher(QWindow *window, bool skip)
{
if(skip)
KWindowSystem::setState(window->winId(),NET::SkipSwitcher);
else
KWindowSystem::clearState(window->winId(),NET::SkipSwitcher);
}
bool XcbInterface::skipTaskBar(const WindowId &wid)
{
const KWindowInfo winfo(wid.value(), NET::WMState);
return winfo.valid() ? winfo.hasState(NET::SkipTaskbar) : false;
}
bool XcbInterface::skipSwitcher(const WindowId &wid)
{
const KWindowInfo winfo(wid.value(), NET::WMState);
return winfo.valid() ? winfo.hasState(NET::SkipSwitcher) : false;
}
bool XcbInterface::isShowingDesktop()
{
return KWindowSystem::showingDesktop();
}
void XcbInterface::setOnAllDesktops(const WindowId &wid)
{
WindowInfo wInfo = requestInfo(wid);
if (!wInfo.isValid()) {
return;
}
if (KWindowSystem::numberOfDesktops() <= 1) {
return;
}
if (wInfo.isOnAllDesktops()) {
KWindowSystem::setOnDesktop(wid.toUInt(), KWindowSystem::currentDesktop());
KWindowSystem::forceActiveWindow(wid.toUInt());
} else {
KWindowSystem::setOnAllDesktops(wid.toUInt(), true);
}
}
NET::WindowType XcbInterface::windowType(WindowId wid)
{
KWindowInfo info(wid.value(),NET::WMWindowType|NET::WMState,NET::WM2TransientFor);
return info.windowType(NET::AllTypesMask);
}
bool XcbInterface::isValidWindow(WindowId wid)
{
if (this->isValidFor(wid)) {
return true;
}
const KWindowInfo winfo{wid.value(), NET::WMWindowType | NET::WMState};
return isValidWindow(winfo);
}
bool XcbInterface::isValidWindow(const KWindowInfo &winfo)
{
if (this->isValidFor(winfo.win())) {
return true;
}
//! ignored windows from tracking
// if (m_ignoredWindows.contains(winfo.win())) {
// return false;
// }
if (m_desktopId == winfo.win()) {
return false;
}
bool hasSkipTaskbar = winfo.hasState(NET::SkipTaskbar);
bool hasSkipPager = winfo.hasState(NET::SkipPager);
bool isSkipped = hasSkipTaskbar && hasSkipPager;
return !isSkipped;
}
void XcbInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
{
// const KWindowInfo info(wid, NET::WMGeometry, NET::WM2WindowClass);
// const auto winClass = info.windowClassName();
// //! ignored windows do not trackd
// if (m_ignoredWindows.contains(wid)) {
// return;
// }
// if (winClass == "plasmashell") {
// //! update desktop id
// if (isPlasmaDesktop(info.geometry())) {
// m_desktopId = wid;
// windowsTracker()->setPlasmaDesktop(wid);
// considerWindowChanged(wid);
// return;
// } else if (isPlasmaPanel(info.geometry())) {
// registerPlasmaPanel(wid);
// return;
// }
// }
//! accept only NET::Properties events,
//! ignore when the user presses a key, or a window is sending X events etc.
//! without needing to (e.g. Firefox, https://bugzilla.mozilla.org/show_bug.cgi?id=1389953)
//! NET::WM2UserTime, NET::WM2IconPixmap etc....
if (prop1 == 0 && !(prop2 & (NET::WM2Activities | NET::WM2TransientFor))) {
return;
}
//! accept only the following NET:Properties changed signals
//! NET::WMState, NET::WMGeometry, NET::ActiveWindow
if ( !(prop1 & NET::WMState)
&& !(prop1 & NET::WMGeometry)
&& !(prop1 & NET::ActiveWindow)
&& !(prop1 & NET::WMDesktop)
&& !(prop1 & (NET::WMName | NET::WMVisibleName)
&& !(prop2 & NET::WM2TransientFor)
&& !(prop2 & NET::WM2Activities)) ) {
return;
}
if (!isValidWindow(wid)) {
return;
}
emit windowChanged(wid);
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/wmregister.cpp 0000664 0001750 0001750 00000002770 14474244170 027443 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "wmregister.h"
#include
#include
#include
#include
#include "../waylandhelper.h"
#include "waylandinterface.h"
#include "xcbinterface.h"
using namespace kdk;
using namespace KWayland::Client;
kdk::WmRegister::WmRegister(QObject *parent)
:QObject(parent)
{
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive))
m_winInterface = new WaylandInterface(this);
else
m_winInterface = new XcbInterface(this);
}
WmRegister::~WmRegister()
{
}
AbstractInterface *WmRegister::winInterface()
{
return m_winInterface;
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/windowmanager/windowinfo.h 0000664 0001750 0001750 00000024642 14474244170 027105 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WINDOWINFO_H
#define WINDOWINFO_H
#include
#include
#include
namespace kdk {
class WindowInfo
{
using WindowId = QVariant;
public:
WindowInfo():
m_handle(nullptr)
, m_isValid(false)
, m_isActive(false)
, m_isMinimized(false)
, m_isMaxVert(false)
, m_isMaxHoriz(false)
, m_isFullscreen(false)
, m_isShaded(false)
, m_isPlasmaDesktop(false)
, m_isKeepAbove(false)
, m_hasSkipTaskbar(false)
, m_hasSkipSwitcher(false)
, m_isOnAllDesktops(false)
, m_isOnAllActivities(false)
, m_isClosable(false)
, m_isFullScreenable(false)
, m_isGroupable(false)
, m_isMaximizable(false)
, m_isMinimizable(false)
, m_isMovable(false)
, m_isResizable(false)
, m_isShadeable(false)
, m_isVirtualDesktopsChangeable(false){}
inline bool isPlasmaDesktop() const;
inline void setIsPlasmaDesktop(bool isPlasmaDesktop);
inline bool isValid() const;
inline void setIsValid(bool isValid);
inline bool isActive() const noexcept;
inline void setIsActive(bool isActive) noexcept;
inline bool isMaxVert() const;
inline void setIsMaxVert(bool isMaxVert);
inline bool isMaxHoriz() const;
inline void setIsMaxHoriz(bool isMaxHoriz);
inline WindowId wid() const;
inline void setWid(const WindowId &wid);
inline bool isKeepAbove() const;
inline void setIsKeepAbove(bool isKeepAbove);
inline bool isMinimized() const;
inline void setIsMinimized(bool isMinimized);
inline bool isMaximized() const;
inline bool isFullscreen() const noexcept;
inline void setIsFullscreen(bool isFullscreen) noexcept;
inline bool isShaded() const noexcept;
inline void setIsShaded(bool isShaded) noexcept;
inline bool hasSkipTaskbar() const noexcept;
inline void setHasSkipTaskbar(bool skipTaskbar) noexcept;
inline bool hasSkipSwitcher() const noexcept;
inline void setHasSkipSwitcher(bool skipSwitcher) noexcept;
inline bool isOnAllDesktops() const noexcept;
inline void setIsOnAllDesktops(bool alldesktops) noexcept;
inline bool isOnAllActivities() const noexcept;
inline void setIsOnAllActivities(bool allactivities) noexcept;
//ability
inline bool isCloseable() const noexcept;
inline void setIsClosable(bool closable) noexcept;
inline bool isFullScreenable() const noexcept;
inline void setIsFullScreenable(bool fullscreenable) noexcept;
inline bool isGroupable() const noexcept;
inline void setIsGroupable(bool groupable) noexcept;
inline bool isMaximizable() const;
inline void setIsMaximizable(bool maximizable);
inline bool isMinimizable() const;
inline void setIsMinimizable(bool minimizable);
inline bool isMovable() const noexcept;
inline void setIsMovable(bool movable) noexcept;
inline bool isResizable() const noexcept;
inline void setIsResizable(bool resizable) noexcept;
inline bool isShadeable() const noexcept;
inline void setIsShadeable(bool shadeble) noexcept;
inline bool isVirtualDesktopsChangeable() const noexcept;
inline void setIsVirtualDesktopsChangeable(bool virtualdesktopchangeable) noexcept;
// //ability
// inline bool isMainWindow() const noexcept;
// inline bool isChildWindow() const noexcept;
// inline QRect geometry() const noexcept;
// inline void setGeometry(const QRect &geometry) noexcept;
// inline QString appName() const noexcept;
// inline void setAppName(const QString &appName) noexcept;
// inline QString display() const noexcept;
// inline void setDisplay(const QString &display) noexcept;
inline QIcon icon() const noexcept;
inline void setIcon(const QIcon &icon) noexcept;
// inline WindowId wid() const noexcept;
// inline void setWid(const WindowId &wid) noexcept;
// inline WindowId parentId() const noexcept;
// inline void setParentId(const WindowId &parentId) noexcept;
inline QStringList desktops() const noexcept;
inline void setDesktops(const QStringList &desktops) noexcept;
// inline QStringList activities() const noexcept;
// inline void setActivities(const QStringList &activities) noexcept;
inline bool isOnDesktop(const QString &desktop) const noexcept;
// inline bool isOnActivity(const QString &activity) const noexcept;
private:
void* m_handle;
bool m_isWayland;
WindowId m_wid{0};
WindowId m_parentId{0};
QRect m_geometry;
bool m_isValid : 1;
bool m_isActive : 1;
bool m_isMinimized : 1;
bool m_isMaxVert : 1;
bool m_isMaxHoriz : 1;
bool m_isFullscreen : 1;
bool m_isShaded : 1;
bool m_isPlasmaDesktop : 1;
bool m_isKeepAbove: 1;
bool m_hasSkipTaskbar: 1;
bool m_isOnAllDesktops: 1;
bool m_isOnAllActivities: 1;
bool m_hasSkipSwitcher: 1;
//!BEGIN: Window Abilities
bool m_isClosable : 1;
bool m_isFullScreenable : 1;
bool m_isGroupable : 1;
bool m_isMaximizable : 1;
bool m_isMinimizable : 1;
bool m_isMovable : 1;
bool m_isResizable : 1;
bool m_isShadeable : 1;
bool m_isVirtualDesktopsChangeable : 1;
QString m_appName;
QString m_display;
QIcon m_icon;
QStringList m_desktops;
QStringList m_activities;
};
bool WindowInfo::isPlasmaDesktop() const
{
return m_isPlasmaDesktop;
}
void WindowInfo::setIsPlasmaDesktop(bool isPlasmaDesktop)
{
m_isPlasmaDesktop = isPlasmaDesktop;
}
bool WindowInfo::isValid() const
{
return m_isValid;
}
void WindowInfo::setIsValid(bool isValid)
{
m_isValid = isValid;
}
bool WindowInfo::isActive() const noexcept
{
return m_isActive;
}
void WindowInfo::setIsActive(bool isActive) noexcept
{
m_isActive = isActive;
}
bool WindowInfo::isMaxVert() const
{
return m_isMaxVert;
}
void WindowInfo::setIsMaxVert(bool isMaxVert)
{
m_isMaxVert = isMaxVert;
}
bool WindowInfo::isMaxHoriz() const
{
return m_isMaxHoriz;
}
void WindowInfo::setIsMaxHoriz(bool isMaxHoriz)
{
m_isMaxHoriz = isMaxHoriz;
}
WindowInfo::WindowId WindowInfo::wid() const
{
return m_wid;
}
void WindowInfo::setWid(const WindowId &wid)
{
m_wid = wid;
}
bool WindowInfo::isKeepAbove() const
{
return m_isKeepAbove;
}
void WindowInfo::setIsKeepAbove(bool isKeepAbove)
{
m_isKeepAbove = isKeepAbove;
}
bool WindowInfo::isMinimized() const
{
return m_isMinimized;
}
void WindowInfo::setIsMinimized(bool isMinimized)
{
m_isMinimized = isMinimized;
}
bool WindowInfo::isMaximized() const
{
return m_isMaxVert && m_isMaxHoriz;
}
bool WindowInfo::isFullscreen() const noexcept
{
return m_isFullscreen;
}
void WindowInfo::setIsFullscreen(bool isFullscreen) noexcept
{
m_isFullscreen = isFullscreen;
}
bool WindowInfo::isShaded() const noexcept
{
return m_isShaded;
}
void WindowInfo::setIsShaded(bool isShaded) noexcept
{
m_isShaded = isShaded;
}
bool WindowInfo::hasSkipTaskbar() const noexcept
{
return m_hasSkipTaskbar;
}
void WindowInfo::setHasSkipTaskbar(bool skipTaskbar) noexcept
{
m_hasSkipTaskbar = skipTaskbar;
}
inline bool WindowInfo::hasSkipSwitcher() const noexcept
{
return m_hasSkipSwitcher;
}
inline void WindowInfo::setHasSkipSwitcher(bool skipSwitcher) noexcept
{
m_hasSkipSwitcher = skipSwitcher;
}
bool WindowInfo::isOnAllDesktops() const noexcept
{
return m_isOnAllDesktops;
}
void WindowInfo::setIsOnAllDesktops(bool alldesktops) noexcept
{
m_isOnAllDesktops = alldesktops;
}
bool WindowInfo::isOnAllActivities() const noexcept
{
return m_isOnAllActivities;
}
void WindowInfo::setIsOnAllActivities(bool allactivities) noexcept
{
m_isOnAllActivities = allactivities;
}
bool WindowInfo::isCloseable() const noexcept
{
return m_isClosable;
}
void WindowInfo::setIsClosable(bool closable) noexcept
{
m_isClosable = closable;
}
bool WindowInfo::isFullScreenable() const noexcept
{
return m_isFullScreenable;
}
void WindowInfo::setIsFullScreenable(bool fullscreenable) noexcept
{
m_isFullScreenable = fullscreenable;
}
bool WindowInfo::isGroupable() const noexcept
{
return m_isGroupable;
}
void WindowInfo::setIsGroupable(bool groupable) noexcept
{
m_isGroupable = groupable;
}
bool WindowInfo::isMaximizable() const
{
return m_isMaximizable;
}
void WindowInfo::setIsMaximizable(bool maximizable)
{
m_isMaximizable = maximizable;
}
bool WindowInfo::isMinimizable() const
{
return m_isMinimizable;
}
void WindowInfo::setIsMinimizable(bool minimizable)
{
m_isMinimizable = minimizable;
}
bool WindowInfo::isOnDesktop(const QString &desktop) const noexcept
{
return m_isOnAllDesktops || m_desktops.contains(desktop);
}
bool WindowInfo::isMovable() const noexcept
{
return m_isMovable;
}
void WindowInfo::setIsMovable(bool movable) noexcept
{
m_isMovable = movable;
}
bool WindowInfo::isResizable() const noexcept
{
return m_isResizable;
}
void WindowInfo::setIsResizable(bool resizable) noexcept
{
m_isResizable = resizable;
}
bool WindowInfo::isShadeable() const noexcept
{
return m_isShadeable;
}
void WindowInfo::setIsShadeable(bool shadeble) noexcept
{
m_isShadeable = shadeble;
}
bool WindowInfo::isVirtualDesktopsChangeable() const noexcept
{
return m_isVirtualDesktopsChangeable;
}
void WindowInfo::setIsVirtualDesktopsChangeable(bool virtualdesktopchangeable) noexcept
{
m_isVirtualDesktopsChangeable = virtualdesktopchangeable;
}
QIcon WindowInfo::icon() const noexcept
{
return m_icon;
}
void WindowInfo::setIcon(const QIcon &icon) noexcept
{
m_icon = icon;
}
QStringList WindowInfo::desktops() const noexcept
{
return m_desktops;
}
void WindowInfo::setDesktops(const QStringList &desktops) noexcept
{
m_desktops = desktops;
}
}
#endif // WINDOWINFO_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/waylandhelper.h 0000664 0001750 0001750 00000002246 14474244170 024713 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WAYLANDHELPER_H
#define WAYLANDHELPER_H
#include "kysdk-waylandhelper_global.h"
#include
namespace kdk
{
class KYSDKWAYLANDHELPER_EXPORT WaylandHelper:public QObject
{
public:
static bool isWaylandServer();
static bool isWaylandClient();
static WaylandHelper *self();
private:
WaylandHelper(QObject* parent=nullptr);
};
}
#endif // WAYLANDHELPER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/waylandhelper.cpp 0000664 0001750 0001750 00000003104 14474244170 025240 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "waylandhelper.h"
#include
#include
using namespace kdk;
static const char* server_flag = "XDG_SESSION_TYPE";
static const char* client_flag = "QT_QPA_PLATFORM";
static WaylandHelper* g_instance = nullptr;
bool WaylandHelper::isWaylandServer()
{
if (qgetenv(server_flag) == QString("wayland"))
{
return true;
}
else
{
return false;
}
}
bool WaylandHelper::isWaylandClient()
{
if (qgetenv(client_flag) == QString("wayland"))
{
return true;
}
else
{
return false;
}
}
WaylandHelper *WaylandHelper::self()
{
if (!g_instance)
g_instance = new WaylandHelper();
return g_instance;
}
WaylandHelper::WaylandHelper(QObject *parent)
:QObject(parent)
{
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ 0000775 0001750 0001750 00000000000 14474244170 025135 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/xatom-helper.cpp 0000664 0001750 0001750 00000013774 14474244076 030267 0 ustar admin admin /*
* KWin Style UKUI
*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "xatom-helper.h"
#include
#include
#include
#include
#include
static XAtomHelper *global_instance = nullptr;
XAtomHelper *XAtomHelper::getInstance()
{
if (!global_instance)
global_instance = new XAtomHelper;
return global_instance;
}
bool XAtomHelper::isFrameLessWindow(int winId)
{
auto hints = getInstance()->getWindowMotifHint(winId);
if (hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) {
return true;
}
return false;
}
bool XAtomHelper::isWindowDecorateBorderOnly(int winId)
{
return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId));
}
bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint)
{
bool isDeco = false;
if (hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) {
if (hint.decorations == MWM_DECOR_BORDER)
isDeco = true;
}
return isDeco;
}
bool XAtomHelper::isUKUICsdSupported()
{
// fixme:
return false;
}
bool XAtomHelper::isUKUIDecorationWindow(int winId)
{
if (m_ukuiDecorationAtion == None)
return false;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
bool isUKUIDecoration = false;
XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion,
0, LONG_MAX, false,
m_ukuiDecorationAtion, &type,
&format, &nitems,
&bytes_after, &data);
if (type == m_ukuiDecorationAtion) {
if (nitems == 1) {
isUKUIDecoration = data[0];
}
}
return isUKUIDecoration;
}
UnityCorners XAtomHelper::getWindowBorderRadius(int winId)
{
UnityCorners corners;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
if (m_unityBorderRadiusAtom != None) {
XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom,
0, LONG_MAX, false,
XA_CARDINAL, &type,
&format, &nitems,
&bytes_after, &data);
if (type == XA_CARDINAL) {
if (nitems == 4) {
corners.topLeft = static_cast(data[0]);
corners.topRight = static_cast(data[1*sizeof (ulong)]);
corners.bottomLeft = static_cast(data[2*sizeof (ulong)]);
corners.bottomRight = static_cast(data[3*sizeof (ulong)]);
}
XFree(data);
}
}
return corners;
}
void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data)
{
if (m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight};
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0]));
}
void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight)
{
if (m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight};
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0]));
}
void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set)
{
if (m_ukuiDecorationAtion == None)
return;
XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1);
}
void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints)
{
if (m_unityBorderRadiusAtom == None)
return;
XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof (MotifWmHints)/ sizeof (ulong));
}
MotifWmHints XAtomHelper::getWindowMotifHint(int winId)
{
MotifWmHints hints;
if (m_unityBorderRadiusAtom == None)
return hints;
uchar *data;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom,
0, sizeof (MotifWmHints)/sizeof (long), false, AnyPropertyType, &type,
&format, &nitems, &bytes_after, &data);
if (type == None) {
return hints;
} else {
hints = *(MotifWmHints *)data;
XFree(data);
}
return hints;
}
XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent)
{
if (!QX11Info::isPlatformX11())
return;
m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false);
m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false);
}
Atom XAtomHelper::registerUKUICsdNetWmSupportAtom()
{
// fixme:
return None;
}
void XAtomHelper::unregisterUKUICsdNetWmSupportAtom()
{
// fixme:
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/xatom-helper.h 0000664 0001750 0001750 00000006253 14474244076 027726 0 ustar admin admin /*
* KWin Style UKUI
*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef XATOMHELPER_H
#define XATOMHELPER_H
#include
struct UnityCorners {
ulong topLeft = 0;
ulong topRight = 0;
ulong bottomLeft = 0;
ulong bottomRight = 0;
};
typedef struct {
ulong flags = 0;
ulong functions = 0;
ulong decorations = 0;
long input_mode = 0;
ulong status = 0;
} MotifWmHints, MwmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
namespace UKUI {
class Decoration;
}
class XAtomHelper : public QObject
{
friend class UKUI::Decoration;
Q_OBJECT
public:
static XAtomHelper *getInstance();
static bool isFrameLessWindow(int winId);
bool isWindowDecorateBorderOnly(int winId);
bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint);
bool isUKUICsdSupported();
bool isUKUIDecorationWindow(int winId);
UnityCorners getWindowBorderRadius(int winId);
void setWindowBorderRadius(int winId, const UnityCorners &data);
void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight);
void setUKUIDecoraiontHint(int winId, bool set = true);
void setWindowMotifHint(int winId, const MotifWmHints &hints);
MotifWmHints getWindowMotifHint(int winId);
private:
explicit XAtomHelper(QObject *parent = nullptr);
unsigned long registerUKUICsdNetWmSupportAtom();
void unregisterUKUICsdNetWmSupportAtom();
unsigned long m_motifWMHintsAtom = 0l;
unsigned long m_unityBorderRadiusAtom = 0l;
unsigned long m_ukuiDecorationAtion = 0l;
};
#endif // XATOMHELPER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-core.c 0000664 0001750 0001750 00000003345 14474244170 031336 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
/* Generated by wayland-scanner 1.18.0 */
#include
#include
#include "wayland-util.h"
#ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
#else
#define WL_PRIVATE
#endif
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *custom_types[] = {
&wl_surface_interface,
&wl_surface_interface,
NULL,
&wl_surface_interface,
NULL,
NULL,
NULL,
NULL,
};
static const struct wl_message ukui_decoration_requests[] = {
{ "move_surface", "o", custom_types + 0 },
{ "set_ukui_decoration_mode", "ou", custom_types + 1 },
{ "set_unity_border_radius", "ouuuu", custom_types + 3 },
};
WL_PRIVATE const struct wl_interface ukui_decoration_interface = {
"ukui_decoration", 1,
3, ukui_decoration_requests,
0, NULL,
};
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.cpp 0000664 0001750 0001750 00000007646 14474244170 032370 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "ukui-decoration-manager.h"
#include "ukui-decoration-client.h"
#include
#include
#include
static UKUIDecorationManager *global_instance = nullptr;
static wl_display *display = nullptr;
static ukui_decoration *ukui_decoration_manager = nullptr;
static void handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) {
if (strcmp(interface, ukui_decoration_interface.name) == 0) {
ukui_decoration_manager = (ukui_decoration *) wl_registry_bind(registry, name, &ukui_decoration_interface, version);
}
}
static void handle_global_remove(void *data, struct wl_registry *registry,
uint32_t name) {
// Who cares
}
static const struct wl_registry_listener registry_listener = {
.global = handle_global,
.global_remove = handle_global_remove,
};
UKUIDecorationManager *UKUIDecorationManager::getInstance()
{
if (!global_instance)
global_instance = new UKUIDecorationManager;
return global_instance;
}
bool UKUIDecorationManager::supportUKUIDecoration()
{
return ukui_decoration_manager;
}
bool UKUIDecorationManager::moveWindow(QWindow *windowHandle)
{
if (!supportUKUIDecoration())
return false;
auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle);
if (!kde_surface)
return false;
wl_surface *surface = *kde_surface;
if (!surface)
return false;
ukui_decoration_move_surface(ukui_decoration_manager, surface);
wl_surface_commit(surface);
wl_display_roundtrip(display);
return true;
}
bool UKUIDecorationManager::removeHeaderBar(QWindow *windowHandle)
{
if (!supportUKUIDecoration())
return false;
auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle);
if (!kde_surface)
return false;
wl_surface *surface = *kde_surface;
if (!surface)
return false;
ukui_decoration_set_ukui_decoration_mode(ukui_decoration_manager, surface, 1);
wl_surface_commit(surface);
wl_display_roundtrip(display);
return true;
}
bool UKUIDecorationManager::setCornerRadius(QWindow *windowHandle, int topleft, int topright, int bottomleft, int bottomright)
{
if (!supportUKUIDecoration())
return false;
auto kde_surface = KWayland::Client::Surface::fromWindow(windowHandle);
if (!kde_surface)
return false;
wl_surface *surface = *kde_surface;
if (!surface)
return false;
ukui_decoration_set_unity_border_radius(ukui_decoration_manager, surface, topleft, topright, bottomleft, bottomright);
wl_surface_commit(surface);
wl_display_roundtrip(display);
return true;
}
UKUIDecorationManager::UKUIDecorationManager()
{
auto connectionThread = KWayland::Client::ConnectionThread::fromApplication(qApp);
display = connectionThread->display();
struct wl_registry *registry = wl_display_get_registry(display);
// get ukui_decoration_manager
wl_registry_add_listener(registry, ®istry_listener, nullptr);
wl_display_roundtrip(display);
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-manager.h 0000664 0001750 0001750 00000002411 14474244170 032016 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef UKUIDECORATIONMANAGER_H
#define UKUIDECORATIONMANAGER_H
#include
class UKUIDecorationManager
{
public:
static UKUIDecorationManager *getInstance();
bool supportUKUIDecoration();
bool moveWindow(QWindow *windowHandle);
bool removeHeaderBar(QWindow *windowHandle);
bool setCornerRadius(QWindow *windowHandle, int topleft, int topright, int bottomleft, int bottomright);
private:
UKUIDecorationManager();
};
#endif // UKUIDECORATIONMANAGER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.h 0000664 0001750 0001750 00000002340 14474244170 030543 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef UKUISTYLEHELPER_H
#define UKUISTYLEHELPER_H
#include
namespace kdk {
class UkuiStyleHelper:public QObject
{
public:
static UkuiStyleHelper *self();
/**
* @brief 移除窗管标题栏
* @param widget
*/
void removeHeader(QWidget* widget);
protected:
bool eventFilter(QObject *obj, QEvent *ev) override;
private:
UkuiStyleHelper();
QWidget* m_widget;
};
}
#endif // UKUISTYLEHELPER_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukuistylehelper.cpp 0000664 0001750 0001750 00000004244 14474244170 031103 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "ukuistylehelper.h"
#include "../waylandhelper.h"
#include "ukui-decoration-manager.h"
#include "xatom-helper.h"
#include
#include
namespace kdk {
static UkuiStyleHelper *global_instance = nullptr;
UkuiStyleHelper *UkuiStyleHelper::self()
{
if(global_instance)
return global_instance;
else
{
global_instance = new UkuiStyleHelper();
return global_instance;
}
}
void UkuiStyleHelper::removeHeader(QWidget* widget)
{
if(!widget)
return;
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive))
{
m_widget = widget;
m_widget->installEventFilter(this);
}
else
{
MotifWmHints hints1;
hints1.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints1.functions = MWM_FUNC_ALL;
hints1.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(widget->winId(), hints1);
}
}
bool UkuiStyleHelper::eventFilter(QObject *obj, QEvent *ev)
{
if(obj == m_widget && (ev->type() == QEvent::PlatformSurface || ev->type() == QEvent::Show || ev->type() == QEvent::Paint))
{
UKUIDecorationManager::getInstance()->removeHeaderBar(m_widget->windowHandle());
}
return QObject::eventFilter(obj,ev);
}
UkuiStyleHelper::UkuiStyleHelper()
{
}
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/ukuistylehelper/ukui-decoration-client.h 0000664 0001750 0001750 00000010066 14474244170 031667 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
/* Generated by wayland-scanner 1.18.0 */
#ifndef CUSTOM_CLIENT_PROTOCOL_H
#define CUSTOM_CLIENT_PROTOCOL_H
#include
#include
#include "wayland-client.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ukui_decoration;
struct wl_surface;
/**
* @page page_iface_ukui_decoration ukui_decoration
* @section page_iface_ukui_decoration_desc Description
*
* This example shows how to add extra functionality to Wayland
* through an extension. This is the global object of the extension.
* @section page_iface_ukui_decoration_api API
* See @ref iface_ukui_decoration.
*/
/**
* @defgroup iface_ukui_decoration The ukui_decoration interface
*
* This example shows how to add extra functionality to Wayland
* through an extension. This is the global object of the extension.
*/
extern const struct wl_interface ukui_decoration_interface;
#define UKUI_DECORATION_MOVE_SURFACE 0
#define UKUI_DECORATION_SET_UKUI_DECORATION_MODE 1
#define UKUI_DECORATION_SET_UNITY_BORDER_RADIUS 2
/**
* @ingroup iface_ukui_decoration
*/
#define UKUI_DECORATION_MOVE_SURFACE_SINCE_VERSION 1
/**
* @ingroup iface_ukui_decoration
*/
#define UKUI_DECORATION_SET_UKUI_DECORATION_MODE_SINCE_VERSION 1
/**
* @ingroup iface_ukui_decoration
*/
#define UKUI_DECORATION_SET_UNITY_BORDER_RADIUS_SINCE_VERSION 1
/** @ingroup iface_ukui_decoration */
static inline void
ukui_decoration_set_user_data(struct ukui_decoration *ukui_decoration, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) ukui_decoration, user_data);
}
/** @ingroup iface_ukui_decoration */
static inline void *
ukui_decoration_get_user_data(struct ukui_decoration *ukui_decoration)
{
return wl_proxy_get_user_data((struct wl_proxy *) ukui_decoration);
}
static inline uint32_t
ukui_decoration_get_version(struct ukui_decoration *ukui_decoration)
{
return wl_proxy_get_version((struct wl_proxy *) ukui_decoration);
}
/** @ingroup iface_ukui_decoration */
static inline void
ukui_decoration_destroy(struct ukui_decoration *ukui_decoration)
{
wl_proxy_destroy((struct wl_proxy *) ukui_decoration);
}
/**
* @ingroup iface_ukui_decoration
*
* Inform the compositor that the client has a new surface that is
* covered by the extension.
*/
static inline void
ukui_decoration_move_surface(struct ukui_decoration *ukui_decoration, struct wl_surface *surface)
{
wl_proxy_marshal((struct wl_proxy *) ukui_decoration,
UKUI_DECORATION_MOVE_SURFACE, surface);
}
/**
* @ingroup iface_ukui_decoration
*
* The compositor should perform a move animation on the surface.
*/
static inline void
ukui_decoration_set_ukui_decoration_mode(struct ukui_decoration *ukui_decoration, struct wl_surface *surface, uint32_t mode)
{
wl_proxy_marshal((struct wl_proxy *) ukui_decoration,
UKUI_DECORATION_SET_UKUI_DECORATION_MODE, surface, mode);
}
/**
* @ingroup iface_ukui_decoration
*
* The compositor should perform a move animation on the surface.
*/
static inline void
ukui_decoration_set_unity_border_radius(struct ukui_decoration *ukui_decoration, struct wl_surface *surface, uint32_t topleft, uint32_t topright, uint32_t bottomleft, uint32_t bottomright)
{
wl_proxy_marshal((struct wl_proxy *) ukui_decoration,
UKUI_DECORATION_SET_UNITY_BORDER_RADIUS, surface, topleft, topright, bottomleft, bottomright);
}
#ifdef __cplusplus
}
#endif
#endif
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/src/kysdk-waylandhelper_global.h 0000664 0001750 0001750 00000002111 14474244170 027345 0 ustar admin admin /*
* libkysdk-waylandhelper's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef KYSDKWAYLANDHELPER_GLOBAL_H
#define KYSDKWAYLANDHELPER_GLOBAL_H
#include
#if defined(KYSDKWAYLANDHELPER_LIBRARY)
# define KYSDKWAYLANDHELPER_EXPORT Q_DECL_EXPORT
#else
# define KYSDKWAYLANDHELPER_EXPORT Q_DECL_IMPORT
#endif
#endif // KYSDKWAYLANDHELPER_GLOBAL_H
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/ 0000775 0001750 0001750 00000000000 14474244076 022074 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/ 0000775 0001750 0001750 00000000000 14474244170 025531 5 ustar admin admin libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/ 0000775 0001750 0001750 00000000000 14474244170 031173 5 ustar admin admin ././@LongLink 0000644 0000000 0000000 00000000146 00000000000 011604 L ustar root root libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.cpp libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.cp0000664 0001750 0001750 00000014327 14474244170 033011 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "widget.h"
#include
#include
#include
using namespace kdk;
Widget::Widget(QWidget *parent)
: QWidget(parent),
m_subWidget1(nullptr),
m_subWidget2(nullptr)
{
m_manager = new kdk::WindowManager();
m_timer = new QTimer(this);
m_timer->setInterval(2000);
initUI();
initConnection();
}
Widget::~Widget()
{
}
void Widget::initUI()
{
QVBoxLayout* mainLayout = new QVBoxLayout(this);
QHBoxLayout* hLayout1 = new QHBoxLayout();
m_btnMinimize = new QPushButton("minimize",this);
m_btnMaximum = new QPushButton("maximum",this);
m_btnActivate = new QPushButton("activate",this);
m_btnStayOnTop = new QPushButton("stayOnTop",this);
m_btnClose = new QPushButton("close",this);
m_btnShowDesktop = new QPushButton("shwDsktp",this);
m_shwWindowTitle = new QPushButton("shwTitle",this);
m_shwWindowIcon = new QPushButton("shwIcon",this);
hLayout1->addWidget(m_btnMinimize);
hLayout1->addWidget(m_btnMaximum);
hLayout1->addWidget(m_btnActivate);
hLayout1->addWidget(m_btnStayOnTop);
hLayout1->addWidget(m_btnClose);
hLayout1->addWidget(m_btnShowDesktop);
hLayout1->addWidget(m_shwWindowTitle);
hLayout1->addWidget(m_shwWindowIcon);
QHBoxLayout* hLayout2 = new QHBoxLayout();
m_shwWdg1btn1 = new QPushButton("showWg1",this);
m_shwWdg1btn2 = new QPushButton("showWg2",this);
hLayout2->addWidget(m_shwWdg1btn1);
hLayout2->addWidget(m_shwWdg1btn2);
QHBoxLayout* hLayout3 = new QHBoxLayout();
m_btnChangeIcon = new QPushButton("changeIcon",this);
m_btnChangeTitle = new QPushButton("changeTitle",this);
hLayout3->addWidget(m_btnChangeIcon);
hLayout3->addWidget(m_btnChangeTitle);
mainLayout->addLayout(hLayout1);
mainLayout->addLayout(hLayout2);
mainLayout->addLayout(hLayout3);
this->setWindowIcon(QIcon::fromTheme("kylin-music"));
}
void Widget::initConnection()
{
connect(m_manager,&WindowManager::activeWindowChanged,this,[=](const WindowId&wid){
qDebug()<<"activeWindowChanged:"<currentActiveWindow();
});
connect(m_manager,&WindowManager::windowAdded,this,[=](const WindowId& windowId){
m_lastestWindowId = windowId;
qDebug()<<"windowAdded:"<minimizeWindow(m_subWidget1->winId());
}
});
connect(m_btnMaximum,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
m_manager->maximizeWindow(m_subWidget1->winId());
}
});
connect(m_btnActivate,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
m_manager->activateWindow(m_subWidget1->winId());
}
});
connect(m_btnStayOnTop,&QPushButton::clicked,this,[=](){
if(!m_subWidget1)
{
m_subWidget1 = new QWidget();
m_subWidget1->setWindowTitle("widget1");
}
m_manager->keepWindowAbove(m_subWidget1->winId());
});
connect(m_btnClose,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
m_manager->closeWindow(m_subWidget1->winId());
}
});
connect(m_btnShowDesktop,&QPushButton::clicked,this,[=](){
m_manager->showDesktop();
m_timer->start();
connect(m_timer,&QTimer::timeout,this,[=](){
m_manager->hideDesktop();
});
});
connect(m_shwWdg1btn1,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
m_subWidget1->show();
}
else
{
m_subWidget1 = new QWidget();
m_subWidget1->setWindowTitle("widget1");
m_subWidget1->show();
}
});
connect(m_shwWdg1btn2,&QPushButton::clicked,this,[=](){
if(m_subWidget2)
{
m_subWidget2->show();
}
else
{
m_subWidget2 = new QWidget();
m_subWidget2->setWindowTitle("widget2");
m_subWidget2->show();
}
});
connect(m_btnChangeTitle,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
if(m_subWidget1->windowTitle()!= QString("originTitle"))
m_subWidget1->setWindowTitle("originTitle");
else
m_subWidget1->setWindowTitle("changedTitle");
}
});
connect(m_btnChangeIcon,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
if(!m_subWidget1->windowIcon().name().contains("kylin-music"))
m_subWidget1->setWindowIcon(QIcon::fromTheme("kylin-music"));
else
m_subWidget1->setWindowIcon(QIcon::fromTheme("kylin-network"));
}
});
connect(m_shwWindowTitle,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
qDebug() << m_manager->getWindowTitle(m_subWidget1->winId());
});
connect(m_shwWindowIcon,&QPushButton::clicked,this,[=](){
if(m_subWidget1)
{
WindowId nb = m_manager->currentActiveWindow();
qDebug() << m_manager->getWindowIcon(nb);
}
});
}
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager/widget.h 0000664 0001750 0001750 00000003163 14474244170 032632 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#ifndef WIDGET_H
#define WIDGET_H
#include
#include
#include
#include "windowmanager/windowmanager.h"
using namespace kdk;
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
void initUI();
void initConnection();
private:
QWidget* m_subWidget1;
QWidget* m_subWidget2;
QPushButton* m_btnMinimize;
QPushButton* m_btnMaximum;
QPushButton* m_btnActivate;
QPushButton* m_btnStayOnTop;
QPushButton* m_btnClose;
QPushButton* m_btnShowDesktop;
QPushButton* m_btnChangeIcon;
QPushButton* m_btnChangeTitle;
QPushButton* m_shwWdg1btn1;
QPushButton* m_shwWdg1btn2;
QPushButton* m_shwWindowTitle;
QPushButton* m_shwWindowIcon;
kdk::WindowManager *m_manager;
QTimer* m_timer;
WindowId m_lastestWindowId;
};
#endif // WIDGET_H
././@LongLink 0000644 0000000 0000000 00000000154 00000000000 011603 L ustar root root libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.2fbbdfe libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro.user.0000664 0001750 0001750 00000053174 14474244076 032767 0 ustar admin admin
EnvironmentId
{2fbbdfe0-46ea-4bec-b909-73a0b852001a}
ProjectExplorer.Project.ActiveTarget
0
ProjectExplorer.Project.EditorSettings
true
false
true
Cpp
CppGlobal
QmlJS
QmlJSGlobal
2
UTF-8
false
4
false
80
true
true
1
true
false
0
true
true
0
8
true
1
true
true
true
false
ProjectExplorer.Project.PluginSettings
ProjectExplorer.Project.Target.0
桌面
桌面
{d0fe3a0f-07ac-433e-b833-ff24c72691fa}
0
0
0
/home/sunzhen/kysdk-waylandhelper/build
true
QtProjectManager.QMakeBuildStep
true
false
false
false
true
Qt4ProjectManager.MakeStep
false
false
2
Build
Build
ProjectExplorer.BuildSteps.Build
true
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Debug
Qt4ProjectManager.Qt4BuildConfiguration
2
/home/sunzhen/kysdk-waylandhelper/test/build-testWindowManager-unknown-Release
true
QtProjectManager.QMakeBuildStep
false
false
false
true
true
Qt4ProjectManager.MakeStep
false
false
2
Build
Build
ProjectExplorer.BuildSteps.Build
true
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Release
Qt4ProjectManager.Qt4BuildConfiguration
0
/home/sunzhen/kysdk-waylandhelper/test/build-testWindowManager-unknown-Profile
true
QtProjectManager.QMakeBuildStep
true
false
true
true
true
Qt4ProjectManager.MakeStep
false
false
2
Build
Build
ProjectExplorer.BuildSteps.Build
true
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Profile
Qt4ProjectManager.Qt4BuildConfiguration
0
3
0
Deploy
Deploy
ProjectExplorer.BuildSteps.Deploy
1
ProjectExplorer.DefaultDeployConfiguration
1
dwarf
cpu-cycles
250
-e
cpu-cycles
--call-graph
dwarf,4096
-F
250
-F
true
4096
false
false
1000
true
false
false
false
false
true
0.01
10
true
kcachegrind
1
25
1
true
false
true
valgrind
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
Qt4ProjectManager.Qt4RunConfiguration:/home/sunzhen/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro
/home/sunzhen/kysdk-waylandhelper/test/testWindowManager/testWindowManager.pro
false
false
true
true
false
false
true
/home/sunzhen/kysdk-waylandhelper/build
1
ProjectExplorer.Project.TargetCount
1
ProjectExplorer.Project.Updater.FileVersion
22
Version
22
libkysdk-applications-2.2.1.1/kysdk-waylandhelper/test/testWindowManager/widget.cpp 0000664 0001750 0001750 00000036417 14474244170 027533 0 ustar admin admin /*
*
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Zhen Sun
*
*/
#include "widget.h"
#include
#include
#include
#include
#include
#include
#include
#include
using namespace kdk;
Widget::Widget(QWidget *parent)
: QWidget(parent),
m_subWidget(nullptr)
{
m_timer = new QTimer(this);
m_timer->setInterval(2000);
connect(WindowManager::self(),&WindowManager::windowAdded,this,[=](const WindowId& windowId){
/*注意:
* 最新创建的窗体被设置为操作窗体,此demo中每个按钮对应一个接口函数调用,所有接口函数操作的窗口都是该最新创建的窗体
*/
m_lastestWindowId = windowId;
qDebug()<<"窗口添加:"<setText("注意:最新创建的窗体被设置为操作窗体,此demo中每个按钮对应一个接口函数调用,所有接口函数操作的窗口都是该最新创建的窗体");
m_btnMinimize = new QPushButton("最小化窗口",this);
m_btnMaximum = new QPushButton("最大化窗口",this);
m_btnActivate = new QPushButton("激活窗口",this);
m_btnStayOnTop = new QPushButton("置顶窗口",this);
m_btnClose = new QPushButton("关闭窗口",this);
m_btnShowDesktop = new QPushButton("显示桌面",this);
m_shwWindowTitle = new QPushButton("获取窗口标题",this);
m_shwWindowIcon = new QPushButton("获取窗口图标",this);
m_btnShowGroup = new QPushButton("获取窗口所属组",this);
m_btnprintList = new QPushButton("获取窗口列表",this);
m_btnSetGeometry = new QPushButton("设置窗口大小",this);
hLayout1->addWidget(m_btnMinimize);
hLayout1->addWidget(m_btnMaximum);
hLayout1->addWidget(m_btnActivate);
hLayout1->addWidget(m_btnStayOnTop);
hLayout1->addWidget(m_btnClose);
QLabel *label = new QLabel(this);
label->setText("依次输入起点x,起点y,宽度w,高度h");
m_posX = new QSpinBox(this);
m_posY = new QSpinBox(this);
m_width = new QSpinBox(this);
m_height = new QSpinBox(this);
m_posX->setRange(0,2000);
m_posY->setRange(0,2000);
m_width->setRange(1,2000);
m_height->setRange(1,2000);
m_posX->setValue(0);
m_posY->setValue(0);
m_width->setValue(800);
m_height->setValue(600);
QHBoxLayout *hLayout5 = new QHBoxLayout;
hLayout5->addWidget(m_posX);
hLayout5->addWidget(m_posY);
hLayout5->addWidget(m_width);
hLayout5->addWidget(m_height);
QHBoxLayout* hLayout2 = new QHBoxLayout();
m_shwWdgbtn = new QPushButton("打开测试窗口",this);
hLayout2->addWidget(m_shwWdgbtn);
hLayout2->addWidget(m_btnSetGeometry);
hLayout2->addWidget(new QLabel("设置窗口类型",this));
m_setTypeBox = new QComboBox(this);
QStringList l;
l<<"Widget"<<"Window"<<"Dialog"<<"Sheet"<<"Drawer"<<"Popup"<<"Tool"<<"ToolTip"<<
"SplashScreen"<<"Desktop"<<"SubWindow"<<"ForeignWindow"<<"CoverWindow";
m_setTypeBox->addItems(l);
hLayout2->addWidget(m_setTypeBox);
QHBoxLayout* hLayout4 = new QHBoxLayout();
hLayout4->addWidget(m_btnShowDesktop);
hLayout4->addWidget(m_shwWindowTitle);
hLayout4->addWidget(m_shwWindowIcon);
hLayout4->addWidget(m_btnShowGroup);
hLayout4->addWidget(m_btnprintList);
QHBoxLayout* hLayout3 = new QHBoxLayout();
m_btnChangeIcon = new QPushButton("更改图标",this);
m_btnChangeTitle = new QPushButton("更改标题",this);
m_btnGetType = new QPushButton("获取窗口类型",this);
hLayout3->addWidget(m_btnChangeIcon);
hLayout3->addWidget(m_btnChangeTitle);
hLayout3->addWidget(m_btnGetType);
QGroupBox *box2 = new QGroupBox("2.0需求接口",this);
QHBoxLayout *hLayout6 = new QHBoxLayout();
m_skipTaskbarBtn = new QPushButton("跳过任务栏",this);
m_skipSwitcherBtn = new QPushButton("跳过窗口选择器",this);
hLayout6->addWidget(m_skipTaskbarBtn);
hLayout6->addWidget(m_skipSwitcherBtn);
QHBoxLayout *hLayout7 = new QHBoxLayout();
m_showOnAllDesktop = new QPushButton("在所有桌面中显示",this);
m_isDesktopShowing = new QPushButton("获取桌面是否处于显示状态",this);
hLayout7->addWidget(m_showOnAllDesktop);
hLayout7->addWidget(m_isDesktopShowing);
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->addLayout(hLayout6);
vlayout->addLayout(hLayout7);
box2->setLayout(vlayout);
QGroupBox *box3 = new QGroupBox("2.1需求接口",this);
QVBoxLayout *vLayout = new QVBoxLayout();
QHBoxLayout *hLayout8 = new QHBoxLayout();
m_isOnCurrentDesktop = new QPushButton("被测窗体是否在当前桌面",this);
hLayout8->addStretch();
hLayout8->addWidget(m_isOnCurrentDesktop);
vLayout->addLayout(hLayout8);
box3->setLayout(vLayout);
mainLayout->addWidget(m_label);
mainLayout->addLayout(hLayout1);
mainLayout->addWidget(label);
mainLayout->addLayout(hLayout5);
mainLayout->addLayout(hLayout2);
mainLayout->addLayout(hLayout3);
mainLayout->addLayout(hLayout4);
mainLayout->addWidget(box2);
mainLayout->addWidget(box3);
m_subWidget = new QWidget();
m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-music"));
m_subWidget->setWindowTitle("widget");
}
void Widget::initConnection()
{
connect(m_setTypeBox,static_cast(&QComboBox::currentIndexChanged),this,[=](int index)
{
switch (index) {
case 0:
m_subWidget->setWindowFlags(Qt::Widget);
break;
case 1:
m_subWidget->setWindowFlags(Qt::Window);
break;
case 2:
m_subWidget->setWindowFlags(Qt::Dialog);
break;
case 3:
m_subWidget->setWindowFlags(Qt::Sheet);
break;
case 4:
m_subWidget->setWindowFlags(Qt::Drawer);
break;
case 5:
m_subWidget->setWindowFlags(Qt::Popup);
break;
case 6:
m_subWidget->setWindowFlags(Qt::Tool);
break;
case 7:
m_subWidget->setWindowFlags(Qt::ToolTip);
break;
case 8:
m_subWidget->setWindowFlags(Qt::SplashScreen);
break;
case 9:
m_subWidget->setWindowFlags(Qt::Desktop);
break;
case 10:
m_subWidget->setWindowFlags(Qt::SubWindow);
break;
case 11:
m_subWidget->setWindowFlags(Qt::ForeignWindow);
break;
case 12:
m_subWidget->setWindowFlags(Qt::CoverWindow);
break;
default:
break;
}
});
connect(WindowManager::self(),&WindowManager::activeWindowChanged,this,[=](const WindowId&wid){
qDebug()<<"活动窗口改变:"<start();
connect(m_timer,&QTimer::timeout,this,[=](){
WindowManager::hideDesktop();
});
});
connect(m_btnShowGroup,&QPushButton::clicked,this,[=](){
qDebug()<<"窗口所属组:"<show();
});
connect(m_btnChangeTitle,&QPushButton::clicked,this,[=](){
if(m_subWidget)
{
if(m_subWidget->windowTitle()!= QString("originTitle"))
m_subWidget->setWindowTitle("originTitle");
else
m_subWidget->setWindowTitle("changedTitle");
}
});
connect(m_btnChangeIcon,&QPushButton::clicked,this,[=](){
if(m_subWidget)
{
if(!m_subWidget->windowIcon().name().contains("kylin-music"))
m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-music"));
else
m_subWidget->setWindowIcon(QIcon::fromTheme("kylin-network"));
}
});
connect(m_shwWindowTitle,&QPushButton::clicked,this,[=](){
if(m_subWidget)
qDebug() << "窗口标题为:"<< WindowManager::getWindowTitle(m_lastestWindowId);
});
connect(m_shwWindowIcon,&QPushButton::clicked,this,[=](){
if(m_subWidget)
{
qDebug() <<"窗口图标为:"< lists = WindowManager::windows();
qDebug()<<"打印窗口列表:";
for(auto id : lists)
{
qDebug()<show();
QRect rect(m_posX->value(),m_posY->value(),m_width->value(),m_height->value());
WindowManager::setGeometry(m_subWidget->windowHandle(),rect);
});
connect(m_btnGetType,&QPushButton::clicked,this,[=](){
/*
*Unknown = -1,
*Normal = 0
*Desktop = 1,
*Dock = 2,
*Toolbar = 3,
*Menu = 4,
*Dialog = 5,
*Override = 6, // NON STANDARD
*TopMenu = 7, // NON STANDARD
*Utility = 8,
*Splash = 9,
*DropdownMenu = 10,
*PopupMenu = 11,
*Tooltip = 12,
*Notification = 13,
*ComboBox = 14,
*DNDIcon = 15,
*OnScreenDisplay = 16,
*CriticalNotification = 17
*/
switch (WindowManager::getWindowType(m_subWidget->winId()))
{
case NET::WindowType::Unknown:
qDebug()<<"Unknown";
break;
case NET::WindowType::Normal:
qDebug()<<"normal";
break;
case NET::WindowType::Desktop:
qDebug()<<"Desktop";
break;
case NET::WindowType::Dock:
qDebug()<<"Dock";
break;
case NET::WindowType::Toolbar:
qDebug()<<"Toolbar";
break;
case NET::WindowType::Menu:
qDebug()<<"Menu";
break;
case NET::WindowType::Dialog:
qDebug()<<"Dialog";
break;
case NET::WindowType::Override:
qDebug()<<"Override";
break;
case NET::WindowType::TopMenu:
qDebug()<<"TopMenu";
break;
case NET::WindowType::Splash:
qDebug()<<"Splash";
break;
case NET::WindowType::Utility:
qDebug()<<"Utility";
break;
case NET::WindowType::DropdownMenu:
qDebug()<<"DropdownMenu";
break;
case NET::WindowType::PopupMenu:
qDebug()<<"PopupMenu";
break;
case NET::WindowType::Tooltip:
qDebug()<<"Tooltip";
break;
case NET::WindowType::Notification:
qDebug()<<"Notification";
break;
case NET::WindowType::ComboBox:
qDebug()<<"ComboBox";
break;
case NET::WindowType::DNDIcon:
qDebug()<<"DNDIcon";
break;
case NET::WindowType::OnScreenDisplay:
qDebug()<<"OnScreenDisplay";
break;
case NET::WindowType::CriticalNotification:
qDebug()<<"CriticalNotification";
break;
default:
qDebug()<winId());
break;
} ;
});
connect(m_skipTaskbarBtn,&QPushButton::clicked,this,[=](){;
WindowManager::setSkipTaskBar(this->windowHandle(),true);
QTimer::singleShot(1000,this,[=](){
qDebug()<<"跳过任务栏:"<windowHandle(),true);
QTimer::singleShot(1000,this,[=](){
qDebug()<<"跳过窗口选择器"<