diff options
author | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2011-12-04 20:22:32 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@l3000.localdomain> | 2011-12-04 20:22:32 -0500 |
commit | cf1930f4b1ce485c8d9264c0c1a639f766373646 (patch) | |
tree | e8f9d40de0d0b450d0e5f62b5a4ec56ad505f897 |
Checkin
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | window.c | 81 | ||||
-rw-r--r-- | window.h | 55 |
4 files changed, 148 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e2136df --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +CFLAGS = `pkg-config --cflags pixman-1 x11` +LDFLAGS = `pkg-config --libs pixman-1 x11` + +pintria: window.c window.h main.c + $(CC) $(CFLAGS) -o pintria window.c main.c $(LDFLAGS) @@ -0,0 +1,7 @@ +#include <stdio.h> + +int +main () +{ + printf ("Hello world\n"); +} diff --git a/window.c b/window.c new file mode 100644 index 0000000..f4350b3 --- /dev/null +++ b/window.c @@ -0,0 +1,81 @@ +#include <stdlib.h> +#include <X11/Xlib.h> +#include "window.h" + +struct ws_t +{ + Display *display; +}; + +struct window_t +{ + XID xid; +}; + +/* Window system */ +ws_t * +ws_open (void) +{ + ws_t *ws = malloc (sizeof *ws); + + ws->display = XOpenDisplay (NULL); + + if (!ws->display) + return NULL; + + return ws; +} + +/* Window */ +window_t * +ws_create_window (ws_t *ws, + int x, + int y, + int width, + int height) +{ + window_t *window = malloc (sizeof *window); + Window root = DefaultRootWindow (ws->display); + + window->xid = XCreateSimpleWindow ( + ws->display, root, x, y, width, height, 0, 0, None); + + return window; +} + +void ws_window_ref (window_t *window); +void ws_window_unref (window_t *window); +void ws_window_show (window_t *window); +void ws_window_hide (window_t *window); +void ws_window_move (window_t *window, + int x, + int y); +void ws_window_resize (window_t *window, + int w, + int h); +void ws_window_copy_area (window_t *window, + int src_x, + int src_y, + int dst_x, + int dst_y, + int width, + int height); +void ws_window_copy_from_image (window_t *window, + pixman_image_t *image, + int image_x, + int image_y, + int win_x, + int win_y, + int width, + int height); +void ws_window_copy_to_image (window_t *window, + pixman_image_t *image, + int image_x, + int image_y, + int win_x, + int win_y, + int width, + int height); + +void ws_window_finish (window_t **windows, + int n_windows); diff --git a/window.h b/window.h new file mode 100644 index 0000000..3def92e --- /dev/null +++ b/window.h @@ -0,0 +1,55 @@ +#include <stdio.h> +#include <pixman.h> + +typedef struct ws_t ws_t; +typedef struct drawable_t drawable_t; +typedef struct window_t window_t; +typedef struct surfade_t surface_t; + +/* Window system */ +ws_t * ws_open (void); +int ws_get_width (ws_t *ws); +int ws_get_height (ws_t *ws); + +/* Window */ +window_t *ws_create_window (ws_t *ws, + int x, + int y, + int width, + int height); +void ws_window_ref (window_t *window); +void ws_window_unref (window_t *window); +void ws_window_show (window_t *window); +void ws_window_hide (window_t *window); +void ws_window_move (window_t *window, + int x, + int y); +void ws_window_resize (window_t *window, + int w, + int h); +void ws_window_copy_area (window_t *window, + int src_x, + int src_y, + int dst_x, + int dst_y, + int width, + int height); +void ws_window_copy_from_image (window_t *window, + pixman_image_t *image, + int image_x, + int image_y, + int win_x, + int win_y, + int width, + int height); +void ws_window_copy_to_image (window_t *window, + pixman_image_t *image, + int image_x, + int image_y, + int win_x, + int win_y, + int width, + int height); + +void ws_window_finish (window_t **windows, + int n_windows); |