| | |
| | | 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]() { |
| | |
| | | } g_hook{}; |
| | | #endif |
| | | |
| | | class NSWindowProxy { |
| | | Q_DISABLE_COPY(NSWindowProxy) |
| | | |
| | | public: |
| | | struct NSWindowProxy { |
| | | NSWindowProxy(NSWindow *macWindow) { |
| | | if (instances.contains(macWindow)) { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | ~NSWindowProxy() override { |
| | | ~NSWindowProxy() { |
| | | instances.remove(nswindow); |
| | | if (instances.count() <= 0) { |
| | | restoreImplementations(); |
| | |
| | | } |
| | | |
| | | private: |
| | | Q_DISABLE_COPY(NSWindowProxy) |
| | | |
| | | NSWindow *nswindow = nil; |
| | | // NSEvent *lastMouseDownEvent = nil; |
| | | |
| | |
| | | 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); |
| | | } |
| | |
| | | ::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 |
| | |
| | | } |
| | | 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); |
| | |
| | | // 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); |
| | | } |
| | |
| | | #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 |
| | |
| | | |
| | | 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. |
| | |
| | | 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, |
| | |
| | | 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: |
| | |
| | | |
| | | } |
| | | |
| | | #include "quickwindowagent_win.moc" |
| | | #include "quickwindowagent_win.moc" |
| | |
| | | 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(); |
| | |
| | | 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); |
| | |
| | | |
| | | } |
| | | |
| | | #include "widgetwindowagent_win.moc" |
| | | #include "widgetwindowagent_win.moc" |