diff --git a/src/core/framelessconfig.cpp b/src/core/framelessconfig.cpp index 093da49..adccfd3 100644 --- a/src/core/framelessconfig.cpp +++ b/src/core/framelessconfig.cpp @@ -23,7 +23,6 @@ */ #include "framelessconfig_p.h" -#include #include #include #include @@ -81,7 +80,6 @@ static constexpr const auto OptionCount = std::size(OptionsTable); struct ConfigData { - QMutex mutex; bool loaded = false; bool options[OptionCount] = {}; bool disableEnvVar = false; @@ -134,7 +132,6 @@ FramelessConfig *FramelessConfig::instance() void FramelessConfig::reload(const bool force) { - const QMutexLocker locker(&g_data()->mutex); if (g_data()->loaded && !force) { return; } @@ -160,25 +157,21 @@ void FramelessConfig::reload(const bool force) void FramelessConfig::set(const Option option, const bool on) { - const QMutexLocker locker(&g_data()->mutex); g_data()->options[static_cast(option)] = on; } bool FramelessConfig::isSet(const Option option) const { - const QMutexLocker locker(&g_data()->mutex); return g_data()->options[static_cast(option)]; } void FramelessConfig::setLoadFromEnvironmentVariablesDisabled(const bool on) { - const QMutexLocker locker(&g_data()->mutex); g_data()->disableEnvVar = on; } void FramelessConfig::setLoadFromConfigurationFileDisabled(const bool on) { - const QMutexLocker locker(&g_data()->mutex); g_data()->disableCfgFile = on; } diff --git a/src/core/framelesshelper_qt.cpp b/src/core/framelesshelper_qt.cpp index 222d4c3..0a5ce32 100644 --- a/src/core/framelesshelper_qt.cpp +++ b/src/core/framelesshelper_qt.cpp @@ -28,7 +28,6 @@ #include "framelessconfig_p.h" #include "framelesshelpercore_global_p.h" #include "utils.h" -#include #include #include #include @@ -61,7 +60,6 @@ struct QtHelperData struct QtHelper { - QMutex mutex; QHash data = {}; }; @@ -78,9 +76,7 @@ void FramelessHelperQt::addWindow(FramelessParamsConst params) return; } const WId windowId = params->getWindowId(); - g_qtHelper()->mutex.lock(); if (g_qtHelper()->data.contains(windowId)) { - g_qtHelper()->mutex.unlock(); return; } QtHelperData data = {}; @@ -89,7 +85,6 @@ void FramelessHelperQt::addWindow(FramelessParamsConst params) // Give it a parent so that it can be deleted even if we forget to do so. data.eventFilter = new FramelessHelperQt(window); g_qtHelper()->data.insert(windowId, data); - g_qtHelper()->mutex.unlock(); const auto shouldApplyFramelessFlag = []() -> bool { #ifdef Q_OS_MACOS return false; @@ -121,7 +116,6 @@ void FramelessHelperQt::removeWindow(const WId windowId) if (!windowId) { return; } - const QMutexLocker locker(&g_qtHelper()->mutex); if (!g_qtHelper()->data.contains(windowId)) { return; } @@ -175,13 +169,10 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) } const auto window = qobject_cast(object); const WId windowId = window->winId(); - g_qtHelper()->mutex.lock(); if (!g_qtHelper()->data.contains(windowId)) { - g_qtHelper()->mutex.unlock(); return QObject::eventFilter(object, event); } const QtHelperData data = g_qtHelper()->data.value(windowId); - g_qtHelper()->mutex.unlock(); #if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) if (type == QEvent::DevicePixelRatioChange) #else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0) @@ -208,9 +199,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) switch (type) { case QEvent::MouseButtonPress: { if (button == Qt::LeftButton) { - g_qtHelper()->mutex.lock(); g_qtHelper()->data[windowId].leftButtonPressed = true; - g_qtHelper()->mutex.unlock(); if (!windowFixedSize) { const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos); if (edges != Qt::Edges{}) { @@ -223,7 +212,6 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) } break; case QEvent::MouseButtonRelease: { if (button == Qt::LeftButton) { - const QMutexLocker locker(&g_qtHelper()->mutex); g_qtHelper()->data[windowId].leftButtonPressed = false; } if (button == Qt::RightButton) { @@ -251,12 +239,10 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event) if (cs == Qt::ArrowCursor) { if (data.cursorShapeChanged) { data.params.unsetCursor(); - const QMutexLocker locker(&g_qtHelper()->mutex); g_qtHelper()->data[windowId].cursorShapeChanged = false; } } else { data.params.setCursor(cs); - const QMutexLocker locker(&g_qtHelper()->mutex); g_qtHelper()->data[windowId].cursorShapeChanged = true; } } diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index d6abc4b..4293b31 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -31,7 +31,6 @@ #include "framelesshelper_windows.h" #include "framelesshelpercore_global_p.h" #include -#include #include #include #include @@ -105,7 +104,6 @@ struct Win32HelperData struct Win32Helper { - QMutex mutex; std::unique_ptr nativeEventFilter = nullptr; QHash data = {}; QHash fallbackTitleBarToParentWindowMapping = {}; @@ -142,18 +140,14 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) return DefWindowProcW(hWnd, uMsg, wParam, lParam); } const auto windowId = reinterpret_cast(hWnd); - g_win32Helper()->mutex.lock(); if (!g_win32Helper()->fallbackTitleBarToParentWindowMapping.contains(windowId)) { - g_win32Helper()->mutex.unlock(); return DefWindowProcW(hWnd, uMsg, wParam, lParam); } const WId parentWindowId = g_win32Helper()->fallbackTitleBarToParentWindowMapping.value(windowId); if (!g_win32Helper()->data.contains(parentWindowId)) { - g_win32Helper()->mutex.unlock(); return DefWindowProcW(hWnd, uMsg, wParam, lParam); } const Win32HelperData data = g_win32Helper()->data.value(parentWindowId); - g_win32Helper()->mutex.unlock(); const auto parentWindowHandle = reinterpret_cast(parentWindowId); // All mouse events: client area mouse events + non-client area mouse events. // Hit-testing event should not be considered as a mouse event. @@ -285,7 +279,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) WARNING << Utils::getSystemErrorMessage(kTrackMouseEvent); break; } - const QMutexLocker locker(&g_win32Helper()->mutex); g_win32Helper()->data[parentWindowId].trackingMouse = true; } } break; @@ -293,7 +286,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) case WM_MOUSELEAVE: { // When the mouse leaves the drag rect, make sure to dismiss any hover. releaseButtons(std::nullopt); - const QMutexLocker locker(&g_win32Helper()->mutex); g_win32Helper()->data[parentWindowId].trackingMouse = false; } break; // NB: *Shouldn't be forwarding these* when they're not over the caption @@ -500,7 +492,6 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) WARNING << "Failed to re-position the fallback title bar window."; return false; } - const QMutexLocker locker(&g_win32Helper()->mutex); g_win32Helper()->data[parentWindowId].fallbackTitleBarWindowId = fallbackTitleBarWindowId; g_win32Helper()->fallbackTitleBarToParentWindowMapping.insert(fallbackTitleBarWindowId, parentWindowId); return true; @@ -517,9 +508,7 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params) return; } const WId windowId = params->getWindowId(); - g_win32Helper()->mutex.lock(); if (g_win32Helper()->data.contains(windowId)) { - g_win32Helper()->mutex.unlock(); return; } Win32HelperData data = {}; @@ -530,7 +519,6 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params) g_win32Helper()->nativeEventFilter = std::make_unique(); qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get()); } - g_win32Helper()->mutex.unlock(); DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; #if 0 params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint); @@ -588,9 +576,7 @@ void FramelessHelperWin::removeWindow(const WId windowId) if (!windowId) { return; } - g_win32Helper()->mutex.lock(); if (!g_win32Helper()->data.contains(windowId)) { - g_win32Helper()->mutex.unlock(); return; } g_win32Helper()->data.remove(windowId); @@ -611,7 +597,6 @@ void FramelessHelperWin::removeWindow(const WId windowId) } ++it; } - g_win32Helper()->mutex.unlock(); if (DestroyWindow(reinterpret_cast(hwnd)) == FALSE) { WARNING << Utils::getSystemErrorMessage(kDestroyWindow); } @@ -646,13 +631,10 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me return false; } const auto windowId = reinterpret_cast(hWnd); - g_win32Helper()->mutex.lock(); if (!g_win32Helper()->data.contains(windowId)) { - g_win32Helper()->mutex.unlock(); return false; } const Win32HelperData data = g_win32Helper()->data.value(windowId); - g_win32Helper()->mutex.unlock(); const bool frameBorderVisible = Utils::isWindowFrameBorderVisible(); const WPARAM wParam = msg->wParam; const LPARAM lParam = msg->lParam; @@ -669,7 +651,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me if (Utils::isValidGeometry(data.restoreGeometry) && (data.restoreGeometry == rect)) { return; } - const QMutexLocker locker(&g_win32Helper()->mutex); g_win32Helper()->data[windowId].restoreGeometry = rect; }; @@ -1192,14 +1173,12 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me } DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd) << "is" << newDpi << "(was" << oldDpi << ")."; - g_win32Helper()->mutex.lock(); g_win32Helper()->data[windowId].dpi = newDpi; if (Utils::isValidGeometry(data.restoreGeometry)) { // Update the window size only. The position should not be changed. g_win32Helper()->data[windowId].restoreGeometry.setSize( Utils::rescaleSize(data.restoreGeometry.size(), oldDpi.x, newDpi.x)); } - g_win32Helper()->mutex.unlock(); data.params.forceChildrenRepaint(500); } break; case WM_DWMCOMPOSITIONCHANGED: { diff --git a/src/core/framelesshelpercore_global.cpp b/src/core/framelesshelpercore_global.cpp index ec35204..c95b3b3 100644 --- a/src/core/framelesshelpercore_global.cpp +++ b/src/core/framelesshelpercore_global.cpp @@ -26,7 +26,6 @@ #include "framelesshelpercore_global_p.h" #include "versionnumber_p.h" #include "utils.h" -#include #include #include #include @@ -148,7 +147,6 @@ FRAMELESSHELPER_BYTEARRAY_CONSTANT(xcb) struct CoreData { - QMutex mutex; QList initHooks = {}; QList uninitHooks = {}; }; @@ -161,7 +159,6 @@ void registerInitializeHook(const InitializeHookCallback &cb) if (!cb) { return; } - const QMutexLocker locker(&coreData()->mutex); coreData()->initHooks.append(cb); } @@ -171,7 +168,6 @@ void registerUninitializeHook(const UninitializeHookCallback &cb) if (!cb) { return; } - const QMutexLocker locker(&coreData()->mutex); coreData()->uninitHooks.append(cb); } @@ -232,7 +228,6 @@ void initialize() QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif - const QMutexLocker locker(&coreData()->mutex); if (!coreData()->initHooks.isEmpty()) { for (auto &&hook : std::as_const(coreData()->initHooks)) { Q_ASSERT(hook); @@ -252,7 +247,6 @@ void uninitialize() } uninited = true; - const QMutexLocker locker(&coreData()->mutex); if (coreData()->uninitHooks.isEmpty()) { return; } diff --git a/src/core/micamaterial.cpp b/src/core/micamaterial.cpp index a6e49ea..7c047a7 100644 --- a/src/core/micamaterial.cpp +++ b/src/core/micamaterial.cpp @@ -28,7 +28,6 @@ #include "utils.h" #include "framelessconfig_p.h" #include -#include #include #include #include @@ -72,7 +71,6 @@ FRAMELESSHELPER_STRING_CONSTANT2(NoiseImageFilePath, ":/org.wangwenx190.Frameles struct MicaMaterialData { - QMutex mutex; QPixmap blurredWallpaper = {}; bool graphicsResourcesReady = false; }; @@ -507,17 +505,12 @@ const MicaMaterialPrivate *MicaMaterialPrivate::get(const MicaMaterial *q) void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force) { - g_micaMaterialData()->mutex.lock(); if (!g_micaMaterialData()->blurredWallpaper.isNull() && !force) { - g_micaMaterialData()->mutex.unlock(); return; } - g_micaMaterialData()->mutex.unlock(); const QSize size = QGuiApplication::primaryScreen()->virtualSize(); - g_micaMaterialData()->mutex.lock(); g_micaMaterialData()->blurredWallpaper = QPixmap(size); g_micaMaterialData()->blurredWallpaper.fill(kDefaultTransparentColor); - g_micaMaterialData()->mutex.unlock(); const QString wallpaperFilePath = Utils::getWallpaperFilePath(); if (wallpaperFilePath.isEmpty()) { WARNING << "Failed to retrieve the wallpaper file path."; @@ -562,7 +555,6 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force) const QRect rect = alignedRect(Qt::LeftToRight, Qt::AlignCenter, image.size(), desktopRect); bufferPainter.drawImage(rect.topLeft(), image); } - g_micaMaterialData()->mutex.lock(); QPainter painter(&g_micaMaterialData()->blurredWallpaper); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); @@ -571,7 +563,6 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force) #else // !FRAMELESSHELPER_CORE_NO_PRIVATE qt_blurImage(&painter, buffer, kDefaultBlurRadius, true, false); #endif // FRAMELESSHELPER_CORE_NO_PRIVATE - g_micaMaterialData()->mutex.unlock(); if (initialized) { Q_Q(MicaMaterial); Q_EMIT q->shouldRedraw(); @@ -617,9 +608,7 @@ void MicaMaterialPrivate::paint(QPainter *painter, const QSize &size, const QPoi painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); if (active) { - g_micaMaterialData()->mutex.lock(); painter->drawPixmap(originPoint, g_micaMaterialData()->blurredWallpaper, QRect(pos, size)); - g_micaMaterialData()->mutex.unlock(); } painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->setOpacity(qreal(1)); @@ -661,13 +650,10 @@ void MicaMaterialPrivate::initialize() void MicaMaterialPrivate::prepareGraphicsResources() { - g_micaMaterialData()->mutex.lock(); if (g_micaMaterialData()->graphicsResourcesReady) { - g_micaMaterialData()->mutex.unlock(); return; } g_micaMaterialData()->graphicsResourcesReady = true; - g_micaMaterialData()->mutex.unlock(); maybeGenerateBlurredWallpaper(); } diff --git a/src/core/sysapiloader.cpp b/src/core/sysapiloader.cpp index dcf6a90..13024ed 100644 --- a/src/core/sysapiloader.cpp +++ b/src/core/sysapiloader.cpp @@ -45,7 +45,6 @@ #endif // SYSAPILOADER_QLIBRARY #include -#include #include #include #include @@ -74,7 +73,6 @@ static Q_LOGGING_CATEGORY(lcSysApiLoader, "wangwenx190.framelesshelper.core.sysa struct SysApiLoaderData { - QMutex mutex; QHash functionCache = {}; }; @@ -197,7 +195,6 @@ bool SysApiLoader::isAvailable(const QString &library, const QString &function) return false; } const QString key = generateUniqueKey(library, function); - const QMutexLocker locker(&g_loaderData()->mutex); if (g_loaderData()->functionCache.contains(key)) { if (LoaderDebugFlag) { DEBUG << Q_FUNC_INFO << "Function cache found:" << key; @@ -227,7 +224,6 @@ QFunctionPointer SysApiLoader::get(const QString &library, const QString &functi return nullptr; } const QString key = generateUniqueKey(library, function); - const QMutexLocker locker(&g_loaderData()->mutex); if (g_loaderData()->functionCache.contains(key)) { if (LoaderDebugFlag) { DEBUG << Q_FUNC_INFO << "Function cache found:" << key; diff --git a/src/core/utils_mac.mm b/src/core/utils_mac.mm index 2ce9808..1e1a76b 100644 --- a/src/core/utils_mac.mm +++ b/src/core/utils_mac.mm @@ -28,7 +28,6 @@ #include "framelessconfig_p.h" #include "framelesshelpercore_global_p.h" #include -#include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) @@ -551,7 +550,6 @@ private: struct MacUtilsData { - QMutex mutex; QHash hash = {}; }; @@ -577,7 +575,6 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData); if (!windowId) { return nil; } - const QMutexLocker locker(&g_macUtilsData()->mutex); if (!g_macUtilsData()->hash.contains(windowId)) { QWindow * const qwindow = Utils::findWindow(windowId); Q_ASSERT(qwindow); @@ -592,9 +589,9 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData); const auto proxy = new NSWindowProxy(qwindow, nswindow); g_macUtilsData()->hash.insert(windowId, proxy); } +#if 0 volatile static const auto hook = []() -> int { registerUninitializeHook([](){ - const QMutexLocker locker(&g_macUtilsData()->mutex); if (g_macUtilsData()->hash.isEmpty()) { return; } @@ -610,6 +607,7 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData); return 0; }(); Q_UNUSED(hook); +#endif return g_macUtilsData()->hash.value(windowId); } @@ -778,7 +776,6 @@ void Utils::removeWindowProxy(const WId windowId) if (!windowId) { return; } - const QMutexLocker locker(&g_macUtilsData()->mutex); if (!g_macUtilsData()->hash.contains(windowId)) { return; } diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index 473b28b..0a33d1b 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -32,7 +32,6 @@ #include "framelesshelpercore_global_p.h" #include "versionnumber_p.h" #include "scopeguard_p.h" -#include #include #include #include @@ -196,20 +195,12 @@ struct Win32UtilsHelperData struct Win32UtilsHelper { - QMutex mutex; QHash data = {}; + QList micaWindowIds = {}; }; Q_GLOBAL_STATIC(Win32UtilsHelper, g_utilsHelper) -struct MicaWindowData -{ - QMutex mutex; - QList windowIds = {}; -}; - -Q_GLOBAL_STATIC(MicaWindowData, g_micaData) - struct SYSTEM_METRIC { int DPI_96 = 0; // 100%. The scale factor for the device is 1x. @@ -498,13 +489,10 @@ static inline void moveWindowToMonitor(const HWND hwnd, const MONITORINFOEXW &ac return 0; } const auto windowId = reinterpret_cast(hWnd); - g_utilsHelper()->mutex.lock(); if (!g_utilsHelper()->data.contains(windowId)) { - g_utilsHelper()->mutex.unlock(); return DefWindowProcW(hWnd, uMsg, wParam, lParam); } const Win32UtilsHelperData data = g_utilsHelper()->data.value(windowId); - g_utilsHelper()->mutex.unlock(); const auto getNativePosFromMouse = [lParam]() -> QPoint { return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; }; @@ -666,9 +654,7 @@ void Utils::updateWindowFrameMargins(const WId windowId, const bool reset) if (!API_DWM_AVAILABLE(DwmExtendFrameIntoClientArea)) { return; } - g_micaData()->mutex.lock(); - const bool micaEnabled = g_micaData()->windowIds.contains(windowId); - g_micaData()->mutex.unlock(); + const bool micaEnabled = g_utilsHelper()->micaWindowIds.contains(windowId); const auto margins = [micaEnabled, reset]() -> MARGINS { // To make Mica/Mica Alt work for normal Win32 windows, we have to // let the window frame extend to the whole window (or disable the @@ -1431,7 +1417,6 @@ void Utils::installSystemMenuHook(const WId windowId, FramelessParamsConst param if (!windowId || !params) { return; } - const QMutexLocker locker(&g_utilsHelper()->mutex); if (g_utilsHelper()->data.contains(windowId)) { return; } @@ -1461,7 +1446,6 @@ void Utils::uninstallSystemMenuHook(const WId windowId) if (!windowId) { return; } - const QMutexLocker locker(&g_utilsHelper()->mutex); if (!g_utilsHelper()->data.contains(windowId)) { return; } @@ -1743,11 +1727,9 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode, return false; } const auto restoreWindowFrameMargins = [windowId]() -> void { - g_micaData()->mutex.lock(); - if (g_micaData()->windowIds.contains(windowId)) { - g_micaData()->windowIds.removeAll(windowId); + if (g_utilsHelper()->micaWindowIds.contains(windowId)) { + g_utilsHelper()->micaWindowIds.removeAll(windowId); } - g_micaData()->mutex.unlock(); updateWindowFrameMargins(windowId, false); }; const bool preferMicaAlt = (qEnvironmentVariableIntValue("FRAMELESSHELPER_PREFER_MICA_ALT") != 0); @@ -1818,11 +1800,9 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode, return result; } else { if ((blurMode == BlurMode::Windows_Mica) || (blurMode == BlurMode::Windows_MicaAlt)) { - g_micaData()->mutex.lock(); - if (!g_micaData()->windowIds.contains(windowId)) { - g_micaData()->windowIds.append(windowId); + if (!g_utilsHelper()->micaWindowIds.contains(windowId)) { + g_utilsHelper()->micaWindowIds.append(windowId); } - g_micaData()->mutex.unlock(); // By giving a negative value, DWM will extend the window frame into the whole // client area. We need this step because the Mica material can only be applied // to the non-client area of a window. Without this step, you'll get a window diff --git a/src/quick/framelessquickhelper.cpp b/src/quick/framelessquickhelper.cpp index ef0d28c..96a2616 100644 --- a/src/quick/framelessquickhelper.cpp +++ b/src/quick/framelessquickhelper.cpp @@ -33,7 +33,6 @@ #ifdef Q_OS_WINDOWS # include #endif // Q_OS_WINDOWS -#include #include #include #include @@ -86,7 +85,6 @@ struct QuickHelperData struct QuickHelper { - QMutex mutex; QHash data = {}; }; @@ -160,7 +158,6 @@ void FramelessQuickHelperPrivate::setTitleBarItem(QQuickItem *value) if (!value) { return; } - const QMutexLocker locker(&g_quickHelper()->mutex); QuickHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -181,13 +178,10 @@ void FramelessQuickHelperPrivate::attach() return; } - g_quickHelper()->mutex.lock(); QuickHelperData * const data = getWindowDataMutable(); if (!data || data->ready) { - g_quickHelper()->mutex.unlock(); return; } - g_quickHelper()->mutex.unlock(); SystemParameters params = {}; params.getWindowId = [window]() -> WId { return window->winId(); }; @@ -228,10 +222,8 @@ void FramelessQuickHelperPrivate::attach() FramelessManager::instance()->addWindow(¶ms); - g_quickHelper()->mutex.lock(); data->params = params; data->ready = true; - g_quickHelper()->mutex.unlock(); // We have to wait for a little time before moving the top level window // , because the platform window may not finish initializing by the time @@ -258,7 +250,6 @@ void FramelessQuickHelperPrivate::detach() return; } const WId windowId = w->winId(); - const QMutexLocker locker(&g_quickHelper()->mutex); if (!g_quickHelper()->data.contains(windowId)) { return; } @@ -273,7 +264,6 @@ void FramelessQuickHelperPrivate::setSystemButton(QQuickItem *item, const QuickG if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) { return; } - const QMutexLocker locker(&g_quickHelper()->mutex); QuickHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -306,7 +296,6 @@ void FramelessQuickHelperPrivate::setHitTestVisible(QQuickItem *item, const bool if (!item) { return; } - const QMutexLocker locker(&g_quickHelper()->mutex); QuickHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -326,7 +315,6 @@ void FramelessQuickHelperPrivate::setHitTestVisible(const QRect &rect, const boo if (!rect.isValid()) { return; } - const QMutexLocker locker(&g_quickHelper()->mutex); QuickHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -941,7 +929,6 @@ QuickHelperData FramelessQuickHelperPrivate::getWindowData() const return {}; } const WId windowId = window->winId(); - const QMutexLocker locker(&g_quickHelper()->mutex); if (!g_quickHelper()->data.contains(windowId)) { g_quickHelper()->data.insert(windowId, {}); } diff --git a/src/quick/quickmicamaterial.cpp b/src/quick/quickmicamaterial.cpp index f7b829c..1e70509 100644 --- a/src/quick/quickmicamaterial.cpp +++ b/src/quick/quickmicamaterial.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -58,13 +57,6 @@ FRAMELESSHELPER_BEGIN_NAMESPACE using namespace Global; -struct QuickMicaData -{ - QMutex mutex; -}; - -Q_GLOBAL_STATIC(QuickMicaData, g_data) - class WallpaperImageNode : public QObject, public QSGTransformNode { Q_OBJECT @@ -102,15 +94,11 @@ WallpaperImageNode::~WallpaperImageNode() = default; void WallpaperImageNode::initialize() { - g_data()->mutex.lock(); - QQuickWindow * const window = m_item->window(); m_node = new QSGSimpleTextureNode; m_node->setFiltering(QSGTexture::Linear); - g_data()->mutex.unlock(); - maybeGenerateWallpaperImageCache(); maybeUpdateWallpaperImageClipRect(); @@ -124,7 +112,6 @@ void WallpaperImageNode::initialize() void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force) { - const QMutexLocker locker(&g_data()->mutex); if (!m_pixmapCache.isNull() && !force) { return; } @@ -147,7 +134,6 @@ void WallpaperImageNode::maybeGenerateWallpaperImageCache(const bool force) void WallpaperImageNode::maybeUpdateWallpaperImageClipRect() { - const QMutexLocker locker(&g_data()->mutex); #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) const QSizeF itemSize = m_item->size(); #else diff --git a/src/widgets/framelesswidgetshelper.cpp b/src/widgets/framelesswidgetshelper.cpp index fcf3f56..aeb6323 100644 --- a/src/widgets/framelesswidgetshelper.cpp +++ b/src/widgets/framelesswidgetshelper.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -82,7 +81,6 @@ struct WidgetsHelperData struct WidgetsHelper { - QMutex mutex; QHash data = {}; }; @@ -440,7 +438,6 @@ void FramelessWidgetsHelperPrivate::setTitleBarWidget(QWidget *widget) if (!widget) { return; } - const QMutexLocker locker(&g_widgetsHelper()->mutex); WidgetsHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -463,7 +460,6 @@ void FramelessWidgetsHelperPrivate::setHitTestVisible(QWidget *widget, const boo if (!widget) { return; } - const QMutexLocker locker(&g_widgetsHelper()->mutex); WidgetsHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -483,7 +479,6 @@ void FramelessWidgetsHelperPrivate::setHitTestVisible(const QRect &rect, const b if (!rect.isValid()) { return; } - const QMutexLocker locker(&g_widgetsHelper()->mutex); WidgetsHelperData *data = getWindowDataMutable(); if (!data) { return; @@ -530,13 +525,10 @@ void FramelessWidgetsHelperPrivate::attach() window->setAttribute(Qt::WA_NativeWindow); } - g_widgetsHelper()->mutex.lock(); WidgetsHelperData * const data = getWindowDataMutable(); if (!data || data->ready) { - g_widgetsHelper()->mutex.unlock(); return; } - g_widgetsHelper()->mutex.unlock(); SystemParameters params = {}; params.getWindowId = [window]() -> WId { return window->winId(); }; @@ -575,10 +567,8 @@ void FramelessWidgetsHelperPrivate::attach() FramelessManager::instance()->addWindow(¶ms); - g_widgetsHelper()->mutex.lock(); data->params = params; data->ready = true; - g_widgetsHelper()->mutex.unlock(); // We have to wait for a little time before moving the top level window // , because the platform window may not finish initializing by the time @@ -604,7 +594,6 @@ void FramelessWidgetsHelperPrivate::detach() return; } const WId windowId = m_window->winId(); - const QMutexLocker locker(&g_widgetsHelper()->mutex); if (!g_widgetsHelper()->data.contains(windowId)) { return; } @@ -649,7 +638,6 @@ WidgetsHelperData FramelessWidgetsHelperPrivate::getWindowData() const return {}; } const WId windowId = m_window->winId(); - const QMutexLocker locker(&g_widgetsHelper()->mutex); if (!g_widgetsHelper()->data.contains(windowId)) { g_widgetsHelper()->data.insert(windowId, {}); } @@ -942,7 +930,6 @@ void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const Syste if (!widget || (buttonType == SystemButtonType::Unknown)) { return; } - const QMutexLocker locker(&g_widgetsHelper()->mutex); WidgetsHelperData *data = getWindowDataMutable(); if (!data) { return;