Browse Source

Refocused on xcb instead of xlib

dirkson 4 months ago
parent
commit
130003d21e
8 changed files with 36 additions and 47 deletions
  1. 1
    2
      README.md
  2. 1
    1
      include/boksi.h
  3. 8
    2
      meson.build
  4. 5
    5
      src/boksi.c
  5. 2
    1
      src/example/complex.c
  6. 1
    3
      src/methods.h
  7. 18
    0
      src/methods/boksi_xcb.c
  8. 0
    33
      src/methods/boksi_xlib.c

+ 1
- 2
README.md View File

@@ -92,14 +92,13 @@ Meson can also generate a .so if you really need one.
92 92
 
93 93
 ## TODO
94 94
 
95
-+ Fix Xlib
95
++ Add XCB
96 96
 + Add actual support for OSX.
97 97
 + Add support for Wayland
98 98
 + Add glfw/nuklear
99 99
 + Add sdl/nuklear
100 100
 + Add gdi/nuklear
101 101
 + Add x11/nuklear
102
-+ Add XCB
103 102
 + Add Zenity
104 103
 + Add kdialog
105 104
 + Add linux's "dialog"

+ 1
- 1
include/boksi.h View File

@@ -17,7 +17,7 @@ typedef enum boksi_method
17 17
 	BOKSI_NCURSES     ,
18 18
 	BOKSI_GTK2        ,
19 19
 	BOKSI_STDERR      ,
20
-	BOKSI_XLIB        ,
20
+	BOKSI_XCB         ,
21 21
 	BOKSI_LIBUI       ,
22 22
 	BOKSI_NUKLEAR_SDL ,
23 23
 	BOKSI_NUKLEAR_GLFW,

+ 8
- 2
meson.build View File

@@ -1,7 +1,7 @@
1 1
 project('boksi', 'c', default_options : ['default_library=static', 'c_std=gnu89'])
2 2
 incdir = include_directories(['include', 'src', 'src/methods', 'src/dynload'])
3 3
 
4
-boksisrc = ['src/boksi.c', 'src/methods/boksi_gtk3.c', 'src/methods/boksi_gtk2.c', 'src/methods/boksi_xaw.c', 'src/methods/boksi_xlib.c', 'src/methods/boksi_std.c', 'src/methods/boksi_win.c', 'src/methods/boksi_osx.c', 'src/methods/boksi_ncurses.c', 'src/methods/boksi_libui.c']
4
+boksisrc = ['src/boksi.c', 'src/methods/boksi_gtk3.c', 'src/methods/boksi_gtk2.c', 'src/methods/boksi_xaw.c', 'src/methods/boksi_xcb.c', 'src/methods/boksi_std.c', 'src/methods/boksi_win.c', 'src/methods/boksi_osx.c', 'src/methods/boksi_ncurses.c', 'src/methods/boksi_libui.c']
5 5
 
6 6
 if get_option('buildtype').startswith('debug')
7 7
 	add_project_arguments('-DBOKSI_DEBUG_SELF', language : 'c')
@@ -38,6 +38,12 @@ else
38 38
 	depxaw = cc.find_library('fake_library_boksi', required:false)
39 39
 endif
40 40
 
41
+depxcb = dependency('xcb', required:false)
42
+#depxlib = cc.find_library('Xlib', required:false)
43
+if depxcb.found()
44
+	add_project_arguments('-DBOKSI_BUILD_XCB', language : 'c')
45
+endif
46
+
41 47
 depncurses = cc.find_library('ncurses', required:false)
42 48
 if depncurses.found()
43 49
 	#Currently it won't build on windows. Disabling ncurses for cross builds for now.
@@ -53,7 +59,7 @@ depdynload = dependency('dynload', fallback : ['dynload', 'dynload_dep'])
53 59
 
54 60
 
55 61
 #library
56
-libboksi = library('boksi', boksisrc, include_directories : incdir, dependencies: [depdynload, depgtk, depxt, depxaw, depncurses, deplibui] )
62
+libboksi = library('boksi', boksisrc, include_directories : incdir, dependencies: [depdynload, depgtk, depxt, depxaw, depncurses, deplibui, depxcb] )
57 63
 boksi_dep = declare_dependency(link_with : libboksi, include_directories : incdir)
58 64
 
59 65
 

+ 5
- 5
src/boksi.c View File

@@ -38,6 +38,9 @@ boksi_return boksi_set_info(boksi_info* info, const boksi_method method[])
38 38
 		#ifdef BOKSI_BUILD_XAW
39 39
 			BOKSI_KNOWN_METHOD(BOKSI_XAW);
40 40
 		#endif
41
+		#ifdef BOKSI_BUILD_XCB
42
+			BOKSI_KNOWN_METHOD(BOKSI_XCB);
43
+		#endif
41 44
 		#ifdef BOKSI_BUILD_GTK3
42 45
 			BOKSI_KNOWN_METHOD(BOKSI_GTK3);
43 46
 		#endif
@@ -47,9 +50,6 @@ boksi_return boksi_set_info(boksi_info* info, const boksi_method method[])
47 50
 		#ifdef BOKSI_BUILD_NCURSES
48 51
 			BOKSI_KNOWN_METHOD(BOKSI_NCURSES);
49 52
 		#endif
50
-		#ifdef BOKSI_BUILD_XLIB
51
-			BOKSI_KNOWN_METHOD(BOKSI_XLIB);
52
-		#endif
53 53
 		#ifdef BOKSI_BUILD_LIBUI
54 54
 			BOKSI_KNOWN_METHOD(BOKSI_LIBUI);
55 55
 		#endif
@@ -100,8 +100,8 @@ int boksi_explicit(const boksi_info info, boksi_level level, const char* name, c
100 100
 		#ifdef BOKSI_BUILD_XT
101 101
 			BOKSI_USE_METHOD(BOKSI_XT, boksi_xt(level, name, button, msg));
102 102
 		#endif
103
-		#ifdef BOKSI_BUILD_XLIB
104
-			BOKSI_USE_METHOD(BOKSI_XLIB, boksi_xlib(level, name, button, msg));
103
+		#ifdef BOKSI_BUILD_XCB
104
+			BOKSI_USE_METHOD(BOKSI_XCB, boksi_xcb(level, name, button, msg));
105 105
 		#endif
106 106
 		#ifdef BOKSI_BUILD_LIBUI
107 107
 			BOKSI_USE_METHOD(BOKSI_LIBUI, boksi_libui(level, name, button, msg));

+ 2
- 1
src/example/complex.c View File

@@ -9,7 +9,8 @@ int main()
9 9
 		//BOKSI_NCURSES,
10 10
 		//BOKSI_LIBUI,
11 11
 		//BOKSI_GTK2,
12
-		BOKSI_XAW,
12
+		//BOKSI_XAW,
13
+		BOKSI_XCB,
13 14
 		BOKSI_STDOUT,
14 15
 		BOKSI_GIVEUP};
15 16
 

+ 1
- 3
src/methods.h View File

@@ -7,9 +7,7 @@ extern boksi_return boksi_gtk2   (const boksi_level, const char*, const char*, c
7 7
 
8 8
 extern boksi_return boksi_xaw    (const boksi_level, const char*, const char*, const char*);
9 9
 
10
-extern boksi_return boksi_xlib   (const boksi_level, const char*, const char*, const char*);
11
-
12
-extern boksi_return boksi_xt     (const boksi_level, const char*, const char*, const char*);
10
+extern boksi_return boksi_xcb    (const boksi_level, const char*, const char*, const char*);
13 11
 
14 12
 extern boksi_return boksi_libui  (const boksi_level, const char*, const char*, const char*);
15 13
 

+ 18
- 0
src/methods/boksi_xcb.c View File

@@ -0,0 +1,18 @@
1
+
2
+#ifdef BOKSI_BUILD_XCB
3
+
4
+#include <boksi.h>
5
+#include "methods.h"
6
+//#include <dynload_xcb.h>
7
+#include <stdio.h>
8
+
9
+extern boksi_return boksi_xcb(const boksi_level Level, const char* name_window, const char* name_button, const char* msg)
10
+{
11
+//	if (dynload(&dynload_xcb) != DYNLOAD_SUCCESS)
12
+		return BOKSI_FAILURE;
13
+
14
+	return BOKSI_SUCCESS;
15
+}
16
+
17
+#endif
18
+

+ 0
- 33
src/methods/boksi_xlib.c View File

@@ -1,33 +0,0 @@
1
-
2
-#ifdef BOKSI_BUILD_XLIB
3
-
4
-#include <boksi.h>
5
-#include "methods.h"
6
-#include <dynload_xt.h>
7
-#include <dynload_xlib.h>
8
-#include <stdio.h>
9
-
10
-extern boksi_return boksi_xlib(const boksi_level Level, const char* name_window, const char* name_button, const char* msg)
11
-{
12
-	if (dynload(&dynload_xlib) != DYNLOAD_SUCCESS)
13
-		return BOKSI_FAILURE;
14
-
15
-	//Somehow dynload can't find XOpenDisplay?
16
-	Display* display = XOpenDisplay(NULL);
17
-	Window window = XCreateSimpleWindow(display, XDefaultRootWindow(display), 100, 100, 200, 200, 4, 0, 0);
18
-
19
-	XMapWindow(display, window);
20
-	XSelectInput(display, window, KeyPressMask | ButtonPressMask | ExposureMask);
21
-
22
-	XEvent event;
23
-	while (True)
24
-	{
25
-		XNextEvent(display, &event);
26
-		printf("%d\n", event.type);
27
-	}
28
-
29
-	return BOKSI_SUCCESS;
30
-}
31
-
32
-#endif
33
-

Loading…
Cancel
Save