initial commit 🤞

This commit is contained in:
betty
2025-12-27 20:47:41 -05:00
commit c06f9aeefe
8 changed files with 281 additions and 0 deletions

33
inc/put.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef PUT_H
#define PUT_H
#include <stdint.h>
enum put_event_type {
PUT_EXPOSE,
PUT_MOUSE_DOWN,
PUT_MOUSE_UP,
PUT_MOUSE_MOVE,
PUT_KEY,
PUT_SCROLL
};
enum {
PUT_MOD_SHIFT = 1 << 0,
PUT_MOD_CTRL = 1 << 1,
PUT_MOD_ALT = 1 << 2,
PUT_MOD_SUPER = 1 << 3
};
struct put_event {
enum put_event_type type;
int x;
int y;
int dx;
int dy;
int key;
uint32_t mods;
};
#endif /* PUT_H */

31
inc/screen.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef SCREEN_H
#define SCREEN_H
/*
#include <libpng.h>
#include <cairo/cairo.h>
#include <cairo/cairo-xcb.h>
#include <xcb/xcb.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
*/
#include "thing.h"
#include "put.h"
typedef struct screen screen_t;
// func decs
screen_t *screen_create(int width, int height);
void screen_destroy(screen_t *s);
void screen_add(screen_t *s, thing_t *t);
void screen_remove(screen_t *s, thing_t *t);
void screen_raise(screen_t *s, thing_t *t);
void screen_lower(screen_t *s, thing_t *t);
void screen_dispatch(screen_t *s, const put_event *ev);
void screen_redraw(screen_t *s);
#endif

49
inc/thing.h Normal file
View File

@@ -0,0 +1,49 @@
#ifndef THING_H
#define THING_H
/*
#include <libpng.h>
#include <pango.h>
#include <cairo/cairo.h>
#include <cairo/cairo-xcb.h>
#include <xcb/xcb.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
*/
#include <stdint.h>
typedef struct thing thing_t;
typedef uint64_t thing_id_t;
thing_id_t thing_id(const thing_t *);
typedef struct {
int x;
int y;
int w;
int h;
} thing_geom;
struct put_event;
struct link {
thing_id_t from;
thing_id_t to;
uint32_t type;
};
typedef struct {
void (*draw)(thing_t *self, void *render_ctx);
int (*hit)(thing_t *self, int x, int y);
void (*event)(thing_t *self, const struct put_event *ev);
} thing_ops;
thing_t *thing_create(const thing_ops *ops, void *userdata, thing_geom geom);
void thing_set_geom(thing_t *t, thing_geom g);
thing_geom thing_get_geom(const thing_t *t);
void *thing_userdata(const thing_t *t);
void thing_destroy(thing_t *t);
#endif /* THING_H */