Usermode/AxWin3 - Cleaning up and adding client widget support
authorJohn Hodge <[email protected]>
Fri, 4 Nov 2011 14:25:49 +0000 (22:25 +0800)
committerJohn Hodge <[email protected]>
Fri, 4 Nov 2011 14:25:49 +0000 (22:25 +0800)
- Also fixed a little issue with using a symlink in Libraries/

19 files changed:
Usermode/Applications/axwin3_src/Interface/main.c
Usermode/Applications/axwin3_src/WM/Makefile
Usermode/Applications/axwin3_src/WM/include/ipcmessages.h [deleted file]
Usermode/Applications/axwin3_src/WM/include/wm_renderer.h
Usermode/Applications/axwin3_src/WM/ipc.c
Usermode/Applications/axwin3_src/WM/wm.c
Usermode/Applications/axwin3_src/include/ipcmessages.h [new file with mode: 0644]
Usermode/Applications/axwin3_src/libaxwin3.so_src/Makefile
Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h
Usermode/Applications/axwin3_src/libaxwin3.so_src/include/ipc.h
Usermode/Applications/axwin3_src/libaxwin3.so_src/main.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/r_widget.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/wm.c
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/libaxwin3.so_src [deleted symlink]
Usermode/Libraries/libaxwin3.so_src/Makefile [new file with mode: 0644]
Usermode/include/axwin3/axwin.h
Usermode/include/axwin3/widget.h [new file with mode: 0644]

index 698b2d4..99df835 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include <stdlib.h>
 #include <axwin3/axwin.h>
+#include <axwin3/widget.h>
 
 // === 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); 
index 9bd94a0..83e9323 100644 (file)
@@ -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 (file)
index b0cf14e..0000000
+++ /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 <stdint.h>
-
-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
index afed38c..b734348 100644 (file)
@@ -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
index d842071..a47cc0a 100644 (file)
@@ -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;
index 2ae73fd..a30c470 100644 (file)
@@ -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 (file)
index 0000000..aad587b
--- /dev/null
@@ -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 <stdint.h>
+
+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
index 6e6c3e5..b874291 100644 (file)
@@ -3,7 +3,7 @@
 
 include ../../../Libraries/Makefile.cfg
 
-CPPFLAGS +=
+CPPFLAGS += -I ../include/
 CFLAGS   += -Wall
 LDFLAGS  += -lc -soname libaxwin3.so
 
index 52910bd..4275356 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef _INTERNAL_H_
 #define _INTERNAL_H_
 
+#include <stdint.h>
+
 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
 
index 3686593..4b9f2af 100644 (file)
@@ -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 <ipcmessages.h>
+
+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
 
index 3fba042..2432fd8 100644 (file)
@@ -6,8 +6,8 @@
  * - Entrypoint and setup
  */
 #include <axwin3/axwin.h>
-#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)
index 76b38c2..1059a0a 100644 (file)
@@ -9,7 +9,7 @@
 #include <acess/sys.h>
 #include <string.h>
 #include <stdlib.h>
-#include "include/ipc.h"
+#include <ipcmessages.h>       // AxWin3 common
 #include "include/internal.h"
 
 // === CONSTANTS ===
index e69de29..64d2023 100644 (file)
@@ -0,0 +1,37 @@
+/*
+ * AxWin3 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * main.c
+ * - Entrypoint and setup
+ */
+#include <axwin3/axwin.h>
+#include <axwin3/widget.h>
+#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;
+}
+
index 9f15ad7..e0cfcbe 100644 (file)
@@ -8,8 +8,8 @@
 #include <axwin3/axwin.h>
 #include <stdlib.h>
 #include <string.h>
-#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;
index 47acb80..57e49be 100644 (file)
@@ -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 [email protected]
 
 $(_OBJPREFIX)%.ao: %.$(ASSUFFIX)
diff --git a/Usermode/Libraries/libaxwin3.so_src b/Usermode/Libraries/libaxwin3.so_src
deleted file mode 120000 (symlink)
index f905263..0000000
+++ /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 (file)
index 0000000..7bb1d94
--- /dev/null
@@ -0,0 +1,2 @@
+all clean install all-install: ;
+       @$(MAKE) --no-print-directory -C ../../Applications/axwin3_src/libaxwin3.so_src/ $*
index 6564e23..49fc4df 100644 (file)
@@ -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 (file)
index 0000000..5542e3a
--- /dev/null
@@ -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
+

UCC git Repository :: git.ucc.asn.au