* nanox.c
*
* Replacements for some comomon Xlib functions
+ * Licence: The wxWindows licence
*/
#include "wx/setup.h"
#include <ctype.h>
#include <malloc.h>
+#include <string.h>
+#include <stdio.h>
#include "wx/defs.h"
#include "wx/x11/nanox/X11/Xlib.h"
return Success;
}
-int XUngrabPointer(Display display, Time time)
+int XUngrabPointer(Display* display, Time time)
{
return Success;
}
XWindowAttributes* window_attributes)
{
GR_WINDOW_INFO info;
+ Window parent = 0;
+ GrFlush();
GrGetWindowInfo(w, & info);
window_attributes->x = info.x;
window_attributes->override_redirect = FALSE;
window_attributes->screen = NULL;
+ /* We need to check if any parents are unmapped,
+ * or we will report a window as mapped when it is not.
+ */
+ parent = info.parent;
+ while (parent)
+ {
+ GrGetWindowInfo(parent, & info);
+ if (info.mapped == 0)
+ window_attributes->map_state = IsUnmapped;
+
+ parent = info.parent;
+ }
+
return 1;
}
static XErrorHandler* g_ErrorHandler = NULL;
-static void DefaultNanoXErrorHandler(GR_EVENT_ERROR* ep)
+void DefaultNanoXErrorHandler(GR_EVENT_ERROR* ep)
{
if (g_ErrorHandler)
{
return 1;
}
+typedef struct {
+ const char* name;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+} _wxColourEntry;
+
+static _wxColourEntry _wxColourDatabase[] =
+{
+ { "WHITE", 255, 255, 255 },
+ { "BLACK", 0, 0, 0 },
+ { "RED", 255, 0, 0 },
+ { "GREEN", 0, 255, 0 },
+ { "BLUE", 0, 255, 255 },
+ { "GREY", 128, 128, 128 },
+ { "GRAY", 128, 128, 128 },
+ { "LIGHT GREY", 192, 192, 192 },
+ { "LIGHT GRAY", 192, 192, 192 },
+ { "DARK GREY", 32, 32, 32 },
+ { "DARK GRAY", 32, 32, 32 },
+ { "CYAN", 0, 255, 255 },
+ { "MAGENTA", 255, 255, 0 },
+
+ /* TODO: the rest */
+ { NULL, 0, 0, 0 }
+};
+
int XParseColor(Display* display, Colormap cmap,
const char* cname, XColor* color)
{
- /* TODO */
+ int i = 0;
+ for (;;)
+ {
+ if (!_wxColourDatabase[i].name)
+ break;
+ else
+ {
+ if (strcmp(cname, _wxColourDatabase[i].name) == 0)
+ {
+ color->red = _wxColourDatabase[i].red;
+ color->green = _wxColourDatabase[i].green;
+ color->blue = _wxColourDatabase[i].blue;
+
+ return 1;
+ }
+ i ++;
+ }
+ }
+
+ /* Not found: use black */
+ color->red = 0;
+ color->green = 0;
+ color->blue = 0;
+
return 0;
}
XFontStruct* fontInfo = malloc(sizeof(XFontStruct));
fontInfo->fid = GrCreateFont(fontName, 0, 0);
GrGetFontInfo(fontInfo->fid, & fontInfo->info);
+ printf("Warning: should not call XLoadQueryFont since font spec is not used in Nano-X.\n");
return fontInfo;
}
return 0;
}
+int XConfigureWindow(Display* display, Window w, int mask, XWindowChanges* changes)
+{
+ if ((mask & CWX) && (mask & CWY))
+ GrMoveWindow(w, changes->x, changes->y);
+ if ((mask & CWWidth) && (mask & CWHeight))
+ GrResizeWindow(w, changes->width, changes->height);
+ if (mask & CWBorderWidth)
+ {
+ /* TODO */
+ }
+ if (mask & CWSibling)
+ {
+ /* TODO */
+ }
+ if (mask & CWStackMode)
+ {
+ /* TODO */
+ }
+ return 1;
+}
+
+int XTranslateCoordinates(Display* display, Window srcWindow, Window destWindow, int srcX, int srcY, int* destX, int* destY, Window* childReturn)
+{
+ int offx = 0;
+ int offy = 0;
+
+ Window w = srcWindow;
+ while (w != GR_ROOT_WINDOW_ID)
+ {
+ GR_WINDOW_INFO info;
+ GrGetWindowInfo(w, & info);
+ w = info.parent;
+
+ offx += info.x ;
+ offy += info.y ;
+ }
+
+ w = destWindow;
+
+ while (w != GR_ROOT_WINDOW_ID)
+ {
+ GR_WINDOW_INFO info;
+ GrGetWindowInfo(w, & info);
+ w = info.parent;
+
+ offx -= info.x ;
+ offy -= info.y ;
+ }
+
+ *destX = srcX + offx;
+ *destY = srcY + offy;
+
+ if (childReturn)
+ *childReturn = 0;
+
+ return 1;
+}
+
+/* Should not really be necessary but in no-optimize mode
+ * gcc complains that wxNoop is not found if wxNoop is inline.
+ */
+
+void wxNoop()
+{
+}
+
#endif
/* wxUSE_NANOX */