| 860 | //----------------------------XCB---------------------------- |
| 861 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 862 | static void AppCreateXcbWindow(AppInstance &inst) { |
| 863 | //--Init Connection-- |
| 864 | const xcb_setup_t *setup; |
| 865 | xcb_screen_iterator_t iter; |
| 866 | int scr; |
| 867 | |
| 868 | // API guarantees non-null xcb_connection |
| 869 | inst.xcb_connection = xcb_connect(nullptr, &scr); |
| 870 | int conn_error = xcb_connection_has_error(inst.xcb_connection); |
| 871 | if (conn_error) { |
| 872 | fprintf(stderr, "XCB failed to connect to the X server due to error:%d.\n", conn_error); |
| 873 | fflush(stderr); |
| 874 | xcb_disconnect(inst.xcb_connection); |
| 875 | inst.xcb_connection = nullptr; |
| 876 | return; |
| 877 | } |
| 878 | |
| 879 | setup = xcb_get_setup(inst.xcb_connection); |
| 880 | iter = xcb_setup_roots_iterator(setup); |
| 881 | while (scr-- > 0) { |
| 882 | xcb_screen_next(&iter); |
| 883 | } |
| 884 | |
| 885 | inst.xcb_screen = iter.data; |
| 886 | //------------------- |
| 887 | |
| 888 | inst.xcb_window = xcb_generate_id(inst.xcb_connection); |
| 889 | xcb_create_window(inst.xcb_connection, XCB_COPY_FROM_PARENT, inst.xcb_window, inst.xcb_screen->root, 0, 0, inst.width, |
| 890 | inst.height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, inst.xcb_screen->root_visual, 0, nullptr); |
| 891 | |
| 892 | xcb_intern_atom_cookie_t cookie = xcb_intern_atom(inst.xcb_connection, 1, 12, "WM_PROTOCOLS"); |
| 893 | xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(inst.xcb_connection, cookie, 0); |
| 894 | free(reply); |
| 895 | } |
| 896 | |
| 897 | static VkSurfaceKHR AppCreateXcbSurface(AppInstance &inst) { |
| 898 | if (!inst.xcb_connection) { |
nothing calls this directly
no outgoing calls
no test coverage detected