-
Notifications
You must be signed in to change notification settings - Fork 3
Window Event System
On this page, you will find architectural information regarding the window event system.
Windows allows us to control its windows through a set of events that we must process. A complete list of these events is available at https://wiki.winehq.org/List_Of_Windows_Messages.
In DX Renderer the user can define any number of handlers he wants to a given event, these handlers are defined using lambda functions and registered using the function RegisterWindowEventCallback
.
Here is an example of how to do this:
...
window.RegisterWindowEventCallback(WM_MOVE,{void [](HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam){
std::cout<<"Windows Moved\n";
},WM_MOVE,"Test Module"});
...
When the event handling loop for the window receives a messaage he calls both the default behavior and all other registered event handlers by register order.
Due to limitations on the WINAPI the loop handles messages for the window must always run in the same thread as the window was created on, however is some cases this can cause blocking and even hanging, therefore the recomemded way to handle this is to create the window in the main thread and run all other rendering operations on a second thread.