Making setWindowTitle() on Windows thread safe.

This commit is contained in:
Dario Manesku 2014-08-10 16:23:17 +01:00
parent 2b01f8a874
commit 65f5faceec

View file

@ -17,6 +17,7 @@
#define WM_USER_SET_WINDOW_SIZE (WM_USER+0) #define WM_USER_SET_WINDOW_SIZE (WM_USER+0)
#define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1) #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1)
#define WM_USER_MOUSE_LOCK (WM_USER+2) #define WM_USER_MOUSE_LOCK (WM_USER+2)
#define WM_USER_SET_WINDOW_TITLE (WM_USER+3)
namespace entry namespace entry
{ {
@ -259,6 +260,12 @@ namespace entry
} }
break; break;
case WM_USER_SET_WINDOW_TITLE:
{
SetWindowText(_hwnd, (const char*)_lparam);
}
break;
case WM_USER_TOGGLE_WINDOW_FRAME: case WM_USER_TOGGLE_WINDOW_FRAME:
{ {
if (m_frame) if (m_frame)
@ -586,11 +593,6 @@ namespace entry
} }
} }
void setWindowTitle(const char* _title)
{
SetWindowText(m_hwnd, _title);
}
static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam); static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam);
EventQueue m_eventQueue; EventQueue m_eventQueue;
@ -641,7 +643,7 @@ namespace entry
void setWindowTitle(const char* _title) void setWindowTitle(const char* _title)
{ {
s_ctx.setWindowTitle(_title); PostMessage(s_ctx.m_hwnd, WM_USER_SET_WINDOW_TITLE, 0, (LPARAM)_title);
} }
void toggleWindowFrame() void toggleWindowFrame()