process the WM_GETMINMAXINFO message when the display deconnected

This commit is contained in:
dreamsourcelabTAI 2024-03-29 15:30:37 +08:00
parent 3f5a75b50c
commit da789cbcef
3 changed files with 865 additions and 818 deletions

View File

@ -263,14 +263,14 @@ void MainFrame::OnParentNaitveWindowEvent(int msg)
qApp->processEvents(); //wait the screen dpi ready.
QTimer::singleShot(100, this, [this](){
auto scr = _parentNativeWidget->GetPointScreen();
if (scr == NULL){
auto screen = _parentNativeWidget->GetPointScreen();
if (screen == NULL){
dsv_info("ERROR: MainFrame::OnParentNaitveWindowEvent, failed to get pointing screen.");
return;
screen = QGuiApplication::primaryScreen();
}
PopupDlgList::TryCloseAllByScreenChanged(scr);
PopupDlgList::SetCurrentScreen(scr);
PopupDlgList::TryCloseAllByScreenChanged(screen);
PopupDlgList::SetCurrentScreen(screen);
_parentNativeWidget->UpdateChildDpi();
_parentNativeWidget->ResizeChild();

File diff suppressed because it is too large Load Diff

View File

@ -1,121 +1,123 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WINNATIVEWINDOW_H
#define WINNATIVEWINDOW_H
#include <Windows.h>
#include <Windowsx.h>
#include <QWidget>
#include <QByteArray>
#include "interface/icallbacks.h"
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
#ifndef SM_CXPADDEDBORDER
#define SM_CXPADDEDBORDER 105
#endif
namespace pv {
class WinShadow;
class WinNativeWidget
{
public:
WinNativeWidget(const int x, const int y, const int width, const int heigh, bool isDark);
~WinNativeWidget();
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void SetChildWidget(QWidget *w);
void setGeometry(const int x, const int y, const int width, const int height);
inline HWND Handle(){
return _hWnd;
}
void Show(bool bShow);
void Move(int x, int y);
void ShowNormal();
void ShowMax();
void ShowMin();
void UpdateChildDpi();
void ResizeChild();
QScreen* GetPointScreen();
inline void SetNativeEventCallback(IParentNativeEventCallback *callback){
_event_callback = callback;
}
bool IsMaxsized();
bool IsMinsized();
bool IsNormalsized();
bool isActiveWindow();
void SetBorderColor(QColor color);
bool IsWin11OrGreater();
inline void SetTitleBarWidget(QWidget *w){
_titleBarWidget = w;
}
int GetDevicePixelRatio();
bool IsVisible();
void ReShowWindow();
private:
QScreen* screenFromWindow(HWND hwnd);
bool isWinXOrGreater(DWORD major_version, DWORD minor_version, DWORD build_number);
void showBorder();
void hideBorder();
bool getMonitorWorkArea(HMONITOR hCurrentMonitor, int *outWidth, int *outHeight);
private:
QWidget* childWidget;
HWND _childWindow;
HWND _hWnd;
QWidget *_titleBarWidget;
IParentNativeEventCallback *_event_callback;
bool _is_native_border;
HMONITOR _hCurrentMonitor;
WinShadow *_shadow;
QColor _border_color;
};
}
#endif // WINNATIVEWINDOW_H
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WINNATIVEWINDOW_H
#define WINNATIVEWINDOW_H
#include <Windows.h>
#include <Windowsx.h>
#include <QWidget>
#include <QByteArray>
#include "interface/icallbacks.h"
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
#ifndef SM_CXPADDEDBORDER
#define SM_CXPADDEDBORDER 105
#endif
namespace pv {
class WinShadow;
class WinNativeWidget
{
public:
WinNativeWidget(const int x, const int y, const int width, const int heigh, bool isDark);
~WinNativeWidget();
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void SetChildWidget(QWidget *w);
void setGeometry(const int x, const int y, const int width, const int height);
inline HWND Handle(){
return _hWnd;
}
void Show(bool bShow);
void Move(int x, int y);
void ShowNormal();
void ShowMax();
void ShowMin();
void UpdateChildDpi();
void ResizeChild();
QScreen* GetPointScreen();
inline void SetNativeEventCallback(IParentNativeEventCallback *callback){
_event_callback = callback;
}
bool IsMaxsized();
bool IsMinsized();
bool IsNormalsized();
bool isActiveWindow();
void SetBorderColor(QColor color);
bool IsWin11OrGreater();
inline void SetTitleBarWidget(QWidget *w){
_titleBarWidget = w;
}
int GetDevicePixelRatio();
bool IsVisible();
void ReShowWindow();
private:
QScreen* screenFromCurrentMonitorHandle();
bool isWinXOrGreater(DWORD major_version, DWORD minor_version, DWORD build_number);
void showBorder();
void hideBorder();
static RECT GetMonitorArea(HMONITOR hMonitor, bool isPhysics);
static bool getMonitorWorkArea(HMONITOR hMonitor, int *outWidth, int *outHeight);
private:
QWidget* childWidget;
HWND _childWindow;
HWND _hWnd;
QWidget *_titleBarWidget;
IParentNativeEventCallback *_event_callback;
bool _is_native_border;
HMONITOR _hCurrentMonitor;
WinShadow *_shadow;
QColor _border_color;
};
}
#endif // WINNATIVEWINDOW_H