| | |
| | | g_wndProcHash->insert(hWnd, ctx); |
| | | } |
| | | |
| | | static inline void removeManagedWindow(HWND hWnd, bool restore) { |
| | | static inline void removeManagedWindow(HWND hWnd) { |
| | | // Remove window handle mapping |
| | | if (!g_wndProcHash->remove(hWnd)) |
| | | return; |
| | |
| | | if (g_wndProcHash->empty()) { |
| | | WindowsNativeEventFilter::uninstall(); |
| | | } |
| | | |
| | | // Restore window proc |
| | | if (restore) { |
| | | ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(g_qtWindowProc)); |
| | | } |
| | | } |
| | | |
| | | Win32WindowContext::Win32WindowContext() : AbstractWindowContext() { |
| | |
| | | |
| | | Win32WindowContext::~Win32WindowContext() { |
| | | if (windowId) { |
| | | removeManagedWindow(reinterpret_cast<HWND>(windowId), false); |
| | | removeManagedWindow(reinterpret_cast<HWND>(windowId)); |
| | | } |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | case RaiseWindowHook: { |
| | | if (m_windowHandle->windowStates() & Qt::WindowMinimized) |
| | | m_windowHandle->showNormal(); |
| | | |
| | | auto hWnd = reinterpret_cast<HWND>(windowId); |
| | | |
| | | // I have no idea what this does, but it works mostly |
| | | // https://www.codeproject.com/Articles/1724/Some-handy-dialog-box-tricks-tips-and-workarounds |
| | | |
| | | ::AttachThreadInput(::GetWindowThreadProcessId(::GetForegroundWindow(), nullptr), |
| | | ::GetCurrentThreadId(), TRUE); |
| | | |
| | | ::SetForegroundWindow(hWnd); |
| | | ::SetFocus(hWnd); |
| | | |
| | | ::AttachThreadInput(GetWindowThreadProcessId(GetForegroundWindow(), nullptr), |
| | | GetCurrentThreadId(), FALSE); |
| | | return; |
| | | } |
| | | |
| | | case ShowSystemMenuHook: { |
| | | const auto &pos = *static_cast<const QPoint *>(data); |
| | | auto hWnd = reinterpret_cast<HWND>(windowId); |
| | |
| | | showSystemMenu2(hWnd, qpoint2point(nativeGlobalPos), false, |
| | | m_delegate->isHostSizeFixed(m_host)); |
| | | return; |
| | | } |
| | | |
| | | case WindowAttributeChangedHook: { |
| | | auto args = static_cast<void **>(data); |
| | | const auto &key = *static_cast<const QString *>(args[0]); |
| | | const auto &newVar = *static_cast<const QVariant *>(args[1]); |
| | | const auto &oldVar = *static_cast<const QVariant *>(args[2]); |
| | | |
| | | if (key == QStringLiteral("no-frame-shadow")) { |
| | | if (newVar.toBool()) { |
| | | // TODO: set off |
| | | } else { |
| | | // TODO: set on |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | |
| | | case DefaultColorsHook: { |
| | |
| | | return getWindowFrameBorderThickness(reinterpret_cast<HWND>(windowId)); |
| | | } |
| | | |
| | | void Win32WindowContext::winIdChanged(QWindow *oldWindow, bool destroyed) { |
| | | if (oldWindow) { |
| | | removeManagedWindow(reinterpret_cast<HWND>(windowId), !destroyed); |
| | | } |
| | | |
| | | void Win32WindowContext::winIdChanged(QWindow *oldWindow) { |
| | | removeManagedWindow(reinterpret_cast<HWND>(windowId)); |
| | | if (!m_windowHandle) { |
| | | return; |
| | | } |