extern void IPC_HandleSelect(fd_set *set);
extern void Input_FillSelect(int *nfds, fd_set *set);
extern void Input_HandleSelect(fd_set *set);
+// --- Local WM ---
+extern tApplication *AxWin_RegisterClient(int IdentLen, void *Ident, tMessages_Handle_Callback *Cb, const char *Name);
+extern void AxWin_DeregisterClient(tApplication *App);
// --- Video ---
extern void Video_Setup(void);
extern void Video_Update(void);
void IPC_HandleSelect(fd_set *set);
void Messages_RespondDatagram(void *Ident, size_t Length, void *Data);
void Messages_RespondIPC(void *Ident, size_t Length, void *Data);
-void Messages_Handle(void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond);
+void Messages_Handle(size_t IdentLen, void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond);
// === GLOBALS ===
int giNetworkFileHandle = -1;
// TODO: Check this
giNetworkFileHandle = open("/Devices/ip/loop/udp", OPENFLAG_READ);
tmp = AXWIN_PORT; ioctl(giNetworkFileHandle, 4, &tmp); // TODO: Don't hard-code IOCtl number
-
- // TODO: Open a handle to something like /Devices/proc/cur/messages to watch for messages
-// giMessagesFileHandle = open("/Devices/"
}
void IPC_FillSelect(int *nfds, fd_set *set)
identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] );
msg = staticBuf + identlen;
- Messages_Handle(staticBuf, readlen - identlen, (void*)msg, Messages_RespondDatagram);
+ Messages_Handle(identlen, staticBuf, readlen - identlen, (void*)msg, Messages_RespondDatagram);
}
while(SysGetMessage(NULL, NULL))
char data[len];
SysGetMessage(NULL, data);
- Messages_Handle(&tid, len, (void*)data, Messages_RespondIPC);
+ Messages_Handle(sizeof(tid), &tid, len, (void*)data, Messages_RespondIPC);
}
}
SysSendMessage( *(tid_t*)Ident, Length, Data );
}
-void Messages_Handle(void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond)
+void Messages_Handle(size_t IdentLen, void *Ident, size_t MsgLen, tAxWin_Message *Msg, tMessages_Handle_Callback *Respond)
{
if( MsgLen < sizeof(tAxWin_Message) )
return ;
break;
case MSG_SREQ_REGISTER:
- if( Msg->Len == strnlen(Msg->Len, Msg->Data) ) {
- // Special handling?
+ if( Msg->Data[Msg->Size-1] != '\0' ) {
+ // Invalid message
return ;
}
+ AxWin_RegisterClient(IdentLen, Ident, Respond, Msg->Data);
+
break;
default:
// --- Element type flags
struct {
void (*Init)(tElement *This);
+ void (*Delete)(tElement *This);
void (*UpdateFlags)(tElement *This);
void (*UpdateSize)(tElement *This);
void (*UpdateText)(tElement *This);
{NULL, NULL, NULL, NULL}, // NULL
{NULL, NULL, NULL, NULL} // Box
};
+const int ciWM_NumWidgetTypes = sizeof(gaWM_WidgetTypes)/sizeof(gaWM_WidgetTypes[0]);
// === CODE ===
+tApplication *AxWin_RegisterClient(int IdentLen, void *Ident, tMessages_Handle_Callback *Cb, const char *Name)
+{
+ tApplication *ret = calloc( 1, sizeof(tApplication) + 1 + strlen(Name) + 1 + IdentLen );
+
+ ret->Name = &ret->MetaElement.DebugName[1];
+ strcpy(ret->Name, Name);
+ ret->Ident = ret->Name + strlen(Name) + 1;
+ memcpy(ret->Ident, Ident, IdentLen);
+ ret->SendMessage = Cb;
+
+ ret->Next = gWM_Applications;
+ gWM_Applications = ret;
+
+ // TODO: Inform listeners of the new application
+
+ return ret;
+}
+
+void AxWin_DeregisterClient(tApplication *App)
+{
+ tElement *win, *next;
+ // TODO: Implement DeregisterClient
+
+ for( win = App->MetaElement.FirstChild; win; win = next )
+ {
+ next = win->NextSibling;
+ AxWin_DeleteElement(win);
+ }
+
+ // TODO: Inform listeners of deleted application
+ // TODO: Remove from list
+ free(App);
+}
+
+tElement *AxWin_CreateWindow(tApplication *App, const char *Name)
+{
+ tElement *ret;
+
+ // TODO: Implement _CreateTab
+
+ ret = AxWin_CreateElement(&App->MetaElement, ELETYPE_WINDOW, 0, NULL);
+ ret->Text = strdup(Name);
+ return ret;
+}
+
// --- Widget Creation and Control ---
tAxWin_Element *AxWin_CreateElement(tElement *Parent, int Type, int Flags, const char *DebugName)
{
ret->PaddingT = 2;
ret->PaddingB = 2;
- if( gaWM_WidgetTypes[Type].Init )
+ if( Type < ciWM_NumWidgetTypes && gaWM_WidgetTypes[Type].Init )
gaWM_WidgetTypes[Type].Init(ret);
WM_UpdateMinDims(ret->Parent);
*/
void AxWin_DeleteElement(tElement *Element)
{
+ tElement *child, *next;
+
+ for(child = Element->FirstChild; child; child = next)
+ {
+ next = child->NextSibling;
+ AxWin_DeleteElement(child);
+ }
+
// TODO: Implement AxWin_DeleteElement
+ // TODO: Clean up related data.
+ if( Element->Type < ciWM_NumWidgetTypes && gaWM_WidgetTypes[Element->Type].Delete )
+ gaWM_WidgetTypes[Element->Type].Delete(Element);
+
free(Element);
}
tElement *FirstChild;
tElement *LastChild;
tElement *NextSibling;
-
+
+ // User modifiable attributes
short PaddingL, PaddingR;
short PaddingT, PaddingB;
short GapSize;
+ uint32_t Flags;
+
short FixedWith; // Fixed Long Size attribute (height)
short FixedCross; // Fixed Cross Size attribute (width)
short MinCross; // Minimum cross size
void *Data;
- uint32_t Flags;
-
// -- Render Cache
short CachedX, CachedY;
short CachedW, CachedH;
char DebugName[];
};
-struct sTab
-{
- int Type; // Should be zero, allows a tab to be the parent of an element
-
- tElement *Parent;
- tElement *FirstChild;
- tElement *LastChild;
- tTab *NextTab;
-
- char *Name;
-
- tElement *RootElement;
-};
-
struct sApplication
{
- tApplication *Next;
+ tApplication *Next;
void *Ident;
tMessages_Handle_Callback *SendMessage;
- int nTabs;
- tTab *Tabs;
- tTab *CurrentTab;
-
- char Name[];
+ char *Name;
+ tElement MetaElement;
+
};
#endif
enum eElementTypes
{
ELETYPE_NONE,
+
+ ELETYPE_WINDOW,
ELETYPE_BOX, //!< Content box (invisible in itself)
ELETYPE_TABBAR, //!< Tab Bar
// - Windows
MSG_SREQ_REGISTER, // bool (char[] Name) - Registers this PID with the Window Manager
- MSG_SREQ_ADDTAB, // TAB (char[] Name) - Adds a tab to the window
- MSG_SREQ_DELTAB, // void (TAB Tab) - Closes a tab
+ MSG_SREQ_ADDWIN, // ELEMENT (char[] Name) - Adds a tab to the window
+ MSG_SREQ_DELWIN, // void (ELEMENT Tab) - Closes a tab
- MSG_SREQ_SETICON // void (TAB Tab, char[] IconURI) - Set the icon of a tab (or application)
+ MSG_SREQ_SETICON, // void (TAB Tab, char[] IconURI) - Set the icon of a tab (or application)
MSG_SREQ_NEWDIALOG, // DIALOG (TAB Parent, char[] Name) - Creates a dialog
MSG_SREQ_DELDIALOG, // void (DIALOG Dialog) - Closes a dialog
MSG_SREQ_RECT, MSG_SREQ_FILLRECT,
MSG_SREQ_RIMG, MSG_SREQ_SIMG, // Register/Set Image
MSG_SREQ_SETFONT, MSG_SREQ_PUTTEXT,
+
+ // - Callback Registration
+
+ // - WM Control
+ MSG_SREQ_SET_MAXIMIZE_AREA, // void (uint16_t X, Y, W, H)
// Server->Client Responses
MSG_SRSP_VERSION,