diff --git a/src/accountregdlg.cpp b/src/accountregdlg.cpp index 8bfffd451..83dfcf14e 100644 --- a/src/accountregdlg.cpp +++ b/src/accountregdlg.cpp @@ -79,7 +79,7 @@ AccountRegDlg::AccountRegDlg(PsiCon *psi, QWidget *parent) : QDialog(parent), ps // Fields pane QVBoxLayout *fields_layout = new QVBoxLayout(ui_.page_fields); - fields_layout->setMargin(0); + fields_layout->setContentsMargins(0, 0, 0, 0); fields_container_ = new QScrollArea(ui_.page_fields); fields_layout->addWidget(fields_container_); fields_container_->setWidgetResizable(true); diff --git a/src/actionlist.h b/src/actionlist.h index 911a0d9e2..a521a91a6 100644 --- a/src/actionlist.h +++ b/src/actionlist.h @@ -22,10 +22,10 @@ #include #include +#include class IconAction; class QString; -class QStringList; class ActionList : public QObject { Q_OBJECT diff --git a/src/activeprofiles_dbus.cpp b/src/activeprofiles_dbus.cpp index 81c175742..c71637a6f 100644 --- a/src/activeprofiles_dbus.cpp +++ b/src/activeprofiles_dbus.cpp @@ -101,10 +101,10 @@ QString ActiveProfiles::Private::dbusName(QString prof) QString name = PSIDBUSNAME; name += "."; name - += encodeAlNumD(ApplicationInfo::homeDir(ApplicationInfo::ConfigLocation)).rightRef(qMax(0, 200 - name.size())); + += encodeAlNumD(ApplicationInfo::homeDir(ApplicationInfo::ConfigLocation)).right(qMax(0, 200 - name.size())); if (!prof.isEmpty()) { name += "."; - name += encodeAlNumD(prof).rightRef(qMax(0, 250 - name.size())); + name += encodeAlNumD(prof).right(qMax(0, 250 - name.size())); } return name; } diff --git a/src/chateditproxy.cpp b/src/chateditproxy.cpp index 5e7787ce0..111e40e33 100644 --- a/src/chateditproxy.cpp +++ b/src/chateditproxy.cpp @@ -30,7 +30,7 @@ ChatEditProxy::ChatEditProxy(QWidget *parent) : QWidget(parent), lineEditEnabled_(false), textEdit_(nullptr), layout_(nullptr) { layout_ = new QVBoxLayout(this); - layout_->setMargin(0); + layout_->setContentsMargins(0, 0, 0, 0); layout_->setSpacing(0); connect(PsiOptions::instance(), &PsiOptions::optionChanged, this, &ChatEditProxy::optionsChanged); diff --git a/src/chatsplitter.cpp b/src/chatsplitter.cpp index eb8590917..c429fa135 100644 --- a/src/chatsplitter.cpp +++ b/src/chatsplitter.cpp @@ -127,7 +127,7 @@ void ChatSplitter::updateLayout() delete layout_; splitter_ = new QSplitter(this); layout_ = new QVBoxLayout(this); - layout_->setMargin(0); + layout_->setContentsMargins(0, 0, 0, 0); layout_->addWidget(splitter_); splitter_->setOrientation(Qt::Vertical); splitter_->setVisible(splitterEnabled()); diff --git a/src/contactlistitemmenu.cpp b/src/contactlistitemmenu.cpp index 1ac4c74cd..f31a9300e 100644 --- a/src/contactlistitemmenu.cpp +++ b/src/contactlistitemmenu.cpp @@ -45,7 +45,7 @@ ContactListItemMenu::ContactListItemMenu(ContactListItem *item, ContactListModel _lblTitle->setPalette(palette); _lblTitle->setAutoFillBackground(true); _lblTitle->setAlignment(Qt::AlignCenter); - _lblTitle->setMargin(6); + _lblTitle->setContentsMargins(6, 6, 6, 6); _lblTitle->setFont(font); QWidgetAction *waContextMenuTitle = new QWidgetAction(this); diff --git a/src/eventdlg.cpp b/src/eventdlg.cpp index dea318cea..0a8f86005 100644 --- a/src/eventdlg.cpp +++ b/src/eventdlg.cpp @@ -602,7 +602,7 @@ EventDlg::~EventDlg() void EventDlg::init() { QVBoxLayout *vb1 = new QVBoxLayout(this); - vb1->setMargin(4); + vb1->setContentsMargins(4, 4, 4, 4); vb1->setSpacing(4); // first row @@ -775,7 +775,7 @@ void EventDlg::init() // http auth transaction id d->w_http_id = new QWidget(this); QHBoxLayout *hb_http_id = new QHBoxLayout(d->w_http_id); - hb_http_id->setMargin(0); + hb_http_id->setContentsMargins(0, 0, 0, 0); hb_http_id->setSpacing(4); d->le_http_id = new QLineEdit(d->w_http_id); l = new QLabel(tr("Transaction &identifier:"), d->w_http_id); diff --git a/src/filetransdlg.cpp b/src/filetransdlg.cpp index 4c5d3aa08..345eed4bb 100644 --- a/src/filetransdlg.cpp +++ b/src/filetransdlg.cpp @@ -490,7 +490,7 @@ FileRequestDlg::FileRequestDlg(const Jid &jid, PsiCon *psi, PsiAccount *pa, cons QFrame * hb = new QFrame(this); QHBoxLayout *hbLayout = new QHBoxLayout(hb); - hbLayout->setMargin(0); + hbLayout->setContentsMargins(0, 0, 0, 0); d->lb_identity = new QLabel(tr("Identity: "), hb); hbLayout->addWidget(d->lb_identity); d->cb_ident = d->psi->accountsComboBox(hb); @@ -577,7 +577,7 @@ FileRequestDlg::FileRequestDlg(const QDateTime &ts, FileTransfer *ft, PsiAccount d->cb_ident = nullptr; QFrame * hb = new QFrame(this); QHBoxLayout *hbLayout = new QHBoxLayout(hb); - hbLayout->setMargin(0); + hbLayout->setContentsMargins(0, 0, 0, 0); d->lb_identity = new QLabel(tr("Identity: "), hb); hbLayout->addWidget(d->lb_identity); d->lb_ident = new AccountLabel(hb); diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 8d719772f..7d82891bf 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -366,7 +366,7 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon *psi) : #endif QMenu *viewMenu = new QMenu(tr("View"), this); - d->vb_roster->setMargin(layoutMargin); + d->vb_roster->setContentsMargins(layoutMargin, layoutMargin, layoutMargin, layoutMargin); d->vb_roster->setSpacing(layoutMargin); if (d->allInOne) { diff --git a/src/mucconfigdlg.cpp b/src/mucconfigdlg.cpp index ad19aca5a..67885e0ee 100644 --- a/src/mucconfigdlg.cpp +++ b/src/mucconfigdlg.cpp @@ -43,7 +43,7 @@ MUCConfigDlg::MUCConfigDlg(MUCManager *manager, QWidget *parent) : QDialog(paren setModal(false); QVBoxLayout *data_layout = new QVBoxLayout(ui_.pg_general_data); - data_layout->setMargin(0); + data_layout->setContentsMargins(0, 0, 0, 0); data_container_ = new QScrollArea(ui_.pg_general_data); data_layout->addWidget(data_container_); diff --git a/src/options/opt_tree.cpp b/src/options/opt_tree.cpp index ab4e7d2f3..e01ed09ba 100644 --- a/src/options/opt_tree.cpp +++ b/src/options/opt_tree.cpp @@ -22,7 +22,7 @@ QWidget *OptionsTabTree::widget() QVBoxLayout *layout = new QVBoxLayout(w); // layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); QLabel *lb = new QLabel(tr("Please note: This editor will change the options " "directly. Pressing Cancel will not revert these changes."), diff --git a/src/options/optionsdlgbase.cpp b/src/options/optionsdlgbase.cpp index 0cd20c1fd..16924f1a7 100644 --- a/src/options/optionsdlgbase.cpp +++ b/src/options/optionsdlgbase.cpp @@ -330,7 +330,7 @@ void OptionsDlgBase::Private::openTab(const QString &id) QVBoxLayout *vbox = new QVBoxLayout(w); vbox->setSpacing(0); - vbox->setMargin(0); + vbox->setContentsMargins(0, 0, 0, 0); tab->setParent(w); vbox->addWidget(tab); diff --git a/src/options/optionstab.cpp b/src/options/optionstab.cpp index 700478256..a9410fd6e 100644 --- a/src/options/optionstab.cpp +++ b/src/options/optionstab.cpp @@ -141,7 +141,7 @@ void OptionsTabWidget::updateCurrent(int index) QWidget *w = currentWidget(); if (!w2tab[w].initialized) { QVBoxLayout *vbox = new QVBoxLayout(w); - vbox->setMargin(5); + vbox->setContentsMargins(5, 5, 5, 5); OptionsTab *opttab = w2tab[w].tab; QWidget *tab = opttab->widget(); diff --git a/src/passdialog.cpp b/src/passdialog.cpp index 18781f27d..531471dc0 100644 --- a/src/passdialog.cpp +++ b/src/passdialog.cpp @@ -33,7 +33,7 @@ PassDialog::PassDialog(const QString &jid, QWidget *parent) : QDialog(parent) setWindowTitle(tr("Wrong Account Password")); QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setMargin(6); + mainLayout->setContentsMargins(6, 6, 6, 6); mainLayout->setSpacing(6); QHBoxLayout *botLayout = new QHBoxLayout(); diff --git a/src/proxy.cpp b/src/proxy.cpp index 7ca776d78..752accaa2 100644 --- a/src/proxy.cpp +++ b/src/proxy.cpp @@ -338,7 +338,7 @@ ProxyChooser::ProxyChooser(ProxyManager *m, QWidget *parent) : QWidget(parent) d->m = m; connect(m, SIGNAL(settingsChanged()), SLOT(pm_settingsChanged())); QHBoxLayout *hb = new QHBoxLayout(this); - hb->setMargin(0); + hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(4); d->cb_proxy = new QComboBox(this); d->cb_proxy->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, d->cb_proxy->sizePolicy().verticalPolicy())); diff --git a/src/psidbusnotifier.cpp b/src/psidbusnotifier.cpp index 3e0a8ecec..9b651fb7c 100644 --- a/src/psidbusnotifier.cpp +++ b/src/psidbusnotifier.cpp @@ -67,7 +67,8 @@ class iiibiiay { #endif } iiibiiay() { } - static const int id; + static const decltype(qDBusRegisterMetaType()) id; + int width; int height; int rowstride; @@ -78,7 +79,7 @@ class iiibiiay { }; Q_DECLARE_METATYPE(iiibiiay) -const int iiibiiay::id(qDBusRegisterMetaType()); +const decltype(qDBusRegisterMetaType()) iiibiiay::id{qDBusRegisterMetaType()}; QDBusArgument &operator<<(QDBusArgument &a, const iiibiiay &i) { diff --git a/src/psioptionseditor.cpp b/src/psioptionseditor.cpp index 4250e13f5..47bf132cc 100644 --- a/src/psioptionseditor.cpp +++ b/src/psioptionseditor.cpp @@ -113,7 +113,7 @@ PsiOptionsEditor::PsiOptionsEditor(QWidget *parent) : QWidget(parent) QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); QHBoxLayout *filterLayout = new QHBoxLayout; le_filter = new QLineEdit(this); diff --git a/src/psirosterwidget.cpp b/src/psirosterwidget.cpp index ceadaf9f4..45a3b791a 100644 --- a/src/psirosterwidget.cpp +++ b/src/psirosterwidget.cpp @@ -106,7 +106,7 @@ PsiRosterWidget::PsiRosterWidget(QWidget *parent) : contactListPageView_(nullptr), filterPageView_(nullptr), contactListModel_(nullptr), filterModel_(nullptr) { QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); stackedWidget_ = new QStackedWidget(this); @@ -119,7 +119,7 @@ PsiRosterWidget::PsiRosterWidget(QWidget *parent) : stackedWidget_->addWidget(contactListPage_); QVBoxLayout *contactListPageLayout = new QVBoxLayout(contactListPage_); - contactListPageLayout->setMargin(0); + contactListPageLayout->setContentsMargins(0, 0, 0, 0); contactListPageView_ = new PsiContactListView(contactListPage_); contactListPageView_->installEventFilter(this); contactListPageView_->setObjectName("contactListView"); @@ -132,7 +132,7 @@ PsiRosterWidget::PsiRosterWidget(QWidget *parent) : stackedWidget_->addWidget(filterPage_); QVBoxLayout *filterPageLayout = new QVBoxLayout(filterPage_); - filterPageLayout->setMargin(0); + filterPageLayout->setContentsMargins(0, 0, 0, 0); filterPageLayout->setSpacing(0); filterEdit_ = new ActionLineEdit(filterPage_); diff --git a/src/registrationdlg.cpp b/src/registrationdlg.cpp index c6a5a2c9d..d182136e3 100644 --- a/src/registrationdlg.cpp +++ b/src/registrationdlg.cpp @@ -147,7 +147,7 @@ RegistrationDlg::RegistrationDlg(const Jid &jid, PsiAccount *pa) : QDialog(nullp setWindowTitle(tr("Registration: %1").arg(d->jid.full())); QVBoxLayout *vb1 = new QVBoxLayout(this); - vb1->setMargin(4); + vb1->setContentsMargins(4, 4, 4, 4); d->lb_top = new QLabel(this); d->lb_top->setWordWrap(true); d->lb_top->setFrameStyle(QFrame::Panel | QFrame::Sunken); diff --git a/src/rosteravatarframe.cpp b/src/rosteravatarframe.cpp index 0a534f876..d44675c13 100644 --- a/src/rosteravatarframe.cpp +++ b/src/rosteravatarframe.cpp @@ -28,8 +28,8 @@ RosterAvatarFrame::RosterAvatarFrame(QWidget *parent) : QFrame(parent), statusMessage_("") { ui_.setupUi(this); - layout()->setMargin( - PsiOptions::instance()->getOption("options.ui.contactlist.roster-avatar-frame.avatar.margin").toInt()); + auto margin = PsiOptions::instance()->getOption("options.ui.contactlist.roster-avatar-frame.avatar.margin").toInt(); + layout()->setContentsMargins(margin, margin, margin, margin); layout()->setSpacing(0); setMoodIcon("pep/mood"); setActivityIcon("pep/activities"); @@ -142,9 +142,10 @@ void RosterAvatarFrame::optionChanged(QString option) drawAvatar(); else if (option == "options.ui.look.font.contactlist") setFont(); - else if (option == "options.ui.contactlist.roster-avatar-frame.avatar.margin") - layout()->setMargin(PsiOptions::instance()->getOption(option).toInt()); - else if (option == "options.extended-presence.tune.publish") { + else if (option == "options.ui.contactlist.roster-avatar-frame.avatar.margin") { + auto margin = PsiOptions::instance()->getOption(option).toInt(); + layout()->setContentsMargins(margin, margin, margin, margin); + } else if (option == "options.extended-presence.tune.publish") { bool publishingEnabled = PsiOptions::instance()->getOption(option).toBool(); ui_.tb_tune->setChecked(publishingEnabled); } diff --git a/src/showtextdlg.cpp b/src/showtextdlg.cpp index 8625dbd7f..e34125600 100644 --- a/src/showtextdlg.cpp +++ b/src/showtextdlg.cpp @@ -42,7 +42,7 @@ ShowTextDlg::ShowTextDlg(const QString &fname, bool rich, QWidget *parent) : QDi } QVBoxLayout *vb1 = new QVBoxLayout(this); - vb1->setMargin(8); + vb1->setContentsMargins(8, 8, 8, 8); QTextEdit *te = new QTextEdit(this); te->setReadOnly(true); te->setAcceptRichText(rich); @@ -71,7 +71,7 @@ ShowTextDlg::ShowTextDlg(const QString &text, bool nonfile, bool rich, QWidget * setAttribute(Qt::WA_DeleteOnClose); QVBoxLayout *vb1 = new QVBoxLayout(this); - vb1->setMargin(8); + vb1->setContentsMargins(8, 8, 8, 8); QTextEdit *te = new QTextEdit(this); te->setReadOnly(true); te->setAcceptRichText(rich); diff --git a/src/statusdlg.cpp b/src/statusdlg.cpp index eb8716dcc..e056088dd 100644 --- a/src/statusdlg.cpp +++ b/src/statusdlg.cpp @@ -53,7 +53,7 @@ StatusShowDlg::StatusShowDlg(const UserListItem &u) : QDialog(nullptr) setAttribute(Qt::WA_DeleteOnClose); // build the dialog QVBoxLayout *vb = new QVBoxLayout(this); - vb->setMargin(8); + vb->setContentsMargins(8, 8, 8, 8); PsiTextView *te = new PsiTextView(this); vb->addWidget(te); QHBoxLayout *hb = new QHBoxLayout; @@ -150,7 +150,7 @@ void StatusSetDlg::init() // build the dialog QVBoxLayout *vb = new QVBoxLayout(this); - vb->setMargin(8); + vb->setContentsMargins(8, 8, 8, 8); QHBoxLayout *hb1 = new QHBoxLayout; vb->addLayout(hb1); diff --git a/src/tabs/tabdlg.cpp b/src/tabs/tabdlg.cpp index 1229efae5..ff6f7d588 100644 --- a/src/tabs/tabdlg.cpp +++ b/src/tabs/tabdlg.cpp @@ -116,7 +116,7 @@ TabDlg::TabDlg(TabManager *tabManager, const QString &geometryOption, TabDlgDele delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout(this); - vert1->setMargin(1); + vert1->setContentsMargins(1, 1, 1, 1); vert1->addWidget(tabWidget_); setAcceptDrops(true); @@ -254,7 +254,7 @@ void TabDlg::tab_aboutToShowMenu(QMenu *menu) int tabDlgMetaType = qRegisterMetaType("TabDlg*"); for (TabDlg *tabSet : tabManager_->tabSets()) { QAction *act = sendTo->addAction(tabSet->desiredCaption()); - act->setData(QVariant(tabDlgMetaType, &tabSet)); + act->setData(QVariant(QMetaType(tabDlgMetaType), &tabSet)); act->setEnabled(tabSet != this); } connect(sendTo, SIGNAL(triggered(QAction *)), SLOT(menu_sendTabTo(QAction *))); diff --git a/src/vcardphotodlg.cpp b/src/vcardphotodlg.cpp index 07325f248..4071079a9 100644 --- a/src/vcardphotodlg.cpp +++ b/src/vcardphotodlg.cpp @@ -25,7 +25,7 @@ ShowPhotoDlg::ShowPhotoDlg(QWidget *parent, QPixmap &pixmap) : QDialog(parent), toolbar = new QToolBar(this); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); layout->setSpacing(0); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(toolbar); layout->addWidget(label); diff --git a/src/whiteboarding/wbdlg.cpp b/src/whiteboarding/wbdlg.cpp index 04365f0e5..7ac1e26f0 100644 --- a/src/whiteboarding/wbdlg.cpp +++ b/src/whiteboarding/wbdlg.cpp @@ -24,10 +24,12 @@ #include "wbdlg.h" #include "accountlabel.h" +#include "iconaction.h" #include "iconset.h" #include "psiaccount.h" #include "stretchwidget.h" +#include #include #include #include diff --git a/src/whiteboarding/wbscene.cpp b/src/whiteboarding/wbscene.cpp index 33c6f67ec..cf8e87747 100644 --- a/src/whiteboarding/wbscene.cpp +++ b/src/whiteboarding/wbscene.cpp @@ -103,7 +103,7 @@ void WbScene::ungroup() if (group.nodeName() == "g") { QDomNodeList children = group.childNodes(); - QMatrix groupTransform = WbItem::parseSvgTransform(group.attribute("transform")); + QTransform groupTransform = WbItem::parseSvgTransform(group.attribute("transform")); for (int i = children.size() - 1; i >= 0; i--) { QDomElement child = children.at(i).toElement(); @@ -111,7 +111,7 @@ void WbScene::ungroup() if (!groupTransform.isIdentity()) { // combine the transformations of the group and the child - QMatrix childTransform = WbItem::parseSvgTransform(child.attribute("transform")); + QTransform childTransform = WbItem::parseSvgTransform(child.attribute("transform")); session_->setAttribute(child, "transform", WbItem::toSvgTransform(childTransform * groupTransform)); } diff --git a/src/x11windowsystem.cpp b/src/x11windowsystem.cpp index ad81defca..79da3910d 100644 --- a/src/x11windowsystem.cpp +++ b/src/x11windowsystem.cpp @@ -1,55 +1,26 @@ #include "x11windowsystem.h" +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #include +#else +#include +#endif #include #include // needed for WM_CLASS hinting const long MAX_PROP_SIZE = 100000; X11WindowSystem *X11WindowSystem::_instance = nullptr; -bool X11WindowSystem::isValid() const { - return QX11Info::isPlatformX11(); -} - -void X11WindowSystem::x11wmClass(WId wid, QString resName) -{ -#if defined(LIMIT_X11_USAGE) - return; -#endif - - if (!QX11Info::isPlatformX11()) // Avoid crashes if launched in Wayland - return; - - // Display *dsp = x11Display(); // get the display - // WId win = winId(); // get the window - XClassHint classhint; // class hints - // Get old class hint. It is important to save old class name - XGetClassHint(QX11Info::display(), wid, &classhint); - XFree(classhint.res_name); - const QByteArray latinResName = resName.toLatin1(); - classhint.res_name = const_cast(latinResName.data()); // res_name - XSetClassHint(QX11Info::display(), wid, &classhint); // set the class hints +namespace { - XFree(classhint.res_class); -} - -void X11WindowSystem::bringToFront(QWidget *w) -{ - if (QX11Info::isPlatformX11()) { - // If we're not on the current desktop, do the hide/show trick - long dsk, curr_dsk; - Window win = w->winId(); - if (X11WindowSystem::instance()->desktopOfWindow(&win, &dsk) - && X11WindowSystem::instance()->currentDesktop(&curr_dsk)) { - // qDebug() << "bringToFront current desktop=" << curr_dsk << " windowDesktop=" << dsk; - if ((dsk != curr_dsk) && (dsk != -1)) { // second condition for sticky windows - w->hide(); - } - } - } - - // FIXME: multi-desktop hacks for Win and Mac required +bool isPlatformX11() { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + return QX11Info::isPlatformX11()); +#else + auto x11app = qApp->nativeInterface(); + return !!x11app; +#endif } //>>>-- Nathaniel Gray -- Caltech Computer Science ------> @@ -63,7 +34,7 @@ static bool getCardinal32Prop(Display *display, Window win, char *propName, long return false; #endif - if (!QX11Info::isPlatformX11()) // Avoid crashes if launched in Wayland + if (!isPlatformX11()) // Avoid crashes if launched in Wayland return false; Atom nameAtom, typeAtom, actual_type_return; @@ -78,7 +49,7 @@ static bool getCardinal32Prop(Display *display, Window win, char *propName, long return false; } - // Try to get the property + // Try to get the property result = XGetWindowProperty(display, win, nameAtom, 0, 1, False, typeAtom, &actual_type_return, &actual_format_return, &nitems_return, &bytes_after_return, reinterpret_cast(&result_array)); @@ -99,10 +70,75 @@ static bool getCardinal32Prop(Display *display, Window win, char *propName, long return true; } +auto getDisplay() { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + return QX11Info::display()); +#else + auto x11app = qApp->nativeInterface(); + return x11app->display(); +#endif +} + +auto getRootWindow() { +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + return QX11Info::appRootWindow(); +#else + auto x11app = qApp->nativeInterface(); + return DefaultRootWindow(x11app->display()); +#endif +} + +} + +bool X11WindowSystem::isValid() const { + return ::isPlatformX11(); +} + +void X11WindowSystem::x11wmClass(WId wid, QString resName) +{ +#if defined(LIMIT_X11_USAGE) + return; +#endif + + if (!isValid()) // Avoid crashes if launched in Wayland + return; + + Display *dsp = getDisplay(); // get the display + // WId win = winId(); // get the window + XClassHint classhint; // class hints + // Get old class hint. It is important to save old class name + XGetClassHint(dsp, wid, &classhint); + XFree(classhint.res_name); + + const QByteArray latinResName = resName.toLatin1(); + classhint.res_name = const_cast(latinResName.data()); // res_name + XSetClassHint(dsp, wid, &classhint); // set the class hints + + XFree(classhint.res_class); +} + +void X11WindowSystem::bringToFront(QWidget *w) +{ + if (isValid()) { + // If we're not on the current desktop, do the hide/show trick + long dsk, curr_dsk; + Window win = w->winId(); + if (X11WindowSystem::instance()->desktopOfWindow(&win, &dsk) + && X11WindowSystem::instance()->currentDesktop(&curr_dsk)) { + // qDebug() << "bringToFront current desktop=" << curr_dsk << " windowDesktop=" << dsk; + if ((dsk != curr_dsk) && (dsk != -1)) { // second condition for sticky windows + w->hide(); + } + } + } + + // FIXME: multi-desktop hacks for Win and Mac required +} + // Get the desktop number that a window is on bool X11WindowSystem::desktopOfWindow(Window *window, long *desktop) { - Display *display = QX11Info::display(); + Display *display = getDisplay(); bool result = getCardinal32Prop(display, *window, const_cast("_NET_WM_DESKTOP"), desktop); // if( result ) // qDebug("Desktop: " + QString::number(*desktop)); @@ -113,10 +149,10 @@ bool X11WindowSystem::desktopOfWindow(Window *window, long *desktop) bool X11WindowSystem::currentDesktop(long *desktop) { Window rootWin; - Display *display = QX11Info::display(); + Display *display = getDisplay(); bool result; - rootWin = RootWindow(QX11Info::display(), XDefaultScreen(QX11Info::display())); + rootWin = RootWindow(display, XDefaultScreen(display)); result = getCardinal32Prop(display, rootWin, const_cast("_NET_CURRENT_DESKTOP"), desktop); // if( result ) // qDebug("Current Desktop: " + QString::number(*desktop)); @@ -156,7 +192,7 @@ X11WindowSystem::X11WindowSystem() atoms[i] = 0; #if !defined(LIMIT_X11_USAGE) - XInternAtoms(QX11Info::display(), const_cast(names), atomsCount, true, atoms); + XInternAtoms(getDisplay(), const_cast(names), atomsCount, true, atoms); #endif i = atomsCount; @@ -191,8 +227,9 @@ QRect X11WindowSystem::windowRect(Window win) Window w_unused; int x, y; unsigned int w, h, junk; - XGetGeometry(QX11Info::display(), win, &w_unused, &x, &y, &w, &h, &junk, &junk); - XTranslateCoordinates(QX11Info::display(), win, QX11Info::appRootWindow(), 0, 0, &x, &y, &w_unused); + Display *display = getDisplay(); + XGetGeometry(display, win, &w_unused, &x, &y, &w, &h, &junk, &junk); + XTranslateCoordinates(display, win, getRootWindow(), 0, 0, &x, &y, &w_unused); Atom type_ret; int format_ret; @@ -200,7 +237,7 @@ QRect X11WindowSystem::windowRect(Window win) unsigned long nitems_ret, unused; const Atom XA_CARDINAL = Atom(6); if (net_frame_extents != None - && XGetWindowProperty(QX11Info::display(), win, net_frame_extents, 0l, 4l, False, XA_CARDINAL, &type_ret, + && XGetWindowProperty(display, win, net_frame_extents, 0l, 4l, False, XA_CARDINAL, &type_ret, &format_ret, &nitems_ret, &unused, &data_ret) == Success) { if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 4) { @@ -221,6 +258,7 @@ QRect X11WindowSystem::windowRect(Window win) // Determine if window is obscured by other windows bool X11WindowSystem::isWindowObscured(QWidget *widget, bool alwaysOnTop) { + Display *display = getDisplay(); if (net_wm_state_above != None) { if (!alwaysOnTop) ignoredWindowStates.insert(net_wm_state_above); @@ -243,7 +281,7 @@ bool X11WindowSystem::isWindowObscured(QWidget *widget, bool alwaysOnTop) if (net_client_list_stacking != None) { QRect winRect = windowRect(win); - if (XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(), net_client_list_stacking, 0, + if (XGetWindowProperty(display, getRootWindow(), net_client_list_stacking, 0, MAX_PROP_SIZE, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &unused, &data_ret) == Success) { if (type_ret == XA_WINDOW && format_ret == 32) { @@ -291,9 +329,10 @@ bool X11WindowSystem::windowHasOnlyTypes(Window win, const QSet &allowedTy int format_ret; unsigned char *data_ret; unsigned long nitems_ret, unused; + Display *display = getDisplay(); if (net_wm_window_type != None - && XGetWindowProperty(QX11Info::display(), win, net_wm_window_type, 0l, 2048l, False, XA_ATOM, &type_ret, + && XGetWindowProperty(display, win, net_wm_window_type, 0l, 2048l, False, XA_ATOM, &type_ret, &format_ret, &nitems_ret, &unused, &data_ret) == Success) { if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) { @@ -319,8 +358,10 @@ bool X11WindowSystem::windowHasAnyOfStates(Window win, const QSet &filtere int format_ret; unsigned char *data_ret; unsigned long nitems_ret, unused; + Display *display = getDisplay(); + if (net_wm_state != None - && XGetWindowProperty(QX11Info::display(), win, net_wm_state, 0l, 2048l, False, XA_ATOM, &type_ret, &format_ret, + && XGetWindowProperty(display, win, net_wm_state, 0l, 2048l, False, XA_ATOM, &type_ret, &format_ret, &nitems_ret, &unused, &data_ret) == Success) { if (type_ret == XA_ATOM && format_ret == 32 && nitems_ret > 0) { diff --git a/src/xmlconsole.cpp b/src/xmlconsole.cpp index c86d47e7a..7d21b66d3 100644 --- a/src/xmlconsole.cpp +++ b/src/xmlconsole.cpp @@ -181,7 +181,7 @@ XmlPrompt::XmlPrompt(QWidget *parent) : QDialog(parent) setWindowTitle(tr("XML Input")); QVBoxLayout *vb1 = new QVBoxLayout(this); - vb1->setMargin(8); + vb1->setContentsMargins(8, 8, 8, 8); te = new QTextEdit(this); te->setAcceptRichText(false); diff --git a/version b/version index 4fb56b506..66bc8a89d 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.1670 (2024-03-15, f8711b3e) +1.5.1671 (2024-03-15, d8f0998f)