Fix some bugs found by using raster’s wm_torture

next
Michael Stapelberg 2009-03-07 02:44:46 +01:00
parent 7f17edb4c1
commit 6abcc5f656
2 changed files with 23 additions and 8 deletions

View File

@ -475,6 +475,10 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti
int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
LOG("window's name changed.\n");
if (prop == NULL) {
LOG("prop == NULL\n");
return 1;
}
Client *client = table_get(byChild, window);
if (client == NULL)
return 1;

View File

@ -143,7 +143,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
/* Update the data structures */
Client *old_focused = CUR_CELL->currently_focused;
CUR_CELL->currently_focused = new;
new->container = CUR_CELL;
new->frame = xcb_generate_id(conn);
@ -184,14 +184,15 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
new->titlegc = xcb_generate_id(conn);
xcb_create_gc(conn, new->titlegc, new->frame, 0, 0);
/* Put our data structure (Client) into the table */
table_put(byParent, new->frame, new);
table_put(byChild, child, new);
/* Moves the original window into the new frame we've created for it */
new->awaiting_useless_unmap = true;
xcb_void_cookie_t cookie = xcb_reparent_window_checked(conn, child, new->frame, 0, font->height);
check_error(conn, cookie, "Could not reparent window");
if (xcb_request_check(conn, cookie) != NULL) {
LOG("Could not reparent the window, aborting\n");
xcb_destroy_window(conn, new->frame);
free(new);
return;
}
/* We are interested in property changes */
mask = XCB_CW_EVENT_MASK;
@ -199,7 +200,18 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_ENTER_WINDOW;
cookie = xcb_change_window_attributes_checked(conn, child, mask, values);
check_error(conn, cookie, "Could not change window attributes");
if (xcb_request_check(conn, cookie) != NULL) {
LOG("Could not change window attributes, aborting\n");
xcb_destroy_window(conn, new->frame);
free(new);
return;
}
CUR_CELL->currently_focused = new;
/* Put our data structure (Client) into the table */
table_put(byParent, new->frame, new);
table_put(byChild, child, new);
/* We need to grab the mouse buttons for click to focus */
xcb_grab_button(conn, false, child, XCB_EVENT_MASK_BUTTON_PRESS,
@ -441,7 +453,6 @@ int main(int argc, char *argv[], char *env[]) {
/* Set up the atoms we support */
check_error(conn, xcb_change_property_checked(conn, XCB_PROP_MODE_REPLACE, root, atoms[_NET_SUPPORTED],
ATOM, 32, 7, atoms), "Could not set _NET_SUPPORTED");
/* Set up the window managers name */
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, atoms[_NET_SUPPORTING_WM_CHECK], WINDOW, 32, 1, &root);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, atoms[_NET_WM_NAME], atoms[UTF8_STRING], 8, strlen("i3"), "i3");