+void WM_SetWindowTitle(tWindow *Window, const char *Title)
+{
+ if(Window->Title)
+ free(Window->Title);
+ Window->Title = strdup(Title);
+ _SysDebug("Window %p title set to '%s'", Window, Title);
+}
+
+void WM_RaiseWindow(tWindow *Window)
+{
+ tWindow *parent = Window->Parent;
+ if(!Window->Parent) return ;
+
+ // Remove from list
+ if(Window->PrevSibling)
+ Window->PrevSibling->NextSibling = Window->NextSibling;
+ if(Window->NextSibling)
+ Window->NextSibling->PrevSibling = Window->PrevSibling;
+ if(parent->FirstChild == Window)
+ parent->FirstChild = Window->NextSibling;
+ if(parent->LastChild == Window)
+ parent->LastChild = Window->PrevSibling;
+
+ // Append to end
+ if(parent->LastChild)
+ parent->LastChild->NextSibling = Window;
+ else
+ parent->FirstChild = Window;
+ Window->PrevSibling = parent->LastChild;
+ Window->NextSibling = NULL;
+ parent->LastChild = Window;
+
+ _SysDebug("Raised %p", Window);
+}
+
+/*
+void WM_RaiseWindow(tWindow *Window)
+{
+ // Move to the last render position (move to top)
+ while(Window && Window->Parent)
+ {
+ if( Window->NextSibling )
+ {
+ // remove
+ if( Window->PrevSibling )
+ Window->PrevSibling->NextSibling = Window->NextSibling;
+ Window->NextSibling->PrevSibling = Window->PrevSibling;
+ // Mutate self
+ Window->PrevSibling = Window->Parent->LastChild;
+ Window->NextSibling = NULL;
+ // re-add
+ Window->PrevSibling->NextSibling = Window;
+ Window->Parent->LastChild = Window;
+ }
+ _SysDebug("WM_RaiseWindow: Raised %p", Window);
+ Window = Window->Parent;
+ }
+}
+*/
+
+void WM_FocusWindow(tWindow *Destination)
+{
+ struct sWndMsg_Bool _msg;
+
+ _SysDebug("WM_FocusWindow(%p)", Destination);
+
+ if( gpWM_FocusedWindow == Destination )
+ return ;
+ if( Destination && !(Destination->Flags & WINFLAG_SHOW) )
+ return ;
+
+ if( gpWM_FocusedWindow )
+ {
+ _msg.Val = 0;
+ WM_SendMessage(NULL, gpWM_FocusedWindow, WNDMSG_FOCUS, sizeof(_msg), &_msg);
+ }
+ if( Destination )
+ {
+ _msg.Val = 1;
+ WM_SendMessage(NULL, Destination, WNDMSG_FOCUS, sizeof(_msg), &_msg);
+ }
+
+ // TODO: Leave it up to the renderer to decide to invalidate
+ WM_Invalidate(gpWM_FocusedWindow, 1);
+ WM_Invalidate(Destination, 1);
+
+ gpWM_FocusedWindow = Destination;
+}
+
+