mirror of https://github.com/buggins/dlangui.git
fix #95 - window.close behavior on Win32
This commit is contained in:
parent
61225f156d
commit
0a3ef886b2
|
@ -72,7 +72,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL</versionids>
|
<versionids>EmbedStandardResources Unicode USE_FREETYPE</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
@ -96,6 +96,7 @@
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>2</cRuntime>
|
<cRuntime>2</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
<additionalOptions />
|
<additionalOptions />
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
@ -197,6 +198,7 @@
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>1</cRuntime>
|
<cRuntime>1</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
<additionalOptions />
|
<additionalOptions />
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>2</cRuntime>
|
<cRuntime>2</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
<additionalOptions>-profile</additionalOptions>
|
<additionalOptions>-profile</additionalOptions>
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
@ -197,6 +198,7 @@
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>1</cRuntime>
|
<cRuntime>1</cRuntime>
|
||||||
|
<privatePhobos>0</privatePhobos>
|
||||||
<additionalOptions />
|
<additionalOptions />
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
|
|
@ -773,6 +773,7 @@ class Win32Platform : Platform {
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
|
destroyClosedWindows();
|
||||||
}
|
}
|
||||||
return cast(int)msg.wParam;
|
return cast(int)msg.wParam;
|
||||||
}
|
}
|
||||||
|
@ -788,7 +789,8 @@ class Win32Platform : Platform {
|
||||||
Win32Window wnd = getWindow(hwnd);
|
Win32Window wnd = getWindow(hwnd);
|
||||||
if (wnd) {
|
if (wnd) {
|
||||||
_windowMap.remove(cast(ulong)hwnd);
|
_windowMap.remove(cast(ulong)hwnd);
|
||||||
destroy(window);
|
_windowsToDestroy ~= window;
|
||||||
|
//destroy(window);
|
||||||
}
|
}
|
||||||
return _windowMap.length > 0;
|
return _windowMap.length > 0;
|
||||||
}
|
}
|
||||||
|
@ -823,14 +825,25 @@ class Win32Platform : Platform {
|
||||||
w.dispatchThemeChanged();
|
w.dispatchThemeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
Win32Window _windowToClose;
|
/// list of windows for deferred destroy in message loop
|
||||||
|
Win32Window[] _windowsToDestroy;
|
||||||
|
|
||||||
/// close window
|
/// close window
|
||||||
override void closeWindow(Window w) {
|
override void closeWindow(Window w) {
|
||||||
Win32Window window = cast(Win32Window)w;
|
Win32Window window = cast(Win32Window)w;
|
||||||
_windowToClose = window;
|
_windowsToDestroy ~= window;
|
||||||
|
SendMessage(window._hwnd, WM_CLOSE, 0, 0);
|
||||||
|
//window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// destroy window objects planned for destroy
|
||||||
|
void destroyClosedWindows() {
|
||||||
|
foreach(Window w; _windowsToDestroy) {
|
||||||
|
destroy(w);
|
||||||
|
}
|
||||||
|
_windowsToDestroy.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||||
dstring res = null;
|
dstring res = null;
|
||||||
|
@ -1156,8 +1169,13 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
if (window !is null) {
|
if (window !is null) {
|
||||||
if (!window.handleCanClose())
|
bool canClose = window.handleCanClose();
|
||||||
|
if (!canClose) {
|
||||||
|
Log.d("WM_CLOSE: canClose is false");
|
||||||
return 0; // prevent closing
|
return 0; // prevent closing
|
||||||
|
}
|
||||||
|
Log.d("WM_CLOSE: closing window ");
|
||||||
|
//destroy(window);
|
||||||
}
|
}
|
||||||
// default handler inside DefWindowProc will close window
|
// default handler inside DefWindowProc will close window
|
||||||
break;
|
break;
|
||||||
|
@ -1168,13 +1186,6 @@ LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
//Log.d("Unhandled message ", message);
|
//Log.d("Unhandled message ", message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (w32platform._windowToClose) {
|
|
||||||
Win32Window wnd = w32platform._windowToClose;
|
|
||||||
w32platform._windowToClose = null;
|
|
||||||
destroy(wnd);
|
|
||||||
//HWND w = w32platform._windowToClose._hwnd;
|
|
||||||
//CloseWindow(w);
|
|
||||||
}
|
|
||||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue