From: John Hodge Date: Fri, 4 Nov 2011 14:25:49 +0000 (+0800) Subject: Usermode/AxWin3 - Cleaning up and adding client widget support X-Git-Tag: rel0.14~149 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=4fa95391e2ff812412d7229e0135efd49cd5f3ed;p=tpg%2Facess2.git Usermode/AxWin3 - Cleaning up and adding client widget support - Also fixed a little issue with using a symlink in Libraries/ --- diff --git a/Usermode/Applications/axwin3_src/Interface/main.c b/Usermode/Applications/axwin3_src/Interface/main.c index 698b2d49..99df8359 100644 --- a/Usermode/Applications/axwin3_src/Interface/main.c +++ b/Usermode/Applications/axwin3_src/Interface/main.c @@ -7,6 +7,7 @@ */ #include #include +#include // === GLOBALS === tHWND gSidebar; @@ -24,12 +25,10 @@ int main(int argc, char *argv[]) // Create sidebar // TODO: Use the widget library instead - gSidebar = AxWin3_CreateWindow(NULL, "Widget", 0, 0, NULL, sidebar_callback); - // TODO: Get screen dimensions somehow + gSidebar = AxWin3_Widget_CreateWindow(NULL, 32, 600, 0); - // Size the window - AxWin3_SetWindowPos(gSidebar, 0, 0, 32, 600); + AxWin3_MoveWindow(gSidebar, 0, 0); // Show! AxWin3_ShowWindow(gSidebar, 1); diff --git a/Usermode/Applications/axwin3_src/WM/Makefile b/Usermode/Applications/axwin3_src/WM/Makefile index 9bd94a0c..83e93234 100644 --- a/Usermode/Applications/axwin3_src/WM/Makefile +++ b/Usermode/Applications/axwin3_src/WM/Makefile @@ -2,8 +2,7 @@ -include ../../Makefile.cfg -# Some evil lazy evaulation, hopefully it works -CPPFLAGS += -I include/ +CPPFLAGS += -I include/ -I ../include/ DIR := Apps/AxWin/3.0 BIN := AxWinWM diff --git a/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h b/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h deleted file mode 100644 index b0cf14ea..00000000 --- a/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Acess2 Window Manager v3 - * - By John Hodge (thePowersGang) - * - * ipcmessages.h - * - IPC Message format definition - * - Shared between library and server - */ -#ifndef _IPCMESSAGES_H_ -#define _IPCMESSAGES_H_ - -#include - -typedef struct sAxWin_IPCMessage tAxWin_IPCMessage; -typedef struct sIPCMsg_Return tIPCMsg_Return; -typedef struct sIPCMsg_CreateWin tIPCMsg_CreateWin; -typedef struct sIPCMsg_ShowWindow tIPCMsg_ShowWindow; -typedef struct sIPCMsg_SetWindowPos tIPCMsg_SetWindowPos; - -/** - * \name Flags for IPC Messages - * \{ - */ -//! Request a return value -#define IPCMSG_FLAG_RETURN 0x01 -/** - * \} - */ - -struct sAxWin_IPCMessage -{ - uint8_t ID; - uint8_t Flags; - uint16_t Size; - uint32_t Window; - char Data[]; -}; - -struct sIPCMsg_Return -{ - uint32_t Value; -}; - -struct sIPCMsg_CreateWin -{ - uint32_t NewWinID; - uint32_t Flags; - char Renderer[]; -}; - -struct sIPCMsg_ShowWindow -{ - uint32_t bShow; -}; - -struct sIPCMsg_SetWindowPos -{ - int16_t X; - int16_t Y; - uint16_t W; - uint16_t H; - uint8_t Fields; -}; - -enum eAxWin_IPCMessageTypes -{ - IPCMSG_PING, //!< Get the server version - IPCMSG_SENDMSG, //!< Send a message to another window (or to self) - IPCMSG_CREATEWIN, //!< Create a window - IPCMSG_DESTROYWIN, //!< Destroy a window - IPCMSG_SHOWWINDOW, //!< Show/Hide a window - IPCMSG_SETWINPOS, //!< Set a window position -}; - -#endif diff --git a/Usermode/Applications/axwin3_src/WM/include/wm_renderer.h b/Usermode/Applications/axwin3_src/WM/include/wm_renderer.h index afed38c6..b734348f 100644 --- a/Usermode/Applications/axwin3_src/WM/include/wm_renderer.h +++ b/Usermode/Applications/axwin3_src/WM/include/wm_renderer.h @@ -30,7 +30,7 @@ struct sWMRenderer * \note \a Flags is provided for convinience, the caller will * set the copy in the window structure. */ - tWindow *(*CreateWindow)(int Flags); + tWindow *(*CreateWindow)(int Arg); /** * \brief Redraw a window on the screen diff --git a/Usermode/Applications/axwin3_src/WM/ipc.c b/Usermode/Applications/axwin3_src/WM/ipc.c index d8420710..a47cc0ab 100644 --- a/Usermode/Applications/axwin3_src/WM/ipc.c +++ b/Usermode/Applications/axwin3_src/WM/ipc.c @@ -270,7 +270,7 @@ int IPC_Msg_CreateWin(tIPC_Client *Client, tAxWin_IPCMessage *Msg) return 1; // - Create the new window, and save its pointer - newwin = WM_CreateWindow(parent, info->Flags, info->Renderer); + newwin = WM_CreateWindow(parent, info->RendererArg, info->Renderer); IPC_int_SetWindow(Client, info->NewWinID, newwin); return 0; diff --git a/Usermode/Applications/axwin3_src/WM/wm.c b/Usermode/Applications/axwin3_src/WM/wm.c index 2ae73fdd..a30c470b 100644 --- a/Usermode/Applications/axwin3_src/WM/wm.c +++ b/Usermode/Applications/axwin3_src/WM/wm.c @@ -21,7 +21,7 @@ void WM_RegisterRenderer(tWMRenderer *Renderer) gpWM_Renderers = Renderer; } -tWindow *WM_CreateWindow(tWindow *Parent, int Flags, const char *RendererName) +tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererName) { tWMRenderer *renderer; tWindow *ret; @@ -36,10 +36,7 @@ tWindow *WM_CreateWindow(tWindow *Parent, int Flags, const char *RendererName) return NULL; // - Call create window function - ret = renderer->CreateWindow(Flags); - - // - Fill common fields on that - ret->Flags = Flags; + ret = renderer->CreateWindow(RendererArg); // - Return! return ret; diff --git a/Usermode/Applications/axwin3_src/include/ipcmessages.h b/Usermode/Applications/axwin3_src/include/ipcmessages.h new file mode 100644 index 00000000..aad587bc --- /dev/null +++ b/Usermode/Applications/axwin3_src/include/ipcmessages.h @@ -0,0 +1,75 @@ +/* + * Acess2 Window Manager v3 + * - By John Hodge (thePowersGang) + * + * ipcmessages.h + * - IPC Message format definition + * - Shared between library and server + */ +#ifndef _IPCMESSAGES_H_ +#define _IPCMESSAGES_H_ + +#include + +typedef struct sAxWin_IPCMessage tAxWin_IPCMessage; +typedef struct sIPCMsg_Return tIPCMsg_Return; +typedef struct sIPCMsg_CreateWin tIPCMsg_CreateWin; +typedef struct sIPCMsg_ShowWindow tIPCMsg_ShowWindow; +typedef struct sIPCMsg_SetWindowPos tIPCMsg_SetWindowPos; + +/** + * \name Flags for IPC Messages + * \{ + */ +//! Request a return value +#define IPCMSG_FLAG_RETURN 0x01 +/** + * \} + */ + +struct sAxWin_IPCMessage +{ + uint8_t ID; + uint8_t Flags; + uint16_t Size; + uint32_t Window; + char Data[]; +}; + +struct sIPCMsg_Return +{ + uint32_t Value; +}; + +struct sIPCMsg_CreateWin +{ + uint32_t NewWinID; + uint32_t RendererArg; + char Renderer[]; +}; + +struct sIPCMsg_ShowWindow +{ + uint32_t bShow; +}; + +struct sIPCMsg_SetWindowPos +{ + int16_t X; + int16_t Y; + uint16_t W; + uint16_t H; + uint8_t Fields; +}; + +enum eAxWin_IPCMessageTypes +{ + IPCMSG_PING, //!< Get the server version + IPCMSG_SENDMSG, //!< Send a message to another window (or to self) + IPCMSG_CREATEWIN, //!< Create a window + IPCMSG_DESTROYWIN, //!< Destroy a window + IPCMSG_SHOWWINDOW, //!< Show/Hide a window + IPCMSG_SETWINPOS, //!< Set a window position +}; + +#endif diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/Makefile b/Usermode/Applications/axwin3_src/libaxwin3.so_src/Makefile index 6e6c3e5a..b8742911 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/Makefile +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/Makefile @@ -3,7 +3,7 @@ include ../../../Libraries/Makefile.cfg -CPPFLAGS += +CPPFLAGS += -I ../include/ CFLAGS += -Wall LDFLAGS += -lc -soname libaxwin3.so diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h index 52910bd3..4275356c 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h @@ -8,6 +8,8 @@ #ifndef _INTERNAL_H_ #define _INTERNAL_H_ +#include + struct sAxWin3_Window { uint32_t ServerID; @@ -16,11 +18,7 @@ struct sAxWin3_Window char Data[]; }; -extern const char *gsAxWin3_int_ServerDesc; - -extern tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int Flags, int ExtraBytes); -extern void AxWin3_int_SendIPCMessage(tAxWin_IPCMessage *Msg); -extern tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void); +extern void *AxWin3_int_GetDataPtr(tHWND Window); #endif diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/ipc.h b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/ipc.h index 36865937..4b9f2af1 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/ipc.h +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/ipc.h @@ -2,13 +2,20 @@ * Acess2 Window Manager v3 * - By John Hodge (thePowersGang) * - * ipcmessages.h - * - IPC Message format definition + * internal.h + * - Internal definitions */ -#ifndef _IPCMESSAGES_LIB_H_ -#define _IPCMESSAGES_LIB_H_ +#ifndef _IPC_H_ +#define _IPC_H_ + +#include + +extern const char *gsAxWin3_int_ServerDesc; + +extern tAxWin_IPCMessage *AxWin3_int_AllocateIPCMessage(tHWND Window, int Message, int Flags, int ExtraBytes); +extern void AxWin3_int_SendIPCMessage(tAxWin_IPCMessage *Msg); +extern tAxWin_IPCMessage *AxWin3_int_GetIPCMessage(void); -#include "../../WM/include/ipcmessages.h" #endif diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c index 3fba042f..2432fd88 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c @@ -6,8 +6,8 @@ * - Entrypoint and setup */ #include -#include "include/ipc.h" #include "include/internal.h" +#include "include/ipc.h" // === CODE === int SoMain(void *Base, int argc, const char *argv[], const char **envp) diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c index 76b38c2d..1059a0a2 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c @@ -9,7 +9,7 @@ #include #include #include -#include "include/ipc.h" +#include // AxWin3 common #include "include/internal.h" // === CONSTANTS === diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c index e69de29b..64d2023b 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c @@ -0,0 +1,37 @@ +/* + * AxWin3 Interface Library + * - By John Hodge (thePowersGang) + * + * main.c + * - Entrypoint and setup + */ +#include +#include +#include "include/internal.h" + +// === STRUCTURES === +typedef struct +{ + // Callbacks for each element +} tWidgetWindowInfo; + +// === CODE === +int AxWin3_Widget_MessageHandler(tHWND Window, int Size, void *Data) +{ + return 0; +} + +tHWND AxWin3_Widget_CreateWindow(tHWND Parent, int W, int H, int RootEleFlags) +{ + tHWND ret; + tWidgetWindowInfo *info; + + ret = AxWin3_CreateWindow( + Parent, "Widget", RootEleFlags, + sizeof(*info), AxWin3_Widget_MessageHandler + ); + info = AxWin3_int_GetDataPtr(ret); + + return ret; +} + diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c index 9f15ad7e..e0cfcbe4 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c @@ -8,8 +8,8 @@ #include #include #include -#include "include/ipc.h" #include "include/internal.h" +#include "include/ipc.h" #define WINDOWS_PER_ALLOC (63) @@ -79,9 +79,8 @@ tWindow *AxWin3_int_AllocateWindowInfo(int DataBytes, int *WinID) } tHWND AxWin3_CreateWindow( - tHWND Parent, const char *Renderer, int Flags, - int DataBytes, void **DataPtr, - tAxWin3_WindowMessageHandler MessageHandler + tHWND Parent, const char *Renderer, int RendererArg, + int DataBytes, tAxWin3_WindowMessageHandler MessageHandler ) { tWindow *ret; @@ -99,7 +98,7 @@ tHWND AxWin3_CreateWindow( msg = AxWin3_int_AllocateIPCMessage(Parent, IPCMSG_CREATEWIN, 0, dataSize); create_win = (void*)msg->Data; create_win->NewWinID = newWinID; - create_win->Flags = Flags; + create_win->RendererArg = RendererArg; strcpy(create_win->Renderer, Renderer); // Send and clean up @@ -109,7 +108,6 @@ tHWND AxWin3_CreateWindow( // TODO: Detect and handle possible errors // Return success - if(DataPtr) *DataPtr = ret->Data; return ret; } @@ -122,6 +120,11 @@ void AxWin3_DestroyWindow(tHWND Window) free(msg); } +void *AxWin3_int_GetDataPtr(tHWND Window) +{ + return &Window->Data; +} + void AxWin3_ShowWindow(tHWND Window, int bShow) { tAxWin_IPCMessage *msg; diff --git a/Usermode/Libraries/Makefile.tpl b/Usermode/Libraries/Makefile.tpl index 47acb800..57e49be2 100644 --- a/Usermode/Libraries/Makefile.tpl +++ b/Usermode/Libraries/Makefile.tpl @@ -40,7 +40,7 @@ $(_BIN): $(OBJ) $(_LIBS) $(_OBJPREFIX)%.o: %.c @echo [CC] -o $@ @mkdir -p $(dir $@) - @$(CC) $(CFLAGS) -o $@ -c $< + @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< @$(CC) -M -MT $@ $(CPPFLAGS) $< -o $@.dep $(_OBJPREFIX)%.ao: %.$(ASSUFFIX) diff --git a/Usermode/Libraries/libaxwin3.so_src b/Usermode/Libraries/libaxwin3.so_src deleted file mode 120000 index f905263c..00000000 --- a/Usermode/Libraries/libaxwin3.so_src +++ /dev/null @@ -1 +0,0 @@ -../Applications/axwin3_src/libaxwin3.so/ \ No newline at end of file diff --git a/Usermode/Libraries/libaxwin3.so_src/Makefile b/Usermode/Libraries/libaxwin3.so_src/Makefile new file mode 100644 index 00000000..7bb1d94a --- /dev/null +++ b/Usermode/Libraries/libaxwin3.so_src/Makefile @@ -0,0 +1,2 @@ +all clean install all-install: ; + @$(MAKE) --no-print-directory -C ../../Applications/axwin3_src/libaxwin3.so_src/ $* diff --git a/Usermode/include/axwin3/axwin.h b/Usermode/include/axwin3/axwin.h index 6564e23c..49fc4df3 100644 --- a/Usermode/include/axwin3/axwin.h +++ b/Usermode/include/axwin3/axwin.h @@ -14,14 +14,35 @@ typedef void (*tAxWin3_MessageCallback)(int SourceTID, int Length); typedef int (*tAxWin3_WindowMessageHandler)(tHWND Window, int Length, void *Data); +// --- Connection management extern void AxWin3_Connect(const char *ServerDesc); extern tAxWin3_MessageCallback AxWin3_SetMessageCallback(tAxWin3_MessageCallback Callback); extern void AxWin3_MainLoop(void); -extern tHWND AxWin3_CreateWindow(tHWND Parent, const char *Renderer, int Flags, int DataBytes, void **DataPtr, - tAxWin3_WindowMessageHandler MessageHandler); +// --- Window creation/deletion +/** + * \brief Create a new window (with the required client structures) + * \param Parent Parent window handle + * \param Renderer Symbolic name of the renderer to use + * \param RendererArg Argument to pass to the renderer's initialisation + * \param DataBytes Number of bytes to allocate for the caller's use + * \param MessageHandler Function to call when a message arrives for the window + * \return New window handle + * \note Usually wrapped by renderer-specific functions + */ +extern tHWND AxWin3_CreateWindow( + tHWND Parent, + const char *Renderer, int RendererArg, + int DataBytes, + tAxWin3_WindowMessageHandler MessageHandler + ); +/** + * \brief Destroy a window + * \param Window Handle to a window to destroy + */ extern void AxWin3_DestroyWindow(tHWND Window); +// --- Core window management functions extern void AxWin3_SendMessage(tHWND Window, int Length, void *Data); extern void AxWin3_ShowWindow(tHWND Window, int bShow); extern void AxWin3_SetWindowPos(tHWND Window, short X, short Y, short W, short H); diff --git a/Usermode/include/axwin3/widget.h b/Usermode/include/axwin3/widget.h new file mode 100644 index 00000000..5542e3a8 --- /dev/null +++ b/Usermode/include/axwin3/widget.h @@ -0,0 +1,16 @@ +/* + * Acess2 GUI Version 3 (AxWin3) + * - By John Hodge (thePowersGang) + * + * widget.h + * - Server-side widget library + */ +#ifndef _AXWIN3_WIDGET_H_ +#define _AXWIN3_WIDGET_H_ + +#include "axwin.h" + +extern tHWND AxWin3_Widget_CreateWindow(tHWND Parent, int W, int H, int RootEleFlags); + +#endif +