mirror of https://github.com/bjornbytes/lovr.git
Organization;
This commit is contained in:
parent
df4daa6290
commit
881fcb47fd
|
@ -178,6 +178,11 @@ void os_on_permission(fn_permission* callback) {
|
|||
//
|
||||
}
|
||||
|
||||
// TODO EGL
|
||||
// TODO fullscreen
|
||||
// TODO resizable
|
||||
// TODO title
|
||||
// TODO icon
|
||||
bool os_window_open(const os_window_config* config) {
|
||||
state.connection = xcb_connect(NULL, NULL);
|
||||
|
||||
|
@ -188,6 +193,15 @@ bool os_window_open(const os_window_config* config) {
|
|||
|
||||
xcb_screen_t* screen = xcb_setup_roots_iterator(xcb_get_setup(state.connection)).data;
|
||||
|
||||
uint8_t depth = XCB_COPY_FROM_PARENT;
|
||||
xcb_window_t window = xcb_generate_id(state.connection);
|
||||
xcb_window_t parent = screen->root;
|
||||
uint16_t w = config->width;
|
||||
uint16_t h = config->height;
|
||||
uint16_t border = 0;
|
||||
xcb_window_class_t class = XCB_WINDOW_CLASS_INPUT_OUTPUT;
|
||||
xcb_visual_t visual = screen->root_visual;
|
||||
uint32_t keys = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||
uint32_t values[] = {
|
||||
screen->black_pixel,
|
||||
XCB_EVENT_MASK_KEY_PRESS |
|
||||
|
@ -198,41 +212,18 @@ bool os_window_open(const os_window_config* config) {
|
|||
XCB_EVENT_MASK_FOCUS_CHANGE
|
||||
};
|
||||
|
||||
xcb_window_t window = xcb_generate_id(state.connection);
|
||||
xcb_create_window(state.connection, depth, window, parent, 0, 0, w, h, border, class, visual, keys, values);
|
||||
|
||||
// TODO fullscreen
|
||||
// TODO resizable
|
||||
// TODO title
|
||||
// TODO icon
|
||||
xcb_create_window(
|
||||
state.connection,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
window,
|
||||
screen->root,
|
||||
0,
|
||||
0,
|
||||
config->width,
|
||||
config->height,
|
||||
0,
|
||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
screen->root_visual,
|
||||
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
|
||||
values
|
||||
);
|
||||
|
||||
xcb_map_window(state.connection, window);
|
||||
|
||||
xcb_intern_atom_cookie_t protocolCookie = xcb_intern_atom(state.connection, 1, 12, "WM_PROTOCOLS");
|
||||
xcb_intern_atom_reply_t* protocolReply = xcb_intern_atom_reply(state.connection, protocolCookie, 0);
|
||||
xcb_intern_atom_cookie_t deleteCookie = xcb_intern_atom(state.connection, 0, 16, "WM_DELETE_WINDOW");
|
||||
state.deleteWindow = xcb_intern_atom_reply(state.connection, deleteCookie, 0);
|
||||
xcb_change_property(state.connection, XCB_PROP_MODE_REPLACE, window, protocolReply->atom, 4, 32, 1, &state.deleteWindow->atom);
|
||||
|
||||
xcb_flush(state.connection);
|
||||
xcb_intern_atom_cookie_t protocols = xcb_intern_atom(state.connection, 1, 12, "WM_PROTOCOLS");
|
||||
xcb_intern_atom_cookie_t delete = xcb_intern_atom(state.connection, 1, 16, "WM_DELETE_WINDOW");
|
||||
xcb_intern_atom_reply_t* protocolReply = xcb_intern_atom_reply(state.connection, protocols, 0);
|
||||
xcb_intern_atom_reply_t* deleteReply = xcb_intern_atom_reply(state.connection, delete, 0);
|
||||
xcb_change_property(state.connection, XCB_PROP_MODE_REPLACE, window, protocolReply->atom, 4, 32, 1, &deleteReply->atom);
|
||||
state.deleteWindow = deleteReply;
|
||||
free(protocolReply);
|
||||
|
||||
// TODO EGL
|
||||
|
||||
xcb_map_window(state.connection, window);
|
||||
xcb_flush(state.connection);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue