From 64f8a5a2be73e94d58c3c85ccf88d3d66c296109 Mon Sep 17 00:00:00 2001 From: Filippo Gentile Date: Mon, 25 Mar 2024 16:44:58 +0100 Subject: [PATCH] WIP Qt6 port (#2024) * CMake: FindXCB components are upper case Fixes CMake error * CMake: update dependencies for Qt6 * CMake: link to dbusmenu-lxqt instead of dbusmenu-qt6 StatusNotifierButton: switch to dbusmenu-lxqt * Replace qAsConst() with std::as_const * Replace QPair with std::pair * Replace QLatin1Literal with QLatin1String * QEvent: port pos() to position() and globalPos() to globalPosition() - Now returns floating point QPointF, should we keep it instead of rounding and do floating point calculations? * Fix QWidget::enterEvent(QEnterEvent*) signature * QLayou::setContentsMargin() instead of setMargin() - QEyesPlugin: remove deprecated setMargin() call * QuickLaunchButton: fix ambiguous list initializer * Port QRegExp with QRegularExpression * QLocale territory() instead of country() * Qt6 always enables High-DPI Pixmaps Qt::AA_UseHighDpiPixmaps has no effect now * Plugin: move Q_DECLARE_METATYPE() Fix error: static assertion failed: Pointer Meta Types must either point to fully-defined types or be declared with Q_DECLARE_OPAQUE_POINTER(T *) Q_DECLARE_METATYPE(...) must be used on fully qualified types To avoid including plugin.h inside panelpluginsmodel.h, the declaretion is moved. * Use QColor::fromString() setNamedColor() is deprecated in Qt6 * LXQtTaskButton: fix deprecated constructor * Disable ColorPicker on Wayland * Fix KX11Extras, KWindowSystem includes TODO: Still don't know why prefix does not work - Remove includes to QDesktopWidget * Port QX11Info to QX11Application NOTE: Fix compilation with Xlib.h Xlib.h is tricky because at line 82 has: `#define Bool int` And QtCore/qjsonvalue.h at line 28 has: ``` enum Type { ... Bool = 0x1, ... } ``` This is fixed temporarily by moving Xlib.h include to last and undefine Bool macro Long term we want to hide X11 related code and encapsulate in a backend. This backend will not expose X11 headers. * LXQtTaskButton: port to KX11Extras Many X11 specific functions got moved away from KWindowSystem header. Long term we will move everything to a backend. * LXQtTaskButton: port away from QDesktopWidget Use QScreen instead * QString::arg(...) use mult-arg version Reported by Clazy * LXQtCpuLoad: do not include directly Reported by Clazy * Configuration: fix call to temporary object Teporary objects get destroyed after call ends. State is not updated. * QEyesConfigDialog: avoid allocating temporary container - Reported by Clazy - Also fix formatting a bit * QEyesImageWidget: unneeded QString allocation - Use Qt::CaseInsensitive instead - Pass argument by reference - Format braces * LXQtQuickLaunch: fix QSet warning and better readability * Port LXQtTrayPlugin to Qt6 NOTE: QX11Info::getTimestamp() was replaced with XCB_CURRENT_TIME macro. I don't know if this breaks functionality. Getting real timestamp involves messing with Qt private APIs * LXQtTaskBar: fix include recursion - Forward declare classes - More refactory could be done here * Port LXQtKbIndicatorPlugin to Qt6 * Replace QScopedPointer with std::unique_ptr - Use Xcb::ScopedCPointer for POD types * Replace QVector with QList In Qt6 it's an alias * SNIProxy: use QBitmap::fromImage TODO TODO: is behavior equivalent? Conversion flags... * README: update mentioned dependencies --- CMakeLists.txt | 21 ++- README.md | 2 +- cmake/BuildPlugin.cmake | 8 +- panel/CMakeLists.txt | 4 +- panel/config/configplacement.cpp | 2 +- panel/config/configpluginswidget.cpp | 14 +- panel/config/configpluginswidget.h | 2 +- panel/config/configstyling.cpp | 10 +- panel/lxqtpanel.cpp | 22 +-- panel/lxqtpanel.h | 4 +- panel/lxqtpanelapplication.cpp | 10 +- panel/lxqtpanellayout.cpp | 8 +- panel/main.cpp | 1 - panel/panelpluginsmodel.cpp | 2 +- panel/panelpluginsmodel.h | 6 +- panel/plugin.cpp | 4 +- panel/plugin.h | 1 + panel/pluginmoveprocessor.cpp | 6 +- panel/pluginsettings.h | 2 +- plugin-backlight/sliderdialog.cpp | 2 +- plugin-colorpicker/colorpicker.cpp | 25 +++- plugin-cpuload/lxqtcpuload.cpp | 1 - plugin-customcommand/CMakeLists.txt | 2 +- plugin-desktopswitch/desktopswitch.cpp | 25 +++- plugin-desktopswitch/desktopswitch.h | 6 +- .../desktopswitchconfiguration.cpp | 2 +- plugin-directorymenu/CMakeLists.txt | 2 +- plugin-fancymenu/lxqtfancymenuappmap.cpp | 10 +- plugin-fancymenu/lxqtfancymenuappmap.h | 8 +- plugin-fancymenu/lxqtfancymenuappmodel.cpp | 4 +- plugin-fancymenu/lxqtfancymenuappmodel.h | 4 +- plugin-kbindicator/CMakeLists.txt | 6 +- plugin-kbindicator/kbindicator-plugin.cpp | 12 +- plugin-kbindicator/src/kbdkeeper.cpp | 8 +- plugin-kbindicator/src/kbdwatcher.cpp | 2 +- plugin-kbindicator/src/kbdwatcher.h | 2 +- plugin-kbindicator/src/x11/kbdlayout.cpp | 2 +- plugin-kbindicator/src/x11/kbdlayout.h | 2 +- plugin-mainmenu/actionview.cpp | 8 +- plugin-mainmenu/lxqtmainmenu.cpp | 1 + plugin-mount/CMakeLists.txt | 4 +- plugin-mount/configuration.cpp | 22 ++- plugin-mount/menudiskitem.cpp | 6 +- plugin-mount/popup.cpp | 3 +- plugin-qeyes/qeyes.cpp | 1 - plugin-qeyes/qeyesconfigdialog.cpp | 25 +++- plugin-qeyes/qeyesimagewidget.cpp | 11 +- plugin-qeyes/qeyesimagewidget.h | 2 +- plugin-qeyes/qeyeswidget.cpp | 2 +- plugin-qeyes/qeyeswidget.h | 2 +- plugin-quicklaunch/CMakeLists.txt | 2 +- plugin-quicklaunch/lxqtquicklaunch.cpp | 4 +- plugin-quicklaunch/quicklaunchbutton.cpp | 6 +- plugin-showdesktop/CMakeLists.txt | 2 +- plugin-showdesktop/showdesktop.cpp | 5 +- plugin-statusnotifier/CMakeLists.txt | 10 +- .../statusnotifierbutton.cpp | 2 +- .../statusnotifierwidget.cpp | 4 +- plugin-statusnotifier/statusnotifierwidget.h | 2 +- plugin-sysstat/CMakeLists.txt | 4 +- plugin-sysstat/lxqtsysstatutils.cpp | 13 +- plugin-sysstat/lxqtsysstatutils.h | 2 +- plugin-taskbar/CMakeLists.txt | 2 +- plugin-taskbar/lxqtgrouppopup.cpp | 20 ++- plugin-taskbar/lxqtgrouppopup.h | 11 +- plugin-taskbar/lxqttaskbar.cpp | 18 ++- plugin-taskbar/lxqttaskbar.h | 13 +- plugin-taskbar/lxqttaskbarconfiguration.cpp | 2 +- plugin-taskbar/lxqttaskbarplugin.cpp | 2 + plugin-taskbar/lxqttaskbutton.cpp | 135 +++++++++++++----- plugin-taskbar/lxqttaskgroup.cpp | 51 ++++--- plugin-taskbar/lxqttaskgroup.h | 7 +- plugin-tray/CMakeLists.txt | 18 +-- plugin-tray/fdoselectionmanager.cpp | 54 ++++--- plugin-tray/fdoselectionmanager.h | 3 +- plugin-tray/lxqttrayplugin.cpp | 15 ++ plugin-tray/lxqttrayplugin.h | 15 +- plugin-tray/snidbus.h | 4 +- plugin-tray/sniproxy.cpp | 131 +++++++++-------- plugin-tray/sniproxy.h | 1 + plugin-tray/xcbutils.h | 29 ++-- plugin-volume/CMakeLists.txt | 2 +- plugin-volume/alsaengine.cpp | 2 +- plugin-volume/lxqtvolumeconfiguration.cpp | 2 +- plugin-volume/pulseaudioengine.cpp | 6 +- plugin-volume/volumebutton.cpp | 6 +- plugin-volume/volumebutton.h | 2 +- plugin-volume/volumepopup.cpp | 5 +- plugin-volume/volumepopup.h | 2 +- plugin-worldclock/lxqtworldclock.cpp | 12 +- .../lxqtworldclockconfiguration.cpp | 2 +- .../lxqtworldclockconfigurationtimezones.cpp | 2 +- 92 files changed, 585 insertions(+), 386 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c57b0cec3..25350186d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,17 +29,16 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -set(REQUIRED_QT_VERSION "5.15.0") -set(KF5_MINIMUM_VERSION "5.101.0") -set(LXQT_GLOBALKEYS_MINIMUM_VERSION "1.4.0") -set(LXQT_MINIMUM_VERSION "1.4.0") - -find_package(Qt5DBus ${REQUIRED_QT_VERSION} REQUIRED) -find_package(Qt5LinguistTools ${REQUIRED_QT_VERSION} REQUIRED) -find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED) -find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED) -find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED) -find_package(KF5WindowSystem ${KF5_MINIMUM_VERSION} REQUIRED) +set(REQUIRED_QT_VERSION "6.6.0") +set(KF6_MINIMUM_VERSION "6.0.0") +set(LXQT_GLOBALKEYS_MINIMUM_VERSION "2.0.0") +set(LXQT_MINIMUM_VERSION "2.0.0") + +find_package(Qt6DBus ${REQUIRED_QT_VERSION} REQUIRED) +find_package(Qt6LinguistTools ${REQUIRED_QT_VERSION} REQUIRED) +find_package(Qt6Widgets ${REQUIRED_QT_VERSION} REQUIRED) +find_package(Qt6Xml ${REQUIRED_QT_VERSION} REQUIRED) +find_package(KF6WindowSystem ${KF6_MINIMUM_VERSION} REQUIRED) find_package(lxqt ${LXQT_MINIMUM_VERSION} REQUIRED) find_package(lxqt-globalkeys-ui ${LXQT_GLOBALKEYS_MINIMUM_VERSION} REQUIRED) find_package(lxqt-menu-data ${LXQT_MINIMUM_VERSION} REQUIRED) diff --git a/README.md b/README.md index 237192ac3..69b514706 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ As indicated by the name, a volume control. Technically Alsa, OSS and PulseAudio ### Compiling source code -The runtime dependencies are libxcomposite, libdbusmenu-qt5, KGuiAddons, KWindowSystem, Solid, menu-cache, [lxqt-menu-data](https://github.com/lxqt/lxqt-menu-data), [liblxqt](https://github.com/lxqt/liblxqt) and [lxqt-globalkeys](https://github.com/lxqt/lxqt-globalkeys). +The runtime dependencies are libxcomposite, libdbusmenu-lxqt, KGuiAddons, KWindowSystem, Solid, menu-cache, [lxqt-menu-data](https://github.com/lxqt/lxqt-menu-data), [liblxqt](https://github.com/lxqt/liblxqt) and [lxqt-globalkeys](https://github.com/lxqt/lxqt-globalkeys). Several plugins or features thereof are optional and need additional runtime dependencies. Namely these are (plugin / feature in parenthesis) Alsa library (Alsa support in plugin-volume), PulseAudio client library (PulseAudio support in plugin-volume), lm-sensors (plugin-sensors), libstatgrab (plugin-cpuload, plugin-networkmonitor), [libsysstat](https://github.com/lxqt/libsysstat) (plugin-sysstat). All of them are enabled by default and have to be disabled by CMake variables as required, see below. In addition CMake and [lxqt-build-tools](https://github.com/lxqt/lxqt-build-tools) are mandatory build dependencies. Git is optionally needed to pull latest VCS checkouts. diff --git a/cmake/BuildPlugin.cmake b/cmake/BuildPlugin.cmake index 0dd0d23f0..6c8ca2f66 100644 --- a/cmake/BuildPlugin.cmake +++ b/cmake/BuildPlugin.cmake @@ -36,12 +36,12 @@ MACRO (BUILD_LXQT_PLUGIN NAME) set (PLUGIN_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROGRAM}) endif (NOT DEFINED PLUGIN_DIR) - set(QTX_LIBRARIES Qt5::Widgets) + set(QTX_LIBRARIES Qt6::Widgets) if(QT_USE_QTXML) - set(QTX_LIBRARIES ${QTX_LIBRARIES} Qt5::Xml) + set(QTX_LIBRARIES ${QTX_LIBRARIES} Qt6::Xml) endif() if(QT_USE_QTDBUS) - set(QTX_LIBRARIES ${QTX_LIBRARIES} Qt5::DBus) + set(QTX_LIBRARIES ${QTX_LIBRARIES} Qt6::DBus) endif() list(FIND STATIC_PLUGINS ${NAME} IS_STATIC) @@ -52,7 +52,7 @@ MACRO (BUILD_LXQT_PLUGIN NAME) else() # static add_library(${NAME} STATIC ${SRC}) # build statically linked lib endif() - target_link_libraries(${NAME} ${QTX_LIBRARIES} lxqt ${LIBRARIES} KF5::WindowSystem) + target_link_libraries(${NAME} ${QTX_LIBRARIES} lxqt ${LIBRARIES} KF6::WindowSystem) install(FILES ${CONFIG_FILES} DESTINATION ${PLUGIN_SHARE_DIR}) install(FILES ${DESKTOP_FILES} DESTINATION ${PROG_SHARE_DIR}) diff --git a/panel/CMakeLists.txt b/panel/CMakeLists.txt index 3ea78acf0..916fced2c 100644 --- a/panel/CMakeLists.txt +++ b/panel/CMakeLists.txt @@ -74,7 +74,7 @@ endif () project(${PROJECT}) -set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus) +set(QTX_LIBRARIES Qt6::Widgets Qt6::Xml Qt6::DBus) # Translations lxqt_translate_ts(QM_FILES SOURCES @@ -102,7 +102,7 @@ add_executable(${PROJECT} target_link_libraries(${PROJECT} ${LIBRARIES} ${QTX_LIBRARIES} - KF5::WindowSystem + KF6::WindowSystem ${STATIC_PLUGINS} ) diff --git a/panel/config/configplacement.cpp b/panel/config/configplacement.cpp index d14d545c7..6ae05fe00 100644 --- a/panel/config/configplacement.cpp +++ b/panel/config/configplacement.cpp @@ -30,7 +30,7 @@ #include "../lxqtpanellimits.h" -#include +#include #include #include #include diff --git a/panel/config/configpluginswidget.cpp b/panel/config/configpluginswidget.cpp index e65c29878..9dd23d4d6 100644 --- a/panel/config/configpluginswidget.cpp +++ b/panel/config/configpluginswidget.cpp @@ -43,13 +43,13 @@ ConfigPluginsWidget::ConfigPluginsWidget(LXQtPanel *panel, QWidget* parent) : { ui->setupUi(this); - PanelPluginsModel * plugins = mPanel->mPlugins.data(); + PanelPluginsModel * plugins = mPanel->mPlugins.get(); { - QScopedPointer m(ui->listView_plugins->selectionModel()); + std::unique_ptr m(ui->listView_plugins->selectionModel()); ui->listView_plugins->setModel(plugins); } { - QScopedPointer d(ui->listView_plugins->itemDelegate()); + std::unique_ptr d(ui->listView_plugins->itemDelegate()); ui->listView_plugins->setItemDelegate(new LXQt::HtmlDelegate(QSize(16, 16), ui->listView_plugins)); } @@ -83,11 +83,11 @@ void ConfigPluginsWidget::reset() void ConfigPluginsWidget::showAddPluginDialog() { - if (mAddPluginDialog.isNull()) + if (!mAddPluginDialog) { mAddPluginDialog.reset(new AddPluginDialog); - connect(mAddPluginDialog.data(), &AddPluginDialog::pluginSelected, - mPanel->mPlugins.data(), &PanelPluginsModel::addPlugin); + connect(mAddPluginDialog.get(), &AddPluginDialog::pluginSelected, + mPanel->mPlugins.get(), &PanelPluginsModel::addPlugin); } mAddPluginDialog->show(); mAddPluginDialog->raise(); @@ -96,7 +96,7 @@ void ConfigPluginsWidget::showAddPluginDialog() void ConfigPluginsWidget::resetButtons() { - PanelPluginsModel *model = mPanel->mPlugins.data(); + PanelPluginsModel *model = mPanel->mPlugins.get(); QItemSelectionModel *selectionModel = ui->listView_plugins->selectionModel(); bool hasSelection = selectionModel->hasSelection(); bool isFirstSelected = selectionModel->isSelected(model->index(0)); diff --git a/panel/config/configpluginswidget.h b/panel/config/configpluginswidget.h index 2d3bfbda0..8afc6c45a 100644 --- a/panel/config/configpluginswidget.h +++ b/panel/config/configpluginswidget.h @@ -57,7 +57,7 @@ private slots: private: Ui::ConfigPluginsWidget *ui; - QScopedPointer mAddPluginDialog; + std::unique_ptr mAddPluginDialog; LXQtPanel *mPanel; }; diff --git a/panel/config/configstyling.cpp b/panel/config/configstyling.cpp index b30d3c80f..7035a636d 100644 --- a/panel/config/configstyling.cpp +++ b/panel/config/configstyling.cpp @@ -30,7 +30,7 @@ #include "../lxqtpanellimits.h" -#include +#include #include #include #include @@ -77,9 +77,9 @@ ConfigStyling::ConfigStyling(LXQtPanel *panel, QWidget *parent) : ************************************************/ void ConfigStyling::reset() { - mFontColor.setNamedColor(mOldFontColor.name()); + mFontColor = QColor::fromString(mOldFontColor.name()); ui->pushButton_customFontColor->setStyleSheet(QStringLiteral("background: %1").arg(mOldFontColor.name())); - mBackgroundColor.setNamedColor(mOldBackgroundColor.name()); + mBackgroundColor = QColor::fromString(mOldBackgroundColor.name()); ui->pushButton_customBgColor->setStyleSheet(QStringLiteral("background: %1").arg(mOldBackgroundColor.name())); ui->lineEdit_customBgImage->setText(mOldBackgroundImage); ui->slider_opacity->setValue(mOldOpacity); @@ -190,7 +190,7 @@ void ConfigStyling::pickFontColor() d.setWindowModality(Qt::WindowModal); if (d.exec() && d.currentColor().isValid()) { - mFontColor.setNamedColor(d.currentColor().name()); + mFontColor = QColor::fromString(d.currentColor().name()); ui->pushButton_customFontColor->setStyleSheet(QStringLiteral("background: %1").arg(mFontColor.name())); editChanged(); } @@ -206,7 +206,7 @@ void ConfigStyling::pickBackgroundColor() d.setWindowModality(Qt::WindowModal); if (d.exec() && d.currentColor().isValid()) { - mBackgroundColor.setNamedColor(d.currentColor().name()); + mBackgroundColor = QColor::fromString(d.currentColor().name()); ui->pushButton_customBgColor->setStyleSheet(QStringLiteral("background: %1").arg(mBackgroundColor.name())); editChanged(); } diff --git a/panel/lxqtpanel.cpp b/panel/lxqtpanel.cpp index 05d903089..86ba83141 100644 --- a/panel/lxqtpanel.cpp +++ b/panel/lxqtpanel.cpp @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -49,9 +48,10 @@ #include #include -#include -#include -#include +#include +#include +#include +#include // Turn on this to show the time required to load each plugin during startup // #define DEBUG_PLUGIN_LOADTIME @@ -221,8 +221,8 @@ LXQtPanel::LXQtPanel(const QString &configGroup, LXQt::Settings *settings, QWidg connect(LXQt::Settings::globalSettings(), &LXQt::GlobalSettings::settingsChanged, this, [this] { update(); } ); connect(lxqtApp, &LXQt::Application::themeChanged, this, &LXQtPanel::realign); - connect(mStandaloneWindows.data(), &WindowNotifier::firstShown, this, [this] { showPanel(true); }); - connect(mStandaloneWindows.data(), &WindowNotifier::lastHidden, this, &LXQtPanel::hidePanel); + connect(mStandaloneWindows.get(), &WindowNotifier::firstShown, this, [this] { showPanel(true); }); + connect(mStandaloneWindows.get(), &WindowNotifier::lastHidden, this, &LXQtPanel::hidePanel); readSettings(); @@ -446,11 +446,11 @@ void LXQtPanel::loadPlugins() names_key += QLatin1String(CFG_KEY_PLUGINS); mPlugins.reset(new PanelPluginsModel(this, names_key, pluginDesktopDirs())); - connect(mPlugins.data(), &PanelPluginsModel::pluginAdded, mLayout, &LXQtPanelLayout::addPlugin); - connect(mPlugins.data(), &PanelPluginsModel::pluginMovedUp, mLayout, &LXQtPanelLayout::moveUpPlugin); + connect(mPlugins.get(), &PanelPluginsModel::pluginAdded, mLayout, &LXQtPanelLayout::addPlugin); + connect(mPlugins.get(), &PanelPluginsModel::pluginMovedUp, mLayout, &LXQtPanelLayout::moveUpPlugin); //reemit signals - connect(mPlugins.data(), &PanelPluginsModel::pluginAdded, this, &LXQtPanel::pluginAdded); - connect(mPlugins.data(), &PanelPluginsModel::pluginRemoved, this, &LXQtPanel::pluginRemoved); + connect(mPlugins.get(), &PanelPluginsModel::pluginAdded, this, &LXQtPanel::pluginAdded); + connect(mPlugins.get(), &PanelPluginsModel::pluginRemoved, this, &LXQtPanel::pluginRemoved); const auto plugins = mPlugins->plugins(); for (auto const & plugin : plugins) @@ -1127,7 +1127,7 @@ bool LXQtPanel::event(QEvent *event) // Qt::WA_X11NetWmWindowTypeDock becomes ineffective in Qt 5 // See QTBUG-39887: https://bugreports.qt-project.org/browse/QTBUG-39887 // Let's use KWindowSystem for that - KWindowSystem::setType(effectiveWinId(), NET::Dock); + KX11Extras::setType(effectiveWinId(), NET::Dock); updateWmStrut(); // reserve screen space for the panel KX11Extras::setOnAllDesktops(effectiveWinId(), true); diff --git a/panel/lxqtpanel.h b/panel/lxqtpanel.h index f3be5cd96..7d847dfa6 100644 --- a/panel/lxqtpanel.h +++ b/panel/lxqtpanel.h @@ -470,12 +470,12 @@ private slots: * @brief Pointer to the PanelPluginsModel which will store all the Plugins * that are loaded. */ - QScopedPointer mPlugins; + std::unique_ptr mPlugins; /** * @brief object for storing info if some standalone window is shown * (for preventing hide) */ - QScopedPointer mStandaloneWindows; + std::unique_ptr mStandaloneWindows; /** * @brief Returns the screen index of a screen on which this panel could diff --git a/panel/lxqtpanelapplication.cpp b/panel/lxqtpanelapplication.cpp index c6e264839..430ea6f35 100644 --- a/panel/lxqtpanelapplication.cpp +++ b/panel/lxqtpanelapplication.cpp @@ -47,7 +47,7 @@ LXQtPanelApplicationPrivate::LXQtPanelApplicationPrivate(LXQtPanelApplication *q ILXQtPanel::Position LXQtPanelApplicationPrivate::computeNewPanelPosition(const LXQtPanel *p, const int screenNum) { Q_Q(LXQtPanelApplication); - QVector screenPositions(4, false); // false means not occupied + QList screenPositions(4, false); // false means not occupied for (int i = 0; i < q->mPanels.size(); ++i) { if (p != q->mPanels.at(i)) { @@ -131,7 +131,7 @@ LXQtPanelApplication::LXQtPanelApplication(int& argc, char** argv) panels << QStringLiteral("panel1"); } - for(const QString& i : qAsConst(panels)) + for(const QString& i : std::as_const(panels)) { addPanel(i); } @@ -199,7 +199,7 @@ void LXQtPanelApplication::reloadPanelsAsNeeded() for(const QString& name : names) { bool found = false; - for(LXQtPanel* panel : qAsConst(mPanels)) + for(LXQtPanel* panel : std::as_const(mPanels)) { if(panel->name() == name) { @@ -246,7 +246,7 @@ void LXQtPanelApplication::screenDestroyed(QObject* screenObj) QScreen* screen = static_cast(screenObj); bool reloadNeeded = false; qApp->setQuitOnLastWindowClosed(false); - for(LXQtPanel* panel : qAsConst(mPanels)) + for(LXQtPanel* panel : std::as_const(mPanels)) { QWindow* panelWindow = panel->windowHandle(); if(panelWindow && panelWindow->screen() == screen) @@ -300,7 +300,7 @@ void LXQtPanelApplication::setIconTheme(const QString &iconTheme) if (newTheme != QIcon::themeName()) { QIcon::setThemeName(newTheme); - for(LXQtPanel* panel : qAsConst(mPanels)) + for(LXQtPanel* panel : std::as_const(mPanels)) { panel->update(); panel->updateConfigDialog(); diff --git a/panel/lxqtpanellayout.cpp b/panel/lxqtpanellayout.cpp index 29af42ade..41b8b545b 100644 --- a/panel/lxqtpanellayout.cpp +++ b/panel/lxqtpanellayout.cpp @@ -156,7 +156,7 @@ class LayoutItemGrid void moveItem(int from, int to); private: - QVector mInfoItems; + QList mInfoItems; int mColCount; int mUsedColCount; int mRowCount; @@ -218,7 +218,7 @@ void LayoutItemGrid::rebuild() { clear(); - for(QLayoutItem *item : qAsConst(mItems)) + for(QLayoutItem *item : std::as_const(mItems)) { doAddToGrid(item); } @@ -648,7 +648,7 @@ void LXQtPanelLayout::setGeometryHoriz(const QRect &geometry) } // Calc baselines for plugins like button. - QVector baseLines(qMax(mLeftGrid->colCount(), mRightGrid->colCount())); + QList baseLines(qMax(mLeftGrid->colCount(), mRightGrid->colCount())); const int bh = geometry.height() / baseLines.count(); const int base_center = bh >> 1; const int height_remain = 0 < bh ? geometry.height() % baseLines.size() : 0; @@ -787,7 +787,7 @@ void LXQtPanelLayout::setGeometryVert(const QRect &geometry) } // Calc baselines for plugins like button. - QVector baseLines(qMax(mLeftGrid->colCount(), mRightGrid->colCount())); + QList baseLines(qMax(mLeftGrid->colCount(), mRightGrid->colCount())); const int bw = geometry.width() / baseLines.count(); const int base_center = bw >> 1; const int width_remain = 0 < bw ? geometry.width() % baseLines.size() : 0; diff --git a/panel/main.cpp b/panel/main.cpp index 1991edc93..81fe17675 100644 --- a/panel/main.cpp +++ b/panel/main.cpp @@ -37,7 +37,6 @@ int main(int argc, char *argv[]) { LXQtPanelApplication app(argc, argv); - app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); return app.exec(); } diff --git a/panel/panelpluginsmodel.cpp b/panel/panelpluginsmodel.cpp index b9f4275b4..52f63665c 100644 --- a/panel/panelpluginsmodel.cpp +++ b/panel/panelpluginsmodel.cpp @@ -224,7 +224,7 @@ void PanelPluginsModel::loadPlugins(QStringList const & desktopDirs) timer.start(); qint64 lastTime = 0; #endif - for (auto const & name : qAsConst(plugin_names)) + for (auto const & name : std::as_const(plugin_names)) { pluginslist_t::iterator i = mPlugins.insert(mPlugins.end(), {name, nullptr}); QString type = mPanel->settings()->value(name + QStringLiteral("/type")).toString(); diff --git a/panel/panelpluginsmodel.h b/panel/panelpluginsmodel.h index d76e9346f..697cb9fdf 100644 --- a/panel/panelpluginsmodel.h +++ b/panel/panelpluginsmodel.h @@ -263,7 +263,7 @@ public slots: * * \sa mPlugins */ - typedef QList > > pluginslist_t; + typedef QList > > pluginslist_t; private: /*! @@ -320,7 +320,7 @@ public slots: * \brief mPlugins Stores all the Plugins. * * mPlugins is a QList of elements while each element corresponds to a - * single Plugin. Each element is a QPair of a QString and a QPointer + * single Plugin. Each element is a std::pair of a QString and a QPointer * while the QPointer points to a Plugin. * * To access the elements, you can use indexing or an iterator on the @@ -336,6 +336,4 @@ public slots: LXQtPanel * mPanel; }; -Q_DECLARE_METATYPE(Plugin const *) - #endif // PANELPLUGINSMODEL_H diff --git a/panel/plugin.cpp b/panel/plugin.cpp index d5c8c992e..eb22ed431 100644 --- a/panel/plugin.cpp +++ b/panel/plugin.cpp @@ -31,7 +31,7 @@ #include "pluginsettings_p.h" #include "lxqtpanel.h" -#include +#include #include #include @@ -127,7 +127,7 @@ Plugin::Plugin(const LXQt::PluginInfo &desktopFile, LXQt::Settings *settings, co else { // this plugin is a dynamically loadable module QString baseName = QStringLiteral("lib%1.so").arg(desktopFile.id()); - for(const QString &dirName : qAsConst(dirs)) + for(const QString &dirName : std::as_const(dirs)) { QFileInfo fi(QDir(dirName), baseName); if (fi.exists()) diff --git a/panel/plugin.h b/panel/plugin.h index fdb3e48f6..cde6cb16a 100644 --- a/panel/plugin.h +++ b/panel/plugin.h @@ -130,5 +130,6 @@ private slots: }; +Q_DECLARE_METATYPE(Plugin const *) #endif // PLUGIN_H diff --git a/panel/pluginmoveprocessor.cpp b/panel/pluginmoveprocessor.cpp index 03928dfe9..dfb0d3632 100644 --- a/panel/pluginmoveprocessor.cpp +++ b/panel/pluginmoveprocessor.cpp @@ -86,7 +86,7 @@ void PluginMoveProcessor::doStart() ************************************************/ void PluginMoveProcessor::mouseMoveEvent(QMouseEvent *event) { - QPoint mouse = mLayout->parentWidget()->mapFromGlobal(event->globalPos()); + QPoint mouse = mLayout->parentWidget()->mapFromGlobal(event->globalPosition()).toPoint(); MousePosInfo pos = itemByMousePos(mouse); @@ -243,9 +243,7 @@ void PluginMoveProcessor::drawMark(QLayoutItem *item, MarkType markType) "border-%2: 2px solid rgba(%4, %5, %6, %7); " "border-%3: -2px solid; " "background-color: transparent; }") - .arg(widget->objectName()) - .arg(border1) - .arg(border2) + .arg(widget->objectName(), border1, border2) .arg(Plugin::moveMarkerColor().red()) .arg(Plugin::moveMarkerColor().green()) .arg(Plugin::moveMarkerColor().blue()) diff --git a/panel/pluginsettings.h b/panel/pluginsettings.h index 13faa8573..63e2016c7 100644 --- a/panel/pluginsettings.h +++ b/panel/pluginsettings.h @@ -90,7 +90,7 @@ class LXQT_PANEL_API PluginSettings : public QObject explicit PluginSettings(LXQt::Settings *settings, const QString &group, QObject *parent = nullptr); private: - QScopedPointer d_ptr; + std::unique_ptr d_ptr; Q_DECLARE_PRIVATE(PluginSettings) }; diff --git a/plugin-backlight/sliderdialog.cpp b/plugin-backlight/sliderdialog.cpp index 1af45ebd5..41d28c5ec 100644 --- a/plugin-backlight/sliderdialog.cpp +++ b/plugin-backlight/sliderdialog.cpp @@ -38,7 +38,7 @@ SliderDialog::SliderDialog(QWidget *parent) : QDialog(parent, Qt::Dialog | Qt::W QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); - layout->setMargin(2); + layout->setContentsMargins(2, 2, 2, 2); m_upButton = new QToolButton(); m_upButton->setText(QStringLiteral("☀")); diff --git a/plugin-colorpicker/colorpicker.cpp b/plugin-colorpicker/colorpicker.cpp index 0827ceddd..004314557 100644 --- a/plugin-colorpicker/colorpicker.cpp +++ b/plugin-colorpicker/colorpicker.cpp @@ -29,7 +29,6 @@ #include "colorpicker.h" #include #include -#include #include #include #include @@ -37,6 +36,10 @@ #include #include +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool + const QString ColorPickerWidget::svgIcon = QStringLiteral( "" @@ -143,11 +146,21 @@ void ColorPickerWidget::mouseReleaseEvent(QMouseEvent *event) if (!mCapturing) return; - WId id = QApplication::desktop()->winId(); - QPixmap pixmap = qApp->primaryScreen()->grabWindow(id, event->globalX(), event->globalY(), 1, 1); + QColor col; + + if (auto *x11Application = qGuiApp->nativeInterface()) + { + WId id = XDefaultRootWindow(x11Application->display()); + QPoint point = event->globalPosition().toPoint(); + QPixmap pixmap = qApp->primaryScreen()->grabWindow(id, point.x(), point.y(), 1, 1); - QImage img = pixmap.toImage(); - QColor col = QColor(img.pixel(0,0)); + QImage img = pixmap.toImage(); + col = QColor(img.pixel(0,0)); + } + else + { + qWarning() << "WAYLAND does not support grabbing windows"; + } mColorButton->setColor(col); paste(col.name()); @@ -185,7 +198,7 @@ void ColorPickerWidget::captureMouse() QIcon ColorPickerWidget::colorIcon(QColor color) { - QString data = svgIcon.arg(palette().color(QPalette::Text).name()).arg(color.name()); + QString data = svgIcon.arg(palette().color(QPalette::Text).name(), color.name()); QPixmap pixmap(mColorButton->iconSize()); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); diff --git a/plugin-cpuload/lxqtcpuload.cpp b/plugin-cpuload/lxqtcpuload.cpp index 8590fbce9..4cee6208e 100644 --- a/plugin-cpuload/lxqtcpuload.cpp +++ b/plugin-cpuload/lxqtcpuload.cpp @@ -28,7 +28,6 @@ #include "lxqtcpuload.h" #include "../panel/ilxqtpanelplugin.h" #include "../panel/pluginsettings.h" -#include #include #include #include diff --git a/plugin-customcommand/CMakeLists.txt b/plugin-customcommand/CMakeLists.txt index cb82cac94..49be1b866 100644 --- a/plugin-customcommand/CMakeLists.txt +++ b/plugin-customcommand/CMakeLists.txt @@ -18,7 +18,7 @@ set(UIS ) set(LIBRARIES - Qt5Xdg + Qt6Xdg ) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-desktopswitch/desktopswitch.cpp b/plugin-desktopswitch/desktopswitch.cpp index 380efdf9c..4bd05e08f 100644 --- a/plugin-desktopswitch/desktopswitch.cpp +++ b/plugin-desktopswitch/desktopswitch.cpp @@ -32,15 +32,22 @@ #include #include #include -#include -#include -#include + + #include #include "desktopswitch.h" #include "desktopswitchbutton.h" #include "desktopswitchconfiguration.h" +#include +#include +#include + +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool + static const QString DEFAULT_SHORTCUT_TEMPLATE(QStringLiteral("Control+F%1")); DesktopSwitch::DesktopSwitch(const ILXQtPanelPluginStartupInfo &startupInfo) : @@ -50,9 +57,13 @@ DesktopSwitch::DesktopSwitch(const ILXQtPanelPluginStartupInfo &startupInfo) : m_desktopCount(KX11Extras::numberOfDesktops()), mRows(-1), mShowOnlyActive(false), - mDesktops(new NETRootInfo(QX11Info::connection(), NET::NumberOfDesktops | NET::CurrentDesktop | NET::DesktopNames, NET::WM2DesktopLayout)), + mDesktops(nullptr), mLabelType(static_cast(-1)) { + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "DesktopSwitch", "Expected X11 connection"); + mDesktops.reset(new NETRootInfo(x11Application->connection(), NET::NumberOfDesktops | NET::CurrentDesktop | NET::DesktopNames, NET::WM2DesktopLayout)); + m_buttons = new QButtonGroup(this); connect (m_pSignalMapper, &QSignalMapper::mappedInt, this, &DesktopSwitch::setDesktop); @@ -196,9 +207,13 @@ bool DesktopSwitch::isWindowHighlightable(WId window) if (info.state() & NET::SkipTaskbar) return false; + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "DesktopSwitch", "Expected X11 connection"); + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + // WM_TRANSIENT_FOR hint not set - normal window WId transFor = info.transientFor(); - if (transFor == 0 || transFor == window || transFor == (WId) QX11Info::appRootWindow()) + if (transFor == 0 || transFor == window || transFor == appRootWindow) return true; info = KWindowInfo(transFor, NET::WMWindowType); diff --git a/plugin-desktopswitch/desktopswitch.h b/plugin-desktopswitch/desktopswitch.h index 73d7a9e78..93a930dc2 100644 --- a/plugin-desktopswitch/desktopswitch.h +++ b/plugin-desktopswitch/desktopswitch.h @@ -33,8 +33,8 @@ #include #include #include -#include -#include +#include +#include #include "desktopswitchbutton.h" @@ -85,7 +85,7 @@ class DesktopSwitch : public QObject, public ILXQtPanelPlugin LXQt::GridLayout *mLayout; int mRows; bool mShowOnlyActive; - QScopedPointer mDesktops; + std::unique_ptr mDesktops; DesktopSwitchButton::LabelType mLabelType; void refresh(); diff --git a/plugin-desktopswitch/desktopswitchconfiguration.cpp b/plugin-desktopswitch/desktopswitchconfiguration.cpp index 402981467..943dbdd6b 100644 --- a/plugin-desktopswitch/desktopswitchconfiguration.cpp +++ b/plugin-desktopswitch/desktopswitchconfiguration.cpp @@ -26,7 +26,7 @@ #include "desktopswitchconfiguration.h" #include "ui_desktopswitchconfiguration.h" -#include +#include #include DesktopSwitchConfiguration::DesktopSwitchConfiguration(PluginSettings *settings, QWidget *parent) : diff --git a/plugin-directorymenu/CMakeLists.txt b/plugin-directorymenu/CMakeLists.txt index 319b02ddc..81103a1b4 100644 --- a/plugin-directorymenu/CMakeLists.txt +++ b/plugin-directorymenu/CMakeLists.txt @@ -16,7 +16,7 @@ set(UIS set(LIBRARIES ${LIBRARIES} - Qt5Xdg + Qt6Xdg ) include ("../cmake/BuildPlugin.cmake") diff --git a/plugin-fancymenu/lxqtfancymenuappmap.cpp b/plugin-fancymenu/lxqtfancymenuappmap.cpp index e0b461980..905b56295 100644 --- a/plugin-fancymenu/lxqtfancymenuappmap.cpp +++ b/plugin-fancymenu/lxqtfancymenuappmap.cpp @@ -230,14 +230,14 @@ LXQtFancyMenuAppMap::AppItem *LXQtFancyMenuAppMap::getAppAt(int index) return *mCachedIterator; } -QVector LXQtFancyMenuAppMap::getMatchingApps(const QString &query) const +QList LXQtFancyMenuAppMap::getMatchingApps(const QString &query) const { - QVector byName; - QVector byKeyword; + QList byName; + QList byKeyword; //TODO: implement some kind of score to get better matches on top - for(const AppItem *app : qAsConst(mAppSortedByName)) + for(const AppItem *app : std::as_const(mAppSortedByName)) { if(app->title.contains(query, Qt::CaseInsensitive)) { @@ -280,7 +280,7 @@ void LXQtFancyMenuAppMap::parseMenu(const QDomElement &menu, const QString& topL Category item; item.type = LXQtFancyMenuItemType::CategoryItem; item.menuName = e.attribute(QLatin1String("name")); - item.menuTitle = e.attribute(QLatin1Literal("title"), item.menuName); + item.menuTitle = e.attribute(QLatin1String("title"), item.menuName); QString iconName = e.attribute(QLatin1String("icon")); item.icon = XdgIcon::fromTheme(iconName); mCategories.append(item); diff --git a/plugin-fancymenu/lxqtfancymenuappmap.h b/plugin-fancymenu/lxqtfancymenuappmap.h index 698e40be4..187b327e1 100644 --- a/plugin-fancymenu/lxqtfancymenuappmap.h +++ b/plugin-fancymenu/lxqtfancymenuappmap.h @@ -30,7 +30,7 @@ #define LXQTFANCYMENUAPPMAP_H #include -#include +#include #include #include @@ -74,7 +74,7 @@ class LXQtFancyMenuAppMap LXQtFancyMenuItemType type = LXQtFancyMenuItemType::AppItem; }; - QVector apps; + QList apps; LXQtFancyMenuItemType type; }; @@ -108,7 +108,7 @@ class LXQtFancyMenuAppMap AppItem *getAppAt(int index); - QVector getMatchingApps(const QString& query) const; + QList getMatchingApps(const QString& query) const; private: void parseMenu(const QDomElement& menu, const QString &topLevelCategory); @@ -121,7 +121,7 @@ class LXQtFancyMenuAppMap typedef QMap AppMap; AppMap mAppSortedByDesktopFile; AppMap mAppSortedByName; - QVector mCategories; + QList mCategories; // Cache sort by name map access AppMap::const_iterator mCachedIterator; diff --git a/plugin-fancymenu/lxqtfancymenuappmodel.cpp b/plugin-fancymenu/lxqtfancymenuappmodel.cpp index 0baa05ed9..f72b2de11 100644 --- a/plugin-fancymenu/lxqtfancymenuappmodel.cpp +++ b/plugin-fancymenu/lxqtfancymenuappmodel.cpp @@ -176,7 +176,7 @@ bool LXQtFancyMenuAppModel::dropMimeData(const QMimeData *data_, Qt::DropAction return false; // No-op // realRow is needed because beginMoveRows() behaves differenlty than - // QVector<...>::move() on index counting. + // QList<...>::move() on index counting. beginMoveRows(QModelIndex(), oldRow, oldRow, QModelIndex(), realRow); mAppMap->moveFavoriteItem(oldRow, row); @@ -208,7 +208,7 @@ void LXQtFancyMenuAppModel::setCurrentCategory(int category) endResetModel(); } -void LXQtFancyMenuAppModel::showSearchResults(const QVector &matches) +void LXQtFancyMenuAppModel::showSearchResults(const QList &matches) { beginResetModel(); mSearchMatches = matches; diff --git a/plugin-fancymenu/lxqtfancymenuappmodel.h b/plugin-fancymenu/lxqtfancymenuappmodel.h index def2328d9..6b50cfbd4 100644 --- a/plugin-fancymenu/lxqtfancymenuappmodel.h +++ b/plugin-fancymenu/lxqtfancymenuappmodel.h @@ -59,7 +59,7 @@ class LXQtFancyMenuAppModel : public QAbstractListModel void reloadAppMap(bool end); void setCurrentCategory(int category); - void showSearchResults(const QVector &matches); + void showSearchResults(const QList &matches); void endSearch(); LXQtFancyMenuAppMap *appMap() const; @@ -77,7 +77,7 @@ class LXQtFancyMenuAppModel : public QAbstractListModel LXQtFancyMenuAppMap *mAppMap; int mCurrentCategory; - QVector mSearchMatches; + QList mSearchMatches; bool mInSearch; }; diff --git a/plugin-kbindicator/CMakeLists.txt b/plugin-kbindicator/CMakeLists.txt index 29a208f9d..0a5e36192 100644 --- a/plugin-kbindicator/CMakeLists.txt +++ b/plugin-kbindicator/CMakeLists.txt @@ -29,9 +29,9 @@ set(UIS set(LIBRARIES ) -find_package(XCB REQUIRED COMPONENTS xcb xcb-xkb) +find_package(XCB REQUIRED COMPONENTS XCB XKB) find_package(XKBCommon REQUIRED COMPONENTS XKBCommon X11) -find_package(Qt5 ${QT_MINIMUM_VERSION} REQUIRED COMPONENTS X11Extras Xml) +find_package(Qt6 ${QT_MINIMUM_VERSION} REQUIRED COMPONENTS Xml) include_directories(${XCB_INCLUDE_DIRS}) @@ -50,7 +50,7 @@ set(LIBRARIES ${XCB_LIBRARIES} XKBCommon::XKBCommon XKBCommon::X11 - Qt5::Xml + Qt6::Xml ) add_definitions(-DX11_ENABLED) diff --git a/plugin-kbindicator/kbindicator-plugin.cpp b/plugin-kbindicator/kbindicator-plugin.cpp index b2e69b0c8..ab0580e33 100644 --- a/plugin-kbindicator/kbindicator-plugin.cpp +++ b/plugin-kbindicator/kbindicator-plugin.cpp @@ -26,10 +26,13 @@ #include #include -#include + +#include // For nativeInterface() + #include "src/kbdstate.h" #include "../panel/ilxqtpanelplugin.h" + class LXQtKbIndicatorPlugin: public QObject, public ILXQtPanelPluginLibrary { Q_OBJECT @@ -40,11 +43,14 @@ class LXQtKbIndicatorPlugin: public QObject, public ILXQtPanelPluginLibrary ILXQtPanelPlugin *instance(const ILXQtPanelPluginStartupInfo &startupInfo) const override { - // Currently only X11 supported - if (!QX11Info::connection()) { + auto *x11Application = qGuiApp->nativeInterface(); + if(!x11Application || !x11Application->connection()) + { + // Currently only X11 supported qWarning() << "Currently kbindicator plugin supports X11 only. Skipping."; return nullptr; } + return new KbdState(startupInfo); } }; diff --git a/plugin-kbindicator/src/kbdkeeper.cpp b/plugin-kbindicator/src/kbdkeeper.cpp index 2f53db04b..49009934b 100644 --- a/plugin-kbindicator/src/kbdkeeper.cpp +++ b/plugin-kbindicator/src/kbdkeeper.cpp @@ -25,9 +25,11 @@ * END_COMMON_COPYRIGHT_HEADER */ #include -#include -#include -#include + +#include +#include +#include + #include "kbdkeeper.h" //-------------------------------------------------------------------------------------------------- diff --git a/plugin-kbindicator/src/kbdwatcher.cpp b/plugin-kbindicator/src/kbdwatcher.cpp index 0cf4da74a..0ba9309ce 100644 --- a/plugin-kbindicator/src/kbdwatcher.cpp +++ b/plugin-kbindicator/src/kbdwatcher.cpp @@ -61,7 +61,7 @@ void KbdWatcher::createKeeper(KeeperType type) break; } - connect(m_keeper.data(), &KbdKeeper::changed, this, &KbdWatcher::keeperChanged); + connect(m_keeper.get(), &KbdKeeper::changed, this, &KbdWatcher::keeperChanged); m_keeper->setup(); keeperChanged(); diff --git a/plugin-kbindicator/src/kbdwatcher.h b/plugin-kbindicator/src/kbdwatcher.h index 15553d44a..187d0cde3 100644 --- a/plugin-kbindicator/src/kbdwatcher.h +++ b/plugin-kbindicator/src/kbdwatcher.h @@ -58,7 +58,7 @@ private slots: private: KbdLayout m_layout; - QScopedPointer m_keeper; + std::unique_ptr m_keeper; }; #endif diff --git a/plugin-kbindicator/src/x11/kbdlayout.cpp b/plugin-kbindicator/src/x11/kbdlayout.cpp index 90c2b0bcc..f5dbe2915 100644 --- a/plugin-kbindicator/src/x11/kbdlayout.cpp +++ b/plugin-kbindicator/src/x11/kbdlayout.cpp @@ -97,7 +97,7 @@ class X11Kbd: public QAbstractNativeEventFilter bool isEnabled() const { return true; } - bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override { if (eventType != "xcb_generic_event_t") return false; diff --git a/plugin-kbindicator/src/x11/kbdlayout.h b/plugin-kbindicator/src/x11/kbdlayout.h index fdb4df2f1..c97c68869 100644 --- a/plugin-kbindicator/src/x11/kbdlayout.h +++ b/plugin-kbindicator/src/x11/kbdlayout.h @@ -54,7 +54,7 @@ class X11Kbd: public QObject void checkState(); void keyboardChanged(); private: - QScopedPointer m_priv; + std::unique_ptr m_priv; }; #endif diff --git a/plugin-mainmenu/actionview.cpp b/plugin-mainmenu/actionview.cpp index f585fcebe..ce0f3e306 100644 --- a/plugin-mainmenu/actionview.cpp +++ b/plugin-mainmenu/actionview.cpp @@ -164,11 +164,11 @@ ActionView::ActionView(QWidget * parent /*= nullptr*/) mProxy->setFilterCaseSensitivity(Qt::CaseInsensitive); mProxy->sort(0); { - QScopedPointer guard{selectionModel()}; + std::unique_ptr guard{selectionModel()}; setModel(mProxy); } { - QScopedPointer guard{itemDelegate()}; + std::unique_ptr guard{itemDelegate()}; setItemDelegate(new DelayedIconDelegate{this}); } connect(this, &QAbstractItemView::activated, this, &ActionView::onActivated); @@ -284,7 +284,7 @@ QSize ActionView::minimumSizeHint() const void ActionView::mousePressEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) - mDragStartPosition = event->pos(); + mDragStartPosition = event->position().toPoint(); QListView::mousePressEvent(event); } @@ -294,7 +294,7 @@ void ActionView::mouseMoveEvent(QMouseEvent *event) if (!(event->buttons() & Qt::LeftButton)) return; - if ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()) + if ((event->position().toPoint() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()) return; XdgAction *a = qobject_cast(indexAt(mDragStartPosition).data(ActionView::ActionRole).value()); diff --git a/plugin-mainmenu/lxqtmainmenu.cpp b/plugin-mainmenu/lxqtmainmenu.cpp index a689db423..1db7f911f 100644 --- a/plugin-mainmenu/lxqtmainmenu.cpp +++ b/plugin-mainmenu/lxqtmainmenu.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #endif #define DEFAULT_SHORTCUT "Alt+F1" diff --git a/plugin-mount/CMakeLists.txt b/plugin-mount/CMakeLists.txt index a9a0a1e42..5f817ff51 100644 --- a/plugin-mount/CMakeLists.txt +++ b/plugin-mount/CMakeLists.txt @@ -34,7 +34,7 @@ set(UIS configuration.ui ) -find_package(KF5Solid ${QT_MINIMUM_VERSION} REQUIRED) -set(LIBRARIES Qt5Xdg lxqt-globalkeys KF5::Solid) +find_package(KF6Solid ${QT_MINIMUM_VERSION} REQUIRED) +set(LIBRARIES Qt6Xdg lxqt-globalkeys KF6::Solid) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-mount/configuration.cpp b/plugin-mount/configuration.cpp index da60133c2..9c49a9dbb 100644 --- a/plugin-mount/configuration.cpp +++ b/plugin-mount/configuration.cpp @@ -39,18 +39,30 @@ Configuration::Configuration(PluginSettings *settings, QWidget *parent) : { ui->setupUi(this); - ui->devAddedLabel->sizePolicy().setHorizontalStretch(1); + // Set size policies + QSizePolicy sp = ui->devAddedLabel->sizePolicy(); + sp.setHorizontalStretch(1); + ui->devAddedLabel->setSizePolicy(sp); + sp = ui->devAddedCombo->sizePolicy(); + sp.setHorizontalStretch(1); + ui->devAddedCombo->setSizePolicy(sp); + + sp = ui->ejectPressedLabel->sizePolicy(); + sp.setHorizontalStretch(1); + ui->ejectPressedLabel->setSizePolicy(sp); + + sp = ui->ejectPressedCombo->sizePolicy(); + sp.setHorizontalStretch(1); + ui->ejectPressedCombo->setSizePolicy(sp); + + // Fill combo boxes ui->devAddedCombo->addItem(tr("Popup menu"), QLatin1String(ACT_SHOW_MENU)); ui->devAddedCombo->addItem(tr("Show info"), QLatin1String(ACT_SHOW_INFO)); ui->devAddedCombo->addItem(tr("Do nothing"), QLatin1String(ACT_NOTHING)); - ui->devAddedCombo->sizePolicy().setHorizontalStretch(1); - - ui->ejectPressedLabel->sizePolicy().setHorizontalStretch(1); ui->ejectPressedCombo->addItem(tr("Do nothing"), QLatin1String(ACT_NOTHING)); ui->ejectPressedCombo->addItem(tr("Eject All Optical Drives"), QLatin1String(ACT_EJECT_OPTICAL)); - ui->ejectPressedCombo->sizePolicy().setHorizontalStretch(1); adjustSize(); diff --git a/plugin-mount/menudiskitem.cpp b/plugin-mount/menudiskitem.cpp index bf4a52f21..3f4af34ab 100644 --- a/plugin-mount/menudiskitem.cpp +++ b/plugin-mount/menudiskitem.cpp @@ -65,7 +65,7 @@ MenuDiskItem::MenuDiskItem(Solid::Device device, Popup *popup): QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(mDiskButton); layout->addWidget(mEjectButton); - layout->setMargin(0); + layout->setContentsMargins(QMargins()); layout->setSpacing(0); setLayout(layout); @@ -151,7 +151,7 @@ void MenuDiskItem::onMounted(Solid::ErrorType error, QVariant resultData, const else { QString errorMsg = tr("Mounting of \"%1\" failed: %2"); - errorMsg = errorMsg.arg(mDevice.description()).arg(resultData.toString()); + errorMsg = errorMsg.arg(mDevice.description(), resultData.toString()); LXQt::Notification::notify(tr("Removable media/devices manager"), errorMsg, mDevice.icon()); } } @@ -172,7 +172,7 @@ void MenuDiskItem::onUnmounted(Solid::ErrorType error, QVariant resultData, cons else { QString errorMsg = tr("Unmounting of \"%1\" failed: %2"); - errorMsg = errorMsg.arg(mDevice.description()).arg(resultData.toString()); + errorMsg = errorMsg.arg(mDevice.description(), resultData.toString()); LXQt::Notification::notify(tr("Removable media/devices manager"), errorMsg, mDevice.icon()); } } diff --git a/plugin-mount/popup.cpp b/plugin-mount/popup.cpp index 66d34db3a..20720266f 100644 --- a/plugin-mount/popup.cpp +++ b/plugin-mount/popup.cpp @@ -29,7 +29,6 @@ #include "popup.h" #include "../panel/ilxqtpanelplugin.h" -#include #include #include #include @@ -61,7 +60,7 @@ Popup::Popup(ILXQtPanelPlugin * plugin, QWidget* parent): setObjectName(QStringLiteral("LXQtMountPopup")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setLayout(new QVBoxLayout(this)); - layout()->setMargin(0); + layout()->setContentsMargins(QMargins()); setAttribute(Qt::WA_AlwaysShowToolTips); diff --git a/plugin-qeyes/qeyes.cpp b/plugin-qeyes/qeyes.cpp index f147f8f0b..83df9612d 100644 --- a/plugin-qeyes/qeyes.cpp +++ b/plugin-qeyes/qeyes.cpp @@ -43,7 +43,6 @@ QEyesPlugin::QEyesPlugin(const ILXQtPanelPluginStartupInfo &startupInfo) : w0 = new QWidget(); l = new QVBoxLayout(); l->setSpacing(0); - l->setMargin(0); l->setContentsMargins (0, 0, 0, 0); w0->setLayout(l); diff --git a/plugin-qeyes/qeyesconfigdialog.cpp b/plugin-qeyes/qeyesconfigdialog.cpp index 1ebfd6124..c0e1c2025 100644 --- a/plugin-qeyes/qeyesconfigdialog.cpp +++ b/plugin-qeyes/qeyesconfigdialog.cpp @@ -80,14 +80,19 @@ void QEyesConfigDialog::showEvent(QShowEvent *) { QStringLiteral("2")).toInt(); old_type_eyes = _settings->value(QStringLiteral("eye_type"), QEyesPlugin::internalEye).toString(); + buildList(); + bool found = false; - for (const auto &key : types.keys()) { - if (old_type_eyes == types[key]) { + for (const auto &item : std::as_const(types)) + { + if (old_type_eyes == item) + { found = true; break; } } + if (!found) old_type_eyes = QEyesPlugin::internalEye; @@ -96,8 +101,11 @@ void QEyesConfigDialog::showEvent(QShowEvent *) { typesWidget->clear(); typesWidget->addItem(tr("QEyes default")); - for (const auto &key: types.keys()) - typesWidget->addItem(key); + + for (auto it = types.constBegin(), end = types.constEnd(); it != end; it++) + { + typesWidget->addItem(it.key()); + } resetValue(); @@ -107,11 +115,14 @@ void QEyesConfigDialog::showEvent(QShowEvent *) { numEyesWidget->blockSignals(false); } -void QEyesConfigDialog::resetValue() { +void QEyesConfigDialog::resetValue() +{ int actIndex = 0; int c = 1; // 0 is - for (const auto &key : types.keys()) { - if (old_type_eyes == types[key]) + + for (const auto &item : std::as_const(types)) + { + if (old_type_eyes == item) actIndex = c; c++; } diff --git a/plugin-qeyes/qeyesimagewidget.cpp b/plugin-qeyes/qeyesimagewidget.cpp index 6cc5cd9f8..c1596bff3 100644 --- a/plugin-qeyes/qeyesimagewidget.cpp +++ b/plugin-qeyes/qeyesimagewidget.cpp @@ -32,16 +32,21 @@ #include "qeyesimagewidget.h" -bool ImageStretcher::load(QString fn) { - if (fn.toLower().endsWith(QString::fromUtf8(".svg"))) { +bool ImageStretcher::load(const QString& fn) +{ + if (fn.endsWith(QString::fromUtf8(".svg"), Qt::CaseInsensitive)) + { svg = true; if (!svgrender.load(fn)) return false; - } else { + } + else + { if (!origImage.load(fn)) return false; svg = false; } + stretchedImage = QPixmap(); return true; } diff --git a/plugin-qeyes/qeyesimagewidget.h b/plugin-qeyes/qeyesimagewidget.h index d0b6bf019..e3c284d96 100644 --- a/plugin-qeyes/qeyesimagewidget.h +++ b/plugin-qeyes/qeyesimagewidget.h @@ -30,7 +30,7 @@ class ImageStretcher { QSvgRenderer svgrender; QPixmap origImage, stretchedImage; public: - bool load(QString fn); + bool load(const QString &fn); QPixmap &getImage(int w, int h); int origWidth(); int origHeight(); diff --git a/plugin-qeyes/qeyeswidget.cpp b/plugin-qeyes/qeyeswidget.cpp index 9db035475..4b9c7f023 100644 --- a/plugin-qeyes/qeyeswidget.cpp +++ b/plugin-qeyes/qeyeswidget.cpp @@ -53,7 +53,7 @@ void QAbstractEyesWidget::leaveEvent(QEvent *) { timer.start(); } -void QAbstractEyesWidget::enterEvent(QEvent *) { +void QAbstractEyesWidget::enterEvent(QEnterEvent *) { timer.stop(); } diff --git a/plugin-qeyes/qeyeswidget.h b/plugin-qeyes/qeyeswidget.h index 85118dafe..41f49dabe 100644 --- a/plugin-qeyes/qeyeswidget.h +++ b/plugin-qeyes/qeyeswidget.h @@ -44,7 +44,7 @@ private slots: private: void leaveEvent(QEvent *) override; - void enterEvent(QEvent *) override; + void enterEvent(QEnterEvent *) override; void mouseMoveEvent(QMouseEvent *) override; protected: diff --git a/plugin-quicklaunch/CMakeLists.txt b/plugin-quicklaunch/CMakeLists.txt index dd48bcf4d..eb2e92e0e 100644 --- a/plugin-quicklaunch/CMakeLists.txt +++ b/plugin-quicklaunch/CMakeLists.txt @@ -15,7 +15,7 @@ set(SOURCES ) set(LIBRARIES - Qt5Xdg + Qt6Xdg ) include_directories( diff --git a/plugin-quicklaunch/lxqtquicklaunch.cpp b/plugin-quicklaunch/lxqtquicklaunch.cpp index ae2bf2f49..ab867d970 100644 --- a/plugin-quicklaunch/lxqtquicklaunch.cpp +++ b/plugin-quicklaunch/lxqtquicklaunch.cpp @@ -202,7 +202,9 @@ void LXQtQuickLaunch::dropEvent(QDropEvent *e) } const auto & urls = e->mimeData()->urls(); - for (const QUrl &url : QSet{urls.cbegin(), urls.cend()}) + const QSet uniqueUrls{urls.cbegin(), urls.cend()}; + + for (const QUrl &url : uniqueUrls) { QString fileName(url.isLocalFile() ? url.toLocalFile() : url.url()); QFileInfo fi(fileName); diff --git a/plugin-quicklaunch/quicklaunchbutton.cpp b/plugin-quicklaunch/quicklaunchbutton.cpp index 7dd0945e1..9d1630fcf 100644 --- a/plugin-quicklaunch/quicklaunchbutton.cpp +++ b/plugin-quicklaunch/quicklaunchbutton.cpp @@ -118,7 +118,7 @@ void QuickLaunchButton::this_customContextMenuRequested(const QPoint & /*pos*/) mMoveRightAct->setEnabled(!mPlugin->panel()->isLocked() && panel && panel->indexOfButton(this) < panel->countOfButtons() - 1); mDeleteAct->setEnabled(!mPlugin->panel()->isLocked()); mPlugin->willShowWindow(mMenu); - mMenu->popup(mPlugin->panel()->calculatePopupWindowPos(mapToGlobal({0, 0}), mMenu->sizeHint()).topLeft()); + mMenu->popup(mPlugin->panel()->calculatePopupWindowPos(mapToGlobal(QPoint(0, 0)), mMenu->sizeHint()).topLeft()); } @@ -132,7 +132,7 @@ void QuickLaunchButton::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton && e->modifiers() == Qt::ControlModifier) { - mDragStart = e->pos(); + mDragStart = e->position().toPoint(); return; } @@ -147,7 +147,7 @@ void QuickLaunchButton::mouseMoveEvent(QMouseEvent *e) return; } - if ((e->pos() - mDragStart).manhattanLength() < QApplication::startDragDistance()) + if ((e->position().toPoint() - mDragStart).manhattanLength() < QApplication::startDragDistance()) { return; } diff --git a/plugin-showdesktop/CMakeLists.txt b/plugin-showdesktop/CMakeLists.txt index bf69d2b67..031c90e11 100644 --- a/plugin-showdesktop/CMakeLists.txt +++ b/plugin-showdesktop/CMakeLists.txt @@ -11,7 +11,7 @@ set(SOURCES set(LIBRARIES ${LIBRARIES} lxqt-globalkeys - Qt5Xdg + Qt6Xdg ) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-showdesktop/showdesktop.cpp b/plugin-showdesktop/showdesktop.cpp index 1733489d2..871da62ea 100644 --- a/plugin-showdesktop/showdesktop.cpp +++ b/plugin-showdesktop/showdesktop.cpp @@ -26,12 +26,11 @@ * END_COMMON_COPYRIGHT_HEADER */ #include -#include #include #include #include -#include -#include +#include +#include #include "showdesktop.h" #include "../panel/pluginsettings.h" diff --git a/plugin-statusnotifier/CMakeLists.txt b/plugin-statusnotifier/CMakeLists.txt index d12a0f051..76882bc35 100644 --- a/plugin-statusnotifier/CMakeLists.txt +++ b/plugin-statusnotifier/CMakeLists.txt @@ -1,8 +1,8 @@ set(PLUGIN "statusnotifier") -find_package(dbusmenu-qt5 REQUIRED) -find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Concurrent) +find_package(dbusmenu-lxqt REQUIRED) +find_package(Qt6 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Concurrent) set(HEADERS statusnotifier.h @@ -32,7 +32,7 @@ set(UIS statusnotifierconfiguration.ui ) -qt5_add_dbus_adaptor(DBUS_SOURCES +qt6_add_dbus_adaptor(DBUS_SOURCES org.kde.StatusNotifierItem.xml statusnotifieriteminterface.h StatusNotifierItemInterface @@ -43,8 +43,8 @@ set_source_files_properties(${DBUS_SOURCES} PROPERTIES SKIP_AUTOGEN ON) list(APPEND SOURCES "${DBUS_SOURCES}") set(LIBRARIES - dbusmenu-qt5 - Qt5::Concurrent + dbusmenu-lxqt + Qt6::Concurrent ) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-statusnotifier/statusnotifierbutton.cpp b/plugin-statusnotifier/statusnotifierbutton.cpp index 2f6a5e433..5cd90bfed 100644 --- a/plugin-statusnotifier/statusnotifierbutton.cpp +++ b/plugin-statusnotifier/statusnotifierbutton.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include "../panel/ilxqtpanelplugin.h" #include "sniasync.h" #include diff --git a/plugin-statusnotifier/statusnotifierwidget.cpp b/plugin-statusnotifier/statusnotifierwidget.cpp index d71cca731..2ce89d3a7 100644 --- a/plugin-statusnotifier/statusnotifierwidget.cpp +++ b/plugin-statusnotifier/statusnotifierwidget.cpp @@ -96,7 +96,7 @@ void StatusNotifierWidget::leaveEvent(QEvent * /*event*/) mHideTimer.start(); } -void StatusNotifierWidget::enterEvent(QEvent * /*event*/) +void StatusNotifierWidget::enterEvent(QEnterEvent * /*event*/) { mHideTimer.stop(); } @@ -173,7 +173,7 @@ void StatusNotifierWidget::itemRemoved(const QString &serviceAndPath) if (mShowBtn->isVisible() || mForceVisible) { // hide mShowBtn if no (auto-)hidden item remains bool showBtn = false; - for (const auto &name : qAsConst(mItemTitles)) + for (const auto &name : std::as_const(mItemTitles)) { if (mAutoHideList.contains(name) || mHideList.contains(name)) { diff --git a/plugin-statusnotifier/statusnotifierwidget.h b/plugin-statusnotifier/statusnotifierwidget.h index 1711eb6f4..379722e82 100644 --- a/plugin-statusnotifier/statusnotifierwidget.h +++ b/plugin-statusnotifier/statusnotifierwidget.h @@ -57,7 +57,7 @@ public slots: protected: void leaveEvent(QEvent *event) override; - void enterEvent(QEvent *event) override; + void enterEvent(QEnterEvent *event) override; private: ILXQtPanelPlugin *mPlugin; diff --git a/plugin-sysstat/CMakeLists.txt b/plugin-sysstat/CMakeLists.txt index 6cb28e67d..af013b9f0 100644 --- a/plugin-sysstat/CMakeLists.txt +++ b/plugin-sysstat/CMakeLists.txt @@ -1,6 +1,6 @@ set(PLUGIN "sysstat") -find_package(SysStat-Qt5 REQUIRED) +find_package(SysStat-Qt6 REQUIRED) set(HEADERS lxqtsysstat.h @@ -21,6 +21,6 @@ set(UIS lxqtsysstatcolours.ui ) -set(LIBRARIES sysstat-qt5) +set(LIBRARIES sysstat-qt6) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-sysstat/lxqtsysstatutils.cpp b/plugin-sysstat/lxqtsysstatutils.cpp index fe9bc5ca6..603128439 100644 --- a/plugin-sysstat/lxqtsysstatutils.cpp +++ b/plugin-sysstat/lxqtsysstatutils.cpp @@ -25,7 +25,7 @@ * * END_COMMON_COPYRIGHT_HEADER */ -#include +#include #include #include "lxqtsysstatutils.h" @@ -44,13 +44,14 @@ QString netSpeedToString(int value) return QStringLiteral("%1 %2B/s").arg(1 << (value % 10)).arg(prefix); } -int netSpeedFromString(QString value) +int netSpeedFromString(QStringView value) { - QRegExp re(QStringLiteral("^(\\d+) ([kMG])B/s$")); - if (re.exactMatch(value)) + static const QRegularExpression re(QStringLiteral("^(\\d+) ([kMG])B/s$")); + QRegularExpressionMatch match = re.matchView(value); + if (match.hasMatch()) { int shift = 0; - switch (re.cap(2).at(0).toLatin1()) + switch (match.capturedView(2).at(0).toLatin1()) { case 'k': shift = 10; @@ -65,7 +66,7 @@ int netSpeedFromString(QString value) break; } - return qCeil(qLn(re.cap(1).toInt()) / qLn(2.)) + shift; + return qCeil(qLn(match.capturedView(1).toInt()) / qLn(2.)) + shift; } return 0; diff --git a/plugin-sysstat/lxqtsysstatutils.h b/plugin-sysstat/lxqtsysstatutils.h index e83aee767..f0617edfb 100644 --- a/plugin-sysstat/lxqtsysstatutils.h +++ b/plugin-sysstat/lxqtsysstatutils.h @@ -34,7 +34,7 @@ namespace PluginSysStat { QString netSpeedToString(int value); -int netSpeedFromString(QString value); +int netSpeedFromString(QStringView value); } diff --git a/plugin-taskbar/CMakeLists.txt b/plugin-taskbar/CMakeLists.txt index 4f7b34dc3..1d627f23e 100644 --- a/plugin-taskbar/CMakeLists.txt +++ b/plugin-taskbar/CMakeLists.txt @@ -25,7 +25,7 @@ set(UIS set(LIBRARIES lxqt lxqt-globalkeys - Qt5Xdg + Qt6Xdg ) BUILD_LXQT_PLUGIN(${PLUGIN}) diff --git a/plugin-taskbar/lxqtgrouppopup.cpp b/plugin-taskbar/lxqtgrouppopup.cpp index 822416865..a71ca2b41 100644 --- a/plugin-taskbar/lxqtgrouppopup.cpp +++ b/plugin-taskbar/lxqtgrouppopup.cpp @@ -29,6 +29,8 @@ * END_COMMON_COPYRIGHT_HEADER */ #include "lxqtgrouppopup.h" +#include "lxqttaskgroup.h" + #include #include #include @@ -55,7 +57,7 @@ LXQtGroupPopup::LXQtGroupPopup(LXQtTaskGroup *group): setLayout(new QVBoxLayout); layout()->setSpacing(3); - layout()->setMargin(3); + layout()->setContentsMargins(3, 3, 3, 3); connect(&mCloseTimer, &QTimer::timeout, this, &LXQtGroupPopup::closeTimerSlot); mCloseTimer.setSingleShot(true); @@ -93,14 +95,14 @@ void LXQtGroupPopup::dropEvent(QDropEvent *event) for (int i = 0; i < oldIndex && newIndex == -1; i++) { QWidget *w = layout()->itemAt(i)->widget(); - if (w && w->pos().y() + w->height() / 2 > event->pos().y()) + if (w && w->pos().y() + w->height() / 2 > event->position().y()) newIndex = i; } const int size = layout()->count(); for (int i = size - 1; i > oldIndex && newIndex == -1; i--) { QWidget *w = layout()->itemAt(i)->widget(); - if (w && w->pos().y() + w->height() / 2 < event->pos().y()) + if (w && w->pos().y() + w->height() / 2 < event->position().y()) newIndex = i; } @@ -137,7 +139,7 @@ void LXQtGroupPopup::leaveEvent(QEvent * /*event*/) /************************************************ * ************************************************/ -void LXQtGroupPopup::enterEvent(QEvent * /*event*/) +void LXQtGroupPopup::enterEvent(QEnterEvent * /*event*/) { mCloseTimer.stop(); } @@ -164,6 +166,16 @@ void LXQtGroupPopup::show() QFrame::show(); } +int LXQtGroupPopup::indexOf(LXQtTaskButton *button) +{ + return layout()->indexOf(button); +} + +void LXQtGroupPopup::addButton(LXQtTaskButton *button) +{ + layout()->addWidget(button); +} + void LXQtGroupPopup::closeTimerSlot() { bool button_has_dnd_hover = false; diff --git a/plugin-taskbar/lxqtgrouppopup.h b/plugin-taskbar/lxqtgrouppopup.h index 515236c79..5db42339e 100644 --- a/plugin-taskbar/lxqtgrouppopup.h +++ b/plugin-taskbar/lxqtgrouppopup.h @@ -37,9 +37,8 @@ #include #include -#include "lxqttaskbutton.h" -#include "lxqttaskgroup.h" -#include "lxqttaskbar.h" +class LXQtTaskButton; +class LXQtTaskGroup; class LXQtGroupPopup: public QFrame { @@ -53,11 +52,11 @@ class LXQtGroupPopup: public QFrame void show(); // Layout - int indexOf(LXQtTaskButton *button) { return layout()->indexOf(button); } + int indexOf(LXQtTaskButton *button); int count() { return layout()->count(); } QLayoutItem * itemAt(int i) { return layout()->itemAt(i); } int spacing() { return layout()->spacing(); } - void addButton(LXQtTaskButton* button) { layout()->addWidget(button); } + void addButton(LXQtTaskButton* button); void removeWidget(QWidget *button) { layout()->removeWidget(button); } protected: @@ -65,7 +64,7 @@ class LXQtGroupPopup: public QFrame void dragLeaveEvent(QDragLeaveEvent *event); void dropEvent(QDropEvent * event); void leaveEvent(QEvent * event); - void enterEvent(QEvent * event); + void enterEvent(QEnterEvent *event); void paintEvent(QPaintEvent * event); void closeTimerSlot(); diff --git a/plugin-taskbar/lxqttaskbar.cpp b/plugin-taskbar/lxqttaskbar.cpp index 0138b4f79..5dfa289c9 100644 --- a/plugin-taskbar/lxqttaskbar.cpp +++ b/plugin-taskbar/lxqttaskbar.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -46,6 +45,11 @@ #include "lxqttaskbar.h" #include "lxqttaskgroup.h" +#include "../panel/pluginsettings.h" + +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool using namespace LXQt; @@ -78,7 +82,7 @@ LXQtTaskBar::LXQtTaskBar(ILXQtPanelPlugin *plugin, QWidget *parent) : setStyle(mStyle); mLayout = new LXQt::GridLayout(this); setLayout(mLayout); - mLayout->setMargin(0); + mLayout->setContentsMargins(QMargins()); mLayout->setStretch(LXQt::GridLayout::StretchHorizontal | LXQt::GridLayout::StretchVertical); realign(); @@ -131,9 +135,13 @@ bool LXQtTaskBar::acceptWindow(WId window) const if (info.state() & NET::SkipTaskbar) return false; + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "DesktopSwitch", "Expected X11 connection"); + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + // WM_TRANSIENT_FOR hint not set - normal window WId transFor = info.transientFor(); - if (transFor == 0 || transFor == window || transFor == (WId) QX11Info::appRootWindow()) + if (transFor == 0 || transFor == window || transFor == appRootWindow) return true; info = KWindowInfo(transFor, NET::WMWindowType); @@ -154,7 +162,7 @@ void LXQtTaskBar::dragEnterEvent(QDragEnterEvent* event) if (event->mimeData()->hasFormat(LXQtTaskGroup::mimeDataFormat())) { event->acceptProposedAction(); - buttonMove(nullptr, qobject_cast(event->source()), event->pos()); + buttonMove(nullptr, qobject_cast(event->source()), event->position().toPoint()); } else event->ignore(); QWidget::dragEnterEvent(event); @@ -166,7 +174,7 @@ void LXQtTaskBar::dragEnterEvent(QDragEnterEvent* event) void LXQtTaskBar::dragMoveEvent(QDragMoveEvent * event) { //we don't get any dragMoveEvents if dragEnter wasn't accepted - buttonMove(nullptr, qobject_cast(event->source()), event->pos()); + buttonMove(nullptr, qobject_cast(event->source()), event->position().toPoint()); QWidget::dragMoveEvent(event); } diff --git a/plugin-taskbar/lxqttaskbar.h b/plugin-taskbar/lxqttaskbar.h index 5b2e79e7a..03e2bd0d2 100644 --- a/plugin-taskbar/lxqttaskbar.h +++ b/plugin-taskbar/lxqttaskbar.h @@ -34,22 +34,23 @@ #include "../panel/ilxqtpanel.h" #include "../panel/ilxqtpanelplugin.h" -#include "lxqttaskbarconfiguration.h" -#include "lxqttaskgroup.h" -#include "lxqttaskbutton.h" #include #include #include #include #include "../panel/ilxqtpanel.h" -#include -#include -#include +#include +#include +#include class QSignalMapper; + class LXQtTaskButton; +class LXQtTaskGroup; + class ElidedButtonStyle; +class LeftAlignedTextStyle; namespace LXQt { class GridLayout; diff --git a/plugin-taskbar/lxqttaskbarconfiguration.cpp b/plugin-taskbar/lxqttaskbarconfiguration.cpp index 267d20e8c..b346bb69d 100644 --- a/plugin-taskbar/lxqttaskbarconfiguration.cpp +++ b/plugin-taskbar/lxqttaskbarconfiguration.cpp @@ -29,7 +29,7 @@ #include "lxqttaskbarconfiguration.h" #include "ui_lxqttaskbarconfiguration.h" -#include +#include LXQtTaskbarConfiguration::LXQtTaskbarConfiguration(PluginSettings *settings, QWidget *parent): LXQtPanelPluginConfigDialog(settings, parent), diff --git a/plugin-taskbar/lxqttaskbarplugin.cpp b/plugin-taskbar/lxqttaskbarplugin.cpp index 51dc41456..ae8af1403 100644 --- a/plugin-taskbar/lxqttaskbarplugin.cpp +++ b/plugin-taskbar/lxqttaskbarplugin.cpp @@ -28,6 +28,8 @@ #include "lxqttaskbarplugin.h" +#include "lxqttaskbarconfiguration.h" + LXQtTaskBarPlugin::LXQtTaskBarPlugin(const ILXQtPanelPluginStartupInfo &startupInfo): QObject(), ILXQtPanelPlugin(startupInfo) diff --git a/plugin-taskbar/lxqttaskbutton.cpp b/plugin-taskbar/lxqttaskbutton.cpp index 8c63d4db1..bd6df460f 100644 --- a/plugin-taskbar/lxqttaskbutton.cpp +++ b/plugin-taskbar/lxqttaskbutton.cpp @@ -47,17 +47,19 @@ #include #include #include -#include #include #include "lxqttaskbutton.h" #include "lxqttaskgroup.h" #include "lxqttaskbar.h" -#include +#include // Necessary for closeApplication() -#include -#include +#include + +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool bool LXQtTaskButton::sDraggging = false; @@ -115,8 +117,18 @@ LXQtTaskButton::LXQtTaskButton(const WId window, LXQtTaskBar * taskbar, QWidget mWheelDelta = 0; // forget previous wheel deltas }); - setUrgencyHint(NETWinInfo(QX11Info::connection(), mWindow, QX11Info::appRootWindow(), NET::Properties{}, NET::WM2Urgency).urgency() - || KWindowInfo{mWindow, NET::WMState}.hasState(NET::DemandsAttention)); + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + setUrgencyHint(NETWinInfo(x11Application->connection(), mWindow, appRootWindow, NET::Properties{}, NET::WM2Urgency).urgency() + || KWindowInfo{mWindow, NET::WMState}.hasState(NET::DemandsAttention)); + } + else + { + qWarning() << "LXQtTaskBar: not implemented on Wayland"; + } + connect(LXQt::Settings::globalSettings(), &LXQt::GlobalSettings::iconThemeChanged, this, &LXQtTaskButton::updateIcon); connect(mParentTaskBar, &LXQtTaskBar::iconByClassChanged, this, &LXQtTaskButton::updateIcon); @@ -164,7 +176,21 @@ void LXQtTaskButton::refreshIconGeometry(QRect const & geom) // NOTE: This function announces where the task icon is, // such that X11 WMs can perform their related animations correctly. - xcb_connection_t* x11conn = QX11Info::connection(); + WId appRootWindow = 0; + xcb_connection_t* x11conn = nullptr; + + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + appRootWindow = XDefaultRootWindow(x11Application->display()); + x11conn = x11Application->connection(); + } + else + { + //qWarning() << "LXQtTaskBar: not implemented on Wayland"; + return; + } + if (!x11conn) { return; @@ -172,7 +198,7 @@ void LXQtTaskButton::refreshIconGeometry(QRect const & geom) NETWinInfo info(x11conn, windowId(), - (WId) QX11Info::appRootWindow(), + appRootWindow, NET::WMIconGeometry, NET::Properties2()); NETRect const curr = info.iconGeometry(); @@ -223,7 +249,7 @@ void LXQtTaskButton::dragEnterEvent(QDragEnterEvent *event) event->acceptProposedAction(); if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dragging(event->source(), event->pos()); + emit dragging(event->source(), event->position().toPoint()); setAttribute(Qt::WA_UnderMouse, false); } else { @@ -237,7 +263,7 @@ void LXQtTaskButton::dragMoveEvent(QDragMoveEvent * event) { if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dragging(event->source(), event->pos()); + emit dragging(event->source(), event->position().toPoint()); setAttribute(Qt::WA_UnderMouse, false); } } @@ -253,7 +279,7 @@ void LXQtTaskButton::dropEvent(QDropEvent *event) mDNDTimer->stop(); if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dropped(event->source(), event->pos()); + emit dropped(event->source(), event->position().toPoint()); setAttribute(Qt::WA_UnderMouse, false); } QToolButton::dropEvent(event); @@ -366,7 +392,7 @@ void LXQtTaskButton::mouseMoveEvent(QMouseEvent* event) if (!(event->buttons() & Qt::LeftButton)) return; - if ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()) + if ((event->position().toPoint() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()) return; QDrag *drag = new QDrag(this); @@ -395,7 +421,9 @@ void LXQtTaskButton::mouseMoveEvent(QMouseEvent* event) // release mouse appropriately, by positioning the event outside // the button rectangle (otherwise, the button will be toggled) - QMouseEvent releasingEvent(QEvent::MouseButtonRelease, QPoint(-1,-1), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent releasingEvent(QEvent::MouseButtonRelease, + QPoint(-1,-1), mapToGlobal(QPoint(-1, -1)), + Qt::LeftButton, Qt::NoButton, Qt::NoModifier); mouseReleaseEvent(&releasingEvent); sDraggging = false; @@ -461,15 +489,15 @@ void LXQtTaskButton::maximizeApplication() switch (state) { case NET::MaxHoriz: - KWindowSystem::setState(mWindow, NET::MaxHoriz); + KX11Extras::setState(mWindow, NET::MaxHoriz); break; case NET::MaxVert: - KWindowSystem::setState(mWindow, NET::MaxVert); + KX11Extras::setState(mWindow, NET::MaxVert); break; default: - KWindowSystem::setState(mWindow, NET::Max); + KX11Extras::setState(mWindow, NET::Max); break; } @@ -482,7 +510,7 @@ void LXQtTaskButton::maximizeApplication() ************************************************/ void LXQtTaskButton::deMaximizeApplication() { - KWindowSystem::clearState(mWindow, NET::Max); + KX11Extras::clearState(mWindow, NET::Max); if (!isApplicationActive()) raiseApplication(); @@ -493,7 +521,7 @@ void LXQtTaskButton::deMaximizeApplication() ************************************************/ void LXQtTaskButton::shadeApplication() { - KWindowSystem::setState(mWindow, NET::Shaded); + KX11Extras::setState(mWindow, NET::Shaded); } /************************************************ @@ -501,7 +529,7 @@ void LXQtTaskButton::shadeApplication() ************************************************/ void LXQtTaskButton::unShadeApplication() { - KWindowSystem::clearState(mWindow, NET::Shaded); + KX11Extras::clearState(mWindow, NET::Shaded); } /************************************************ @@ -509,8 +537,16 @@ void LXQtTaskButton::unShadeApplication() ************************************************/ void LXQtTaskButton::closeApplication() { - // FIXME: Why there is no such thing in KWindowSystem?? - NETRootInfo(QX11Info::connection(), NET::CloseWindow).closeWindowRequest(mWindow); + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + // FIXME: Why there is no such thing in KX11Extras?? + NETRootInfo(x11Application->connection(), NET::CloseWindow).closeWindowRequest(mWindow); + } + else + { + qWarning() << "LXQtTaskBar: not implemented on Wayland"; + } } /************************************************ @@ -526,18 +562,18 @@ void LXQtTaskButton::setApplicationLayer() switch(layer) { case NET::KeepAbove: - KWindowSystem::clearState(mWindow, NET::KeepBelow); - KWindowSystem::setState(mWindow, NET::KeepAbove); + KX11Extras::clearState(mWindow, NET::KeepBelow); + KX11Extras::setState(mWindow, NET::KeepAbove); break; case NET::KeepBelow: - KWindowSystem::clearState(mWindow, NET::KeepAbove); - KWindowSystem::setState(mWindow, NET::KeepBelow); + KX11Extras::clearState(mWindow, NET::KeepAbove); + KX11Extras::setState(mWindow, NET::KeepBelow); break; default: - KWindowSystem::clearState(mWindow, NET::KeepBelow); - KWindowSystem::clearState(mWindow, NET::KeepAbove); + KX11Extras::clearState(mWindow, NET::KeepBelow); + KX11Extras::clearState(mWindow, NET::KeepAbove); break; } } @@ -608,11 +644,22 @@ void LXQtTaskButton::moveApplicationToPrevNextMonitor(bool next) NET::States state = KWindowInfo(mWindow, NET::WMState).state(); // NW geometry | y/x | from panel const int flags = 1 | (0b011 << 8) | (0b010 << 12); - KWindowSystem::clearState(mWindow, NET::MaxHoriz | NET::MaxVert | NET::Max | NET::FullScreen); - NETRootInfo(QX11Info::connection(), NET::Properties(), NET::WM2MoveResizeWindow).moveResizeWindowRequest(mWindow, flags, X, Y, 0, 0); + KX11Extras::clearState(mWindow, NET::MaxHoriz | NET::MaxVert | NET::Max | NET::FullScreen); + + + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + NETRootInfo(x11Application->connection(), NET::Properties(), NET::WM2MoveResizeWindow).moveResizeWindowRequest(mWindow, flags, X, Y, 0, 0); + } + else + { + //qWarning() << "LXQtTaskBar: not implemented on Wayland"; + } + QTimer::singleShot(200, this, [this, state] { - KWindowSystem::setState(mWindow, state); + KX11Extras::setState(mWindow, state); raiseApplication(); }); break; @@ -636,7 +683,16 @@ void LXQtTaskButton::moveApplication() int X = g.center().x(); int Y = g.center().y(); QCursor::setPos(X, Y); - NETRootInfo(QX11Info::connection(), NET::WMMoveResize).moveResizeRequest(mWindow, X, Y, NET::Move); + + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + NETRootInfo(x11Application->connection(), NET::WMMoveResize).moveResizeRequest(mWindow, X, Y, NET::Move); + } + else + { + //qWarning() << "LXQtTaskBar: not implemented on Wayland"; + } } /************************************************ @@ -654,7 +710,16 @@ void LXQtTaskButton::resizeApplication() int X = g.bottomRight().x(); int Y = g.bottomRight().y(); QCursor::setPos(X, Y); - NETRootInfo(QX11Info::connection(), NET::WMMoveResize).moveResizeRequest(mWindow, X, Y, NET::BottomRight); + + auto *x11Application = qGuiApp->nativeInterface(); + if(x11Application) + { + NETRootInfo(x11Application->connection(), NET::WMMoveResize).moveResizeRequest(mWindow, X, Y, NET::BottomRight); + } + else + { + //qWarning() << "LXQtTaskBar: not implemented on Wayland"; + } } /************************************************ @@ -849,7 +914,11 @@ bool LXQtTaskButton::isOnDesktop(int desktop) const bool LXQtTaskButton::isOnCurrentScreen() const { - return QApplication::desktop()->screenGeometry(parentTaskBar()).intersects(KWindowInfo(mWindow, NET::WMFrameExtents).frameGeometry()); + QScreen *screen = parentTaskBar()->screen(); + QRect screenGeo = screen->geometry(); + QRect windowGeo = KWindowInfo(mWindow, NET::WMFrameExtents).frameGeometry(); + + return screenGeo.intersects(windowGeo); } bool LXQtTaskButton::isMinimized() const diff --git a/plugin-taskbar/lxqttaskgroup.cpp b/plugin-taskbar/lxqttaskgroup.cpp index b7dd7236e..e192baabf 100644 --- a/plugin-taskbar/lxqttaskgroup.cpp +++ b/plugin-taskbar/lxqttaskgroup.cpp @@ -30,6 +30,7 @@ #include "lxqttaskgroup.h" #include "lxqttaskbar.h" +#include "lxqtgrouppopup.h" #include #include @@ -38,10 +39,12 @@ #include #include #include -#include -#include #include +#include //For nativeInterface() +#include +#include + /************************************************ ************************************************/ @@ -96,7 +99,7 @@ void LXQtTaskGroup::contextMenuEvent(QContextMenuEvent *event) ************************************************/ void LXQtTaskGroup::closeGroup() { - for (LXQtTaskButton *button : qAsConst(mButtonHash) ) + for (LXQtTaskButton *button : std::as_const(mButtonHash) ) if (button->isOnDesktop(KX11Extras::currentDesktop())) button->closeApplication(); } @@ -132,7 +135,7 @@ LXQtTaskButton * LXQtTaskGroup::addWindow(WId id) ************************************************/ LXQtTaskButton * LXQtTaskGroup::checkedButton() const { - for (LXQtTaskButton* button : qAsConst(mButtonHash)) + for (LXQtTaskButton* button : std::as_const(mButtonHash)) if (button->isChecked()) return button; @@ -191,7 +194,7 @@ LXQtTaskButton * LXQtTaskGroup::getNextPrevChildButton(bool next, bool circular) void LXQtTaskGroup::onActiveWindowChanged(WId window) { LXQtTaskButton *button = mButtonHash.value(window, nullptr); - for (LXQtTaskButton *btn : qAsConst(mButtonHash)) + for (LXQtTaskButton *btn : std::as_const(mButtonHash)) btn->setChecked(false); if (button) @@ -283,7 +286,7 @@ int LXQtTaskGroup::buttonsCount() const int LXQtTaskGroup::visibleButtonsCount() const { int i = 0; - for (LXQtTaskButton *btn : qAsConst(mButtonHash)) + for (LXQtTaskButton *btn : std::as_const(mButtonHash)) if (btn->isVisibleTo(mPopup)) i++; return i; @@ -323,7 +326,7 @@ void LXQtTaskGroup::regroup() mSingleButton = true; // Get first visible button LXQtTaskButton * button = nullptr; - for (LXQtTaskButton *btn : qAsConst(mButtonHash)) + for (LXQtTaskButton *btn : std::as_const(mButtonHash)) { if (btn->isVisibleTo(mPopup)) { @@ -368,7 +371,7 @@ void LXQtTaskGroup::recalculateFrameIfVisible() ************************************************/ void LXQtTaskGroup::setAutoRotation(bool value, ILXQtPanel::Position position) { - for (LXQtTaskButton *button : qAsConst(mButtonHash)) + for (LXQtTaskButton *button : std::as_const(mButtonHash)) button->setAutoRotation(false, position); LXQtTaskButton::setAutoRotation(value, position); @@ -382,7 +385,7 @@ void LXQtTaskGroup::refreshVisibility() bool will = false; LXQtTaskBar const * taskbar = parentTaskBar(); const int showDesktop = taskbar->showDesktopNum(); - for(LXQtTaskButton * btn : qAsConst(mButtonHash)) + for(LXQtTaskButton * btn : std::as_const(mButtonHash)) { bool visible = taskbar->isShowOnlyOneDesktopTasks() ? btn->isOnDesktop(0 == showDesktop ? KX11Extras::currentDesktop() : showDesktop) : true; visible &= taskbar->isShowOnlyCurrentScreenTasks() ? btn->isOnCurrentScreen() : true; @@ -448,7 +451,7 @@ void LXQtTaskGroup::refreshIconsGeometry() return; } - for(LXQtTaskButton *but : qAsConst(mButtonHash)) + for(LXQtTaskButton *but : std::as_const(mButtonHash)) { but->refreshIconGeometry(rect); but->setIconSize(QSize(plugin()->panel()->iconSize(), plugin()->panel()->iconSize())); @@ -492,7 +495,7 @@ int LXQtTaskGroup::recalculateFrameWidth() const const QFontMetrics fm = fontMetrics(); int max = 100 * fm.horizontalAdvance(QLatin1Char(' ')); // elide after the max width int txtWidth = 0; - for (LXQtTaskButton *btn : qAsConst(mButtonHash)) + for (LXQtTaskButton *btn : std::as_const(mButtonHash)) txtWidth = qMax(fm.horizontalAdvance(btn->text()), txtWidth); return iconSize().width() + qMin(txtWidth, max) + 30/* give enough room to margins and borders*/; } @@ -538,7 +541,7 @@ void LXQtTaskGroup::leaveEvent(QEvent *event) /************************************************ ************************************************/ -void LXQtTaskGroup::enterEvent(QEvent *event) +void LXQtTaskGroup::enterEvent(QEnterEvent *event) { QToolButton::enterEvent(event); @@ -617,7 +620,7 @@ void LXQtTaskGroup::wheelEvent(QWheelEvent* event) bool LXQtTaskGroup::onWindowChanged(WId window, NET::Properties prop, NET::Properties2 prop2) { // returns true if the class is preserved bool needsRefreshVisibility{false}; - QVector buttons; + QList buttons; if (mButtonHash.contains(window)) buttons.append(mButtonHash.value(window)); @@ -657,18 +660,34 @@ bool LXQtTaskGroup::onWindowChanged(WId window, NET::Properties prop, NET::Prope bool set_urgency = false; bool urgency = false; + if (prop2.testFlag(NET::WM2Urgency)) { set_urgency = true; - urgency = NETWinInfo(QX11Info::connection(), window, QX11Info::appRootWindow(), NET::Properties{}, NET::WM2Urgency).urgency(); + if (auto *x11Application = qGuiApp->nativeInterface()) + { + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + urgency = NETWinInfo(x11Application->connection(), window, appRootWindow, NET::Properties{}, NET::WM2Urgency).urgency(); + } } if (prop.testFlag(NET::WMState)) { KWindowInfo info{window, NET::WMState}; - if (!set_urgency) - urgency = NETWinInfo(QX11Info::connection(), window, QX11Info::appRootWindow(), NET::Properties{}, NET::WM2Urgency).urgency(); + + if(!set_urgency) + { + if (auto *x11Application = qGuiApp->nativeInterface()) + { + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + urgency = NETWinInfo(x11Application->connection(), window, appRootWindow, NET::Properties{}, NET::WM2Urgency).urgency(); + } + } + + // Force refresh urgency + //TODO: maybe do it in common place with NET::WM2Urgency std::for_each(buttons.begin(), buttons.end(), std::bind(&LXQtTaskButton::setUrgencyHint, std::placeholders::_1, urgency || info.hasState(NET::DemandsAttention))); set_urgency = false; + if (info.hasState(NET::SkipTaskbar)) onWindowRemoved(window); diff --git a/plugin-taskbar/lxqttaskgroup.h b/plugin-taskbar/lxqttaskgroup.h index 88dcccb01..f1e7e2469 100644 --- a/plugin-taskbar/lxqttaskgroup.h +++ b/plugin-taskbar/lxqttaskgroup.h @@ -33,10 +33,9 @@ #include "../panel/ilxqtpanel.h" #include "../panel/ilxqtpanelplugin.h" -#include "lxqttaskbar.h" -#include "lxqtgrouppopup.h" + #include "lxqttaskbutton.h" -#include +#include class QVBoxLayout; class ILXQtPanelPlugin; @@ -77,7 +76,7 @@ public slots: QMimeData * mimeData(); void leaveEvent(QEvent * event); - void enterEvent(QEvent * event); + void enterEvent(QEnterEvent *event); void dragEnterEvent(QDragEnterEvent * event); void dragLeaveEvent(QDragLeaveEvent * event); void contextMenuEvent(QContextMenuEvent * event); diff --git a/plugin-tray/CMakeLists.txt b/plugin-tray/CMakeLists.txt index 424b463d4..a0541e226 100644 --- a/plugin-tray/CMakeLists.txt +++ b/plugin-tray/CMakeLists.txt @@ -4,15 +4,15 @@ include(CheckLibraryExists) find_package(XCB REQUIRED COMPONENTS - xcb - xcb-xfixes - xcb-damage - xcb-composite - xcb-randr - xcb-shm - xcb-util - xcb-image - xcb-shape + XCB + XFIXES + DAMAGE + COMPOSITE + RANDR + SHM + UTIL + IMAGE + SHAPE ) find_package(PkgConfig) pkg_check_modules(xtst REQUIRED xtst) diff --git a/plugin-tray/fdoselectionmanager.cpp b/plugin-tray/fdoselectionmanager.cpp index 2486257c8..4afab6716 100644 --- a/plugin-tray/fdoselectionmanager.cpp +++ b/plugin-tray/fdoselectionmanager.cpp @@ -30,11 +30,12 @@ #include #include #include -#include #include #include +#include // For nativeInterface() + #include #include #include @@ -43,14 +44,26 @@ #include "sniproxy.h" #include "xcbutils.h" +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool +#undef Status + #define SYSTEM_TRAY_REQUEST_DOCK 0 #define SYSTEM_TRAY_BEGIN_MESSAGE 1 #define SYSTEM_TRAY_CANCEL_MESSAGE 2 FdoSelectionManager::FdoSelectionManager() - : m_atoms{new Xcb::Atoms} - , m_selectionOwner{new KSelectionOwner{m_atoms->selectionAtom, -1, this}} + : m_atoms{nullptr} + , m_selectionOwner{nullptr} { + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "FdoSelectionManager", "Expected X11 connection"); + m_connection = x11Application->connection(); + + m_atoms.reset(new Xcb::Atoms(m_connection, XDefaultScreen(x11Application->display()))); + m_selectionOwner = new KSelectionOwner{m_atoms->selectionAtom, -1, this}; + qDebug() << "starting"; // we may end up calling QCoreApplication::quit() in this method, at which point we need the event loop running @@ -73,12 +86,11 @@ void FdoSelectionManager::init() qDBusRegisterMetaType(); // load damage extension - xcb_connection_t *c = QX11Info::connection(); - xcb_prefetch_extension_data(c, &xcb_damage_id); - const auto *reply = xcb_get_extension_data(c, &xcb_damage_id); + xcb_prefetch_extension_data(m_connection, &xcb_damage_id); + const auto *reply = xcb_get_extension_data(m_connection, &xcb_damage_id); if (reply && reply->present) { m_damageEventBase = reply->first_event; - xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); + xcb_damage_query_version_unchecked(m_connection, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); } else { // no XDamage means qCritical() << "could not load damage extension. Quitting"; @@ -97,18 +109,17 @@ bool FdoSelectionManager::addDamageWatch(xcb_window_t client) { qDebug() << "adding damage watch for " << client; - xcb_connection_t *c = QX11Info::connection(); - const auto attribsCookie = xcb_get_window_attributes_unchecked(c, client); + const auto attribsCookie = xcb_get_window_attributes_unchecked(m_connection, client); - const auto damageId = xcb_generate_id(c); + const auto damageId = xcb_generate_id(m_connection); m_damageWatches[client] = damageId; - xcb_damage_create(c, damageId, client, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY); + xcb_damage_create(m_connection, damageId, client, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY); xcb_generic_error_t *error = nullptr; - QScopedPointer attr(xcb_get_window_attributes_reply(c, attribsCookie, &error)); - QScopedPointer getAttrError(error); + Xcb::ScopedCPointer attr(xcb_get_window_attributes_reply(m_connection, attribsCookie, &error)); + Xcb::ScopedCPointer getAttrError(error); uint32_t events = XCB_EVENT_MASK_STRUCTURE_NOTIFY; - if (!attr.isNull()) { + if (attr) { events = events | attr->your_event_mask; } // if window is already gone, there is no need to handle it. @@ -117,8 +128,8 @@ bool FdoSelectionManager::addDamageWatch(xcb_window_t client) } // the event mask will not be removed again. We cannot track whether another component also needs STRUCTURE_NOTIFY (e.g. KWindowSystem). // if we would remove the event mask again, other areas will break. - const auto changeAttrCookie = xcb_change_window_attributes_checked(c, client, XCB_CW_EVENT_MASK, &events); - QScopedPointer changeAttrError(xcb_request_check(c, changeAttrCookie)); + const auto changeAttrCookie = xcb_change_window_attributes_checked(m_connection, client, XCB_CW_EVENT_MASK, &events); + Xcb::ScopedCPointer changeAttrError(xcb_request_check(m_connection, changeAttrCookie)); // if window is gone by this point, it will be caught by eventFilter, so no need to check later errors. if (changeAttrError && changeAttrError->error_code == XCB_WINDOW) { return false; @@ -127,7 +138,7 @@ bool FdoSelectionManager::addDamageWatch(xcb_window_t client) return true; } -bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) +bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) { Q_UNUSED(result) @@ -162,7 +173,7 @@ bool FdoSelectionManager::nativeEventFilter(const QByteArray &eventType, void *m const auto sniProxy = m_proxies.value(damagedWId); if (sniProxy) { sniProxy->update(); - xcb_damage_subtract(QX11Info::connection(), m_damageWatches[damagedWId], XCB_NONE, XCB_NONE); + xcb_damage_subtract(m_connection, m_damageWatches[damagedWId], XCB_NONE, XCB_NONE); } } else if (responseType == XCB_CONFIGURE_REQUEST) { const auto event = reinterpret_cast(ev); @@ -211,7 +222,7 @@ void FdoSelectionManager::undock(xcb_window_t winId, bool vanished) auto d_i = m_damageWatches.find(winId); if (d_i != m_damageWatches.end()) { if (!vanished) { - xcb_damage_destroy(QX11Info::connection(), *d_i); + xcb_damage_destroy(m_connection, *d_i); } m_damageWatches.erase(d_i); } @@ -239,8 +250,7 @@ void FdoSelectionManager::onLostOwnership() void FdoSelectionManager::setSystemTrayVisual() { - xcb_connection_t *c = QX11Info::connection(); - auto screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data; + auto screen = xcb_setup_roots_iterator(xcb_get_setup(m_connection)).data; auto trayVisual = screen->root_visual; xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen); xcb_depth_t *depth = nullptr; @@ -265,5 +275,5 @@ void FdoSelectionManager::setSystemTrayVisual() } } - xcb_change_property(c, XCB_PROP_MODE_REPLACE, m_selectionOwner->ownerWindow(), m_atoms->visualAtom, XCB_ATOM_VISUALID, 32, 1, &trayVisual); + xcb_change_property(m_connection, XCB_PROP_MODE_REPLACE, m_selectionOwner->ownerWindow(), m_atoms->visualAtom, XCB_ATOM_VISUALID, 32, 1, &trayVisual); } diff --git a/plugin-tray/fdoselectionmanager.h b/plugin-tray/fdoselectionmanager.h index b0bee5c1b..00e71e3f4 100644 --- a/plugin-tray/fdoselectionmanager.h +++ b/plugin-tray/fdoselectionmanager.h @@ -49,7 +49,7 @@ class FdoSelectionManager : public QObject, public QAbstractNativeEventFilter ~FdoSelectionManager() override; protected: - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; private Q_SLOTS: void onClaimedOwnership(); @@ -65,6 +65,7 @@ private Q_SLOTS: uint8_t m_damageEventBase; + xcb_connection_t *m_connection; QHash m_damageWatches; QHash m_proxies; std::unique_ptr m_atoms; diff --git a/plugin-tray/lxqttrayplugin.cpp b/plugin-tray/lxqttrayplugin.cpp index 3c906fd8d..a21c72e2e 100644 --- a/plugin-tray/lxqttrayplugin.cpp +++ b/plugin-tray/lxqttrayplugin.cpp @@ -29,6 +29,8 @@ #include "lxqttrayplugin.h" #include "fdoselectionmanager.h" +#include // For nativeInterface() + LXQtTrayPlugin::LXQtTrayPlugin(const ILXQtPanelPluginStartupInfo &startupInfo) : QObject() , ILXQtPanelPlugin(startupInfo) @@ -44,3 +46,16 @@ QWidget *LXQtTrayPlugin::widget() { return nullptr; } + +ILXQtPanelPlugin *LXQtTrayPluginLibrary::instance(const ILXQtPanelPluginStartupInfo &startupInfo) const +{ + auto *x11Application = qGuiApp->nativeInterface(); + if(!x11Application || !x11Application->connection()) + { + // Currently only X11 supported + qWarning() << "Currently tray plugin supports X11 only. Skipping."; + return nullptr; + } + + return new LXQtTrayPlugin(startupInfo); +} diff --git a/plugin-tray/lxqttrayplugin.h b/plugin-tray/lxqttrayplugin.h index e8ddd78c0..3bdc6948f 100644 --- a/plugin-tray/lxqttrayplugin.h +++ b/plugin-tray/lxqttrayplugin.h @@ -29,9 +29,10 @@ #pragma once #include "../panel/ilxqtpanelplugin.h" -#include + #include -#include + +#include class FdoSelectionManager; class LXQtTrayPlugin : public QObject, public ILXQtPanelPlugin @@ -58,13 +59,5 @@ class LXQtTrayPluginLibrary: public QObject, public ILXQtPanelPluginLibrary // Q_PLUGIN_METADATA(IID "lxqt.org/Panel/PluginInterface/3.0") Q_INTERFACES(ILXQtPanelPluginLibrary) public: - ILXQtPanelPlugin *instance(const ILXQtPanelPluginStartupInfo &startupInfo) const - { - // Currently only X11 supported - if (!QX11Info::connection()) { - qWarning() << "Currently tray plugin supports X11 only. Skipping."; - return nullptr; - } - return new LXQtTrayPlugin(startupInfo); - } + ILXQtPanelPlugin *instance(const ILXQtPanelPluginStartupInfo &startupInfo) const; }; diff --git a/plugin-tray/snidbus.h b/plugin-tray/snidbus.h index f05a7465d..2ee79821d 100644 --- a/plugin-tray/snidbus.h +++ b/plugin-tray/snidbus.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include // Custom message type for DBus struct KDbusImageStruct { @@ -41,7 +41,7 @@ struct KDbusImageStruct { QByteArray data; }; -typedef QVector KDbusImageVector; +typedef QList KDbusImageVector; struct KDbusToolTipStruct { QString icon; diff --git a/plugin-tray/sniproxy.cpp b/plugin-tray/sniproxy.cpp index a0c732147..9fbe924b4 100644 --- a/plugin-tray/sniproxy.cpp +++ b/plugin-tray/sniproxy.cpp @@ -28,27 +28,34 @@ #include "sniproxy.h" #include -#include -#include - -#include "xcbutils.h" #include #include #include #include -#include #include #include #include +#include "kwindowinfo.h" #include "statusnotifieritemadaptor.h" #include "statusnotifierwatcher_interface.h" #include "xtestsender.h" + +#include +#include + +#include "xcbutils.h" + +//NOTE: Xlib.h defines Bool which conflicts with QJsonValue::Type enum +#include +#undef Bool +#undef Status + //#define VISUAL_DEBUG #define SNI_WATCHER_SERVICE_NAME "org.kde.StatusNotifierWatcher" @@ -59,7 +66,7 @@ static unsigned int XEMBED_VERSION = 0; int SNIProxy::s_serviceCount = 0; -void xembed_message_send(Xcb::Atoms & atoms, xcb_window_t towin, long message, long d1, long d2, long d3) +void xembed_message_send(xcb_connection_t *conn, Xcb::Atoms & atoms, xcb_window_t towin, long message, long d1, long d2, long d3) { xcb_client_message_event_t ev; @@ -72,7 +79,7 @@ void xembed_message_send(Xcb::Atoms & atoms, xcb_window_t towin, long message, l ev.data.data32[3] = d2; ev.data.data32[4] = d3; ev.type = atoms.xembedAtom; - xcb_send_event(QX11Info::connection(), false, towin, XCB_EVENT_MASK_NO_EVENT, (char *)&ev); + xcb_send_event(conn, false, towin, XCB_EVENT_MASK_NO_EVENT, (char *)&ev); } static QRect findOpaqueArea(const QImage & image, int margin = 0) @@ -103,11 +110,16 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) // there is an undocumented feature that you can register an SNI by path, however it doesn't detect an object on a service being removed, only the entire // service closing instead lets use one DBus connection per SNI m_dbus(QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("XembedSniProxy%1").arg(s_serviceCount++))) + , m_connection(nullptr) , m_windowId(wid) , sendingClickEvent(false) , m_injectMode(Direct) , m_atoms{atoms} { + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "SNIProxy", "Expected X11 connection"); + m_connection = x11Application->connection(); + resizeWindow(s_embedSize, s_embedSize); // create new SNI @@ -122,11 +134,9 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) qWarning() << "could not register SNI:" << reply.error().message(); } - auto c = QX11Info::connection(); - // create a container window - auto screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data; - m_containerWid = xcb_generate_id(c); + auto screen = xcb_setup_roots_iterator(xcb_get_setup(m_connection)).data; + m_containerWid = xcb_generate_id(m_connection); uint32_t values[3]; uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; values[0] = screen->black_pixel; // draw a solid background so the embedded icon doesn't get garbage in it @@ -134,7 +144,7 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) values[2] = XCB_EVENT_MASK_VISIBILITY_CHANGE | // receive visibility change, to handle KWin restart #357443 // Redirect and handle structure (size, position) requests from the embedded window. XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; - xcb_create_window(c, /* connection */ + xcb_create_window(m_connection, /* connection */ XCB_COPY_FROM_PARENT, /* depth */ m_containerWid, /* window Id */ screen->root, /* parent window */ @@ -163,42 +173,42 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) #ifndef VISUAL_DEBUG stackContainerWindow(XCB_STACK_MODE_BELOW); - NETWinInfo wm(c, m_containerWid, screen->root, NET::Properties(), NET::Properties2()); + NETWinInfo wm(m_connection, m_containerWid, screen->root, NET::Properties(), NET::Properties2()); wm.setOpacity(0); #endif - xcb_flush(c); + xcb_flush(m_connection); - xcb_map_window(c, m_containerWid); + xcb_map_window(m_connection, m_containerWid); - xcb_reparent_window(c, m_windowId, m_containerWid, 0, 0); + xcb_reparent_window(m_connection, m_windowId, m_containerWid, 0, 0); /* * Render the embedded window offscreen */ - xcb_composite_redirect_window(c, m_windowId, XCB_COMPOSITE_REDIRECT_MANUAL); + xcb_composite_redirect_window(m_connection, m_windowId, XCB_COMPOSITE_REDIRECT_MANUAL); /* we grab the window, but also make sure it's automatically reparented back * to the root window if we should die. */ - xcb_change_save_set(c, XCB_SET_MODE_INSERT, m_windowId); + xcb_change_save_set(m_connection, XCB_SET_MODE_INSERT, m_windowId); // tell client we're embedding it - xembed_message_send(m_atoms, m_windowId, XEMBED_EMBEDDED_NOTIFY, 0, m_containerWid, XEMBED_VERSION); + xembed_message_send(m_connection, m_atoms, m_windowId, XEMBED_EMBEDDED_NOTIFY, 0, m_containerWid, XEMBED_VERSION); // move window we're embedding const uint32_t windowMoveConfigVals[2] = {0, 0}; - xcb_configure_window(c, m_windowId, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, windowMoveConfigVals); + xcb_configure_window(m_connection, m_windowId, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, windowMoveConfigVals); QSize clientWindowSize = calculateClientWindowSize(); // show the embedded window otherwise nothing happens - xcb_map_window(c, m_windowId); + xcb_map_window(m_connection, m_windowId); - xcb_clear_area(c, 0, m_windowId, 0, 0, clientWindowSize.width(), clientWindowSize.height()); + xcb_clear_area(m_connection, 0, m_windowId, 0, 0, clientWindowSize.width(), clientWindowSize.height()); - xcb_flush(c); + xcb_flush(m_connection); // guess which input injection method to use // we can either send an X event to the client or XTest @@ -207,8 +217,8 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) // we query if the client selected button presses in the event mask // if the client does supports that we send directly, otherwise we'll use xtest - auto waCookie = xcb_get_window_attributes(c, m_windowId); - QScopedPointer windowAttributes(xcb_get_window_attributes_reply(c, waCookie, nullptr)); + auto waCookie = xcb_get_window_attributes(m_connection, m_windowId); + Xcb::ScopedCPointer windowAttributes(xcb_get_window_attributes_reply(m_connection, waCookie, nullptr)); if (windowAttributes && !(windowAttributes->all_event_masks & XCB_EVENT_MASK_BUTTON_PRESS)) { m_injectMode = XTest; } @@ -221,12 +231,15 @@ SNIProxy::SNIProxy(xcb_window_t wid, Xcb::Atoms & atoms, QObject *parent) SNIProxy::~SNIProxy() { - auto c = QX11Info::connection(); + auto *x11Application = qGuiApp->nativeInterface(); + Q_ASSERT_X(x11Application, "SNIProxy", "Expected X11 connection"); + + WId appRootWindow = XDefaultRootWindow(x11Application->display()); if (!m_vanished) { - xcb_reparent_window(c, m_windowId, QX11Info::appRootWindow(), 0, 0); + xcb_reparent_window(m_connection, m_windowId, appRootWindow, 0, 0); } - xcb_destroy_window(c, m_containerWid); + xcb_destroy_window(m_connection, m_containerWid); QDBusConnection::disconnectFromBus(m_dbus.name()); } @@ -246,12 +259,10 @@ void SNIProxy::update() void SNIProxy::resizeWindow(const uint16_t width, const uint16_t height) const { - auto connection = QX11Info::connection(); - const uint32_t windowSizeConfigVals[2] = {width, height}; - xcb_configure_window(connection, m_windowId, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, windowSizeConfigVals); + xcb_configure_window(m_connection, m_windowId, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, windowSizeConfigVals); - xcb_flush(connection); + xcb_flush(m_connection); } void SNIProxy::hideContainerWindow(xcb_window_t windowId) const @@ -264,10 +275,8 @@ void SNIProxy::hideContainerWindow(xcb_window_t windowId) const QSize SNIProxy::calculateClientWindowSize() const { - auto c = QX11Info::connection(); - - auto cookie = xcb_get_geometry(c, m_windowId); - QScopedPointer clientGeom(xcb_get_geometry_reply(c, cookie, nullptr)); + auto cookie = xcb_get_geometry(m_connection, m_windowId); + Xcb::ScopedCPointer clientGeom(xcb_get_geometry_reply(m_connection, cookie, nullptr)); QSize clientWindowSize; if (clientGeom) { @@ -318,11 +327,9 @@ bool SNIProxy::isTransparentImage(const QImage &image) const QImage SNIProxy::getImageNonComposite() const { - auto c = QX11Info::connection(); - QSize clientWindowSize = calculateClientWindowSize(); - xcb_image_t *image = xcb_image_get(c, m_windowId, 0, 0, clientWindowSize.width(), clientWindowSize.height(), 0xFFFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); + xcb_image_t *image = xcb_image_get(m_connection, m_windowId, 0, 0, clientWindowSize.width(), clientWindowSize.height(), 0xFFFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); // Don't hook up cleanup yet, we may use a different QImage after all QImage naiveConversion; @@ -393,7 +400,7 @@ QImage SNIProxy::convertFromNative(xcb_image_t *xcbImage) const if (format == QImage::Format_RGB32 && xcbImage->bpp == 32) { QImage m = image.createHeuristicMask(); - QBitmap mask(QPixmap::fromImage(m)); + QBitmap mask = QBitmap::fromImage(m); QPixmap p = QPixmap::fromImage(image); p.setMask(mask); image = p.toImage(); @@ -417,15 +424,13 @@ QPoint SNIProxy::calculateClickPoint() const { QPoint clickPoint = QPoint(0, 0); - auto c = QX11Info::connection(); - // request extent to check if shape has been set - xcb_shape_query_extents_cookie_t extentsCookie = xcb_shape_query_extents(c, m_windowId); + xcb_shape_query_extents_cookie_t extentsCookie = xcb_shape_query_extents(m_connection, m_windowId); // at the same time make the request for rectangles (even if this request isn't needed) - xcb_shape_get_rectangles_cookie_t rectaglesCookie = xcb_shape_get_rectangles(c, m_windowId, XCB_SHAPE_SK_BOUNDING); + xcb_shape_get_rectangles_cookie_t rectaglesCookie = xcb_shape_get_rectangles(m_connection, m_windowId, XCB_SHAPE_SK_BOUNDING); - QScopedPointer extentsReply(xcb_shape_query_extents_reply(c, extentsCookie, nullptr)); - QScopedPointer rectanglesReply(xcb_shape_get_rectangles_reply(c, rectaglesCookie, nullptr)); + Xcb::ScopedCPointer extentsReply(xcb_shape_query_extents_reply(m_connection, extentsCookie, nullptr)); + Xcb::ScopedCPointer rectanglesReply(xcb_shape_get_rectangles_reply(m_connection, rectaglesCookie, nullptr)); if (!extentsReply || !rectanglesReply || !extentsReply->bounding_shaped) { return clickPoint; @@ -452,9 +457,8 @@ QPoint SNIProxy::calculateClickPoint() const void SNIProxy::stackContainerWindow(const uint32_t stackMode) const { - auto c = QX11Info::connection(); const uint32_t stackData[] = {stackMode}; - xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData); + xcb_configure_window(m_connection, m_containerWid, XCB_CONFIG_WINDOW_STACK_MODE, stackData); } //____________properties__________ @@ -548,17 +552,15 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y) qDebug() << "Received click" << mouseButton << "with passed x*y" << x << y; sendingClickEvent = true; - auto c = QX11Info::connection(); - - auto cookieSize = xcb_get_geometry(c, m_windowId); - QScopedPointer clientGeom(xcb_get_geometry_reply(c, cookieSize, nullptr)); + auto cookieSize = xcb_get_geometry(m_connection, m_windowId); + Xcb::ScopedCPointer clientGeom(xcb_get_geometry_reply(m_connection, cookieSize, nullptr)); if (!clientGeom) { return; } - auto cookie = xcb_query_pointer(c, m_windowId); - QScopedPointer pointer(xcb_query_pointer_reply(c, cookie, nullptr)); + auto cookie = xcb_query_pointer(m_connection, m_windowId); + Xcb::ScopedCPointer pointer(xcb_query_pointer_reply(m_connection, cookie, nullptr)); /*qDebug() << "samescreen" << pointer->same_screen << endl << "root x*y" << pointer->root_x << pointer->root_y << endl << "win x*y" << pointer->win_x << pointer->win_y;*/ @@ -580,20 +582,23 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y) else configVals[1] = static_cast(y - clickPoint.y()); } - xcb_configure_window(c, m_containerWid, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, configVals); + xcb_configure_window(m_connection, m_containerWid, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, configVals); // pull window up stackContainerWindow(XCB_STACK_MODE_ABOVE); + auto *x11Application = qGuiApp->nativeInterface(); + WId appRootWindow = XDefaultRootWindow(x11Application->display()); + // mouse down if (m_injectMode == Direct) { xcb_button_press_event_t *event = new xcb_button_press_event_t; memset(event, 0x00, sizeof(xcb_button_press_event_t)); event->response_type = XCB_BUTTON_PRESS; event->event = m_windowId; - event->time = QX11Info::getTimestamp(); + event->time = XCB_CURRENT_TIME; //NOTE: to get proper timestamp we would need Qt Private APIs event->same_screen = 1; - event->root = QX11Info::appRootWindow(); + event->root = appRootWindow; event->root_x = x; event->root_y = y; event->event_x = static_cast(clickPoint.x()); @@ -602,10 +607,10 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y) event->state = 0; event->detail = mouseButton; - xcb_send_event(c, false, m_windowId, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event); + xcb_send_event(m_connection, false, m_windowId, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event); delete event; } else { - sendXTestPressed(QX11Info::display(), mouseButton); + sendXTestPressed(x11Application->display(), mouseButton); } // mouse up @@ -614,9 +619,9 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y) memset(event, 0x00, sizeof(xcb_button_release_event_t)); event->response_type = XCB_BUTTON_RELEASE; event->event = m_windowId; - event->time = QX11Info::getTimestamp(); + event->time = XCB_CURRENT_TIME; //NOTE: to get proper timestamp we would need Qt Private APIs event->same_screen = 1; - event->root = QX11Info::appRootWindow(); + event->root = appRootWindow; event->root_x = x; event->root_y = y; event->event_x = static_cast(clickPoint.x()); @@ -625,10 +630,10 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y) event->state = 0; event->detail = mouseButton; - xcb_send_event(c, false, m_windowId, XCB_EVENT_MASK_BUTTON_RELEASE, (char *)event); + xcb_send_event(m_connection, false, m_windowId, XCB_EVENT_MASK_BUTTON_RELEASE, (char *)event); delete event; } else { - sendXTestReleased(QX11Info::display(), mouseButton); + sendXTestReleased(x11Application->display(), mouseButton); } #ifndef VISUAL_DEBUG diff --git a/plugin-tray/sniproxy.h b/plugin-tray/sniproxy.h index f31b46597..8587568c3 100644 --- a/plugin-tray/sniproxy.h +++ b/plugin-tray/sniproxy.h @@ -168,6 +168,7 @@ public Q_SLOTS: void stackContainerWindow(const uint32_t stackMode) const; QDBusConnection m_dbus; + xcb_connection_t *m_connection; xcb_window_t m_windowId; xcb_window_t m_containerWid; static int s_serviceCount; diff --git a/plugin-tray/xcbutils.h b/plugin-tray/xcbutils.h index 6711b259d..497aa8c84 100644 --- a/plugin-tray/xcbutils.h +++ b/plugin-tray/xcbutils.h @@ -35,9 +35,8 @@ #include #include -#include -#include -#include +#include +#include /** XEMBED messages */ #define XEMBED_EMBEDDED_NOTIFY 0 @@ -53,13 +52,19 @@ namespace Xcb { typedef xcb_window_t WindowId; +struct ScopedCPointerDeleter +{ + static inline void cleanup(void *pointer) noexcept { free(pointer); } + void operator()(void *pointer) const noexcept { cleanup(pointer); } +}; + template -using ScopedCPointer = QScopedPointer; +using ScopedCPointer = std::unique_ptr; class Atom { public: - explicit Atom(const QByteArray &name, bool onlyIfExists = false, xcb_connection_t *c = QX11Info::connection()) + explicit Atom(const QByteArray &name, xcb_connection_t *c, bool onlyIfExists = false) : m_connection(c) , m_retrieved(false) , m_cookie(xcb_intern_atom_unchecked(m_connection, onlyIfExists, name.length(), name.constData())) @@ -105,7 +110,7 @@ class Atom return; } ScopedCPointer reply(xcb_intern_atom_reply(m_connection, m_cookie, nullptr)); - if (!reply.isNull()) { + if (reply) { m_atom = reply->atom; } m_retrieved = true; @@ -120,12 +125,12 @@ class Atom class Atoms { public: - Atoms() - : xembedAtom("_XEMBED") - , selectionAtom(xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", QX11Info::appScreen())) - , opcodeAtom("_NET_SYSTEM_TRAY_OPCODE") - , messageData("_NET_SYSTEM_TRAY_MESSAGE_DATA") - , visualAtom("_NET_SYSTEM_TRAY_VISUAL") + Atoms(xcb_connection_t *c, int defaultScreen) + : xembedAtom("_XEMBED", c) + , selectionAtom(xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", defaultScreen), c) + , opcodeAtom("_NET_SYSTEM_TRAY_OPCODE", c) + , messageData("_NET_SYSTEM_TRAY_MESSAGE_DATA", c) + , visualAtom("_NET_SYSTEM_TRAY_VISUAL", c) { } diff --git a/plugin-volume/CMakeLists.txt b/plugin-volume/CMakeLists.txt index 55457b17f..8527a18e2 100644 --- a/plugin-volume/CMakeLists.txt +++ b/plugin-volume/CMakeLists.txt @@ -27,7 +27,7 @@ set(UIS set(LIBRARIES ${LIBRARIES} lxqt-globalkeys - Qt5Xdg + Qt6Xdg ) if(PULSEAUDIO_FOUND) diff --git a/plugin-volume/alsaengine.cpp b/plugin-volume/alsaengine.cpp index a0bdff521..1d0786b09 100644 --- a/plugin-volume/alsaengine.cpp +++ b/plugin-volume/alsaengine.cpp @@ -70,7 +70,7 @@ int AlsaEngine::volumeMax(AudioDevice *device) const AlsaDevice *AlsaEngine::getDeviceByAlsaElem(snd_mixer_elem_t *elem) const { - for (AudioDevice *device : qAsConst(m_sinks)) { + for (AudioDevice *device : std::as_const(m_sinks)) { AlsaDevice *dev = qobject_cast(device); if (!dev || !dev->element()) continue; diff --git a/plugin-volume/lxqtvolumeconfiguration.cpp b/plugin-volume/lxqtvolumeconfiguration.cpp index beb61cd62..5075c37a4 100644 --- a/plugin-volume/lxqtvolumeconfiguration.cpp +++ b/plugin-volume/lxqtvolumeconfiguration.cpp @@ -80,7 +80,7 @@ void LXQtVolumeConfiguration::setSinkList(const QList sinks) const bool old_block = ui->devAddedCombo->blockSignals(true); ui->devAddedCombo->clear(); - for (const AudioDevice *dev : qAsConst(sinks)) { + for (const AudioDevice *dev : std::as_const(sinks)) { ui->devAddedCombo->addItem(dev->description(), dev->index()); } diff --git a/plugin-volume/pulseaudioengine.cpp b/plugin-volume/pulseaudioengine.cpp index 9b48ed828..041aae0af 100644 --- a/plugin-volume/pulseaudioengine.cpp +++ b/plugin-volume/pulseaudioengine.cpp @@ -179,8 +179,8 @@ void PulseAudioEngine::removeSink(uint32_t idx) if (m_sinks.end() == dev_i) return; - QScopedPointer dev{*dev_i}; - m_cVolumeMap.remove(dev.data()); + std::unique_ptr dev{*dev_i}; + m_cVolumeMap.remove(dev.get()); m_sinks.erase(dev_i); emit sinkListChanged(); } @@ -191,7 +191,7 @@ void PulseAudioEngine::addOrUpdateSink(const pa_sink_info *info) bool newSink = false; QString name = QString::fromUtf8(info->name); - for (AudioDevice *device : qAsConst(m_sinks)) { + for (AudioDevice *device : std::as_const(m_sinks)) { if (device->name() == name) { dev = device; break; diff --git a/plugin-volume/volumebutton.cpp b/plugin-volume/volumebutton.cpp index 95df40460..f10e2d0b6 100644 --- a/plugin-volume/volumebutton.cpp +++ b/plugin-volume/volumebutton.cpp @@ -77,10 +77,10 @@ void VolumeButton::setMixerCommand(const QString &command) m_mixerCommand = m_mixerParams.empty() ? QString{} : m_mixerParams.takeFirst(); } -void VolumeButton::enterEvent(QEvent *event) +void VolumeButton::enterEvent(QEnterEvent *event) { // show tooltip immediately on entering widget - QToolTip::showText(static_cast(event)->globalPos(), toolTip(), this); + QToolTip::showText(event->globalPosition().toPoint(), toolTip(), this); } void VolumeButton::mouseMoveEvent(QMouseEvent *event) @@ -88,7 +88,7 @@ void VolumeButton::mouseMoveEvent(QMouseEvent *event) QToolButton::mouseMoveEvent(event); // show tooltip immediately on moving the mouse if (!QToolTip::isVisible()) // prevent sliding of tooltip - QToolTip::showText(event->globalPos(), toolTip(), this); + QToolTip::showText(event->globalPosition().toPoint(), toolTip(), this); } void VolumeButton::wheelEvent(QWheelEvent *event) diff --git a/plugin-volume/volumebutton.h b/plugin-volume/volumebutton.h index aabbd5b76..a113a5dac 100644 --- a/plugin-volume/volumebutton.h +++ b/plugin-volume/volumebutton.h @@ -51,7 +51,7 @@ public slots: void showVolumeSlider(); protected: - void enterEvent(QEvent *event) override; + void enterEvent(QEnterEvent *event) override; void wheelEvent(QWheelEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/plugin-volume/volumepopup.cpp b/plugin-volume/volumepopup.cpp index 24a50afae..5b589a8c1 100644 --- a/plugin-volume/volumepopup.cpp +++ b/plugin-volume/volumepopup.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include "audioengine.h" #include @@ -75,7 +74,7 @@ VolumePopup::VolumePopup(QWidget* parent): QVBoxLayout *l = new QVBoxLayout(this); l->setSpacing(0); - l->setMargin(0); + l->setContentsMargins(QMargins()); l->addWidget(m_mixerButton, 0, Qt::AlignHCenter); l->addWidget(m_volumeSlider, 0, Qt::AlignHCenter); @@ -110,7 +109,7 @@ bool VolumePopup::eventFilter(QObject * watched, QEvent * event) return QDialog::eventFilter(watched, event); } -void VolumePopup::enterEvent(QEvent * /*event*/) +void VolumePopup::enterEvent(QEnterEvent * /*event*/) { emit mouseEntered(); } diff --git a/plugin-volume/volumepopup.h b/plugin-volume/volumepopup.h index 8d98be0ad..63facdc67 100644 --- a/plugin-volume/volumepopup.h +++ b/plugin-volume/volumepopup.h @@ -60,7 +60,7 @@ class VolumePopup : public QDialog protected: void resizeEvent(QResizeEvent *event) override; - void enterEvent(QEvent *event) override; + void enterEvent(QEnterEvent *event) override; void leaveEvent(QEvent *event) override; bool event(QEvent * event) override; bool eventFilter(QObject * watched, QEvent * event) override; diff --git a/plugin-worldclock/lxqtworldclock.cpp b/plugin-worldclock/lxqtworldclock.cpp index f9ef5e1c6..3c504f93e 100644 --- a/plugin-worldclock/lxqtworldclock.cpp +++ b/plugin-worldclock/lxqtworldclock.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -165,6 +164,8 @@ void LXQtWorldClock::restartTimer() void LXQtWorldClock::settingsChanged() { + static const QRegularExpression regexp(QLatin1String("'[^']*'")); + PluginSettings *_settings = settings(); QString oldFormat = mFormat; @@ -324,7 +325,7 @@ void LXQtWorldClock::settingsChanged() { int update_interval; QString format = mFormat; - format.replace(QRegExp(QLatin1String("'[^']*'")), QString()); + format.replace(regexp, QString()); //don't support updating on millisecond basis -> big performance hit if (format.contains(QLatin1String("s"))) update_interval = 1000; @@ -457,7 +458,7 @@ void LXQtWorldClock::updatePopupContent() QStringList allTimeZones; bool hasTimeZone = formatHasTimeZone(mFormat); - for (QString timeZoneName : qAsConst(mTimeZones)) + for (QString timeZoneName : std::as_const(mTimeZones)) { if (timeZoneName == QLatin1String("local")) timeZoneName = QString::fromLatin1(QTimeZone::systemTimeZoneId()); @@ -476,7 +477,8 @@ void LXQtWorldClock::updatePopupContent() bool LXQtWorldClock::formatHasTimeZone(QString format) { - format.replace(QRegExp(QLatin1String("'[^']*'")), QString()); + static const QRegularExpression regexp(QLatin1String("'[^']*'")); + format.replace(regexp, QString()); return format.contains(QLatin1Char('t'), Qt::CaseInsensitive); } @@ -622,7 +624,7 @@ LXQtWorldClockPopup::LXQtWorldClockPopup(QWidget *parent) : QDialog(parent, Qt::Window | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::Popup | Qt::X11BypassWindowManagerHint) { setLayout(new QHBoxLayout(this)); - layout()->setMargin(1); + layout()->setContentsMargins(1, 1, 1, 1); } void LXQtWorldClockPopup::show() diff --git a/plugin-worldclock/lxqtworldclockconfiguration.cpp b/plugin-worldclock/lxqtworldclockconfiguration.cpp index 384abc260..1dd2f59f3 100644 --- a/plugin-worldclock/lxqtworldclockconfiguration.cpp +++ b/plugin-worldclock/lxqtworldclockconfiguration.cpp @@ -494,7 +494,7 @@ void LXQtWorldClockConfiguration::updateTimeZoneButtons() int LXQtWorldClockConfiguration::findTimeZone(const QString& timeZone) { QList items = ui->timeZonesTW->findItems(timeZone, Qt::MatchExactly); - for (const QTableWidgetItem* item : qAsConst(items)) + for (const QTableWidgetItem* item : std::as_const(items)) if (item->column() == 0) return item->row(); return -1; diff --git a/plugin-worldclock/lxqtworldclockconfigurationtimezones.cpp b/plugin-worldclock/lxqtworldclockconfigurationtimezones.cpp index 2cb3d93b6..3e1630735 100644 --- a/plugin-worldclock/lxqtworldclockconfigurationtimezones.cpp +++ b/plugin-worldclock/lxqtworldclockconfigurationtimezones.cpp @@ -119,7 +119,7 @@ int LXQtWorldClockConfigurationTimeZones::updateAndExec() if (qStrings.size() == 1) qStrings.prepend(tr("Other")); - QTreeWidgetItem *tzItem = new QTreeWidgetItem(QStringList() << qStrings[qStrings.length() - 1] << timeZone.displayName(now) << timeZone.comment() << QLocale::countryToString(timeZone.country())); + QTreeWidgetItem *tzItem = new QTreeWidgetItem(QStringList() << qStrings[qStrings.length() - 1] << timeZone.displayName(now) << timeZone.comment() << QLocale::territoryToString(timeZone.territory())); tzItem->setData(0, Qt::UserRole, ianaId); makeSureParentsExist(qStrings, parentItems)->addChild(tzItem);