Allow non-activatable window on Windows.

This commit is contained in:
John Preston 2020-01-07 15:16:00 +03:00
parent 4ec9e32f8f
commit 26e6a3050c
4 changed files with 22 additions and 0 deletions

View file

@ -43,5 +43,8 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
return false;
}
void IgnoreAllActivation(not_null<QWidget*> widget) {
}
} // namespace Platform
} // namespace Ui

View file

@ -91,5 +91,8 @@ void DrainMainQueue() {
_dispatch_main_queue_callback_4CF(nullptr);
}
void IgnoreAllActivation(not_null<QWidget*> widget) {
}
} // namespace Platform
} // namespace Ui

View file

@ -25,6 +25,7 @@ void ReInitOnTopPanel(not_null<QWidget*> panel);
void UpdateOverlayed(not_null<QWidget*> widget);
void ShowOverAll(not_null<QWidget*> widget, bool canFocus = true);
void BringToBack(not_null<QWidget*> widget);
void IgnoreAllActivation(not_null<QWidget*> widget);
[[nodiscard]] constexpr bool UseMainQueueGeneric();
void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false.

View file

@ -8,6 +8,8 @@
#include <QtWidgets/QApplication>
#include "base/platform/win/base_windows_h.h"
namespace Ui {
namespace Platform {
@ -27,5 +29,18 @@ void UpdateOverlayed(not_null<QWidget*> widget) {
if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false);
}
void IgnoreAllActivation(not_null<QWidget*> widget) {
const auto handle = reinterpret_cast<HWND>(widget->winId());
Assert(handle != nullptr);
ShowWindow(handle, SW_HIDE);
const auto style = GetWindowLong(handle, GWL_EXSTYLE);
SetWindowLong(
handle,
GWL_EXSTYLE,
style | WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
ShowWindow(handle, SW_SHOW);
}
} // namespace Platform
} // namespace Ui