2 * Acess2 Window Manager v3
3 * - By John Hodge (thePowersGang)
6 * - Window manager core
9 #include <wm_internals.h>
10 #include <wm_messages.h>
13 extern tWindow *gpWM_RootWindow;
16 tWindow *WM_int_GetWindowAtPos(int X, int Y)
18 tWindow *win, *next_win, *ret;
20 next_win = gpWM_RootWindow;
26 for(win = ret->FirstChild; win; win = win->NextSibling)
28 if( !(win->Flags & WINFLAG_SHOW) ) continue ;
29 if( X < win->X || X >= win->X + win->W ) continue;
30 if( Y < win->Y || Y >= win->Y + win->H ) continue;
31 next_win = win; // Overwrite as we want the final rendered window
38 void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY)
40 tWindow *win, *newWin;
41 struct sWndMsg_MouseMove msg;
43 win = WM_int_GetWindowAtPos(OldX, OldY);
44 msg.X = NewX - win->X;
45 msg.Y = NewY - win->Y;
48 WM_SendMessage(NULL, win, WNDMSG_MOUSEMOVE, sizeof(msg), &msg);
50 // If the new coordinates are not in a new window
51 // NOTE: Should this handle crossing over a small window?
53 newWin = WM_int_GetWindowAtPos(NewX, NewY);
54 if(win == newWin) return;
56 // TODO: Send mouseup to match mousedown if the cursor moves out of a window?
59 msg.X = NewX - win->X;
60 msg.Y = NewY - win->Y;
63 WM_SendMessage(NULL, win, WNDMSG_MOUSEMOVE, sizeof(msg), &msg);
66 void WM_Input_MouseButton(int X, int Y, int ButtonIndex, int Pressed)
68 tWindow *win = WM_int_GetWindowAtPos(X, Y);
69 struct sWndMsg_MouseButton msg;
71 // Send Press/Release message
74 msg.Button = ButtonIndex;
75 msg.bPressed = !!Pressed;
77 WM_SendMessage(NULL, win, WNDMSG_MOUSEBTN, sizeof(msg), &msg);