+
+// --- Message Handlers ---
+int Widget_IPC_Create(tWindow *Win, size_t Len, const void *Data)
+{
+ tWidgetWin *Info = Win->RendererInfo;
+ const tWidgetIPC_Create *Msg = Data;
+ const int max_debugname_len = Len - sizeof(*Msg);
+ tElement *parent;
+
+ // Sanity check
+ if( Len < sizeof(*Msg) )
+ return -1;
+ if( strnlen(Msg->DebugName, max_debugname_len) == max_debugname_len )
+ return -1;
+
+ _SysDebug("Widget_NewWidget (%i %i Type %i Flags 0x%x)",
+ Msg->Parent, Msg->NewID, Msg->Type, Msg->Flags);
+
+ if(Msg->Type >= ciWM_NumWidgetTypes)
+ {
+ _SysDebug("Widget_NewWidget - Bad widget type %i", Msg->Type);
+ return 1;
+ }
+
+ // Create
+ parent = Widget_GetElementById(Info, Msg->Parent);
+ if(!parent)
+ {
+ _SysDebug("Widget_NewWidget - Bad parent ID %i", Msg->Parent);
+ return 1;
+ }
+
+ Widget_int_Create(Info, parent, Msg->NewID, Msg->Type, Msg->Flags);
+
+ Widget_UpdateMinDims(parent);
+ return 0;
+}
+
+int Widget_IPC_NewWidgetSubwin(tWindow *Win, size_t Len, const void *Data)
+{
+ tWidgetWin *Info = Win->RendererInfo;
+ const tWidgetIPC_CreateSubWin *Msg = Data;
+ const int max_debugname_len = Len - sizeof(*Msg);
+ tElement *parent, *new;
+
+ // Sanity check
+ if( Len < sizeof(*Msg) )
+ return -1;
+ if( strnlen(Msg->DebugName, max_debugname_len) == max_debugname_len )
+ return -1;
+
+ parent = Widget_GetElementById(Info, Msg->Parent);
+ if(!parent) return 1;
+ if( Widget_GetElementById(Info, Msg->NewID) ) return 1;
+
+ new = Widget_int_Create(Info, parent, Msg->NewID, Msg->Type, Msg->Flags);
+ new->Data = WM_GetWindowByID(parent->Window, Msg->WindowHandle);
+ Widget_UpdateMinDims(parent);
+ return 0;
+}
+
+// TODO: Widget_IPC_Delete
+
+int Widget_IPC_SetFocus(tWindow *Win, size_t Len, const void *Data)
+{
+ tWidgetWin *info = Win->RendererInfo;
+ tElement *ele;
+ const tWidgetIPC_SetFocus *msg = Data;
+ if(Len < sizeof(*msg)) return -1;
+
+ ele = Widget_GetElementById(info, msg->WidgetID);
+ Widget_SetFocus(info, ele);
+ return 0;
+}
+
+int Widget_IPC_SetFlags(tWindow *Win, size_t Len, const void *Data)