// === GLOBALS ===
tHWND gSidebar;
tAxWin3_Widget *gSidebarRoot;
+ int giScreenWidth;
+ int giScreenHeight;
// === CODE ===
int systembutton_fire(tAxWin3_Widget *Widget)
{
tAxWin3_Widget *btn, *txt, *ele;
+ // TODO: Register to be told when the display layout changes
+ AxWin3_GetDisplayDims(0, NULL, NULL, &giScreenWidth, &giScreenHeight);
+
// Create sidebar
- // TODO: Get screen dimensions somehow
- gSidebar = AxWin3_Widget_CreateWindow(NULL, SIDEBAR_WIDTH, 480, ELEFLAG_VERTICAL);
+ gSidebar = AxWin3_Widget_CreateWindow(NULL, SIDEBAR_WIDTH, giScreenHeight, ELEFLAG_VERTICAL);
AxWin3_MoveWindow(gSidebar, 0, 0);
gSidebarRoot = AxWin3_Widget_GetRoot(gSidebar);
ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_BOX, ELEFLAG_VERTICAL|ELEFLAG_NOSTRETCH, "Version/Time");
txt = AxWin3_Widget_AddWidget(ele, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String");
AxWin3_Widget_SetSize(txt, 20);
- AxWin3_Widget_SetText(txt, "2.0");
+ AxWin3_Widget_SetText(txt, "3.0");
// Show!
AxWin3_ShowWindow(gSidebar, 1);
}
+void create_mainmenu(void)
+{
+}
+
return 0;
}
+int IPC_Msg_GetDisplayCount(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
+{
+ tAxWin_IPCMessage *ret_hdr;
+ tIPCMsg_ReturnInt *ret;
+ char buf[sizeof(*ret_hdr)+sizeof(*ret)];
+
+ if( !(Msg->Flags & IPCMSG_FLAG_RETURN) ) return 0;
+
+ ret_hdr = (void*)buf;
+ ret_hdr->ID = IPCMSG_GETDISPLAYCOUNT;
+ ret_hdr->Flags = 0;
+ ret_hdr->Window = -1;
+ ret_hdr->Size = sizeof(*ret);
+ ret = (void*)ret_hdr->Data;
+ ret->Value = 1; // HARD CODE - Current version only supports one display
+
+ Client->IPCType->SendMessage(Client->Ident, sizeof(buf), buf);
+ return 0;
+}
+
+int IPC_Msg_GetDisplayDims(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
+{
+ tIPCMsg_GetDisplayDims *info;
+ tAxWin_IPCMessage *ret_hdr;
+ tIPCMsg_RetDisplayDims *ret;
+ char buf[sizeof(*ret_hdr)+sizeof(*ret)];
+
+ if( !(Msg->Flags & IPCMSG_FLAG_RETURN) ) return 0;
+
+ info = (void*)Msg->Data;
+
+ ret_hdr = (void*)buf;
+ ret_hdr->ID = IPCMSG_GETDISPLAYDIMS;
+ ret_hdr->Flags = 0;
+ ret_hdr->Window = -1;
+ ret_hdr->Size = sizeof(*ret);
+ ret = (void*)ret_hdr->Data;
+
+ // HARD CODE! Only one display supported
+ if( info->DisplayID == 0 )
+ {
+ ret->X = 0;
+ ret->Y = 0;
+ ret->W = giScreenWidth;
+ ret->H = giScreenHeight;
+ }
+ else
+ {
+ ret->X = 0; ret->Y = 0;
+ ret->W = 0; ret->H = 0;
+ }
+
+ Client->IPCType->SendMessage(Client->Ident, sizeof(buf), buf);
+ return 0;
+}
+
void IPC_Handle(const tIPC_Type *IPCType, const void *Ident, size_t MsgLen, tAxWin_IPCMessage *Msg)
{
tIPC_Client *client;
if( Msg->Size < 4 ) return;
if( Msg->Flags & IPCMSG_FLAG_RETURN )
{
+ tIPCMsg_ReturnInt *ret = (void*)Msg->Data;
Msg->ID = IPCMSG_PING;
- Msg->Size = sizeof(tIPCMsg_Return);
- ((tIPCMsg_Return*)Msg->Data)->Value = AXWIN_VERSION;
- IPCType->SendMessage(Ident, sizeof(tIPCMsg_Return), Msg);
+ Msg->Size = sizeof(*ret);
+ ret->Value = AXWIN_VERSION;
+ IPCType->SendMessage(Ident, sizeof(*Msg)+sizeof(*ret), Msg);
}
break;
+ // -- Get display count
+ case IPCMSG_GETDISPLAYCOUNT:
+ rv = IPC_Msg_GetDisplayCount(client, Msg);
+ break;
+
+ // --- Get display dimensions
+ case IPCMSG_GETDISPLAYDIMS:
+ rv = IPC_Msg_GetDisplayDims(client, Msg);
+ break;
+
// --- Send a message
case IPCMSG_SENDMSG:
_SysDebug(" IPC_Handle: IPCMSG_SENDMSG %i", ((tIPCMsg_SendMsg*)Msg->Data)->ID);
exit(-1);
}
- // Set width
- tmpInt = giScreenWidth;
- tmpInt = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, &tmpInt );
- if(tmpInt != giScreenWidth)
- {
- fprintf(stderr, "Warning: Selected width (%i) is invalid, clipped to %i\n",
- giScreenWidth, tmpInt);
- giScreenWidth = tmpInt;
- }
-
- // Set height
- tmpInt = giScreenHeight;
- tmpInt = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, &tmpInt );
- if(tmpInt != giScreenHeight)
- {
- fprintf(stderr, "Warning: Selected height (%i) is invalid, clipped to %i\n",
- giScreenHeight, tmpInt);
- giScreenHeight = tmpInt;
- }
// Set mode to video
tmpInt = TERM_MODE_FB;
ioctl( giTerminalFD, TERM_IOCTL_MODETYPE, &tmpInt );
+ // Get dimensions
+ giScreenWidth = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, NULL );
+ giScreenHeight = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, NULL );
+
// Force VT to be shown
ioctl( giTerminalFD, TERM_IOCTL_FORCESHOW, NULL );
#include <stdint.h>
typedef struct sAxWin_IPCMessage tAxWin_IPCMessage;
-typedef struct sIPCMsg_Return tIPCMsg_Return;
+typedef struct sIPCMsg_ReturnInt tIPCMsg_ReturnInt;
typedef struct sIPCMsg_CreateWin tIPCMsg_CreateWin;
typedef struct sIPCMsg_ShowWindow tIPCMsg_ShowWindow;
typedef struct sIPCMsg_SetWindowPos tIPCMsg_SetWindowPos;
typedef struct sIPCMsg_SendMsg tIPCMsg_SendMsg;
+typedef struct sIPCMsg_GetDisplayDims tIPCMsg_GetDisplayDims;
+typedef struct sIPCMsg_RetDisplayDims tIPCMsg_RetDisplayDims;
+
/**
* \name Flags for IPC Messages
* \{
char Data[];
};
-struct sIPCMsg_Return
+struct sIPCMsg_ReturnInt
{
uint32_t Value;
};
uint8_t bSetDims;
};
+struct sIPCMsg_GetDisplayDims
+{
+ uint16_t DisplayID;
+};
+
+struct sIPCMsg_RetDisplayDims
+{
+ uint16_t X;
+ uint16_t Y;
+ uint16_t W;
+ uint16_t H;
+};
+
enum eAxWin_IPCMessageTypes
{
IPCMSG_PING, //!< Get the server version
+ IPCMSG_GETDISPLAYCOUNT,
+ IPCMSG_GETDISPLAYDIMS,
+
IPCMSG_SENDMSG, //!< Send a message to another window (or to self)
IPCMSG_CREATEWIN, //!< Create a window
IPCMSG_DESTROYWIN, //!< Destroy a window
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 tAxWin_IPCMessage *AxWin3_int_WaitIPCMessage(int WantedID);
extern void AxWin3_int_HandleMessage(tAxWin_IPCMessage *Msg);
#include <stdlib.h>
#include <ipcmessages.h> // AxWin3 common
#include "include/internal.h"
+#include "include/ipc.h"
// === CONSTANTS ===
enum eConnectionType
return ret;
}
+tAxWin_IPCMessage *AxWin3_int_WaitIPCMessage(int WantedID)
+{
+ tAxWin_IPCMessage *msg;
+ for(;;)
+ {
+ msg = AxWin3_int_GetIPCMessage();
+ if(msg->ID == WantedID) return msg;
+ AxWin3_int_HandleMessage( msg );
+ free(msg);
+ }
+}
+
}
if( newID == info->nElements )
{
- info->nElements ++;
+ const int size_step = 4;
+ info->nElements += 4;
info->Elements = realloc(info->Elements, sizeof(*info->Elements)*info->nElements);
- newID = info->nElements - 1;
- _SysDebug("Expanded and allocated %i", newID);
+ newID = info->nElements - 4;
+ memset( &info->Elements[newID+1], 0, (size_step-1)*sizeof(info->Elements));
+ _SysDebug("Expanded to %i and allocated %i", info->nElements, newID);
}
else
_SysDebug("Allocated %i", newID);
return ret;
}
+int AxWin3_GetDisplayCount(void)
+{
+ tAxWin_IPCMessage *msg;
+ tIPCMsg_ReturnInt *ret;
+ int rv;
+
+ msg = AxWin3_int_AllocateIPCMessage(NULL, IPCMSG_GETDISPLAYCOUNT, IPCMSG_FLAG_RETURN, 0);
+ AxWin3_int_SendIPCMessage(msg);
+ free(msg);
+
+ msg = AxWin3_int_WaitIPCMessage(IPCMSG_GETDISPLAYCOUNT);
+ if(msg->Size < sizeof(*ret)) return -1;
+ ret = (void*)msg->Data;
+ rv = ret->Value;
+ free(msg);
+ return rv;
+}
+
+int AxWin3_GetDisplayDims(int Display, int *X, int *Y, int *Width, int *Height)
+{
+ tAxWin_IPCMessage *msg;
+ tIPCMsg_GetDisplayDims *req;
+ tIPCMsg_RetDisplayDims *ret;
+
+ msg = AxWin3_int_AllocateIPCMessage(NULL, IPCMSG_GETDISPLAYDIMS, IPCMSG_FLAG_RETURN, sizeof(*req));
+ req = (void*)msg->Data;
+ req->DisplayID = Display;
+ AxWin3_int_SendIPCMessage(msg);
+ free(msg);
+
+ msg = AxWin3_int_WaitIPCMessage(IPCMSG_GETDISPLAYDIMS);
+ if(msg->Size < sizeof(*ret)) return -1;
+ ret = (void*)msg->Data;
+
+ if(X) *X = ret->X;
+ if(X) *X = ret->Y;
+ if(Width) *Width = ret->W;
+ if(Height) *Height = ret->H;
+
+ return 0;
+}
+
tHWND AxWin3_CreateWindow(
tHWND Parent, const char *Renderer, int RendererArg,
int DataBytes, tAxWin3_WindowMessageHandler MessageHandler
extern tAxWin3_MessageCallback AxWin3_SetMessageCallback(tAxWin3_MessageCallback Callback);
extern void AxWin3_MainLoop(void);
+// --- Non-Window based functions
+extern int AxWin3_GetDisplayCount(void);
+extern int AxWin3_GetDisplayDims(int Display, int *X, int *Y, int *Width, int *Height);
+
// --- Window creation/deletion
/**
* \brief Create a new window (with the required client structures)