From 4fa95391e2ff812412d7229e0135efd49cd5f3ed Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 4 Nov 2011 22:25:49 +0800 Subject: [PATCH] Usermode/AxWin3 - Cleaning up and adding client widget support - Also fixed a little issue with using a symlink in Libraries/ --- .../Applications/axwin3_src/Interface/main.c | 7 ++-- Usermode/Applications/axwin3_src/WM/Makefile | 3 +- .../axwin3_src/WM/include/wm_renderer.h | 2 +- Usermode/Applications/axwin3_src/WM/ipc.c | 2 +- Usermode/Applications/axwin3_src/WM/wm.c | 7 +--- .../axwin3_src/{WM => }/include/ipcmessages.h | 2 +- .../axwin3_src/libaxwin3.so_src/Makefile | 2 +- .../libaxwin3.so_src/include/internal.h | 8 ++-- .../axwin3_src/libaxwin3.so_src/include/ipc.h | 17 ++++++--- .../axwin3_src/libaxwin3.so_src/main.c | 2 +- .../axwin3_src/libaxwin3.so_src/msg.c | 2 +- .../axwin3_src/libaxwin3.so_src/r_widget.c | 37 +++++++++++++++++++ .../axwin3_src/libaxwin3.so_src/wm.c | 15 +++++--- Usermode/Libraries/Makefile.tpl | 2 +- Usermode/Libraries/libaxwin3.so_src | 1 - Usermode/Libraries/libaxwin3.so_src/Makefile | 2 + Usermode/include/axwin3/axwin.h | 25 ++++++++++++- Usermode/include/axwin3/widget.h | 16 ++++++++ 18 files changed, 115 insertions(+), 37 deletions(-) rename Usermode/Applications/axwin3_src/{WM => }/include/ipcmessages.h (98%) delete mode 120000 Usermode/Libraries/libaxwin3.so_src create mode 100644 Usermode/Libraries/libaxwin3.so_src/Makefile create mode 100644 Usermode/include/axwin3/widget.h 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/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/WM/include/ipcmessages.h b/Usermode/Applications/axwin3_src/include/ipcmessages.h similarity index 98% rename from Usermode/Applications/axwin3_src/WM/include/ipcmessages.h rename to Usermode/Applications/axwin3_src/include/ipcmessages.h index b0cf14ea..aad587bc 100644 --- a/Usermode/Applications/axwin3_src/WM/include/ipcmessages.h +++ b/Usermode/Applications/axwin3_src/include/ipcmessages.h @@ -44,7 +44,7 @@ struct sIPCMsg_Return struct sIPCMsg_CreateWin { uint32_t NewWinID; - uint32_t Flags; + uint32_t RendererArg; char Renderer[]; }; 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 + -- 2.20.1