From: John Hodge Date: Sun, 5 Jun 2011 13:44:09 +0000 (+0800) Subject: AxWin2 - More fiddling, almost ready now :) X-Git-Tag: rel0.10~79 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=fe24894229067f695d5db33c213fc09086740dec;p=tpg%2Facess2.git AxWin2 - More fiddling, almost ready now :) --- diff --git a/Usermode/Applications/axwin2_src/Shell_src/main.c b/Usermode/Applications/axwin2_src/Shell_src/main.c index 2bc0becb..f1c0416b 100644 --- a/Usermode/Applications/axwin2_src/Shell_src/main.c +++ b/Usermode/Applications/axwin2_src/Shell_src/main.c @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) AxWin_AddMenuItem(menu, "&Close Tab\tCtrl-Shift-W", EVENT_CLOSE_TAB); AxWin_AddMenuItem(menu, "E&xit\tAlt-F4", EVENT_EXIT); - tab = AxWin_CreateTab("root@acess: ~"); + tab = AxWin_CreateWindow("root@acess: ~"); //geConsole = AxWin_CreateElement(); AxWin_MessageLoop(); diff --git a/Usermode/Applications/axwin2_src/WM/common.h b/Usermode/Applications/axwin2_src/WM/common.h index a515bdc0..2d92cb58 100644 --- a/Usermode/Applications/axwin2_src/WM/common.h +++ b/Usermode/Applications/axwin2_src/WM/common.h @@ -89,6 +89,7 @@ extern void Input_HandleSelect(fd_set *set); extern tApplication *AxWin_RegisterClient(tIPC_Type *Method, void *Ident, const char *Name); extern void AxWin_DeregisterClient(tApplication *App); extern tApplication *AxWin_GetClient(tIPC_Type *Method, void *Ident); +extern tElement *AxWin_CreateAppWindow(tApplication *App, const char *Name); // --- Video --- extern void Video_Setup(void); extern void Video_Update(void); diff --git a/Usermode/Applications/axwin2_src/WM/messages.c b/Usermode/Applications/axwin2_src/WM/messages.c index f876f505..7c7c7178 100644 --- a/Usermode/Applications/axwin2_src/WM/messages.c +++ b/Usermode/Applications/axwin2_src/WM/messages.c @@ -19,6 +19,7 @@ void IPC_Init(void); void IPC_FillSelect(int *nfds, fd_set *set); void IPC_HandleSelect(fd_set *set); void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message *Msg); +void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value); int IPC_Type_Datagram_GetSize(void *Ident); int IPC_Type_Datagram_Compare(void *Ident1, void *Ident2); void IPC_Type_Datagram_Send(void *Ident, size_t Length, void *Data); @@ -86,6 +87,7 @@ void IPC_HandleSelect(fd_set *set) void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message *Msg) { tApplication *app; + tElement *ele; if( MsgLen < sizeof(tAxWin_Message) ) return ; @@ -131,8 +133,27 @@ void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message * return ; } + ele = AxWin_CreateAppWindow(app, Msg->Data); + IPC_ReturnValue(IPCType, Ident, MSG_SREQ_ADDWIN, ele->ApplicationID); break; + // --- Set a window's icon + case MSG_SREQ_SETICON: + // TODO: Find a good way of implementing this + break; + + // --- Create an element + case MSG_SREQ_INSERT: { + struct sAxWin_SReq_NewElement *info = (void *)Msg->Data; + + if( Msg->Size != sizeof(*info) ) return; + + if( !app || info->Parent > app->MaxElementIndex ) return ; + + ele = AxWin_CreateElement( app->EleIndex[info->Parent], info->Type, info->Flags, NULL ); + IPC_ReturnValue(IPCType, Ident, MSG_SREQ_ADDWIN, ele->ApplicationID); + break; } + // --- Unknown message default: fprintf(stderr, "WARNING: Unknown message %i (%p)\n", Msg->ID, IPCType); @@ -141,6 +162,22 @@ void IPC_Handle(tIPC_Type *IPCType, void *Ident, size_t MsgLen, tAxWin_Message * } } +void IPC_ReturnValue(tIPC_Type *IPCType, void *Ident, int MessageID, uint32_t Value) +{ + char data[sizeof(tAxWin_Message) + sizeof(tAxWin_RetMsg)]; + tAxWin_Message *msg = (void *)data; + tAxWin_RetMsg *ret_msg = (void *)msg->Data; + + msg->Source = 0; // 0 = Server + msg->ID = MSG_SRSP_RETURN; + msg->Size = sizeof(tAxWin_RetMsg); + ret_msg->ReqID = MessageID; + ret_msg->Rsvd = 0; + ret_msg->Value = Value; + + IPCType->SendMessage(Ident, sizeof(data), data); +} + int IPC_Type_Datagram_GetSize(void *Ident) { return 4 + Net_GetAddressSize( ((uint16_t*)Ident)[1] ); diff --git a/Usermode/Applications/axwin2_src/WM/wm.c b/Usermode/Applications/axwin2_src/WM/wm.c index dc1de6a2..8b709363 100644 --- a/Usermode/Applications/axwin2_src/WM/wm.c +++ b/Usermode/Applications/axwin2_src/WM/wm.c @@ -125,11 +125,9 @@ tApplication *AxWin_GetClient(tIPC_Type *Method, void *Ident) return NULL; } -tElement *AxWin_CreateWindow(tApplication *App, const char *Name) +tElement *AxWin_CreateAppWindow(tApplication *App, const char *Name) { tElement *ret; - - // TODO: Implement _CreateTab ret = AxWin_CreateElement(&App->MetaElement, ELETYPE_WINDOW, 0, NULL); ret->Text = strdup(Name); diff --git a/Usermode/Libraries/libaxwin2.so_src/main.c b/Usermode/Libraries/libaxwin2.so_src/main.c index cc96839f..f71a73ce 100644 --- a/Usermode/Libraries/libaxwin2.so_src/main.c +++ b/Usermode/Libraries/libaxwin2.so_src/main.c @@ -54,7 +54,7 @@ int AxWin_Register(const char *Name, tAxWin_MessageCallback *DefaultCallback) strcpy(req.Data, Name); msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req); - ret = ((tAxWin_RetMsg*)msg->Data)->Bool; + ret = ((tAxWin_RetMsg*)msg->Data)->Value; free(msg); gAxWin_DefaultCallback = DefaultCallback; @@ -62,7 +62,7 @@ int AxWin_Register(const char *Name, tAxWin_MessageCallback *DefaultCallback) return !!ret; } -tAxWin_Element *AxWin_CreateTab(const char *Title) +tAxWin_Element *AxWin_CreateWindow(const char *Title) { tAxWin_Message req; tAxWin_Message *msg; @@ -74,7 +74,7 @@ tAxWin_Element *AxWin_CreateTab(const char *Title) strcpy(req.Data, Title); msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req); - ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Handle; + ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Value; free(msg); return ret; diff --git a/Usermode/include/axwin2/axwin.h b/Usermode/include/axwin2/axwin.h index e164e8d9..5e2a0dde 100644 --- a/Usermode/include/axwin2/axwin.h +++ b/Usermode/include/axwin2/axwin.h @@ -13,13 +13,11 @@ // === Core Types === typedef struct sAxWin_Element tAxWin_Element; -//typedef struct sAxWin_Message tAxWin_Message; typedef int tAxWin_MessageCallback(tAxWin_Message *); -//typedef int tAxWin_MessageCallback(void *Source, int Message, int Length, void *Data); // === Functions === extern int AxWin_Register(const char *ApplicationName, tAxWin_MessageCallback *DefaultHandler); -extern tAxWin_Element *AxWin_CreateTab(const char *TabTitle); +extern tAxWin_Element *AxWin_CreateWindow(const char *TabTitle); extern tAxWin_Element *AxWin_AddMenuItem(tAxWin_Element *Parent, const char *Label, int Message); extern int AxWin_MessageLoop(void); diff --git a/Usermode/include/axwin2/messages.h b/Usermode/include/axwin2/messages.h index d944f515..61536f35 100644 --- a/Usermode/include/axwin2/messages.h +++ b/Usermode/include/axwin2/messages.h @@ -28,7 +28,6 @@ enum eAxWin_Messages MSG_SREQ_REGISTER, // bool (char[] Name) - Registers this PID with the Window Manager 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) @@ -39,11 +38,12 @@ enum eAxWin_Messages MSG_SREQ_GETNAME, // char[] (ELEMENT Element) // - Builtin Elements - MSG_SREQ_INSERT, // void (ELEMENT Parent, eAxWin_Controls Type, u32 Flags) + MSG_SREQ_INSERT, // ELEMENT (ELEMENT Parent, eAxWin_Controls Type, u32 Flags) + MSG_SREQ_DELETE, // void (ELEMENT Element) // - Drawing // All drawing functions take an ELEMENT as their first parameter. - // This must be either a Tab, Dialog or Canvas control + // This must be either a Window or Canvas control MSG_SREQ_SETCOL, MSG_SREQ_PSET, MSG_SREQ_LINE, MSG_SREQ_CURVE, @@ -81,6 +81,13 @@ struct sAxWin_SReq_NewWindow uint32_t Flags; }; +struct sAxWin_SReq_NewElement +{ + uint16_t Parent; + uint16_t Type; + uint32_t Flags; +}; + // --- Server Responses /** @@ -94,15 +101,6 @@ struct sAxWin_SRsp_Version uint16_t Build; }; -/** - * \brief Server Response - New Window - * \see eAxWin_Messages.MSG_SRSP_NEWWINDOW - */ -struct sAxWin_SRsp_NewWindow -{ - uint32_t Handle; -}; - // === Core Message Structure /** @@ -121,12 +119,7 @@ struct sAxWin_RetMsg { uint16_t ReqID; uint16_t Rsvd; - union - { - uint8_t Bool; - uint32_t Handle; - int Integer; - }; + uint32_t Value; }; #endif