$(BINDIR)/screenlock: LIBS += -lui -lX11 -lXft -lfontconfig -lcrypt -lXrandr
$(BINDIR)/terminal: LIBS += -lui -lX11 -lXft -lfontconfig
$(BINDIR)/winmgr: LIBS += -lX11 -lXft -lfontconfig -lXinerama
+$(BINDIR)/uitest: LIBS += -lui -lX11 -lXft -lfontconfig -lXinerama
--- /dev/null
+#include "liba.h"
+#include "libui.h"
+#include <unistd.h>
+
+#include <impl/libui.h>
+
+#define COLOR(c) ((c) | ((c) >> 8))
+
+void SetBackground(UIWin* win, int c)
+{
+ XftColorFree(X.display, X.visual, X.colormap, &(win->bg));
+ win->bg.color.alpha = 0xFFFF;
+ win->bg.color.red = COLOR((c & 0x00FF0000) >> 8);
+ win->bg.color.green = COLOR((c & 0x0000FF00));
+ win->bg.color.blue = COLOR((c & 0x000000FF) << 8);
+ XftColorAllocValue(X.display, X.visual, X.colormap, &(win->bg.color), &(win->bg));
+}
+
+void SetForeground(UIWin* win, int c)
+{
+ XftColorFree(X.display, X.visual, X.colormap, &(win->fg));
+ win->fg.color.alpha = 0xFFFF;
+ win->fg.color.red = COLOR((c & 0x00FF0000) >> 8);
+ win->fg.color.green = COLOR((c & 0x0000FF00));
+ win->fg.color.blue = COLOR((c & 0x000000FF) << 8);
+ XftColorAllocValue(X.display, X.visual, X.colormap, &(win->fg.color), &(win->fg));
+}
+
+void DrawRectangle(UIWin* win, int px, int py, int width, int height)
+{
+ XftDrawRect(win->xft, &(win->fg), px, py, width, height);
+}
+
+void DrawGlyphs(UIWin* win, XftFont* font, XftGlyphSpec* specs, long nspecs)
+{
+ XftDrawGlyphSpec(win->xft, &(win->fg), font, specs, nspecs);
+}
+
+void DrawString(UIWin* win, XftFont* font, int posx, int posy, char* str)
+{
+ XftDrawStringUtf8(win->xft, &(win->fg), font, posx, posy, (const FcChar8*)str, strlen(str));
+}
+
+
+
+void update(UIWin* win)
+{
+ SetForeground(win, 0xFF0000);
+ DrawRectangle(win, 0, 0, 100, 100);
+ win_repaint(win);
+}
+
+
+int main(int argc, char** argv)
+{
+ UIWin* win = win_create("UI Test");
+ win_show(win);
+
+ XEvent ev;
+ while (1)
+ {
+ XNextEvent(X.display, &ev);
+ update(win);
+ }
+
+ return 0;
+}
+
+
+typedef struct WidgetClass WidgetClass;
+typedef struct Widget Widget;
+
+struct WidgetClass {
+ void (*onresize)();
+ void (*onredraw)();
+ void (*onaction)();
+};
+
+struct Widget {
+ WidgetClass* class;
+ Widget* first;
+ Widget* last;
+};
+
GC gc;
XftDraw* xft;
XftFont* font;
+
+ XftColor bg;
+ XftColor fg;
};
struct XConf
typedef struct UIFont UIFont;
typedef struct UIWin UIWin;
+typedef struct {
+ /* keyboard events */
+ void (*onkeyup)();
+ void (*onkeydown)();
+
+ /* mouse events */
+ void (*onclick)();
+ void (*onmousemove)();
+} UIEventHandlers;
+
UIWin* win_create(char* title);
void win_delete(UIWin* win);
void win_show(UIWin* win);
void win_hide(UIWin* win);
+void win_repaint(UIWin* win);
+
UIFont font_load(char* patt);
void font_close(UIFont font);
-void ui_begin(UIWin* win);
-void ui_end(UIWin* win);
-
-
-typedef struct Attr {
- struct Attr* next;
- char* name;
- char* value;
-} Attr;
+//typedef struct Attr {
+// struct Attr* next;
+// char* name;
+// char* value;
+//} Attr;
+//
+//typedef struct Widget {
+// Attr* attributes;
+// void (*render)(struct Widget* w);
+//} Widget;
-typedef struct Widget {
- Attr* attributes;
- void (*render)(struct Widget* w);
-} Widget;
+//
+//typdef stuct UIWindow {
+// void* model;
+// void (*update)(struct UIWindow*, struct UIEvent*);
+// void (*redraw)(struct UIWindow*);
+//} UIWindow;
\ No newline at end of file
--- /dev/null
+typedef struct JobManager_T JobManager_T;
+
+typedef enum {
+ JOB_EVENT_WRRDY,
+ JOB_EVENT_RDRDY,
+ JOB_EVENT_CLOSED,
+ JOB_EVENT_ERROR
+} JobEventType_T;
+
+void JobManager_Init(JobManager_T* jm);
+void JobManager_Poll(JobManager_T* jm, int ms);
+void JobManager_JoinAll(JobManager_T* jm);
+int JobManager_Fork(JobManager_T* jm, int fd, void (*readfn)(JobEventType_T, int, void*), void* data);
+int JobManager_Exec(JobManager_T* jm, char** cmd);
+++ /dev/null
-#include <liba.h>
-#include <libui.h>
-#include <impl/libui.h>
-
-void ui_begin(UIWin* win)
-{
- XSetForeground(X.display, win->gc, 0xEAEAEA);
- XFillRectangle(X.display, win->pixmap, win->gc, 0, 0, win->width, win->height);
-}
X.colormap = wa.colormap;
win->width = 640;
win->height = 480;
- win->self = XCreateSimpleWindow(X.display, X.root, 0, 0, win->width, win->height, 0, 0, 0xEAEAEA);
+
+ XSetWindowAttributes attr;
+ attr.background_pixel = 0xEAEAEA;
+ attr.bit_gravity = NorthWestGravity;
+ attr.backing_store = WhenMapped;
+ win->self = XCreateWindow(
+ X.display, X.root, 0, 0, win->width, win->height, 0, X.depth, InputOutput, X.visual,
+ CWBackPixel | CWBitGravity | CWBackingStore,
+ &attr);
XStoreName(X.display, win->self, title);
/* initialize the graphics */
-#include <liba.h>
#include <libui.h>
#include <impl/libui.h>
-void ui_end(UIWin* win)
+void win_repaint(UIWin* win)
{
XCopyArea(X.display, win->pixmap, win->self, win->gc, 0, 0, win->width, win->height, 0, 0);
- XSync(X.display, False);
+ XFlush(X.display);
}
void win_show(UIWin* win)
{
XMapWindow(X.display, win->self);
- XSync(X.display, False);
+ XSync(X.display, True);
}
$(OBJECT)
$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_delete.o
-include $(OUTDIR)/obj/lib/ui/window_delete.d
-$(OUTDIR)/obj/lib/ui/ui_end.o: lib/ui/ui_end.c config.mk
- $(OBJECT)
-$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/ui_end.o
--include $(OUTDIR)/obj/lib/ui/ui_end.d
-$(OUTDIR)/obj/lib/ui/ui_begin.o: lib/ui/ui_begin.c config.mk
- $(OBJECT)
-$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/ui_begin.o
--include $(OUTDIR)/obj/lib/ui/ui_begin.d
$(OUTDIR)/obj/lib/ui/font_close.o: lib/ui/font_close.c config.mk
$(OBJECT)
$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/font_close.o
-include $(OUTDIR)/obj/lib/ui/font_close.d
+$(OUTDIR)/obj/lib/ui/window_repaint.o: lib/ui/window_repaint.c config.mk
+ $(OBJECT)
+$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_repaint.o
+-include $(OUTDIR)/obj/lib/ui/window_repaint.d
$(OUTDIR)/obj/lib/ui/window_create.o: lib/ui/window_create.c config.mk
$(OBJECT)
$(OUTDIR)/lib/libui.a: $(OUTDIR)/obj/lib/ui/window_create.o
$(OUTDIR)/bin/terminal: | $(libs)
$(BINARY)
bins: $(OUTDIR)/bin/terminal
+$(OUTDIR)/obj/bin/uitest/main.o: bin/uitest/main.c config.mk
+ $(OBJECT)
+$(OUTDIR)/bin/uitest: $(OUTDIR)/obj/bin/uitest/main.o
+-include $(OUTDIR)/obj/bin/uitest/main.d
+$(OUTDIR)/bin/uitest: | $(libs)
+ $(BINARY)
+bins: $(OUTDIR)/bin/uitest
$(OUTDIR)/obj/bin/winmgr/client.o: bin/winmgr/client.c config.mk
$(OBJECT)
$(OUTDIR)/bin/winmgr: $(OUTDIR)/obj/bin/winmgr/client.o