Pop-ups are no longer children of the GetForegroundWindow() when no parent window is specified. Instead, they are displayed as a standalone app.

This commit is contained in:
Simon Rozman 2017-02-21 15:13:20 +01:00
parent e7d5ecb50b
commit 48d46617d2

View File

@ -118,19 +118,24 @@ void eap::peer_ttls_ui::invoke_config_ui(
// Initialize application. // Initialize application.
wxInitializerPeer init(m_instance); wxInitializerPeer init(m_instance);
{ wxWindow *parent;
if (hwndParent) {
// Create wxWidget-approved parent window. // Create wxWidget-approved parent window.
wxWindow parent; parent = new wxWindow;
parent.SetHWND((WXHWND)(hwndParent ? hwndParent : GetForegroundWindow())); parent->SetHWND((WXHWND)hwndParent);
parent.AdoptAttributesFromHWND(); parent->AdoptAttributesFromHWND();
wxTopLevelWindows.Append(&parent); wxTopLevelWindows.Append(parent);
} else
parent = NULL;
// Create and launch configuration dialog. // Create and launch configuration dialog.
wxEAPConfigDialog<wxTTLSConfigWindow> dlg(cfg, &parent); wxEAPConfigDialog<wxTTLSConfigWindow> dlg(cfg, parent);
if (!parent) ::FlashWindow(dlg.GetHWND(), TRUE);
result = dlg.ShowModal(); result = dlg.ShowModal();
wxTopLevelWindows.DeleteObject(&parent); if (parent) {
parent.SetHWND((WXHWND)NULL); wxTopLevelWindows.DeleteObject(parent);
parent->SetHWND((WXHWND)NULL);
} }
} }
@ -153,6 +158,9 @@ void eap::peer_ttls_ui::invoke_identity_ui(
_Out_ DWORD *pdwUserDataOutSize, _Out_ DWORD *pdwUserDataOutSize,
_Out_ LPWSTR *ppwszIdentity) _Out_ LPWSTR *ppwszIdentity)
{ {
#ifdef _DEBUG
//::Sleep(10000);
#endif
assert(ppwszIdentity); assert(ppwszIdentity);
// Unpack configuration. // Unpack configuration.
@ -178,19 +186,23 @@ void eap::peer_ttls_ui::invoke_identity_ui(
// Initialize application. // Initialize application.
wxInitializerPeer init(m_instance); wxInitializerPeer init(m_instance);
{ wxWindow *parent;
if (hwndParent) {
// Create wxWidget-approved parent window. // Create wxWidget-approved parent window.
wxWindow parent; parent = new wxWindow;
parent.SetHWND((WXHWND)(hwndParent ? hwndParent : GetForegroundWindow())); parent->SetHWND((WXHWND)hwndParent);
parent.AdoptAttributesFromHWND(); parent->AdoptAttributesFromHWND();
wxTopLevelWindows.Append(&parent); wxTopLevelWindows.Append(parent);
} else
parent = NULL;
if (cfg.m_providers.size() > 1) { if (cfg.m_providers.size() > 1) {
// Multiple identity providers: User has to select one first. // Multiple identity providers: User has to select one first.
wxEAPProviderSelectDialog dlg(cfg, &parent); wxEAPProviderSelectDialog dlg(cfg, parent);
// Centre and display dialog. // Centre and display dialog.
dlg.Centre(wxBOTH); dlg.Centre(wxBOTH);
if (!parent) ::FlashWindow(dlg.GetHWND(), TRUE);
if ((result = dlg.ShowModal()) == wxID_OK) { if ((result = dlg.ShowModal()) == wxID_OK) {
cfg_prov = dlg.GetSelection(); cfg_prov = dlg.GetSelection();
assert(cfg_prov); assert(cfg_prov);
@ -240,7 +252,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
src_outer != eap::credentials::source_config && eap::config_method::status_cred_begin <= cfg_method->m_last_status && cfg_method->m_last_status < eap::config_method::status_cred_end) src_outer != eap::credentials::source_config && eap::config_method::status_cred_begin <= cfg_method->m_last_status && cfg_method->m_last_status < eap::config_method::status_cred_end)
{ {
// Build dialog to prompt for outer credentials. // Build dialog to prompt for outer credentials.
wxEAPCredentialsDialog dlg(*cfg_prov, &parent); wxEAPCredentialsDialog dlg(*cfg_prov, parent);
if (eap::config_method::status_cred_begin <= cfg_method->m_last_status && cfg_method->m_last_status < eap::config_method::status_cred_end) if (eap::config_method::status_cred_begin <= cfg_method->m_last_status && cfg_method->m_last_status < eap::config_method::status_cred_end)
dlg.AddContent(new wxEAPCredentialWarningPanel(*cfg_prov, cfg_method->m_last_status, &dlg)); dlg.AddContent(new wxEAPCredentialWarningPanel(*cfg_prov, cfg_method->m_last_status, &dlg));
auto panel = new wxTLSCredentialsPanel(*cfg_prov, *cfg_method, *cred, &dlg, false); auto panel = new wxTLSCredentialsPanel(*cfg_prov, *cfg_method, *cred, &dlg, false);
@ -253,6 +265,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
// Centre and display dialog. // Centre and display dialog.
dlg.Centre(wxBOTH); dlg.Centre(wxBOTH);
if (!parent) ::FlashWindow(dlg.GetHWND(), TRUE);
if ((result = dlg.ShowModal()) == wxID_OK) { if ((result = dlg.ShowModal()) == wxID_OK) {
// Write credentials to credential manager. // Write credentials to credential manager.
if (panel->GetRemember()) { if (panel->GetRemember()) {
@ -290,7 +303,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
#endif #endif
{ {
// Native inner methods. Build dialog to prompt for inner credentials. // Native inner methods. Build dialog to prompt for inner credentials.
wxEAPCredentialsDialog dlg(*cfg_prov, &parent); wxEAPCredentialsDialog dlg(*cfg_prov, parent);
if (eap::config_method::status_cred_begin <= cfg_method->m_inner->m_last_status && cfg_method->m_inner->m_last_status < eap::config_method::status_cred_end) if (eap::config_method::status_cred_begin <= cfg_method->m_inner->m_last_status && cfg_method->m_inner->m_last_status < eap::config_method::status_cred_end)
dlg.AddContent(new wxEAPCredentialWarningPanel(*cfg_prov, cfg_method->m_inner->m_last_status, &dlg)); dlg.AddContent(new wxEAPCredentialWarningPanel(*cfg_prov, cfg_method->m_inner->m_last_status, &dlg));
wxEAPCredentialsPanelBase *panel = NULL; wxEAPCredentialsPanelBase *panel = NULL;
@ -321,6 +334,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
// Centre and display dialog. // Centre and display dialog.
dlg.Centre(wxBOTH); dlg.Centre(wxBOTH);
if (!parent) ::FlashWindow(dlg.GetHWND(), TRUE);
if ((result = dlg.ShowModal()) == wxID_OK) { if ((result = dlg.ShowModal()) == wxID_OK) {
// Write credentials to credential manager. // Write credentials to credential manager.
if (panel->GetRemember()) { if (panel->GetRemember()) {
@ -374,8 +388,9 @@ void eap::peer_ttls_ui::invoke_identity_ui(
} }
} }
wxTopLevelWindows.DeleteObject(&parent); if (parent) {
parent.SetHWND((WXHWND)NULL); wxTopLevelWindows.DeleteObject(parent);
parent->SetHWND((WXHWND)NULL);
} }
} }
@ -434,12 +449,15 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
// Initialize application. // Initialize application.
wxInitializerPeer init(m_instance); wxInitializerPeer init(m_instance);
{ wxWindow *parent;
if (hwndParent) {
// Create wxWidget-approved parent window. // Create wxWidget-approved parent window.
wxWindow parent; parent = new wxWindow;
parent.SetHWND((WXHWND)(hwndParent ? hwndParent : GetForegroundWindow())); parent->SetHWND((WXHWND)hwndParent);
parent.AdoptAttributesFromHWND(); parent->AdoptAttributesFromHWND();
wxTopLevelWindows.Append(&parent); wxTopLevelWindows.Append(parent);
} else
parent = NULL;
{ {
sanitizing_wstring sanitizing_wstring
@ -447,7 +465,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
response; response;
// Build dialog to prompt for response. // Build dialog to prompt for response.
wxGTCResponseDialog dlg(*cfg_prov, &parent); wxGTCResponseDialog dlg(*cfg_prov, parent);
auto panel = new wxGTCResponsePanel(response, challenge.c_str(), &dlg); auto panel = new wxGTCResponsePanel(response, challenge.c_str(), &dlg);
dlg.AddContent(panel); dlg.AddContent(panel);
@ -457,6 +475,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
// Centre and display dialog. // Centre and display dialog.
dlg.Centre(wxBOTH); dlg.Centre(wxBOTH);
if (!parent) ::FlashWindow(dlg.GetHWND(), TRUE);
if ((result = dlg.ShowModal()) == wxID_OK) { if ((result = dlg.ShowModal()) == wxID_OK) {
// Save response. // Save response.
ctx.m_data.assign( ctx.m_data.assign(
@ -465,8 +484,9 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
} }
} }
wxTopLevelWindows.DeleteObject(&parent); if (parent) {
parent.SetHWND((WXHWND)NULL); wxTopLevelWindows.DeleteObject(parent);
parent->SetHWND((WXHWND)NULL);
} }
} }