summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile17
-rw-r--r--src/defs.h14
-rw-r--r--src/main.c43
-rw-r--r--src/scapx.h17
4 files changed, 91 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..4b00009
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,17 @@
+CC = gcc
+CFLAGS = -Wall -Wextra -Wpedantic -std=c99 -Wunreachable-code -Werror-implicit-function-declaration
+LD_CFLAGS = -lxcb
+BIN_DIR = ../bin
+TARGET = $(BIN_DIR)/scapx
+#SRC = main.c
+#HEADERS = scapx.h
+
+
+all:
+ $(CC) $(CFLAGS) $(LD_CFLAGS) -o $(BIN_DIR)/scapx main.c
+
+$(BIN_DIR):
+ mkdir -p $(BIN_DIR)
+
+clean:
+ rm $(BIN_DIR)/*.o
diff --git a/src/defs.h b/src/defs.h
new file mode 100644
index 0000000..2e40298
--- /dev/null
+++ b/src/defs.h
@@ -0,0 +1,14 @@
+#include <stdint.h>
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+typedef int8_t i8;
+typedef int16_t i16;
+typedef int32_t i32;
+typedef int64_t i64;
+
+typedef float f32;
+typedef double f64;
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..0230dfd
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,43 @@
+#include "scapx.h"
+
+
+Scr_info *init_XCB_server()
+{
+ Scr_info *info = malloc(sizeof(Scr_info));
+ if (!info) {
+ fprintf(stderr, "memory allocation failed.\n");
+ return NULL;
+ }
+
+ info->con = xcb_connect(NULL, NULL);
+ if (xcb_connection_has_error(info->con) > 0) {
+ fprintf(stderr, "Error opening display.\n");
+ free(info);
+ return NULL;
+ }
+
+ const xcb_setup_t *setup = xcb_get_setup(info->con);
+ info->scr = xcb_setup_roots_iterator(setup).data;
+
+ return info;
+}
+
+int main()
+{
+ Scr_info *info = init_XCB_server();
+
+ if (!info || !info->scr) {
+ fprintf(stderr, "Error opening display.\n");
+ if (info) {
+ xcb_disconnect(info->con);
+ free(info);
+ }
+ exit(EXIT_FAILURE);
+ }
+
+ // TODO: event loop
+
+ xcb_disconnect(info->con);
+ free(info);
+ return 0;
+}
diff --git a/src/scapx.h b/src/scapx.h
new file mode 100644
index 0000000..0615e47
--- /dev/null
+++ b/src/scapx.h
@@ -0,0 +1,17 @@
+#ifndef SCAPX_H
+#define SCAPX_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <xcb/xcb.h>
+
+typedef struct {
+ xcb_connection_t *con;
+ xcb_screen_t *scr;
+} Scr_info;
+
+
+/* Connects to the X Server, and accesses the screen */
+Scr_info *init_XCB_server();
+
+#endif