diff options
author | Egor Nemtsev <enemtsev@luxoft.com> | 2020-04-01 16:10:30 +0300 |
---|---|---|
committer | Egor Nemtsev <enemtsev@luxoft.com> | 2020-04-07 10:52:03 +0000 |
commit | 5875d67d4e66db9fd97fdfa4ea35bef56ea6a96d (patch) | |
tree | 9e20b3aa9f61f1b1e162821741a999fa9168e268 | |
parent | 0b3dceee64bfd16ee4578a5f714f3a0690be1948 (diff) |
[qsr] fix for window transparency in Windows
- QWindow doesn't allow making window background transparent on Windows.
We have to use native calls to set black color as transparent. We set stay on
top flag to make qsr window be on top of cluster window.
Fixes: AUTOSUITE-1531
Change-Id: I2f3af57464c230fcdee470d3e4163c3a0c983bd4
Reviewed-by: Grigorii Zimin <gzimin@luxoft.com>
-rw-r--r-- | src/neptune3-ui-qsr-cluster/neptune3-ui-qsr-cluster.pro | 1 | ||||
-rw-r--r-- | src/neptune3-ui-qsr-cluster/safewindow.cpp | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/neptune3-ui-qsr-cluster/neptune3-ui-qsr-cluster.pro b/src/neptune3-ui-qsr-cluster/neptune3-ui-qsr-cluster.pro index f8dc7355..e67bfe3d 100644 --- a/src/neptune3-ui-qsr-cluster/neptune3-ui-qsr-cluster.pro +++ b/src/neptune3-ui-qsr-cluster/neptune3-ui-qsr-cluster.pro @@ -19,6 +19,7 @@ win32 { wrapper.files = neptune3-ui-qsr-cluster_wrapper.bat wrapper.path = $$INSTALL_PREFIX/neptune3 INSTALLS += wrapper + LIBS += -lUser32 } QT = core gui qtsaferenderer network ivicore diff --git a/src/neptune3-ui-qsr-cluster/safewindow.cpp b/src/neptune3-ui-qsr-cluster/safewindow.cpp index 93fff2ae..4901caf4 100644 --- a/src/neptune3-ui-qsr-cluster/safewindow.cpp +++ b/src/neptune3-ui-qsr-cluster/safewindow.cpp @@ -74,6 +74,21 @@ SafeWindow::SafeWindow(const SafeRenderer::QSafeSize &size, // transparent om Mac QTBUG-77637 SafeWindowMac::setWindowTransparent(reinterpret_cast<void*>(this->winId())); #endif + #ifdef Q_OS_WIN32 + // QWindow doesn't allow making window background transparent on Windows, + // we have to use native calls to set black color as transparent. + // We make window stay on top as rise() function doesn't work as it does on + // macOS and Linux platforms (still remains under cluster window) + this->setFlag(Qt::WindowStaysOnTopHint); + this->setFlag(Qt::WindowTitleHint); + this->setFlag(Qt::WindowSystemMenuHint); + this->setFlag(Qt::WindowCloseButtonHint); + + HWND hwnd = reinterpret_cast<HWND>(this->winId()); + SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + SetLayeredWindowAttributes(hwnd, 0, 0, LWA_COLORKEY); + #endif + QSurfaceFormat fmt = format(); fmt.setAlphaBufferSize(8); setFormat(fmt); |