From a582d95e0c13d758e36d6045198f42a567a270fb Mon Sep 17 00:00:00 2001 From: leeffo Date: Thu, 29 Dec 2022 15:42:49 +0800 Subject: [PATCH] delete keyboard wayland --- src/frame/CMakeLists.txt | 17 +- src/frame/modules/keyboard/customedit.cpp | 75 +----- src/frame/modules/keyboard/customedit.h | 9 - src/frame/modules/keyboard/keyboardwork.cpp | 8 +- src/frame/modules/keyboard/keyboardwork.h | 1 - .../modules/keyboard/shortcutcontent.cpp | 85 +----- src/frame/modules/keyboard/shortcutcontent.h | 10 - src/frame/modules/keyboard/shortcutitem.cpp | 1 - src/frame/modules/keyboard/shortcutmodel.cpp | 33 +-- src/frame/modules/keyboard/shortcutmodel.h | 1 - .../authentication/biologicalbasedialog.h | 2 +- .../authentication/faceiddetailwidget.cpp | 2 +- .../window/modules/keyboard/customcontent.cpp | 73 ------ .../window/modules/keyboard/customcontent.h | 7 - .../modules/keyboard/keyboardmodule.cpp | 18 +- .../keyboard/shortcutsettingwidget.cpp | 78 +----- .../modules/keyboard/shortcutsettingwidget.h | 7 - ...wayland-keyboard-grab-v1-client-protocol.h | 248 ------------------ ...yland-xwayland-keyboard-grab-v1-protocol.c | 60 ----- .../window/modules/keyboard/waylandgrab.cpp | 79 ------ .../window/modules/keyboard/waylandgrab.h | 45 ---- src/frame/window/utils.h | 12 - tests/dde-control-center/CMakeLists.txt | 12 +- 23 files changed, 19 insertions(+), 864 deletions(-) delete mode 100644 src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h delete mode 100644 src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c delete mode 100644 src/frame/window/modules/keyboard/waylandgrab.cpp delete mode 100644 src/frame/window/modules/keyboard/waylandgrab.h diff --git a/src/frame/CMakeLists.txt b/src/frame/CMakeLists.txt index a5c64d0..223eeb7 100644 --- a/src/frame/CMakeLists.txt +++ b/src/frame/CMakeLists.txt @@ -22,6 +22,9 @@ endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") +# disable qt keywords, cause gio have signals member; +ADD_DEFINITIONS(-DQT_NO_KEYWORDS) + if (DEFINED ENABLE_MIEEE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee") endif() @@ -406,9 +409,6 @@ set(KEYBOARD_FILES window/modules/keyboard/systemlanguagesettingwidget.cpp window/modules/keyboard/shortcutsettingwidget.cpp window/modules/keyboard/systemlanguagewidget.cpp - window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c - window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h - window/modules/keyboard/waylandgrab.cpp ) # load mouse @@ -598,15 +598,12 @@ find_package(Qt5 COMPONENTS DBus Multimedia Svg - WaylandClient REQUIRED) if(${Qt5_VERSION} VERSION_GREATER "5.15.1") find_package(Qt5 COMPONENTS XkbCommonSupport REQUIRED) endif() -find_package(KF5Wayland QUIET) -pkg_check_modules(WaylandClient REQUIRED wayland-client) pkg_check_modules(XCB_EWMH REQUIRED xcb-ewmh x11 xext xkbcommon) pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus) pkg_check_modules(QGSettings REQUIRED gsettings-qt) @@ -624,7 +621,6 @@ set(Qt_LIBS Qt5::Widgets Qt5::X11Extras Qt5::Multimedia - Qt5::WaylandClient ) set(DEEPIN_PW_CHECK libdeepin_pw_check.so) @@ -730,7 +726,6 @@ target_include_directories(dccwidgets PUBLIC ${CMAKE_SOURCE_DIR}/include ${DtkWidget_INCLUDE_DIRS} ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} ${WaylandClient_INCLUDE_DIRS} ${XCB_EWMH_INCLUDE_DIRS} ) @@ -745,9 +740,6 @@ target_link_libraries(dccwidgets PRIVATE ${DtkWidget_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Svg_LIBRARIES} - KF5::WaylandClient - Qt5::WaylandClient - ${WaylandClient_LIBRARIES} ) @@ -782,9 +774,6 @@ target_link_libraries(${BIN_NAME} PRIVATE crypt ${LIBS} PolkitQt5-1::Agent - KF5::WaylandClient - Qt5::WaylandClient - ${WaylandClient_LIBRARIES} ) # bin install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/frame/modules/keyboard/customedit.cpp b/src/frame/modules/keyboard/customedit.cpp index fe5b6ad..99347a9 100644 --- a/src/frame/modules/keyboard/customedit.cpp +++ b/src/frame/modules/keyboard/customedit.cpp @@ -5,19 +5,15 @@ #include "customedit.h" #include "widgets/translucentframe.h" #include "customitem.h" -#include "window/modules/keyboard/waylandgrab.h" -#include "window/utils.h" #include #include #include #include -#include #include DWIDGET_USE_NAMESPACE -using namespace DCC_NAMESPACE; keyboard::CustomEdit::CustomEdit(ShortcutModel *model, QWidget *parent): ContentWidget(parent), @@ -27,12 +23,8 @@ keyboard::CustomEdit::CustomEdit(ShortcutModel *model, QWidget *parent): m_command(new LineEditWidget), m_short(new CustomItem(this)), m_tip(new QLabel), - m_conflict(nullptr), - m_waylandGrab(nullptr) + m_conflict(nullptr) { - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - m_waylandGrab = new WaylandGrab(this->topLevelWidget()); - } m_tip->setVisible(false); m_tip->setWordWrap(true); @@ -204,68 +196,3 @@ void keyboard::CustomEdit::onUpdateKey() { Q_EMIT requestUpdateKey(nullptr); } - -void keyboard::CustomEdit::onGrab(ShortcutInfo *info) -{ - if (m_waylandGrab) - m_waylandGrab->onGrab(info); -} - -void keyboard::CustomEdit::keyPressEvent(QKeyEvent *e) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - m_waylandGrab->setKeyValue(WaylandkeyMap[e->key()]); - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - - m_waylandGrab->setRecordState(true); - keyEvent(true, m_waylandGrab->getRecordState() ? lastKey + keyValue : keyValue); - if (e->key() == Qt::Key_Control || e->key() == Qt::Key_Alt - || e->key() == Qt::Key_Shift || e->key() == Qt::Key_Super_L || e->key() == Qt::Key_Super_R) { - lastKey += ("<" + keyValue.remove(keyValue.indexOf("_"), 2) + ">"); - m_waylandGrab->setLastKey(lastKey); - } - QWidget::keyPressEvent(e); -} - -void keyboard::CustomEdit::keyReleaseEvent(QKeyEvent *e) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm() || !m_waylandGrab->getRecordState()) { - return; - } - QString lastKey = m_waylandGrab->getLastKey(); - const QString keyValue = m_waylandGrab->getKeyValue(); - if (!lastKey.isEmpty()) { - if (WaylandkeyMap[Qt::Key_Control] == keyValue - || WaylandkeyMap[Qt::Key_Alt] == keyValue || WaylandkeyMap[Qt::Key_Shift] == keyValue) { - keyEvent(false, ""); - } else if (WaylandkeyMap[Qt::Key_Super_L] == keyValue || WaylandkeyMap[Qt::Key_Super_R] == keyValue) { - keyEvent(false, "Super_L"); - } else { - keyEvent(false, lastKey + keyValue); - } - } else { - keyEvent(false, ""); - } - m_waylandGrab->setLastKey(""); - m_waylandGrab->setRecordState(false); - m_waylandGrab->onUnGrab(); - QWidget::keyReleaseEvent(e); -} - -void keyboard::CustomEdit::mousePressEvent(QMouseEvent *e) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - setFocus(); - if (!m_waylandGrab->getRecordState()) { - m_waylandGrab->onUnGrab(); - } - QWidget::mousePressEvent(e); -} diff --git a/src/frame/modules/keyboard/customedit.h b/src/frame/modules/keyboard/customedit.h index cceeb3b..bfc5ac6 100644 --- a/src/frame/modules/keyboard/customedit.h +++ b/src/frame/modules/keyboard/customedit.h @@ -16,8 +16,6 @@ using namespace dcc; using namespace dcc::widgets; -class WaylandGrab; - namespace dcc { namespace keyboard{ struct ShortcutInfo; @@ -37,12 +35,6 @@ Q_SIGNALS: public Q_SLOTS: void setBottomTip(ShortcutInfo *conflict); void keyEvent(bool press, const QString &shortcut); - void onGrab(ShortcutInfo *info); - -protected: - void keyPressEvent(QKeyEvent *e) override; - void keyReleaseEvent(QKeyEvent *e) override; - void mousePressEvent(QMouseEvent *e) override; private Q_SLOTS: void onOpenFile(); @@ -58,7 +50,6 @@ private: ShortcutInfo *m_info; QLabel *m_tip; ShortcutInfo *m_conflict; - WaylandGrab *m_waylandGrab; }; } } diff --git a/src/frame/modules/keyboard/keyboardwork.cpp b/src/frame/modules/keyboard/keyboardwork.cpp index 1f66cf7..b4f8723 100644 --- a/src/frame/modules/keyboard/keyboardwork.cpp +++ b/src/frame/modules/keyboard/keyboardwork.cpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace dcc { namespace keyboard{ @@ -605,11 +604,8 @@ void KeyboardWorker::updateKey(ShortcutInfo *info) { if (m_shortcutModel) m_shortcutModel->setCurrentInfo(info); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - Q_EMIT stareGrab(info); - } else { - m_keybindInter->SelectKeystroke(); - } + + m_keybindInter->SelectKeystroke(); } void KeyboardWorker::cleanShortcutSlef(const QString &id, const int type, const QString &shortcut) diff --git a/src/frame/modules/keyboard/keyboardwork.h b/src/frame/modules/keyboard/keyboardwork.h index d5b1add..f04b1fe 100644 --- a/src/frame/modules/keyboard/keyboardwork.h +++ b/src/frame/modules/keyboard/keyboardwork.h @@ -83,7 +83,6 @@ Q_SIGNALS: // 快捷键恢复默认完成 void onResetFinished(); - void stareGrab(ShortcutInfo *info); public Q_SLOTS: #ifndef DCC_DISABLE_LANGUAGE diff --git a/src/frame/modules/keyboard/shortcutcontent.cpp b/src/frame/modules/keyboard/shortcutcontent.cpp index c3f5129..815b15d 100644 --- a/src/frame/modules/keyboard/shortcutcontent.cpp +++ b/src/frame/modules/keyboard/shortcutcontent.cpp @@ -9,15 +9,10 @@ #include "keyboardcontrol.h" #include "widgets/translucentframe.h" #include "keyboardmodel.h" -#include "window/modules/keyboard/waylandgrab.h" -#include "window/utils.h" #include -#include #include -using namespace DCC_NAMESPACE; - namespace dcc { namespace keyboard { ShortcutContent::ShortcutContent(ShortcutModel *model, QWidget *parent) @@ -26,11 +21,7 @@ ShortcutContent::ShortcutContent(ShortcutModel *model, QWidget *parent) , m_conflict(nullptr) , m_shortcutItem(new ShortcutItem) , m_buttonTuple(new ButtonTuple(ButtonTuple::Save)) - , m_waylandGrab(nullptr) { - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - m_waylandGrab = new WaylandGrab(this->topLevelWidget()); - } TranslucentFrame *widget = new TranslucentFrame(); setContentsMargins(10, 10, 10, 10); QVBoxLayout *layout = new QVBoxLayout(); @@ -117,17 +108,12 @@ void ShortcutContent::setShortcut(const QString &shortcut) m_shortcutItem->setShortcut(shortcut); } -void ShortcutContent::setConflictShortcut(const QString &shortcut) -{ - m_conflictShortcut = shortcut; -} - void ShortcutContent::keyEvent(bool press, const QString &shortcut) { if (!press) { if (shortcut.isEmpty()) { - setBottomTip(m_shortcut == m_conflictShortcut ? m_conflict : nullptr); + setBottomTip(m_info); m_shortcutItem->setShortcut(m_shortcut); return; } @@ -145,12 +131,9 @@ void ShortcutContent::keyEvent(bool press, const QString &shortcut) if (info && info != m_info && info->accels != m_info->accels) { m_shortcutItem->setShortcut(info->accels); setBottomTip(info); - setConflictShortcut(shortcut); return; } - } - if (!shortcut.isEmpty()) { setBottomTip(nullptr); m_shortcutItem->setShortcut(shortcut); } @@ -175,71 +158,5 @@ void ShortcutContent::onUpdateKey() Q_EMIT requestUpdateKey(nullptr); } -void ShortcutContent::onGrab(ShortcutInfo *info) -{ - if (m_waylandGrab) - m_waylandGrab->onGrab(info); -} - -void ShortcutContent::keyPressEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - unsigned int keKey = static_cast(ke->key()); - m_waylandGrab->setKeyValue(WaylandkeyMap[keKey]); - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - - m_waylandGrab->setRecordState(true); - keyEvent(true, m_waylandGrab->getRecordState() ? lastKey + keyValue : keyValue); - if (keKey == Qt::Key_Control || keKey == Qt::Key_Alt - || keKey == Qt::Key_Shift || keKey == Qt::Key_Super_L || keKey == Qt::Key_Super_R) { - lastKey += ("<" + keyValue.remove(keyValue.indexOf("_"), 2) + ">"); - m_waylandGrab->setLastKey(lastKey); - } - return QWidget::keyPressEvent(ke); -} - -void ShortcutContent::keyReleaseEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()|| !m_waylandGrab->getRecordState()) { - return; - } - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - if (!lastKey.isEmpty()) { - if (WaylandkeyMap[Qt::Key_Control] == keyValue - || WaylandkeyMap[Qt::Key_Alt] == keyValue || WaylandkeyMap[Qt::Key_Shift] == keyValue) { - keyEvent(false, ""); - } else if (WaylandkeyMap[Qt::Key_Super_L] == keyValue || WaylandkeyMap[Qt::Key_Super_R] == keyValue) { - keyEvent(false, "Super_L"); - } else { - keyEvent(false, lastKey + keyValue); - } - } else { - keyEvent(false, ""); - } - m_waylandGrab->setLastKey(""); - m_waylandGrab->setRecordState(false); - m_waylandGrab->onUnGrab(); - return QWidget::keyReleaseEvent(ke); -} - -void ShortcutContent::mousePressEvent(QMouseEvent *e) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - setFocus(); - if (!m_waylandGrab->getRecordState()) { - m_waylandGrab->onUnGrab(); - } - QWidget::mousePressEvent(e); -} - } } diff --git a/src/frame/modules/keyboard/shortcutcontent.h b/src/frame/modules/keyboard/shortcutcontent.h index 5e31eb8..f1138a1 100644 --- a/src/frame/modules/keyboard/shortcutcontent.h +++ b/src/frame/modules/keyboard/shortcutcontent.h @@ -14,7 +14,6 @@ #include "widgets/buttontuple.h" using namespace dcc; -class WaylandGrab; namespace dcc { namespace keyboard{ @@ -31,7 +30,6 @@ public: void setBottomTip(ShortcutInfo *conflict); void setInfo(ShortcutInfo *info); void setShortcut(const QString &shortcut); - void setConflictShortcut(const QString &shortcut); Q_SIGNALS: void requestUpdateKey(ShortcutInfo *conflict); @@ -42,12 +40,6 @@ public Q_SLOTS: void keyEvent(bool press, const QString &shortcut); void onReplace(); void onUpdateKey(); - void onGrab(ShortcutInfo *info); - -protected: - void keyPressEvent(QKeyEvent *ke) override; - void keyReleaseEvent(QKeyEvent *ke) override; - void mousePressEvent(QMouseEvent *e) override; private: ShortcutModel *m_model; @@ -58,8 +50,6 @@ private: dcc::widgets::ButtonTuple *m_buttonTuple; TitleButtonItem* m_item; QString m_shortcut; - QString m_conflictShortcut; - WaylandGrab *m_waylandGrab; }; } } diff --git a/src/frame/modules/keyboard/shortcutitem.cpp b/src/frame/modules/keyboard/shortcutitem.cpp index facb5d2..1a75eff 100644 --- a/src/frame/modules/keyboard/shortcutitem.cpp +++ b/src/frame/modules/keyboard/shortcutitem.cpp @@ -128,7 +128,6 @@ void ShortcutItem::setShortcut(const QString &shortcut) accels = accels.replace("Control", "Ctrl"); m_key->setTextList(accels.split("-")); - m_key->setFocus(); QTimer::singleShot(0, this, &ShortcutItem::updateTitleSize); } diff --git a/src/frame/modules/keyboard/shortcutmodel.cpp b/src/frame/modules/keyboard/shortcutmodel.cpp index 44c33d8..df1112f 100644 --- a/src/frame/modules/keyboard/shortcutmodel.cpp +++ b/src/frame/modules/keyboard/shortcutmodel.cpp @@ -303,12 +303,8 @@ void ShortcutModel::setCurrentInfo(ShortcutInfo *currentInfo) ShortcutInfo *ShortcutModel::getInfo(const QString &shortcut) { - QString newShortcut = shortcut; - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - newShortcut = parseKeystroke(newShortcut); - } auto res = std::find_if(m_infos.begin(), m_infos.end(), [ = ] (const ShortcutInfo *info)->bool{ - return !QString::compare(info->accels, newShortcut, Qt::CaseInsensitive); //判断是否相等,相等则返回0 + return !QString::compare(info->accels, shortcut, Qt::CaseInsensitive); //判断是否相等,相等则返回0 }); if (res != m_infos.end()) { @@ -318,33 +314,6 @@ ShortcutInfo *ShortcutModel::getInfo(const QString &shortcut) return nullptr; } -QString ShortcutModel::parseKeystroke(QString& shortcut) -{ - // 如L转换后为L - QStringList keys = shortcut.replace(">", ">,").split(","); - keys.removeAll(""); - QString sortArr[5]; - foreach (const QString& key, keys) { - if (key.contains("Shift")) { - sortArr[0] = key; - } else if (key.contains("Control")) { - sortArr[1] = key; - } else if (key.contains("Alt")) { - sortArr[2] = key; - } else if (key.contains("Super")) { - sortArr[3] = key; - } else { - sortArr[4] = key; - } - } - QString newShort; - for (const QString& key : sortArr) { - if (!key.isEmpty()) { - newShort += key; - } - } - return newShort; -} void ShortcutModel::setSearchResult(const QString &searchResult) { diff --git a/src/frame/modules/keyboard/shortcutmodel.h b/src/frame/modules/keyboard/shortcutmodel.h index 0e67f1f..537ec4d 100644 --- a/src/frame/modules/keyboard/shortcutmodel.h +++ b/src/frame/modules/keyboard/shortcutmodel.h @@ -78,7 +78,6 @@ public: ShortcutInfo *getInfo(const QString &shortcut); void setSearchResult(const QString &searchResult); bool getWindowSwitch(); - QString parseKeystroke(QString& shortcuts); Q_SIGNALS: void listChanged(QList, InfoType); diff --git a/src/frame/window/modules/authentication/biologicalbasedialog.h b/src/frame/window/modules/authentication/biologicalbasedialog.h index 77c28fd..7f25e05 100644 --- a/src/frame/window/modules/authentication/biologicalbasedialog.h +++ b/src/frame/window/modules/authentication/biologicalbasedialog.h @@ -24,7 +24,7 @@ public: explicit BiologicalBaseDialog(QWidget *parent = nullptr); ~BiologicalBaseDialog(); -public slots: +public Q_SLOTS: void onShowDisclaimer(); void onAcceptDisclaimer(bool accept); diff --git a/src/frame/window/modules/authentication/faceiddetailwidget.cpp b/src/frame/window/modules/authentication/faceiddetailwidget.cpp index cc32719..2dd32eb 100644 --- a/src/frame/window/modules/authentication/faceiddetailwidget.cpp +++ b/src/frame/window/modules/authentication/faceiddetailwidget.cpp @@ -43,7 +43,7 @@ FaceidDetailWidget::FaceidDetailWidget(dcc::authentication::CharaMangerModel *mo FaceidDetailWidget::~FaceidDetailWidget() { - emit requestStopEnroll(); + Q_EMIT requestStopEnroll(); } void FaceidDetailWidget::initFaceidShow() diff --git a/src/frame/window/modules/keyboard/customcontent.cpp b/src/frame/window/modules/keyboard/customcontent.cpp index 0fd17e1..d36c02c 100644 --- a/src/frame/window/modules/keyboard/customcontent.cpp +++ b/src/frame/window/modules/keyboard/customcontent.cpp @@ -12,8 +12,6 @@ #include "widgets/buttontuple.h" #include "widgets/lineeditwidget.h" #include "widgets/settingsgroup.h" -#include "window/utils.h" -#include "waylandgrab.h" #include @@ -24,7 +22,6 @@ #include #include #include -#include DWIDGET_USE_NAMESPACE @@ -38,12 +35,7 @@ CustomContent::CustomContent(ShortcutModel *model, QWidget *parent) , m_conflict(nullptr) , m_model(model) , m_buttonTuple(new ButtonTuple(ButtonTuple::Save)) - , m_waylandGrab(nullptr) { - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - m_waylandGrab = new WaylandGrab(this->parent()); - } - QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setContentsMargins(10, 35, 10, 0); //~ contents_path /keyboard/Shortcuts/Add Custom Shortcut @@ -207,68 +199,3 @@ void CustomContent::updateKey() { Q_EMIT requestUpdateKey(nullptr); } - -void CustomContent::onGrab(ShortcutInfo *info) -{ - if (m_waylandGrab) - m_waylandGrab->onGrab(info); -} - -void CustomContent::keyPressEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - m_waylandGrab->setKeyValue(WaylandkeyMap[ke->key()]); - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - - m_waylandGrab->setRecordState(true); - keyEvent(true, m_waylandGrab->getRecordState() ? lastKey + keyValue : keyValue); - if (ke->key() == Qt::Key_Control || ke->key() == Qt::Key_Alt - || ke->key() == Qt::Key_Shift || ke->key() == Qt::Key_Super_L || ke->key() == Qt::Key_Super_R) { - lastKey += ("<" + keyValue.remove(keyValue.indexOf("_"), 2) + ">"); - m_waylandGrab->setLastKey(lastKey); - } - return QWidget::keyPressEvent(ke); -} - -void CustomContent::keyReleaseEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm() || !m_waylandGrab->getRecordState()) { - return; - } - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - if (!lastKey.isEmpty()) { - if (WaylandkeyMap[Qt::Key_Control] == keyValue - || WaylandkeyMap[Qt::Key_Alt] == keyValue || WaylandkeyMap[Qt::Key_Shift] == keyValue) { - keyEvent(false, ""); - } else if (WaylandkeyMap[Qt::Key_Super_L] == keyValue || WaylandkeyMap[Qt::Key_Super_R] == keyValue) { - keyEvent(false, "Super_L"); - } else { - keyEvent(false, lastKey + keyValue); - } - } else { - keyEvent(false, ""); - } - m_waylandGrab->setLastKey(""); - m_waylandGrab->setRecordState(false); - m_waylandGrab->onUnGrab(); - return QWidget::keyReleaseEvent(ke); -} - -void CustomContent::mousePressEvent(QMouseEvent *e) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - setFocus(); - if (!m_waylandGrab->getRecordState()) { - m_waylandGrab->onUnGrab(); - } - QWidget::mousePressEvent(e); -} \ No newline at end of file diff --git a/src/frame/window/modules/keyboard/customcontent.h b/src/frame/window/modules/keyboard/customcontent.h index adfa6ab..076cc6f 100644 --- a/src/frame/window/modules/keyboard/customcontent.h +++ b/src/frame/window/modules/keyboard/customcontent.h @@ -51,12 +51,6 @@ public Q_SLOTS: void keyEvent(bool press, const QString &shortcut); void updateKey(); - void onGrab(dcc::keyboard::ShortcutInfo *info); - -protected: - void keyPressEvent(QKeyEvent *ke) override; - void keyReleaseEvent(QKeyEvent *ke) override; - void mousePressEvent(QMouseEvent *e) override; private: dcc::keyboard::KeyboardWorker *m_work; @@ -68,7 +62,6 @@ private: dcc::keyboard::ShortcutModel *m_model; dcc::widgets::ButtonTuple *m_buttonTuple; - WaylandGrab *m_waylandGrab; }; } } diff --git a/src/frame/window/modules/keyboard/keyboardmodule.cpp b/src/frame/window/modules/keyboard/keyboardmodule.cpp index 12e8d74..463c627 100644 --- a/src/frame/window/modules/keyboard/keyboardmodule.cpp +++ b/src/frame/window/modules/keyboard/keyboardmodule.cpp @@ -20,7 +20,6 @@ #include "modules/keyboard/shortcutcontent.h" #include "window/mainwindow.h" -#include using namespace dcc; using namespace dcc::keyboard; @@ -352,7 +351,7 @@ void KeyboardModule::onAddLocale(const QModelIndex &index) void KeyboardModule::showShortCutSetting() { m_work->refreshShortcut(); - m_shortcutSettingWidget = new ShortCutSettingWidget(m_shortcutModel, m_pMainWindow); + m_shortcutSettingWidget = new ShortCutSettingWidget(m_shortcutModel); GSettingWatcher::instance()->bind("keyboardShortcut", m_shortcutSettingWidget); // 使用GSettings来控制显示状态 m_shortcutSettingWidget->setVisible(false); connect(m_shortcutSettingWidget, &ShortCutSettingWidget::customShortcut, this, &KeyboardModule::onPushCustomShortcut); @@ -368,9 +367,6 @@ void KeyboardModule::showShortCutSetting() connect(m_work, &KeyboardWorker::searchChangd, m_shortcutSettingWidget, &ShortCutSettingWidget::onSearchInfo); connect(m_work, &KeyboardWorker::onResetFinished, m_shortcutSettingWidget, &ShortCutSettingWidget::onResetFinished); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(m_work, &KeyboardWorker::stareGrab, m_shortcutSettingWidget, &ShortCutSettingWidget::onGrab); - } m_frameProxy->pushWidget(this, m_shortcutSettingWidget); m_shortcutSettingWidget->setVisible(GSettingWatcher::instance()->getStatus("keyboardShortcut") != "Hidden"); @@ -393,7 +389,7 @@ void KeyboardModule::onPushSystemLanguageSetting() void KeyboardModule::onPushCustomShortcut() { - m_customContent = new CustomContent(m_shortcutModel, m_pMainWindow); + m_customContent = new CustomContent(m_shortcutModel); m_customContent->setVisible(false); m_customContent->setAccessibleName(tr("Custom Shortcut")); connect(m_customContent, &CustomContent::requestUpdateKey, m_work, &KeyboardWorker::updateKey); @@ -401,9 +397,6 @@ void KeyboardModule::onPushCustomShortcut() connect(m_customContent, &CustomContent::requestForceSubs, m_work, &KeyboardWorker::onDisableShortcut); connect(m_customContent, &CustomContent::back, this, &KeyboardModule::showShortCutSetting); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(m_work, &KeyboardWorker::stareGrab, m_customContent, &CustomContent::onGrab); - } m_frameProxy->pushWidget(this, m_customContent); m_customContent->setVisible(true); @@ -419,13 +412,9 @@ void KeyboardModule::onPushConflict(ShortcutInfo *info, const QString &shortcut) connect(m_scContent, &ShortcutContent::requestUpdateKey, m_work, &KeyboardWorker::updateKey); connect(m_scContent, &ShortcutContent::requestDisableShortcut, m_work, &KeyboardWorker::onDisableShortcut); connect(m_scContent, &ShortcutContent::back, this, &KeyboardModule::showShortCutSetting); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(m_work, &KeyboardWorker::stareGrab, m_scContent, &ShortcutContent::onGrab); - } m_scContent->setInfo(info); m_scContent->setShortcut(shortcut); - m_scContent->setConflictShortcut(shortcut); m_scContent->setBottomTip(m_shortcutModel->getInfo(shortcut)); m_frameProxy->pushWidget(this, m_scContent); @@ -446,9 +435,6 @@ void KeyboardModule::onShortcutEdit(ShortcutInfo *info) connect(m_customEdit, &CustomEdit::requestSaveShortcut, head, &SettingsHead::toCancel); connect(m_customEdit, &CustomEdit::requestSaveShortcut, m_work, &KeyboardWorker::modifyCustomShortcut); connect(m_customEdit, &CustomEdit::back, this, &KeyboardModule::showShortCutSetting); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(m_work, &KeyboardWorker::stareGrab, m_customEdit, &CustomEdit::onGrab); - } m_frameProxy->pushWidget(this, m_customEdit); m_customEdit->setVisible(true); diff --git a/src/frame/window/modules/keyboard/shortcutsettingwidget.cpp b/src/frame/window/modules/keyboard/shortcutsettingwidget.cpp index 8b7024e..44989b0 100644 --- a/src/frame/window/modules/keyboard/shortcutsettingwidget.cpp +++ b/src/frame/window/modules/keyboard/shortcutsettingwidget.cpp @@ -12,12 +12,10 @@ #include "widgets/settingsgroup.h" #include "widgets/searchinput.h" #include "window/gsettingwatcher.h" -#include "waylandgrab.h" #include #include -#include using namespace DCC_NAMESPACE; using namespace DCC_NAMESPACE::keyboard; @@ -29,12 +27,7 @@ ShortCutSettingWidget::ShortCutSettingWidget(ShortcutModel *model, QWidget *pare , m_workspaceGroup(nullptr) , m_assistiveToolsGroup(nullptr) , m_model(model) - , m_waylandGrab(nullptr) { - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - m_waylandGrab = new WaylandGrab(this->parent()); - } - setAccessibleName("ShortCutSettingWidget"); m_searchDelayTimer = new QTimer(this); m_searchDelayTimer->setInterval(300); @@ -242,12 +235,12 @@ void ShortCutSettingWidget::addShortcut(QList list, ShortcutMode ShortcutItem *item = new ShortcutItem(); item->setAccessibleName(info->name); connect(item, &ShortcutItem::requestUpdateKey, this, &ShortCutSettingWidget::requestUpdateKey); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(item, &ShortcutItem::waylandEditKeyFinshed, this, [ this ]{ - if(m_waylandGrab && !m_waylandGrab->getRecordState()) - m_waylandGrab->onUnGrab(); - }); - } + //if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { + // connect(item, &ShortcutItem::waylandEditKeyFinshed, this, [ this ]{ + // if(m_waylandGrab && !m_waylandGrab->getRecordState()) + // m_waylandGrab->onUnGrab(); + // }); + //} item->setShortcutInfo(info); item->setTitle(info->name); info->item = item; @@ -444,11 +437,6 @@ void ShortCutSettingWidget::onSearchStringFinish(const QList sear ShortcutItem *item = new ShortcutItem; connect(item, &ShortcutItem::requestUpdateKey, this, &ShortCutSettingWidget::requestUpdateKey); - if (QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive)) { - connect(this, &ShortCutSettingWidget::changed, [ & ] { - onSearchTextChanged(m_searchText); - }); - } item->setShortcutInfo(list[i]); item->setTitle(list[i]->name); item->setFixedHeight(36); @@ -536,57 +524,3 @@ void ShortCutSettingWidget::onResetFinished() { m_bIsResting = false; } - -void ShortCutSettingWidget::onGrab(ShortcutInfo *info) -{ - if (m_waylandGrab) - m_waylandGrab->onGrab(info); -} - -void ShortCutSettingWidget::keyPressEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm()) { - return; - } - unsigned int keKey = static_cast(ke->key()); - m_waylandGrab->setKeyValue(WaylandkeyMap[keKey]); - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - - m_waylandGrab->setRecordState(true); - onKeyEvent(true, m_waylandGrab->getRecordState() ? lastKey + keyValue : keyValue); - if (keKey == Qt::Key_Control || keKey == Qt::Key_Alt - || keKey == Qt::Key_Shift || keKey == Qt::Key_Super_L || keKey == Qt::Key_Super_R) { - lastKey += ("<" + keyValue.remove(keyValue.indexOf("_"), 2) + ">"); - m_waylandGrab->setLastKey(lastKey); - } - QWidget::keyPressEvent(ke); -} - -void ShortCutSettingWidget::keyReleaseEvent(QKeyEvent *ke) -{ - if (!QGuiApplication::platformName().startsWith("wayland", Qt::CaseInsensitive) - || !m_waylandGrab || !m_waylandGrab->getZxgm() || !m_waylandGrab->getRecordState()) { - return; - } - QString lastKey = m_waylandGrab->getLastKey(); - QString keyValue = m_waylandGrab->getKeyValue(); - if (!lastKey.isEmpty()) { - if (WaylandkeyMap[Qt::Key_Control] == keyValue - || WaylandkeyMap[Qt::Key_Alt] == keyValue || WaylandkeyMap[Qt::Key_Shift] == keyValue) { - onKeyEvent(false, ""); - } else if (WaylandkeyMap[Qt::Key_Super_L] == keyValue || WaylandkeyMap[Qt::Key_Super_R] == keyValue) { - onKeyEvent(false, "Super_L"); - } else { - onKeyEvent(false, lastKey + keyValue); - } - } else { - onKeyEvent(false, ""); - } - m_waylandGrab->setLastKey(""); - m_waylandGrab->setRecordState(false); - Q_EMIT changed(m_waylandGrab->getInfo()->id, m_waylandGrab->getInfo()->type); - m_waylandGrab->onUnGrab(); - QWidget::keyReleaseEvent(ke); -} diff --git a/src/frame/window/modules/keyboard/shortcutsettingwidget.h b/src/frame/window/modules/keyboard/shortcutsettingwidget.h index d9941f5..d8ced0a 100644 --- a/src/frame/window/modules/keyboard/shortcutsettingwidget.h +++ b/src/frame/window/modules/keyboard/shortcutsettingwidget.h @@ -61,7 +61,6 @@ Q_SIGNALS: void requestReset(); void requestSearch(const QString &key); - void changed(const QString &in0, int in1); public Q_SLOTS: void onSearchTextChanged(const QString &text); @@ -75,11 +74,6 @@ public Q_SLOTS: void onKeyEvent(bool press, const QString &shortcut); void onResetFinished(); - void onGrab(dcc::keyboard::ShortcutInfo *info); - -protected: - void keyPressEvent(QKeyEvent *ke) override; - void keyReleaseEvent(QKeyEvent *ke) override; private: QWidget *m_searchWidget; @@ -115,7 +109,6 @@ private: QStringList m_assistiveToolsIdList; QStringList m_workspaceIdList; - WaylandGrab *m_waylandGrab; }; } } diff --git a/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h b/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h deleted file mode 100644 index 1da9fdc..0000000 --- a/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h +++ /dev/null @@ -1,248 +0,0 @@ -/* Generated by wayland-scanner 1.16.0 */ - -#ifndef XWAYLAND_KEYBOARD_GRAB_UNSTABLE_V1_CLIENT_PROTOCOL_H -#define XWAYLAND_KEYBOARD_GRAB_UNSTABLE_V1_CLIENT_PROTOCOL_H - -#include -#include -#include "wayland-client.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @page page_xwayland_keyboard_grab_unstable_v1 The xwayland_keyboard_grab_unstable_v1 protocol - * Protocol for grabbing the keyboard from Xwayland - * - * @section page_desc_xwayland_keyboard_grab_unstable_v1 Description - * - * This protocol is application-specific to meet the needs of the X11 - * protocol through Xwayland. It provides a way for Xwayland to request - * all keyboard events to be forwarded to a surface even when the - * surface does not have keyboard focus. - * - * In the X11 protocol, a client may request an "active grab" on the - * keyboard. On success, all key events are reported only to the - * grabbing X11 client. For details, see XGrabKeyboard(3). - * - * The core Wayland protocol does not have a notion of an active - * keyboard grab. When running in Xwayland, X11 applications may - * acquire an active grab inside Xwayland but that cannot be translated - * to the Wayland compositor who may set the input focus to some other - * surface. In doing so, it breaks the X11 client assumption that all - * key events are reported to the grabbing client. - * - * This protocol specifies a way for Xwayland to request all keyboard - * be directed to the given surface. The protocol does not guarantee - * that the compositor will honor this request and it does not - * prescribe user interfaces on how to handle the respond. For example, - * a compositor may inform the user that all key events are now - * forwarded to the given client surface, or it may ask the user for - * permission to do so. - * - * Compositors are required to restrict access to this application - * specific protocol to Xwayland alone. - * - * Warning! The protocol described in this file is experimental and - * backward incompatible changes may be made. Backward compatible - * changes may be added together with the corresponding interface - * version bump. - * Backward incompatible changes are done by bumping the version - * number in the protocol and interface names and resetting the - * interface version. Once the protocol is to be declared stable, - * the 'z' prefix and the version number in the protocol and - * interface names are removed and the interface version number is - * reset. - * - * @section page_ifaces_xwayland_keyboard_grab_unstable_v1 Interfaces - * - @subpage page_iface_zwp_xwayland_keyboard_grab_manager_v1 - context object for keyboard grab manager - * - @subpage page_iface_zwp_xwayland_keyboard_grab_v1 - interface for grabbing the keyboard - * @section page_copyright_xwayland_keyboard_grab_unstable_v1 Copyright - *
- *
- * Copyright © 2017 Red Hat Inc.
- *
- * 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 (including the next
- * paragraph) 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.
- * 
- */ -struct wl_seat; -struct wl_surface; -struct zwp_xwayland_keyboard_grab_manager_v1; -struct zwp_xwayland_keyboard_grab_v1; - -/** - * @page page_iface_zwp_xwayland_keyboard_grab_manager_v1 zwp_xwayland_keyboard_grab_manager_v1 - * @section page_iface_zwp_xwayland_keyboard_grab_manager_v1_desc Description - * - * A global interface used for grabbing the keyboard. - * @section page_iface_zwp_xwayland_keyboard_grab_manager_v1_api API - * See @ref iface_zwp_xwayland_keyboard_grab_manager_v1. - */ -/** - * @defgroup iface_zwp_xwayland_keyboard_grab_manager_v1 The zwp_xwayland_keyboard_grab_manager_v1 interface - * - * A global interface used for grabbing the keyboard. - */ -extern const struct wl_interface zwp_xwayland_keyboard_grab_manager_v1_interface; -/** - * @page page_iface_zwp_xwayland_keyboard_grab_v1 zwp_xwayland_keyboard_grab_v1 - * @section page_iface_zwp_xwayland_keyboard_grab_v1_desc Description - * - * A global interface used for grabbing the keyboard. - * @section page_iface_zwp_xwayland_keyboard_grab_v1_api API - * See @ref iface_zwp_xwayland_keyboard_grab_v1. - */ -/** - * @defgroup iface_zwp_xwayland_keyboard_grab_v1 The zwp_xwayland_keyboard_grab_v1 interface - * - * A global interface used for grabbing the keyboard. - */ -extern const struct wl_interface zwp_xwayland_keyboard_grab_v1_interface; - -#define ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_DESTROY 0 -#define ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_GRAB_KEYBOARD 1 - - -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 - */ -#define ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_DESTROY_SINCE_VERSION 1 -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 - */ -#define ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_GRAB_KEYBOARD_SINCE_VERSION 1 - -/** @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 */ -static inline void -zwp_xwayland_keyboard_grab_manager_v1_set_user_data(struct zwp_xwayland_keyboard_grab_manager_v1 *zwp_xwayland_keyboard_grab_manager_v1, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1, user_data); -} - -/** @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 */ -static inline void * -zwp_xwayland_keyboard_grab_manager_v1_get_user_data(struct zwp_xwayland_keyboard_grab_manager_v1 *zwp_xwayland_keyboard_grab_manager_v1) -{ - return wl_proxy_get_user_data((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1); -} - -static inline uint32_t -zwp_xwayland_keyboard_grab_manager_v1_get_version(struct zwp_xwayland_keyboard_grab_manager_v1 *zwp_xwayland_keyboard_grab_manager_v1) -{ - return wl_proxy_get_version((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1); -} - -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 - * - * Destroy the keyboard grab manager. - */ -static inline void -zwp_xwayland_keyboard_grab_manager_v1_destroy(struct zwp_xwayland_keyboard_grab_manager_v1 *zwp_xwayland_keyboard_grab_manager_v1) -{ - wl_proxy_marshal((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1, - ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_DESTROY); - - wl_proxy_destroy((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1); -} - -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_manager_v1 - * - * The grab_keyboard request asks for a grab of the keyboard, forcing - * the keyboard focus for the given seat upon the given surface. - * - * The protocol provides no guarantee that the grab is ever satisfied, - * and does not require the compositor to send an error if the grab - * cannot ever be satisfied. It is thus possible to request a keyboard - * grab that will never be effective. - * - * The protocol: - * - * * does not guarantee that the grab itself is applied for a surface, - * the grab request may be silently ignored by the compositor, - * * does not guarantee that any events are sent to this client even - * if the grab is applied to a surface, - * * does not guarantee that events sent to this client are exhaustive, - * a compositor may filter some events for its own consumption, - * * does not guarantee that events sent to this client are continuous, - * a compositor may change and reroute keyboard events while the grab - * is nominally active. - */ -static inline struct zwp_xwayland_keyboard_grab_v1 * -zwp_xwayland_keyboard_grab_manager_v1_grab_keyboard(struct zwp_xwayland_keyboard_grab_manager_v1 *zwp_xwayland_keyboard_grab_manager_v1, struct wl_surface *surface, struct wl_seat *seat) -{ - struct wl_proxy *id; - - id = wl_proxy_marshal_constructor((struct wl_proxy *) zwp_xwayland_keyboard_grab_manager_v1, - ZWP_XWAYLAND_KEYBOARD_GRAB_MANAGER_V1_GRAB_KEYBOARD, &zwp_xwayland_keyboard_grab_v1_interface, NULL, surface, seat); - - return (struct zwp_xwayland_keyboard_grab_v1 *) id; -} - -#define ZWP_XWAYLAND_KEYBOARD_GRAB_V1_DESTROY 0 - - -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_v1 - */ -#define ZWP_XWAYLAND_KEYBOARD_GRAB_V1_DESTROY_SINCE_VERSION 1 - -/** @ingroup iface_zwp_xwayland_keyboard_grab_v1 */ -static inline void -zwp_xwayland_keyboard_grab_v1_set_user_data(struct zwp_xwayland_keyboard_grab_v1 *zwp_xwayland_keyboard_grab_v1, void *user_data) -{ - wl_proxy_set_user_data((struct wl_proxy *) zwp_xwayland_keyboard_grab_v1, user_data); -} - -/** @ingroup iface_zwp_xwayland_keyboard_grab_v1 */ -static inline void * -zwp_xwayland_keyboard_grab_v1_get_user_data(struct zwp_xwayland_keyboard_grab_v1 *zwp_xwayland_keyboard_grab_v1) -{ - return wl_proxy_get_user_data((struct wl_proxy *) zwp_xwayland_keyboard_grab_v1); -} - -static inline uint32_t -zwp_xwayland_keyboard_grab_v1_get_version(struct zwp_xwayland_keyboard_grab_v1 *zwp_xwayland_keyboard_grab_v1) -{ - return wl_proxy_get_version((struct wl_proxy *) zwp_xwayland_keyboard_grab_v1); -} - -/** - * @ingroup iface_zwp_xwayland_keyboard_grab_v1 - * - * Destroy the grabbed keyboard object. If applicable, the compositor - * will ungrab the keyboard. - */ -static inline void -zwp_xwayland_keyboard_grab_v1_destroy(struct zwp_xwayland_keyboard_grab_v1 *zwp_xwayland_keyboard_grab_v1) -{ - wl_proxy_marshal((struct wl_proxy *) zwp_xwayland_keyboard_grab_v1, - ZWP_XWAYLAND_KEYBOARD_GRAB_V1_DESTROY); - - wl_proxy_destroy((struct wl_proxy *) zwp_xwayland_keyboard_grab_v1); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c b/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c deleted file mode 100644 index 1947d41..0000000 --- a/src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Generated by wayland-scanner 1.16.0 */ - -/* - * Copyright © 2017 Red Hat Inc. - * - * 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 (including the next - * paragraph) 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. - */ - -#include -#include -#include "wayland-util.h" - -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface zwp_xwayland_keyboard_grab_v1_interface; - -static const struct wl_interface *types[] = { - &zwp_xwayland_keyboard_grab_v1_interface, - &wl_surface_interface, - &wl_seat_interface, -}; - -static const struct wl_message zwp_xwayland_keyboard_grab_manager_v1_requests[] = { - { "destroy", "", types + 0 }, - { "grab_keyboard", "noo", types + 0 }, -}; - -WL_EXPORT const struct wl_interface zwp_xwayland_keyboard_grab_manager_v1_interface = { - "zwp_xwayland_keyboard_grab_manager_v1", 1, - 2, zwp_xwayland_keyboard_grab_manager_v1_requests, - 0, NULL, -}; - -static const struct wl_message zwp_xwayland_keyboard_grab_v1_requests[] = { - { "destroy", "", types + 0 }, -}; - -WL_EXPORT const struct wl_interface zwp_xwayland_keyboard_grab_v1_interface = { - "zwp_xwayland_keyboard_grab_v1", 1, - 1, zwp_xwayland_keyboard_grab_v1_requests, - 0, NULL, -}; - diff --git a/src/frame/window/modules/keyboard/waylandgrab.cpp b/src/frame/window/modules/keyboard/waylandgrab.cpp deleted file mode 100644 index 5b2f6fb..0000000 --- a/src/frame/window/modules/keyboard/waylandgrab.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: LGPL-3.0-or-later - -#include "waylandgrab.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace dcc::keyboard; - -static struct zwp_xwayland_keyboard_grab_manager_v1* xkgm = nullptr; - -void MyRegistryListener(void *data, - struct wl_registry *registry, - uint32_t id, - const QString &interface, - uint32_t version) -{ - Q_UNUSED(data); - Q_UNUSED(version); - if(interface == QLatin1String("zwp_xwayland_keyboard_grab_manager_v1")){ - xkgm = static_cast(wl_registry_bind( - registry,id,&zwp_xwayland_keyboard_grab_manager_v1_interface,version)); - } -} - -WaylandGrab::WaylandGrab(QObject *parent) - : QObject(parent) - , m_zxgm(nullptr) - , m_info(nullptr) - , m_record(false) - , m_lastKey("") - , m_keyValue("") -{ - dynamic_cast(parent)->createWinId(); - QtWaylandClient::QWaylandWindow* waylandwindow = static_cast(dynamic_cast(parent)->windowHandle()->handle()); - QtWaylandClient::QWaylandIntegration * waylandIntergration = static_cast( - QGuiApplicationPrivate::platformIntegration()); - m_wlSurface = waylandwindow->wlSurface(); - m_wlSeat = waylandIntergration->display()->currentInputDevice()->wl_seat(); - waylandIntergration->display()->addRegistryListener(MyRegistryListener, nullptr); -} - -WaylandGrab::~WaylandGrab() -{ - if (m_zxgm) { - zwp_xwayland_keyboard_grab_v1_destroy(m_zxgm); - m_zxgm = nullptr; - } - if (xkgm) { - zwp_xwayland_keyboard_grab_manager_v1_destroy(xkgm); - xkgm = nullptr; - } -} - -void WaylandGrab::onGrab(ShortcutInfo *info) -{ - m_info = info; - m_zxgm = zwp_xwayland_keyboard_grab_manager_v1_grab_keyboard(xkgm, m_wlSurface, m_wlSeat); -} - -void WaylandGrab::onUnGrab() -{ - if (m_zxgm) { - zwp_xwayland_keyboard_grab_v1_destroy(m_zxgm); - m_zxgm = nullptr; - } - -} \ No newline at end of file diff --git a/src/frame/window/modules/keyboard/waylandgrab.h b/src/frame/window/modules/keyboard/waylandgrab.h deleted file mode 100644 index 30876fb..0000000 --- a/src/frame/window/modules/keyboard/waylandgrab.h +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: LGPL-3.0-or-later - -#ifndef WAYLANDGRAB_H -#define WAYLANDGRAB_H - -#include "wayland-xwayland-keyboard-grab-v1-client-protocol.h" -#include "modules/keyboard/shortcutmodel.h" - -class WaylandGrab : public QObject -{ - Q_OBJECT -public: - explicit WaylandGrab(QObject *parent = nullptr); - ~WaylandGrab(); - -private: - QString m_lastKey, m_keyValue; - bool m_record; - dcc::keyboard::ShortcutInfo *m_info; - - struct ::wl_seat* m_wlSeat; - struct ::wl_surface* m_wlSurface; - struct zwp_xwayland_keyboard_grab_v1 *m_zxgm; - -public: - QString getLastKey() { return m_lastKey; } - QString getKeyValue() { return m_keyValue; } - bool getRecordState() { return m_record; } - void setLastKey(QString key) { m_lastKey = key; } - void setKeyValue(QString key) { m_keyValue = key; } - void setRecordState(bool state) { m_record = state; } - dcc::keyboard::ShortcutInfo *getInfo() { return m_info; } - struct zwp_xwayland_keyboard_grab_v1 *getZxgm() { return m_zxgm; } - -public Q_SLOTS: - void onGrab(dcc::keyboard::ShortcutInfo *info); - void onUnGrab(); -}; - - - - -#endif // WAYLANDGRAB_Hs \ No newline at end of file diff --git a/src/frame/window/utils.h b/src/frame/window/utils.h index 5cc5309..4c49439 100644 --- a/src/frame/window/utils.h +++ b/src/frame/window/utils.h @@ -62,18 +62,6 @@ const bool DisableDeveloperMode = { false #endif }; -const QMap WaylandkeyMap = { {Qt::Key_A, "A"}, {Qt::Key_B, "B"}, {Qt::Key_C, "C"}, {Qt::Key_D, "D"}, {Qt::Key_E, "E"}, - {Qt::Key_F, "F"}, {Qt::Key_G, "G"}, {Qt::Key_H, "H"}, {Qt::Key_I, "I"}, {Qt::Key_J, "J"}, {Qt::Key_K, "K"}, {Qt::Key_L, "L"}, {Qt::Key_M, "M"}, - {Qt::Key_N, "N"}, {Qt::Key_O, "O"}, {Qt::Key_P, "P"}, {Qt::Key_Q, "Q"}, {Qt::Key_R, "R"}, {Qt::Key_S, "S"}, {Qt::Key_T, "T"}, {Qt::Key_U, "U"}, - {Qt::Key_V, "V"}, {Qt::Key_W, "W"}, {Qt::Key_X, "X"}, {Qt::Key_Y, "Y"}, {Qt::Key_Z, "Z"}, {Qt::Key_Escape, "Escape"}, {Qt::Key_Tab, "Tab"}, - {Qt::Key_Backtab, "Tab"}, {Qt::Key_Backspace, "Backspace"}, {Qt::Key_Return, "Return"}, {Qt::Key_Enter, "Enter"}, {Qt::Key_Insert, "Insert"}, - {Qt::Key_Delete, "Delete"}, {Qt::Key_Pause, "Pause"}, {Qt::Key_Print, "Print"}, {Qt::Key_SysReq, "SysReq"}, {Qt::Key_Clear, "Clear"}, {Qt::Key_Home, "Home"}, - {Qt::Key_End, "End"}, {Qt::Key_Left, "←"}, {Qt::Key_Up, "↑"}, {Qt::Key_Right, "→"}, {Qt::Key_Down, "↓"}, {Qt::Key_PageUp, "PageUp"}, - {Qt::Key_PageDown, "PageDown"}, {Qt::Key_Shift, "Shift_L"}, {Qt::Key_Control, "Control_L"}, {Qt::Key_Super_L, "Super_L"}, {Qt::Key_Super_R, "Super_R"}, {Qt::Key_Alt, "Alt_L"}, - {Qt::Key_CapsLock, "CapLock"}, {Qt::Key_NumLock, "NumLock"}, {Qt::Key_ScrollLock, "ScrollLock"}, {Qt::Key_F1, "F1"}, {Qt::Key_F2, "F2"}, {Qt::Key_F3, "F3"}, - {Qt::Key_F4, "F4"}, {Qt::Key_F5, "F5"}, {Qt::Key_F6, "F6"}, {Qt::Key_F7, "F7"}, {Qt::Key_F8, "F8"}, {Qt::Key_F9, "F9"}, - {Qt::Key_F10, "F10"}, {Qt::Key_F11, "F11"}, {Qt::Key_F12, "F12"}, {Qt::Key_Space, "Space"}, {Qt::Key_AsciiTilde, "~"} -}; struct ListSubItem { ListSubItem(); diff --git a/tests/dde-control-center/CMakeLists.txt b/tests/dde-control-center/CMakeLists.txt index 6ad2b77..3e8c998 100644 --- a/tests/dde-control-center/CMakeLists.txt +++ b/tests/dde-control-center/CMakeLists.txt @@ -143,9 +143,6 @@ file(GLOB_RECURSE KEYBOARD_Tasks_SRCS ../../src/frame/window/modules/keyboard/systemlanguagewidget.cpp ../../src/frame/window/modules/keyboard/systemlanguagesettingwidget.cpp ../../src/frame/window/modules/keyboard/shortcutsettingwidget.cpp - ../../src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-client-protocol.h - ../../src/frame/window/modules/keyboard/wayland-xwayland-keyboard-grab-v1-protocol.c - ../../src/frame/window/modules/keyboard/waylandgrab.cpp ../../src/frame/modules/keyboard/keyboardmodel.cpp ../../src/frame/modules/keyboard/indexmodel.cpp ../../src/frame/modules/keyboard/shortcutmodel.cpp @@ -163,10 +160,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -lgcov") # 查找依赖库 find_package(PkgConfig REQUIRED) -find_package(Qt5 COMPONENTS Widgets Test DBus WaylandClient REQUIRED Concurrent Svg) +find_package(Qt5 COMPONENTS Widgets Test DBus REQUIRED Concurrent Svg) find_package(DtkWidget REQUIRED) find_package(GTest REQUIRED) -find_package(KF5Wayland QUIET) pkg_check_modules(QGSettings REQUIRED gsettings-qt) pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus) @@ -318,8 +314,6 @@ target_link_libraries(${SYSTEMINFO_NAME} PRIVATE -lpthread ) -find_package(PkgConfig REQUIRED) -pkg_check_modules(WaylandClient REQUIRED wayland-client) # 键盘模块链接库 target_link_libraries(${KEYBOARD_NAME} PRIVATE @@ -334,9 +328,6 @@ target_link_libraries(${KEYBOARD_NAME} PRIVATE ${DtkWidget_LIBRARIES} ${GTEST_LIBRARIES} -lpthread - KF5::WaylandClient - Qt5::WaylandClient - ${WaylandClient_LIBRARIES} ) # 系统信息模块引用头文件 @@ -355,7 +346,6 @@ target_include_directories(${KEYBOARD_NAME} PUBLIC ${QGSettings_INCLUDE_DIRS} ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${DFrameworkDBus_INCLUDE_DIRS} - ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} ) add_custom_target(check -- 2.20.1