+ dialog_width = width_longest_message + 2 * border_width + 2 * margin;
+ dialog_height = num_lines * config.font.height + 2 * border_width + 2 * margin;
+}
+
+static void sighandler_create_dialogs(void) {
+ Output *output;
+ TAILQ_FOREACH(output, &outputs, outputs) {
+ if (!output->active) {
+ continue;
+ }
+
+ dialog_t *dialog = scalloc(1, sizeof(struct dialog_t));
+ TAILQ_INSERT_TAIL(&dialogs, dialog, dialogs);
+
+ xcb_visualid_t visual = get_visualid_by_depth(root_depth);
+ dialog->colormap = xcb_generate_id(conn);
+ xcb_create_colormap(conn, XCB_COLORMAP_ALLOC_NONE, dialog->colormap, root, visual);
+
+ uint32_t mask = 0;
+ uint32_t values[4];
+ int i = 0;
+
+ /* Needs to be set in the case of a 32-bit root depth. */
+ mask |= XCB_CW_BACK_PIXEL;
+ values[i++] = root_screen->black_pixel;
+
+ /* Needs to be set in the case of a 32-bit root depth. */
+ mask |= XCB_CW_BORDER_PIXEL;
+ values[i++] = root_screen->black_pixel;
+
+ mask |= XCB_CW_OVERRIDE_REDIRECT;
+ values[i++] = 1;
+
+ /* Needs to be set in the case of a 32-bit root depth. */
+ mask |= XCB_CW_COLORMAP;
+ values[i++] = dialog->colormap;
+
+ dialog->dims.x = output->rect.x + (output->rect.width / 2);
+ dialog->dims.y = output->rect.y + (output->rect.height / 2);
+ dialog->dims.width = dialog_width;
+ dialog->dims.height = dialog_height;
+
+ /* Make sure the dialog is centered. */
+ dialog->dims.x -= dialog->dims.width / 2;
+ dialog->dims.y -= dialog->dims.height / 2;
+
+ dialog->id = create_window(conn, dialog->dims, root_depth, visual,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, XCURSOR_CURSOR_POINTER,
+ true, mask, values);
+
+ draw_util_surface_init(conn, &(dialog->surface), dialog->id, get_visualtype_by_id(visual),
+ dialog->dims.width, dialog->dims.height);
+
+ xcb_grab_keyboard(conn, false, dialog->id, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
+
+ /* Confine the pointer to the crash dialog. */
+ xcb_grab_pointer(conn, false, dialog->id, XCB_NONE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, dialog->id,
+ XCB_NONE, XCB_CURRENT_TIME);