diff --git a/src/common.cpp b/src/common.cpp index 7474a3591..3ea0e3755 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -467,20 +467,7 @@ void bringToFront(QWidget *widget, bool) QWidget *w = widget->window(); #ifdef HAVE_X11 - 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 + X11WindowSystem::instance()->bringToFront(w); #endif if (w->isMaximized()) { diff --git a/src/common.h b/src/common.h index ab586fd7b..e863d4fc2 100644 --- a/src/common.h +++ b/src/common.h @@ -165,8 +165,7 @@ TabbableWidget *findActiveTab(); #include "x11windowsystem.h" #define X11WM_CLASS(x) \ { \ - if (QX11Info::isPlatformX11()) \ - X11WindowSystem::instance()->x11wmClass(winId(), (x)); \ + X11WindowSystem::instance()->x11wmClass(winId(), (x)); \ }; #else #define X11WM_CLASS(x) /* dummy */ diff --git a/src/contactmanager/contactmanagermodel.cpp b/src/contactmanager/contactmanagermodel.cpp index 6e1757afe..1979bc5da 100644 --- a/src/contactmanager/contactmanagermodel.cpp +++ b/src/contactmanager/contactmanagermodel.cpp @@ -251,7 +251,7 @@ void ContactManagerModel::invertByMatch(int columnIndex, int matchType, const QS for (UserListItem *u : std::as_const(_userList)) { data = userFieldString(u, columnRole); if ((matchType == ContactManagerModel::SimpleMatch && str == data) - || (matchType == ContactManagerModel::RegexpMatch && reg.indexIn(data) != -1)) { + || (matchType == ContactManagerModel::RegexpMatch && reg.match(data).hasMatch())) { QString jid = u->jid().full(); if (checks.contains(jid)) { checks.remove(jid); diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 897047c14..8d719772f 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -1578,9 +1578,10 @@ void MainWin::toggleVisible(bool fromTray) } #elif defined(HAVE_X11) Q_UNUSED(fromTray); - if (QX11Info::isPlatformX11()) { + auto x11 = X11WindowSystem::instance(); + if (x11->isValid()) { hidden = isHidden() - || X11WindowSystem::instance()->isWindowObscured( + || x11->isWindowObscured( this, PsiOptions::instance()->getOption("options.ui.contactlist.always-on-top").toBool()); } else { hidden = isHidden() || !isActiveWindow(); diff --git a/src/mcmdmanager.cpp b/src/mcmdmanager.cpp index 0665cf6ee..231412bca 100644 --- a/src/mcmdmanager.cpp +++ b/src/mcmdmanager.cpp @@ -21,6 +21,7 @@ #include "mcmdmanager.h" #include +#include MCmdSimpleState::MCmdSimpleState(QString name, QString prompt) : name_(name), prompt_(prompt), flags_(0) { } diff --git a/src/msgmle.cpp b/src/msgmle.cpp index 2fdb7bc98..1ca20fba1 100644 --- a/src/msgmle.cpp +++ b/src/msgmle.cpp @@ -105,8 +105,9 @@ public slots: return; } else { QRegularExpression capitalizeAfter("(?:^[^.][.]+\\s+)|(?:\\s*[^.]{2,}[.]+\\s+)|(?:[!?]\\s+)"); - int index = te_->toPlainText().lastIndexOf(capitalizeAfter); - if (index != -1 && index == pos - capitalizeAfter.matchedLength()) { + QRegularExpressionMatch match; + int index = te_->toPlainText().lastIndexOf(capitalizeAfter, 0, &match); + if (index != -1 && index == pos - match.capturedLength()) { capitalizeNext_ = true; } } diff --git a/src/x11windowsystem.cpp b/src/x11windowsystem.cpp index e9b124716..ad81defca 100644 --- a/src/x11windowsystem.cpp +++ b/src/x11windowsystem.cpp @@ -7,6 +7,10 @@ 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) @@ -30,6 +34,24 @@ void X11WindowSystem::x11wmClass(WId wid, QString resName) 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 +} + //>>>-- Nathaniel Gray -- Caltech Computer Science ------> //>>>-- Mojave Project -- http://mojave.cs.caltech.edu --> // Copied from http://www.nedit.org/archives/discuss/2002-Aug/0386.html diff --git a/src/x11windowsystem.h b/src/x11windowsystem.h index 3c279e8db..3431753cc 100644 --- a/src/x11windowsystem.h +++ b/src/x11windowsystem.h @@ -4,7 +4,6 @@ #include #include #include -//#include #include // TODO: Find a way to include Xlib here and not redefine Atom and Window types @@ -36,6 +35,7 @@ class X11WindowSystem { public: static X11WindowSystem *instance(); + bool isValid() const; QRect windowRect(Window win); bool isWindowObscured(QWidget *widget, bool alwaysOnTop); bool windowHasOnlyTypes(Window win, const QSet &allowedTypes); @@ -43,6 +43,7 @@ class X11WindowSystem { bool currentDesktop(long *desktop); bool desktopOfWindow(Window *window, long *desktop); void x11wmClass(WId wid, QString resName); + void bringToFront(QWidget *w); }; #endif // X11WINDOWSYSTEM_H diff --git a/version b/version index b3b53d1d8..ee224dd2b 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.1664 (2024-03-14, d668704d) +1.5.1665 (2024-03-14, 694f4289)