diff options
Diffstat (limited to 'alf/alftoplevel.cpp')
| -rw-r--r-- | alf/alftoplevel.cpp | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/alf/alftoplevel.cpp b/alf/alftoplevel.cpp index b9f2e7b..d54d4b3 100644 --- a/alf/alftoplevel.cpp +++ b/alf/alftoplevel.cpp @@ -8,6 +8,7 @@ typedef struct { void *closure; ALFListHeader toplevelList; ALFApplication *app; + DWORD modalDisableDepth; DWORD flags; LPARAM modalResult; ALFLayout layout; @@ -461,6 +462,10 @@ ALF_CreateToplevelWindow(DWORD exstyle, DWORD style, HWND hwndOwner, ALFApplicat if (hwndOwner && GetWindowLong(hwndOwner, GWL_STYLE) & WS_CHILD) hwndOwner = GetParent(hwndOwner); + // copy app of owner, but only if we're in the same thread + if (!app && hwndOwner && GetWindowThreadProcessId(hwndOwner, NULL) == GetCurrentThreadId()) + app = ALF_Toplevel_Application(hwndOwner); + struct ALFToplevel_CreateParams params; params.vtbl = vtbl; params.closure = closure; @@ -487,6 +492,9 @@ ALF_Toplevel_ShowModal(HWND toplevel) ShowWindow(toplevel, SW_SHOW); + if (priv->app) + ALF_Application_DisableWindowsForModal(priv->app, toplevel); + if (owner) ownerEnabled = !EnableWindow(owner, FALSE); @@ -504,8 +512,11 @@ ALF_Toplevel_ShowModal(HWND toplevel) } } - if (owner) - EnableWindow(owner, ownerEnabled); + if (owner && ownerEnabled) + EnableWindow(owner, TRUE); + + if (priv->app) + ALF_Application_ReenableWindowsForModal(priv->app, toplevel); ShowWindow(toplevel, SW_HIDE); @@ -636,12 +647,42 @@ ALF_Application_PreTranslateMessage(ALFApplication *app, MSG *msg, HWND modalTop || (app->activeToplevel && app->activeToplevel->hwnd != modalToplevel && ALF_Toplevel_PreTranslateMessage(app->activeToplevel->hwnd, msg)); } -// TODO: implement modal stuff -/*void -ALF_Application_DisableWindowsForModal(ALFApplication *app, HWND skip); +void +ALF_Application_DisableWindowsForModal(ALFApplication *app, HWND skip) +{ + ALF_FOR_LIST(ALFToplevelPriv, toplevelList, &app->toplevelList, t) { + if (t->hwnd == skip) + continue; + + DWORD c = t->modalDisableDepth & 0x7fffffff; + if (c == 0) { + t->modalDisableDepth = 1; + if (EnableWindow(t->hwnd, FALSE)) + t->modalDisableDepth |= 0x80000000; // flag: was already disabled + } else { + t->modalDisableDepth++; + } + } +} void -ALF_Application_ReenableWindowsForModal(ALFApplication *app, HWND skip);*/ +ALF_Application_ReenableWindowsForModal(ALFApplication *app, HWND skip) +{ + ALF_FOR_LIST(ALFToplevelPriv, toplevelList, &app->toplevelList, t) { + if (t->hwnd == skip) + continue; + + DWORD c = t->modalDisableDepth & 0x7fffffff; + if (c == 1) { + if (!(t->modalDisableDepth & 0x80000000)) + EnableWindow(t->hwnd, TRUE); + + t->modalDisableDepth = 0; + } else { + t->modalDisableDepth--; + } + } +} void ALF_DestroyApplication(ALFApplication *app) |
