summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--checkdispsrv.c19
-rw-r--r--include/luma/main.h10
-rw-r--r--initx.c6
-rw-r--r--main.c1
-rw-r--r--stdlibsock/gfx/crtwin.c23
6 files changed, 44 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index b30e613..5d506d2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CC=clang
CFLAGS+=-Iinclude -std=c17 -Wall -Wextra -Wpedantic -Werror
CFLAGS+=-march=native -O3
-LIBS=-lgmp -lmpfr -lOpenGL -lpthread -lX11 -lxcb -lvulkan
+LIBS=-lgmp -lmpfr -lpthread -lxcb -lvulkan -lwayland-client
HDR=\
include/luma/stdlibsock/gfx.h \
include/luma/main.h \
@@ -9,6 +9,7 @@ HDR=\
SRC=\
stdlibsock/gfx/crtwin.c \
stdlibsock/gfx/destwin.c \
+ checkdispsrv.c \
initx.c \
main.c
OBJ=$(SRC:.c=.o)
diff --git a/checkdispsrv.c b/checkdispsrv.c
new file mode 100644
index 0000000..a7e6bbf
--- /dev/null
+++ b/checkdispsrv.c
@@ -0,0 +1,19 @@
+# include <luma/main.h>
+# include <stdint.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+void luma__checkdispsrv(uint32_t * retval) {
+ retval = 0x0;
+ char const * sesstype = getenv("XDG_SESSION_TYPE");
+ if(strncmp(sesstype,"wayland",0x10)) {
+ luma__dat.dispsrv = "wayland";
+ }
+ else if(strncmp(sesstype,"x11",0x10)) {
+ luma__dat.dispsrv = "x";
+ }
+ else {
+ printf("Environment variable $XDG_SESSION_TYPE is \"%s\", which is not understood.\n");
+ *retval = 0x1;
+ }
+}
diff --git a/include/luma/main.h b/include/luma/main.h
index cd945ce..960ece1 100644
--- a/include/luma/main.h
+++ b/include/luma/main.h
@@ -20,13 +20,13 @@
# include <luma/stdlibsock.h>
# include <luma/stdlibsock/gfx.h>
# include <stdint.h>
-# include <stdio.h>
# include <xcb/xcb.h>
struct luma__dat_t {
- xcb_connection_t * xcbconn;
- xcb_screen_t * xcbscrn;
- xcb_window_t xcbwin;
+ char * dispsrv;
+ xcb_connection_t * xconn;
+ xcb_screen_t * xscrn;
+ xcb_window_t xwin;
};
struct luma__dat_t extern luma__dat;
-void luma__crtxconn(uint32_t * retval);
+void luma__initx(uint32_t * retval);
# endif
diff --git a/initx.c b/initx.c
index 35b619d..9e2b5d7 100644
--- a/initx.c
+++ b/initx.c
@@ -2,9 +2,9 @@
# include <stdint.h>
# include <stdio.h>
# include <xcb/xcb.h>
-void luma__crtxconn(uint32_t * retval) {
- if(luma__dat.xcbconn) {
- luma__dat.xcbconn = xcb_connect(NULL,NULL);
+void luma__initx(uint32_t * retval) {
+ if(luma__dat.xconn) {
+ luma__dat.xconn = xcb_connect(NULL,NULL);
}
else {
printf("luma__crtxconn called with a valid X connection!\n");
diff --git a/main.c b/main.c
index 31bb08f..45241d7 100644
--- a/main.c
+++ b/main.c
@@ -10,6 +10,7 @@ int main(int argc, char * * argv) {
}
if((access(argv[0x1], F_OK) == 0)) {
printf("\f");
+ luma__initstdlib__gfx();
luma__stdlibsock__gfx__crtwin("luma test",0x0,0x0,0x400,0x300,false);
}
else {
diff --git a/stdlibsock/gfx/crtwin.c b/stdlibsock/gfx/crtwin.c
index f820716..4ab2fcf 100644
--- a/stdlibsock/gfx/crtwin.c
+++ b/stdlibsock/gfx/crtwin.c
@@ -10,14 +10,19 @@ uint8_t luma__stdlibsock__gfx__crtwin(char * nm,uint16_t pos_x,uint16_t pos_y,ui
if(flscrn) {
printf("Fullscreen is not supported yet!\n");
}
- luma__crtxconn(&retval);
- luma__dat.xcbscrn = xcb_setup_roots_iterator(xcb_get_setup(luma__dat.xcbconn)).data;
- luma__dat.xcbwin = xcb_generate_id(luma__dat.xcbconn);
- xcb_create_window(luma__dat.xcbconn,XCB_COPY_FROM_PARENT,luma__dat.xcbwin,luma__dat.xcbscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,luma__dat.xcbscrn->root_visual,0x0,NULL);
- xcb_change_property(luma__dat.xcbconn,XCB_PROP_MODE_REPLACE,luma__dat.xcbwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,strlen(nm),nm);
- xcb_map_window(luma__dat.xcbconn,luma__dat.xcbwin);
- xcb_flush(luma__dat.xcbconn);
- sleep(0x6);
- xcb_disconnect(luma__dat.xcbconn);
+ if(strncmp(luma__dat.dispsrv,"wayland",0x10)) {
+
+ }
+ else if(strncmp(luma__dat.dispsrv,"x",0x10)) {
+ luma__initx(&retval);
+ luma__dat.xscrn = xcb_setup_roots_iterator(xcb_get_setup(luma__dat.xconn)).data;
+ luma__dat.xwin = xcb_generate_id(luma__dat.xconn);
+ xcb_create_window(luma__dat.xconn,XCB_COPY_FROM_PARENT,luma__dat.xwin,luma__dat.xscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,luma__dat.xscrn->root_visual,0x0,NULL);
+ xcb_change_property(luma__dat.xconn,XCB_PROP_MODE_REPLACE,luma__dat.xwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,strlen(nm),nm);
+ xcb_map_window(luma__dat.xconn,luma__dat.xwin);
+ xcb_flush(luma__dat.xconn);
+ sleep(0x6);
+ xcb_disconnect(luma__dat.xconn);
+ }
return 0x0;
}