18 #include <xcb/xcb_event.h>
20 #include <X11/keysym.h>
28 "To debug this problem, either attach gdb now",
30 "- 'e' to exit and get a core-dump,",
31 "- 'r' to restart i3 in-place or",
32 "- 'f' to forget the current layout and restart"
42 xcb_rectangle_t border = { 0, 0,
width, height},
43 inner = { 2, 2, width - 4, height - 4};
52 for (
int i = 0; i <
sizeof(
crash_text) /
sizeof(
char*); i++) {
54 8, 5 + i * font_height, width - 16);
69 uint16_t
state =
event->state;
76 xcb_keysym_t sym = xcb_key_press_lookup_keysym(
keysyms, event, state);
79 DLOG(
"User issued exit-command, raising error again.\n");
98 xcb_window_t win = xcb_generate_id(conn);
103 mask |= XCB_CW_BACK_PIXEL;
106 mask |= XCB_CW_OVERRIDE_REDIRECT;
110 uint32_t
x = screen_rect.
x + ((screen_rect.
width / 2) - (width / 2)),
111 y = screen_rect.
y + ((screen_rect.
height / 2) - (height / 2));
113 xcb_create_window(conn,
114 XCB_COPY_FROM_PARENT,
119 XCB_WINDOW_CLASS_INPUT_OUTPUT,
120 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
125 xcb_map_window(conn, win);
137 DLOG(
"i3 crashed. SIG: %d\n", sig);
139 struct sigaction action;
140 action.sa_handler = SIG_DFL;
141 sigaction(sig, &action, NULL);
145 int crash_text_num =
sizeof(
crash_text) /
sizeof(
char*);
152 int width = font_width + 20;
169 xcb_grab_keyboard(
conn,
false, win, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
172 xcb_grab_pointer(
conn,
false, win, XCB_NONE, XCB_GRAB_MODE_ASYNC,
173 XCB_GRAB_MODE_ASYNC, win, XCB_NONE, XCB_CURRENT_TIME);
179 xcb_generic_event_t *event;
181 while ((event = xcb_wait_for_event(
conn))) {
183 int type = (
event->response_type & 0x7F);
184 if (type == XCB_KEY_PRESS) {
196 struct sigaction action;
199 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
200 sigemptyset(&action.sa_mask);
203 if (sigaction(SIGQUIT, &action, NULL) == -1 ||
204 sigaction(SIGILL, &action, NULL) == -1 ||
205 sigaction(SIGABRT, &action, NULL) == -1 ||
206 sigaction(SIGFPE, &action, NULL) == -1 ||
207 sigaction(SIGSEGV, &action, NULL) == -1)
208 ELOG(
"Could not setup signal handler");