fix:the shadow is not displayed when window restore from minimized in windows 7

This commit is contained in:
dreamsourcelabTAI
2024-04-18 21:33:12 +08:00
parent bd067129eb
commit e3a66a12a1
3 changed files with 34 additions and 15 deletions
+25 -13
View File
@@ -44,6 +44,10 @@
#define FIXED_HEIGHT(widget) (widget->minimumHeight() >= widget->maximumHeight())
#define FIXED_SIZE(widget) (FIXED_WIDTH(widget) && FIXED_HEIGHT(widget))
#define WINDOW_STATUS_MAX 1
#define WINDOW_STATUS_NORMAL 2
#define WINDOW_STATUS_MIN 3
namespace pv {
//-----------------------------WinNativeWidget
@@ -55,7 +59,6 @@ WinNativeWidget::WinNativeWidget(const int x, const int y, const int width,
_hWnd = NULL;
_event_callback = NULL;
_is_lose_foreground = false;
_is_ncdown = false;
_titleBarWidget = NULL;
_is_native_border = IsWin11OrGreater();
@@ -145,6 +148,8 @@ void WinNativeWidget::ReShowWindow()
LRESULT CALLBACK WinNativeWidget::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bool bMoving = false;
WinNativeWidget *self = reinterpret_cast<WinNativeWidget*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
if (self == NULL){
@@ -177,15 +182,14 @@ LRESULT CALLBACK WinNativeWidget::WndProc(HWND hWnd, UINT message, WPARAM wParam
QApplication::sendEvent(self->_childWidget->GetBodyView(), &keyEvent);
break;
}
case WM_NCLBUTTONDOWN:
case WM_ENTERSIZEMOVE:
{
self->_is_ncdown = true;
bMoving = true;
break;
}
case WM_NCLBUTTONUP:
case WM_EXITSIZEMOVE:
{
self->_is_ncdown = false;
bMoving = false;
break;
}
case WM_NCCALCSIZE:
@@ -292,17 +296,17 @@ LRESULT CALLBACK WinNativeWidget::WndProc(HWND hWnd, UINT message, WPARAM wParam
}
break;
}
case WM_WINDOWPOSCHANGED:
case WM_WINDOWPOSCHANGING:
{
static int lst_state = -1;
if (self->_childWidget != NULL && self->_is_ncdown == false){
if (self->_childWidget != NULL && !bMoving){
int st = 3;
int st = WINDOW_STATUS_MIN;
if (self->IsMaxsized())
st = 1;
st = WINDOW_STATUS_MAX;
else if (self->IsNormalsized())
st = 2;
st = WINDOW_STATUS_NORMAL;
if (lst_state != st || self->_is_lose_foreground)
{
@@ -317,6 +321,14 @@ LRESULT CALLBACK WinNativeWidget::WndProc(HWND hWnd, UINT message, WPARAM wParam
break;
}
case WM_WINDOWPOSCHANGED:
{
if (IsIconic(hWnd)){
//the window switch to minimized.
self->_is_lose_foreground = true;
}
break;
}
case WM_GETMINMAXINFO:
{
if (self->_childWidget && self->_hCurrentMonitor)
@@ -763,19 +775,19 @@ void WinNativeWidget::setShadowStatus(int windowStatus)
switch (windowStatus)
{
case 1: //maximized
case WINDOW_STATUS_MAX:
{
_shadow->hideShadow();
hideBorder();
break;
}
case 2: //normal
case WINDOW_STATUS_NORMAL:
{
_shadow->showLater();
showBorder();
break;
}
case 3: //minimized
case WINDOW_STATUS_MIN:
{
_shadow->hideShadow();
break;
-1
View File
@@ -123,7 +123,6 @@ private:
WinShadow *_shadow;
QColor _border_color;
bool _is_lose_foreground;
bool _is_ncdown;
};
}
+9 -1
View File
@@ -101,8 +101,11 @@ void WinShadow::hideShadow()
if (!isVisible())
return;
QWidget::hide();
m_bActived = false;
repaint();
QWidget::hide();
}
bool WinShadow::nativeEvent(const QByteArray &eventType, void *message, long *result)
@@ -177,6 +180,11 @@ void WinShadow::moveShadow()
void WinShadow::paintEvent(QPaintEvent *event)
{
// The shandow is hiden.
if (!m_bActived){
return;
}
const int shadow_width = SHADOW_BORDER_WIDTH;
QPainter painter(this);
painter.setCompositionMode(QPainter::CompositionMode_Source);