+ WM_SendMessage(NULL, Win, WNDMSG_MOUSEBTN, sizeof(msg), &msg);
+}
+
+void WM_Input_MouseButton(int X, int Y, int ButtonIndex, int Pressed)
+{
+ tWindow *win;
+
+ win = WM_int_GetWindowAtPos(X, Y);
+
+ // Handle press of primary button to change focus
+ if( ButtonIndex == 0 && Pressed == 1 )
+ {
+ _SysDebug("Gave focus to %p", win);
+ WM_GiveFocus(win);
+ WM_RaiseWindow(win);
+ }
+
+ // Make sure that even if the mouse has moved out of the original window,
+ // mouse release messages reach the window.
+ if( !Pressed && ButtonIndex < MAX_BUTTONS && gpWM_DownStartWindow[ButtonIndex] != win )
+ {
+ WM_Input_int_SendBtnMsg(gpWM_DownStartWindow[ButtonIndex], X, Y, ButtonIndex, 0);
+ }
+ if( Pressed && ButtonIndex < MAX_BUTTONS )
+ {
+ gpWM_DownStartWindow[ButtonIndex] = win;
+ }
+
+ // Send Press/Release message
+ WM_Input_int_SendBtnMsg(win, X, Y, ButtonIndex, Pressed);
+}
+
+// --- Manipulation Functions ---
+void WM_GiveFocus(tWindow *Destination)
+{
+ struct sWndMsg_Bool _msg;
+
+ if( gpWM_FocusedWindow == Destination )
+ return ;
+
+ _msg.Val = 0;
+ WM_SendMessage(NULL, gpWM_FocusedWindow, WNDMSG_FOCUS, sizeof(_msg), &_msg);
+ _msg.Val = 1;
+ WM_SendMessage(NULL, Destination, WNDMSG_FOCUS, sizeof(_msg), &_msg);
+
+ gpWM_FocusedWindow = Destination;