Skip to content

Commit

Permalink
gh-275: Fix dialog glitches moving between monitors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximus5 committed Nov 17, 2017
1 parent 66e47b6 commit ebf6483
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/ConEmu/AboutDlg.cpp
Expand Up @@ -521,8 +521,7 @@ void ConEmuAbout::OnInfo_About(LPCWSTR asPageName /*= NULL*/)

{
DontEnable de;
if (!mp_DpiAware)
mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);
HWND hParent = (ghOpWnd && IsWindowVisible(ghOpWnd)) ? ghOpWnd : ghWnd;
// Modal dialog (CreateDialog)
INT_PTR iRc = CDynDialog::ExecuteDialog(IDD_ABOUT, hParent, aboutProc, (LPARAM)asPageName);
Expand Down
3 changes: 1 addition & 2 deletions src/ConEmu/Attach.cpp
Expand Up @@ -125,8 +125,7 @@ void CAttachDlg::AttachDlg()
return;
}

if (!mp_DpiAware)
mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);

bool bPrev = gpConEmu->SetSkipOnFocus(true);
// (CreateDialog)
Expand Down
17 changes: 17 additions & 0 deletions src/ConEmu/DpiAware.cpp
Expand Up @@ -406,6 +406,23 @@ class CDpiForDialog - handle per-monitor dpi for our resource-based dialogs
MMap<int, MArray<DlgItem>*> m_Items;
*/

bool CDpiForDialog::Create(CDpiForDialog*& pHelper)
{
if (pHelper)
return true;

// In Win10 and newly implemented PerMonitor DPI support we don't need dialog handlers anymore
if (IsWin10())
return false;

// Only if required
if (!CDpiAware::IsPerMonitorDpi())
return false;

pHelper = new CDpiForDialog();
return (pHelper != nullptr);
}

CDpiForDialog::CDpiForDialog()
{
mh_Dlg = NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/ConEmu/DpiAware.h
Expand Up @@ -122,8 +122,9 @@ class CDpiForDialog
};
MMap<int, MArray<DlgItem>*> m_Items;

public:
CDpiForDialog();
public:
static bool Create(CDpiForDialog*& pHelper);

~CDpiForDialog();

Expand Down
3 changes: 1 addition & 2 deletions src/ConEmu/FindDlg.cpp
Expand Up @@ -85,8 +85,7 @@ void CEFindDlg::FindTextDialog()

gpConEmu->SkipOneAppsRelease(true);

if (!mp_DpiAware)
mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);

// (CreateDialog)
mp_Dlg = CDynDialog::ShowDialog(IDD_FIND, ghWnd, findTextProc, 0/*Param*/);
Expand Down
2 changes: 1 addition & 1 deletion src/ConEmu/HotkeyDlg.cpp
Expand Up @@ -59,7 +59,7 @@ CHotKeyDialog::CHotKeyDialog(HWND hParent, DWORD aVkMod)
m_HK.HkType = chk_User;
m_HK.SetVkMod(aVkMod);

mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);
}

CHotKeyDialog::~CHotKeyDialog()
Expand Down
9 changes: 1 addition & 8 deletions src/ConEmu/OptionsClass.cpp
Expand Up @@ -1761,14 +1761,7 @@ void CSettings::Dialog(int IdShowPage /*= 0*/)
// Сначала обновить DC, чтобы некрасивостей не было
gpConEmu->UpdateWindowChild(NULL);

if (!gpSetCls->mp_DpiAware
#ifndef _DEBUG
&& CDpiAware::IsPerMonitorDpi()
#endif
)
{
gpSetCls->mp_DpiAware = new CDpiForDialog();
}
CDpiForDialog::Create(gpSetCls->mp_DpiAware);

wchar_t szLog[80]; _wsprintf(szLog, SKIPCOUNT(szLog) L"Creating settings dialog, IdPage=%u", IdShowPage);
LogString(szLog);
Expand Down
2 changes: 1 addition & 1 deletion src/ConEmu/OptionsFast.cpp
Expand Up @@ -850,7 +850,7 @@ void CheckOptionsFast(LPCWSTR asTitle, SettingsLoadedFlags slfFlags)
TerminateProcess(GetCurrentProcess(), CERR_FASTCONFIG_QUIT);
}

gp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(gp_DpiAware);

// Modal dialog (CreateDialog)

Expand Down
4 changes: 2 additions & 2 deletions src/ConEmu/RealConsole.cpp
Expand Up @@ -861,7 +861,7 @@ bool CRealConsole::ChangeAffinityPriority(LPCWSTR asAffinity /*= NULL*/, LPCWSTR
else
{
DontEnable de;
mp_PriorityDpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_PriorityDpiAware);
iRc = CDynDialog::ExecuteDialog(IDD_AFFINITY, ghWnd, priorityProc, (LPARAM)this);
SafeDelete(mp_PriorityDpiAware);
}
Expand Down Expand Up @@ -11354,7 +11354,7 @@ void CRealConsole::DoRenameTab()
return;

DontEnable de;
mp_RenameDpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_RenameDpiAware);
// Modal dialog (CreateDialog)
INT_PTR iRc = CDynDialog::ExecuteDialog(IDD_RENAMETAB, ghWnd, renameProc, (LPARAM)this);
if (iRc == IDOK)
Expand Down
3 changes: 1 addition & 2 deletions src/ConEmu/Recreate.cpp
Expand Up @@ -117,8 +117,7 @@ int CRecreateDlg::RecreateDlg(RConStartArgsEx* apArgs, bool abDontAutoSelCmd /*=
InitVars();

bool bPrev = gpConEmu->SetSkipOnFocus(true);
if (!mp_DpiAware)
mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);
// Modal dialog (CreateDialog)
int nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, (LPARAM)this);
UNREFERENCED_PARAMETER(nRc);
Expand Down
2 changes: 1 addition & 1 deletion src/ConEmu/SetPgApps.cpp
Expand Up @@ -680,7 +680,7 @@ bool CSetPgApps::CreateChildDlg()

if (!mp_DpiDistinct2 && mp_ParentDpi)
{
mp_DpiDistinct2 = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiDistinct2);
mp_DpiDistinct2->Attach(mh_Child, mh_Dlg, mp_DlgDistinct2);
}

Expand Down
3 changes: 1 addition & 2 deletions src/ConEmu/SetPgBase.cpp
Expand Up @@ -100,8 +100,7 @@ void CSetPgBase::InitObject(HWND ahParent, UINT anActivateTabMsg, const CDpiForD

if (apParentDpi)
{
if (!mp_DpiAware)
mp_DpiAware = new CDpiForDialog();
CDpiForDialog::Create(mp_DpiAware);
mb_DpiChanged = false;
}
else
Expand Down

0 comments on commit ebf6483

Please sign in to comment.