Zhao Yuhang
2023-12-14 5ee113e2c4f916b1078ace782bb130f5edf64bcf
minor tweaks
6个文件已修改
37 ■■■■ 已修改文件
examples/mainwindow/mainwindow.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/cocoawindowcontext.mm 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/qwindowkit_windows.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/quick/quickwindowagent_win.cpp 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetwindowagent_win.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/mainwindow/mainwindow.cpp
@@ -176,7 +176,7 @@
        QTimer::singleShot(75, [iconButton, agent]() {
            if (iconButton->property("double-click-close").toBool())
                return;
            agent->showSystemMenu(iconButton->mapToGlobal({0, iconButton->height()}));
            agent->showSystemMenu(iconButton->mapToGlobal(QPoint{0, iconButton->height()}));
        });
    });
    connect(iconButton, &QWK::WindowButton::doubleClicked, this, [iconButton, this]() {
src/core/contexts/cocoawindowcontext.mm
@@ -15,10 +15,7 @@
    } g_hook{};
#endif
    class NSWindowProxy {
        Q_DISABLE_COPY(NSWindowProxy)
    public:
    struct NSWindowProxy {
        NSWindowProxy(NSWindow *macWindow) {
            if (instances.contains(macWindow)) {
                return;
@@ -31,7 +28,7 @@
            }
        }
        ~NSWindowProxy() override {
        ~NSWindowProxy() {
            instances.remove(nswindow);
            if (instances.count() <= 0) {
                restoreImplementations();
@@ -184,6 +181,8 @@
        }
    private:
        Q_DISABLE_COPY(NSWindowProxy)
        NSWindow *nswindow = nil;
        // NSEvent *lastMouseDownEvent = nil;
src/core/contexts/win32windowcontext.cpp
@@ -428,8 +428,8 @@
        const auto monitorInfo = getMonitorForWindow(hwnd);
        RECT windowRect{};
        ::GetWindowRect(hwnd, &windowRect);
        const auto newX = (RECT_WIDTH(monitorInfo.rcMonitor) - RECT_WIDTH(windowRect)) / 2;
        const auto newY = (RECT_HEIGHT(monitorInfo.rcMonitor) - RECT_HEIGHT(windowRect)) / 2;
        const auto newX = monitorInfo.rcMonitor.left + (RECT_WIDTH(monitorInfo.rcMonitor) - RECT_WIDTH(windowRect)) / 2;
        const auto newY = monitorInfo.rcMonitor.top + (RECT_HEIGHT(monitorInfo.rcMonitor) - RECT_HEIGHT(windowRect)) / 2;
        ::SetWindowPos(hwnd, nullptr, newX, newY, 0, 0,
                       SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
    }
@@ -448,6 +448,9 @@
        ::GetWindowPlacement(hwnd, &wp);
        return ((wp.showCmd == SW_NORMAL) || (wp.showCmd == SW_RESTORE));
#else
        if (isFullScreen(hwnd)) {
            return false;
        }
        const auto style = static_cast<DWORD>(::GetWindowLongPtrW(hwnd, GWL_STYLE));
        return (!(style & (WS_MINIMIZE | WS_MAXIMIZE)));
#endif
@@ -840,7 +843,7 @@
                }
                painter.save();
                // ### TODO: do we need to enable or disable it?
                // We needs anti-aliasing to give us better result.
                painter.setRenderHint(QPainter::Antialiasing);
                painter.setPen(pen);
@@ -1236,7 +1239,7 @@
                    // If wParam is TRUE, the window is being shown.
                    // If lParam is zero, the message was sent because of a call to the ShowWindow
                    // function.
                    if (wParam && lParam == 0) {
                    if (wParam && !lParam) {
                        centered = true;
                        moveToDesktopCenter(hWnd);
                    }
src/core/qwindowkit_windows.h
@@ -15,11 +15,11 @@
#endif
#ifndef IsMinimized
#  define IsMinimized(hwnd) (::IsIconic(hwnd) != FALSE)
#  define IsMinimized(hwnd) (::IsIconic(hwnd))
#endif
#ifndef IsMaximized
#  define IsMaximized(hwnd) (::IsZoomed(hwnd) != FALSE)
#  define IsMaximized(hwnd) (::IsZoomed(hwnd))
#endif
#ifndef RECT_WIDTH
src/quick/quickwindowagent_win.cpp
@@ -31,8 +31,7 @@
    BorderItem::BorderItem(QQuickItem *parent, AbstractWindowContext *context)
        : QQuickPaintedItem(parent), context(context) {
        setAntialiasing(true);   // ### FIXME: do we need to enable or disable this?
        setMipmap(true);         // ### FIXME: do we need to enable or disable this?
        setAntialiasing(true);   // We needs anti-aliasing to give us better result.
        setFillColor({});        // Will improve the performance a little bit.
        setOpaquePainting(true); // Will also improve the performance, we don't draw
                                 // semi-transparent borders of course.
@@ -43,7 +42,7 @@
        anchors->setLeft(parentPri->left());
        anchors->setRight(parentPri->right());
        setZ(10);
        setZ(9999); // Make sure our fake border always above everything in the window.
        context->installNativeEventFilter(this);
        connect(window(), &QQuickWindow::activeChanged, this,
@@ -84,7 +83,7 @@
    bool BorderItem::nativeEventFilter(const QByteArray &eventType, void *message,
                                       QT_NATIVE_EVENT_RESULT_TYPE *result) {
        Q_UNUSED(eventType)
        auto msg = reinterpret_cast<const MSG *>(message);
        const auto msg = static_cast<const MSG *>(message);
        switch (msg->message) {
            case WM_THEMECHANGED:
            case WM_SYSCOLORCHANGE:
src/widgets/widgetwindowagent_win.cpp
@@ -35,7 +35,7 @@
        bool nativeEventFilter(const QByteArray &eventType, void *message,
                               QT_NATIVE_EVENT_RESULT_TYPE *result) override {
            Q_UNUSED(eventType)
            auto msg = reinterpret_cast<const MSG *>(message);
            const auto msg = static_cast<const MSG *>(message);
            switch (msg->message) {
                case WM_DPICHANGED: {
                    updateGeometry();
@@ -67,7 +67,7 @@
        bool eventFilter(QObject *obj, QEvent *event) override {
            switch (event->type()) {
                case QEvent::Paint: {
                    if (widget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen))
                    if (widget->windowState() & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen))
                        break;
                    auto paintEvent = static_cast<QPaintEvent *>(event);