diff --git a/README.md b/README.md index ec8eed6..3f46c77 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ For now this repo has bindings to libxcb, libxcb-image and libxcb-shm (bundled w They come in two flavors: 1) libname.jai - a version that will make Jai link the library -2) libname-dynamic.jai - a version that will not link the library, but you will have to load function pointers yourself. This is helpful when you want to ship a binary that supports both X11 and Wayland, but you don't want user's computer to necessarily have both installed in order for the program to run at all. +2) libname_fp.jai - a version that will not link the library, but you will have to load function pointers yourself (hence _fp suffix). This is helpful when you want to ship a binary that supports both X11 and Wayland, but you don't want user's computer to necessarily have both installed in order for the program to run at all. -See `xcb_example.jai` +See `xcb_simple.jai` ## TODO - [ ] xcb-based XDND implementation for dragndrop - [ ] XInput for smooth scrolling and gestures -- [ ] xkbcommon for keyboard handling +- [V] xkbcommon for keyboard handling - [ ] EGL for graphics - [ ] WM hints for icons and stuff like that - [ ] xcb-based clipboard hangling diff --git a/examples/xcb_simple.jai b/examples/xcb_simple.jai index e735e93..04c5906 100644 --- a/examples/xcb_simple.jai +++ b/examples/xcb_simple.jai @@ -4,8 +4,8 @@ XCB_LINKED :: false; #load "../generated/xcb.jai"; #load "../generated/xcb_image.jai"; } else { - #load "../generated/xcb_dynamic.jai"; - #load "../generated/xcb_image_dynamic.jai"; + #load "../generated/xcb_fp.jai"; + #load "../generated/xcb_image_fp.jai"; using xcb_procs: XCB_Procs; using xcb_image_procs: XCB_Image_Procs; diff --git a/generate.jai b/generate.jai index b860cff..3532d4d 100644 --- a/generate.jai +++ b/generate.jai @@ -54,7 +54,6 @@ generate_bindings :: () -> bool { // xcb-image { parent_struct_initted = false; - opts: Generate_Bindings_Options; array_add(*opts.source_files, "/usr/include/xcb/xcb_image.h"); @@ -71,6 +70,10 @@ generate_bindings :: () -> bool { result := generate_bindings(opts, "generated/xcb_image.jai"); if !result return result; + // TODO: seems like bindings generator eats this when it generates the bindings + // once and on subsequent generations it doesn't have this info anymore. + // Need to research + array_add(*opts.path_fragments_to_treat_as_non_system_paths, "/usr/include/xcb/shm.h"); opts.generate_library_declarations = false; context.procs_struct_name = "XCB_Image_Procs"; defer context.procs_struct_name = ""; diff --git a/generated/xcb_image_fp.jai b/generated/xcb_image_fp.jai index 8739ef8..9ed601b 100644 --- a/generated/xcb_image_fp.jai +++ b/generated/xcb_image_fp.jai @@ -6,6 +6,189 @@ +XCB_SHM_MAJOR_VERSION :: 1; +XCB_SHM_MINOR_VERSION :: 2; + +XCB_SHM_COMPLETION :: 0; + +XCB_SHM_BAD_SEG :: 0; + +XCB_SHM_QUERY_VERSION :: 0; + +XCB_SHM_ATTACH :: 1; + +XCB_SHM_DETACH :: 2; + +XCB_SHM_PUT_IMAGE :: 3; + +XCB_SHM_GET_IMAGE :: 4; + +XCB_SHM_CREATE_PIXMAP :: 5; + +XCB_SHM_ATTACH_FD :: 6; + +XCB_SHM_CREATE_SEGMENT :: 7; + +xcb_shm_id: xcb_extension_t; + +xcb_shm_seg_t :: u32; + +xcb_shm_seg_iterator_t :: struct { + data: *xcb_shm_seg_t; + rem: s32; + index: s32; +} + +xcb_shm_completion_event_t :: struct { + response_type: u8; + pad0: u8; + sequence: u16; + drawable: xcb_drawable_t; + minor_event: u16; + major_event: u8; + pad1: u8; + shmseg: xcb_shm_seg_t; + offset: u32; +} + +xcb_shm_bad_seg_error_t :: xcb_value_error_t; + +xcb_shm_query_version_cookie_t :: struct { + sequence: u32; +} + +xcb_shm_query_version_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; +} + +xcb_shm_query_version_reply_t :: struct { + response_type: u8; + shared_pixmaps: u8; + sequence: u16; + length: u32; + major_version: u16; + minor_version: u16; + uid: u16; + gid: u16; + pixmap_format: u8; + pad0: [15] u8; +} + +xcb_shm_attach_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + shmseg: xcb_shm_seg_t; + shmid: u32; + read_only: u8; + pad0: [3] u8; +} + +xcb_shm_detach_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + shmseg: xcb_shm_seg_t; +} + +xcb_shm_put_image_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + drawable: xcb_drawable_t; + gc: xcb_gcontext_t; + total_width: u16; + total_height: u16; + src_x: u16; + src_y: u16; + src_width: u16; + src_height: u16; + dst_x: s16; + dst_y: s16; + depth: u8; + format: u8; + send_event: u8; + pad0: u8; + shmseg: xcb_shm_seg_t; + offset: u32; +} + +xcb_shm_get_image_cookie_t :: struct { + sequence: u32; +} + +xcb_shm_get_image_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + drawable: xcb_drawable_t; + x: s16; + y: s16; + width: u16; + height: u16; + plane_mask: u32; + format: u8; + pad0: [3] u8; + shmseg: xcb_shm_seg_t; + offset: u32; +} + +xcb_shm_get_image_reply_t :: struct { + response_type: u8; + depth: u8; + sequence: u16; + length: u32; + visual: xcb_visualid_t; + size: u32; +} + +xcb_shm_create_pixmap_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + pid: xcb_pixmap_t; + drawable: xcb_drawable_t; + width: u16; + height: u16; + depth: u8; + pad0: [3] u8; + shmseg: xcb_shm_seg_t; + offset: u32; +} + +xcb_shm_attach_fd_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + shmseg: xcb_shm_seg_t; + read_only: u8; + pad0: [3] u8; +} + +xcb_shm_create_segment_cookie_t :: struct { + sequence: u32; +} + +xcb_shm_create_segment_request_t :: struct { + major_opcode: u8; + minor_opcode: u8; + length: u16; + shmseg: xcb_shm_seg_t; + size: u32; + read_only: u8; + pad0: [3] u8; +} + +xcb_shm_create_segment_reply_t :: struct { + response_type: u8; + nfd: u8; + sequence: u16; + length: u32; + pad0: [24] u8; +} + xcb_image_t :: struct { width: u16; height: u16; @@ -40,6 +223,28 @@ xcb_shm_segment_info_t :: struct { } XCB_Image_Procs :: struct #type_info_procedures_are_void_pointers { + xcb_shm_seg_next: #type (i: *xcb_shm_seg_iterator_t) -> void #c_call; + xcb_shm_seg_end: #type (i: xcb_shm_seg_iterator_t) -> xcb_generic_iterator_t #c_call; + xcb_shm_query_version: #type (c: *xcb_connection_t) -> xcb_shm_query_version_cookie_t #c_call; + xcb_shm_query_version_unchecked: #type (c: *xcb_connection_t) -> xcb_shm_query_version_cookie_t #c_call; + xcb_shm_query_version_reply: #type (c: *xcb_connection_t, cookie: xcb_shm_query_version_cookie_t, e: **xcb_generic_error_t) -> *xcb_shm_query_version_reply_t #c_call; + xcb_shm_attach_checked: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, shmid: u32, read_only: u8) -> xcb_void_cookie_t #c_call; + xcb_shm_attach: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, shmid: u32, read_only: u8) -> xcb_void_cookie_t #c_call; + xcb_shm_detach_checked: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t) -> xcb_void_cookie_t #c_call; + xcb_shm_detach: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t) -> xcb_void_cookie_t #c_call; + xcb_shm_put_image_checked: #type (c: *xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: s16, dst_y: s16, depth: u8, format: u8, send_event: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_void_cookie_t #c_call; + xcb_shm_put_image: #type (c: *xcb_connection_t, drawable: xcb_drawable_t, gc: xcb_gcontext_t, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: s16, dst_y: s16, depth: u8, format: u8, send_event: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_void_cookie_t #c_call; + xcb_shm_get_image: #type (c: *xcb_connection_t, drawable: xcb_drawable_t, x: s16, y: s16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_shm_get_image_cookie_t #c_call; + xcb_shm_get_image_unchecked: #type (c: *xcb_connection_t, drawable: xcb_drawable_t, x: s16, y: s16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_shm_get_image_cookie_t #c_call; + xcb_shm_get_image_reply: #type (c: *xcb_connection_t, cookie: xcb_shm_get_image_cookie_t, e: **xcb_generic_error_t) -> *xcb_shm_get_image_reply_t #c_call; + xcb_shm_create_pixmap_checked: #type (c: *xcb_connection_t, pid: xcb_pixmap_t, drawable: xcb_drawable_t, width: u16, height: u16, depth: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_void_cookie_t #c_call; + xcb_shm_create_pixmap: #type (c: *xcb_connection_t, pid: xcb_pixmap_t, drawable: xcb_drawable_t, width: u16, height: u16, depth: u8, shmseg: xcb_shm_seg_t, offset: u32) -> xcb_void_cookie_t #c_call; + xcb_shm_attach_fd_checked: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, shm_fd: s32, read_only: u8) -> xcb_void_cookie_t #c_call; + xcb_shm_attach_fd: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, shm_fd: s32, read_only: u8) -> xcb_void_cookie_t #c_call; + xcb_shm_create_segment: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, size: u32, read_only: u8) -> xcb_shm_create_segment_cookie_t #c_call; + xcb_shm_create_segment_unchecked: #type (c: *xcb_connection_t, shmseg: xcb_shm_seg_t, size: u32, read_only: u8) -> xcb_shm_create_segment_cookie_t #c_call; + xcb_shm_create_segment_reply: #type (c: *xcb_connection_t, cookie: xcb_shm_create_segment_cookie_t, e: **xcb_generic_error_t) -> *xcb_shm_create_segment_reply_t #c_call; + xcb_shm_create_segment_reply_fds: #type (c: *xcb_connection_t, reply: *xcb_shm_create_segment_reply_t) -> *s32 #c_call; xcb_image_annotate: #type (image: *xcb_image_t) -> void #c_call; xcb_image_create: #type (width: u16, height: u16, format: xcb_image_format_t, xpad: u8, depth: u8, bpp: u8, unit: u8, byte_order: xcb_image_order_t, bit_order: xcb_image_order_t, base: *void, bytes: u32, data: *u8) -> *xcb_image_t #c_call; xcb_image_create_native: #type (c: *xcb_connection_t, width: u16, height: u16, format: xcb_image_format_t, depth: u8, base: *void, bytes: u32, data: *u8) -> *xcb_image_t #c_call;