67 lines
1.5 KiB
C
67 lines
1.5 KiB
C
#include <xcb/xcb.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main (void) {
|
|
int active = 1;
|
|
|
|
unsigned short int window_width = 640;
|
|
unsigned short int window_height = 480;
|
|
|
|
xcb_window_t window = 0;
|
|
xcb_connection_t * connection = NULL;
|
|
xcb_screen_t * screen = NULL;
|
|
xcb_generic_event_t * event = NULL;
|
|
|
|
unsigned int window_flags [2] = {
|
|
0,
|
|
XCB_EVENT_MASK_NO_EVENT |
|
|
XCB_EVENT_MASK_EXPOSURE |
|
|
XCB_EVENT_MASK_RESIZE_REDIRECT |
|
|
XCB_EVENT_MASK_KEY_RELEASE |
|
|
XCB_EVENT_MASK_KEY_PRESS |
|
|
XCB_EVENT_MASK_BUTTON_RELEASE |
|
|
XCB_EVENT_MASK_BUTTON_PRESS
|
|
};
|
|
|
|
connection = xcb_connect (NULL, NULL);
|
|
|
|
screen = xcb_setup_roots_iterator (xcb_get_setup (connection)).data;
|
|
|
|
window = xcb_generate_id (connection);
|
|
|
|
window_flags [0] = screen->black_pixel;
|
|
|
|
xcb_create_window (connection, screen->root_depth, window, screen->root, 0, 0, window_width, window_height, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual,
|
|
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, window_flags);
|
|
|
|
xcb_map_window (connection, window);
|
|
|
|
xcb_flush (connection);
|
|
|
|
while (active) {
|
|
event = xcb_wait_for_event (connection);
|
|
|
|
switch (event->response_type & 127) {
|
|
case XCB_EXPOSE:
|
|
xcb_flush (connection);
|
|
break;
|
|
case XCB_KEY_PRESS:
|
|
if ((int) ((xcb_key_press_event_t *) event)->detail == 24) {
|
|
active = 0;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
free (event);
|
|
}
|
|
|
|
xcb_destroy_window (connection, window);
|
|
|
|
xcb_disconnect (connection);
|
|
|
|
return (0);
|
|
}
|