mirror of
https://github.com/0intro/wmii
synced 2025-01-12 21:29:19 +03:00
proceeded with liblitz (several cleanups)
This commit is contained in:
parent
0104091f56
commit
942665ff64
@ -6,7 +6,7 @@ include ../config.mk
|
||||
CFLAGS += -I../libixp -I../libcext
|
||||
LDFLAGS += -L../libixp -lixp -L../libcext -lcext
|
||||
|
||||
SRC = blitz.c color.c font.c input.c label.c tile.c widget.c
|
||||
SRC = blitz.c color.c font.c input.c label.c tile.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: liblitz.a
|
||||
|
@ -14,16 +14,12 @@ typedef struct Blitz Blitz;
|
||||
typedef enum BlitzAlign BlitzAlign;
|
||||
typedef struct BlitzColor BlitzColor;
|
||||
typedef struct BlitzFont BlitzFont;
|
||||
typedef struct BlitzTile BlitzTile;
|
||||
typedef struct BlitzInput BlitzInput;
|
||||
typedef union BlitzWidget BlitzWidget;
|
||||
#define BLITZWIDGET(p) ((BlitzWidget *)(p))
|
||||
typedef struct BlitzWidget BlitzWidget;
|
||||
|
||||
struct Blitz {
|
||||
Display *display;
|
||||
int screen;
|
||||
Window root;
|
||||
BlitzWidget *widgets;
|
||||
};
|
||||
|
||||
enum BlitzAlign {
|
||||
@ -51,37 +47,16 @@ struct BlitzFont {
|
||||
int descent;
|
||||
};
|
||||
|
||||
struct BlitzTile {
|
||||
struct BlitzWidget {
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
void (*event[LASTEvent]) (BlitzWidget *, XEvent *);
|
||||
BlitzWidget *next;
|
||||
/* widget specific */
|
||||
BlitzColor color;
|
||||
XRectangle rect; /* relative rect */
|
||||
XRectangle *notch; /* relative notch rect */
|
||||
};
|
||||
|
||||
struct BlitzInput {
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
void (*event[LASTEvent]) (BlitzWidget *, XEvent *);
|
||||
BlitzWidget *next;
|
||||
/* widget specific */
|
||||
BlitzColor color;
|
||||
BlitzAlign align;
|
||||
BlitzFont font;
|
||||
XRectangle rect; /* relative rect */
|
||||
XRectangle *notch; /* relative notch rect */
|
||||
char *text;
|
||||
};
|
||||
|
||||
union BlitzWidget {
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
void (*event[LASTEvent]) (BlitzWidget *, XEvent *);
|
||||
BlitzWidget *next;
|
||||
BlitzTile tile;
|
||||
BlitzInput input;
|
||||
void (*draw)(BlitzWidget *);
|
||||
};
|
||||
|
||||
/* obsolete, will be replaced soon */
|
||||
@ -111,18 +86,15 @@ void blitz_drawlabel(BlitzDraw *d);
|
||||
void blitz_drawborder(BlitzDraw *d);
|
||||
|
||||
/* input.c */
|
||||
BlitzInput *blitz_create_input(Drawable drawable, GC gc);
|
||||
void blitz_destroy_input(BlitzInput *t);
|
||||
BlitzWidget *blitz_create_input(Drawable drawable, GC gc);
|
||||
void blitz_draw_input(BlitzWidget *i);
|
||||
void blitz_destroy_input(BlitzWidget *i);
|
||||
|
||||
/* tile.c */
|
||||
BlitzTile *blitz_create_tile(Drawable drawable, GC gc);
|
||||
void blitz_draw_tile(BlitzTile *t);
|
||||
void blitz_destroy_tile(BlitzTile *t);
|
||||
BlitzWidget *blitz_create_tile(Drawable drawable, GC gc);
|
||||
void blitz_draw_tile(BlitzWidget *t);
|
||||
void blitz_destroy_tile(BlitzWidget *t);
|
||||
|
||||
/* font.c */
|
||||
unsigned int blitz_textwidth(BlitzFont *font, char *text);
|
||||
void blitz_loadfont(BlitzFont *font, char *fontstr);
|
||||
|
||||
/* widget.c */
|
||||
void blitz_add_widget(BlitzWidget *w);
|
||||
void blitz_rm_widget(BlitzWidget *w);
|
||||
|
@ -4,24 +4,27 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cext.h>
|
||||
|
||||
#include "blitz.h"
|
||||
|
||||
BlitzInput *
|
||||
BlitzWidget *
|
||||
blitz_create_input(Drawable drawable, GC gc)
|
||||
{
|
||||
BlitzInput *i = cext_emallocz(sizeof(BlitzInput));
|
||||
BlitzWidget *i = cext_emallocz(sizeof(BlitzWidget));
|
||||
i->drawable = drawable;
|
||||
i->gc = gc;
|
||||
blitz_add_widget(BLITZWIDGET(i));
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_destroy_input(BlitzInput *i)
|
||||
blitz_draw_input(BlitzWidget *i)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
blitz_destroy_input(BlitzWidget *i)
|
||||
{
|
||||
blitz_rm_widget(BLITZWIDGET(i));
|
||||
free(i);
|
||||
}
|
||||
|
@ -4,23 +4,20 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cext.h>
|
||||
|
||||
#include "blitz.h"
|
||||
|
||||
BlitzTile *
|
||||
BlitzWidget *
|
||||
blitz_create_tile(Drawable drawable, GC gc)
|
||||
{
|
||||
BlitzTile *t = cext_emallocz(sizeof(BlitzTile));
|
||||
BlitzWidget *t = cext_emallocz(sizeof(BlitzWidget));
|
||||
t->drawable = drawable;
|
||||
t->gc = gc;
|
||||
blitz_add_widget(BLITZWIDGET(t));
|
||||
return t;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_draw_tile(BlitzTile *t)
|
||||
blitz_draw_tile(BlitzWidget *t)
|
||||
{
|
||||
XPoint points[5];
|
||||
XSetForeground(__blitz.display, t->gc, t->color.bg);
|
||||
@ -41,8 +38,7 @@ blitz_draw_tile(BlitzTile *t)
|
||||
}
|
||||
|
||||
void
|
||||
blitz_destroy_tile(BlitzTile *t)
|
||||
blitz_destroy_tile(BlitzWidget *t)
|
||||
{
|
||||
blitz_rm_widget(BLITZWIDGET(t));
|
||||
free(t);
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cext.h>
|
||||
|
||||
#include "blitz.h"
|
||||
|
||||
void
|
||||
blitz_add_widget(BlitzWidget *w)
|
||||
{
|
||||
BlitzWidget **wp;
|
||||
for(wp = &__blitz.widgets; *wp; wp = &(*wp)->next);
|
||||
w->next = nil;
|
||||
*wp = w;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_rm_widget(BlitzWidget *w)
|
||||
{
|
||||
BlitzWidget **wp;
|
||||
for(wp = &__blitz.widgets; *wp && *wp != w; wp = &(*wp)->next);
|
||||
cext_assert(*wp == w);
|
||||
*wp = w->next;
|
||||
}
|
Loading…
Reference in New Issue
Block a user