aboutsummaryrefslogtreecommitdiffstats
path: root/simple_x.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2015-06-19 19:12:12 +0100
committerEliteTK <tomasz.kramkowski@gmail.com>2015-06-19 19:12:12 +0100
commitda87fcf25e0c94e57f00df84679cd6fadc56ed46 (patch)
tree3c53eea9db01039990455af870a2ca65e7e5a123 /simple_x.c
parent75d2e00662416224f4b745e0004f48f1fc1d9665 (diff)
parent7bf25fb8f0e4643a67894417a95d39e5901b1824 (diff)
downloadc-stuff-da87fcf25e0c94e57f00df84679cd6fadc56ed46.tar.gz
c-stuff-da87fcf25e0c94e57f00df84679cd6fadc56ed46.tar.xz
c-stuff-da87fcf25e0c94e57f00df84679cd6fadc56ed46.zip
Merge branch 'master' of https://github.com/EliteTK/c-stuff
Diffstat (limited to 'simple_x.c')
-rw-r--r--simple_x.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/simple_x.c b/simple_x.c
deleted file mode 100644
index 98ddbbe..0000000
--- a/simple_x.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * SimplX - Proposed name if not taken already.
- *
- * Copyright (C) 2014 Tomasz Kramkowski <tk@the-tk.com>
- *
- * This program is free software. It is licensed under version 3 of the
- * GNU General Public License.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see [http://www.gnu.org/licenses/].
- */
-#include <stdlib.h>
-#include <xcb/xcb.h>
-#include <xcb/xcb_image.h>
-
-/*
- * TODO: Figure out the alignment of these things fix the arrangement.
- * Find a good name for this.
- */
-typedef struct sx_gc {
- /*struct {*/
- xcb_connection_t *connection;
- xcb_screen_t *screen;
- xcb_drawable_t window;
- xcb_pixmap_t pixmap;
- xcb_image_t *image;
- xcb_gcontext_t gc;
- /*} xcb;*/
-} SX;
-
-SX *sx_new_gc(uint16_t width, uint16_t height)
-{
- SX *sx = malloc(sizeof(SX));
-
- sx->connection = xcb_connect(NULL, NULL);
-
- sx->screen = xcb_setup_roots_iterator(xcb_get_setup(sx->connection)).data;
-
- uint32_t mask = XCB_CW_BACK_PIXEL; /* Needs events */
- uint32_t values[] = {sx->screen->black_pixel};
-
- sx->window = xcb_generate_id(sx->connection);
- xcb_create_window(sx->connection,
- 24,
- sx->window,
- sx->screen->root,
- 0, 0,
- width, height,
- 1,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- sx->screen->root_visual,
- mask, values);
-
- sx->pixmap = xcb_generate_id(sx->connection);
- xcb_create_pixmap(sx->connection,
- 24,
- sx->pixmap,
- sx->window,
- width, height);
-
- uint8_t *img = malloc(width * height * 4);
- xcb_image_t *image = xcb_image_create(width, height,
- XCB_IMAGE_FORMAT_Z_PIXMAP,
- 8, 24, 32,
- 0,
- XCB_IMAGE_ORDER_MSB_FIRST,
- XCB_IMAGE_ORDER_LSB_FIRST,
- img,
- width * height * 4,
- img);
-
- mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
- values[0] = sx->screen->black_pixel;
- values[1] = 0xFFFFFF;
-
- sx->gc = xcb_generate_id(sx->connection);
- xcb_create_gc(sx->connection,
- sx->gc,
- sx->pixmap,
- mask, values);
-
- return sx;
-}