/** Update the size hints of a client. * \param c The client. * \param cookie Cookie returned by property_get_wm_normal_hints. */ void property_update_wm_normal_hints(client_t *c, xcb_get_property_cookie_t cookie) { xcb_icccm_get_wm_normal_hints_reply(globalconf.connection, cookie, &c->size_hints, NULL); }
void set_window_size_hints(xcwm_window_t *window, xcwm_property_t *property) { xcb_get_property_cookie_t cookie; cookie = xcb_icccm_get_wm_normal_hints(window->context->conn, window->window_id); if (!xcb_icccm_get_wm_normal_hints_reply(window->context->conn, cookie, &(window->size_hints), NULL)) { /* Use 0 for all values (as set in calloc), or previous values */ return; } }
//! Process WM_NORMAL_HINTS reply and update size hints fields void Client::process_wm_normal_hints(xcb_get_property_cookie_t gpc) { if (xcb_icccm_get_wm_normal_hints_reply(g_xcb.connection, gpc, &m_wm_size_hints.m_data, NULL)) { INFO << "ICCCM: " << m_wm_size_hints.m_data; } else { WARN << "ICCCM WM_NORMAL_HINTS / WM_SIZE_HINTS could not be retrieved."; m_wm_size_hints.m_data.flags = 0; } }
void client_update_size_hints(Client *c) { xcb_size_hints_t hints; if(xcb_icccm_get_wm_normal_hints_reply(conn, xcb_icccm_get_wm_normal_hints(conn, c->win), &hints, NULL)) /* size is uninitialized, ensure that size.flags aren't used */ hints.flags = XCB_ICCCM_SIZE_HINT_P_SIZE; if(hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) { c->basew = hints.base_width; c->baseh = hints.base_height; } else if(hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) { c->basew = hints.min_width; c->baseh = hints.min_height; } else c->basew = c->baseh = 0; if(hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC) { c->incw = hints.width_inc; c->inch = hints.height_inc; } else c->incw = c->inch = 0; if(hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) { c->maxw = hints.max_width; c->maxh = hints.max_height; } else c->maxw = c->maxh = 0; if(hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) { c->minw = hints.min_width; c->minh = hints.min_height; } else if(hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) { c->minw = hints.base_width; c->minh = hints.base_height; } else c->minw = c->minh = 0; if(hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT) { c->mina = (float)hints.min_aspect_den / hints.min_aspect_num; c->maxa = (float)hints.max_aspect_num / hints.max_aspect_den; } else c->maxa = c->mina = 0.0; c->isfixed = (c->maxw && c->minw && c->maxh && c->minh && c->maxw == c->minw && c->maxh == c->minh); }
/** Update the size hints of a client. * \param c The client. * \param reply (Optional) An existing reply. */ void property_update_wm_normal_hints(client_t *c, xcb_get_property_reply_t *reply) { if(reply) { if(!xcb_icccm_get_wm_size_hints_from_reply(&c->size_hints, reply)) return; } else { if(!xcb_icccm_get_wm_normal_hints_reply(globalconf.connection, xcb_icccm_get_wm_normal_hints_unchecked(globalconf.connection, c->window), &c->size_hints, NULL)) return; } }
void Client::updateNormalHints(xcb_connection_t* conn, xcb_get_property_cookie_t cookie) { if (xcb_icccm_get_wm_normal_hints_reply(conn, cookie, &mNormalHints, 0)) { // overwrite the response from xcb_get_geometry_unchecked enum { SIZE = (XCB_ICCCM_SIZE_HINT_US_SIZE|XCB_ICCCM_SIZE_HINT_P_SIZE) }; if ((mNormalHints.flags & SIZE) == SIZE) { mRect.width = mNormalHints.width; mRect.height = mNormalHints.height; } enum { POS = (XCB_ICCCM_SIZE_HINT_P_POSITION|XCB_ICCCM_SIZE_HINT_US_POSITION) }; if ((mNormalHints.flags & POS) == POS) { mRect.x = mNormalHints.x; mRect.y = mNormalHints.y; } } else { memset(&mNormalHints, '\0', sizeof(mNormalHints)); } }
void property_notify(xcb_generic_event_t *evt) { xcb_property_notify_event_t *e = (xcb_property_notify_event_t *) evt; /* PRINTF("property notify %X\n", e->window); */ if (e->atom != XCB_ATOM_WM_HINTS && e->atom != XCB_ATOM_WM_NORMAL_HINTS) return; coordinates_t loc; if (!locate_window(e->window, &loc)) return; if (e->atom == XCB_ATOM_WM_HINTS) { xcb_icccm_wm_hints_t hints; if (xcb_icccm_get_wm_hints_reply(dpy, xcb_icccm_get_wm_hints(dpy, e->window), &hints, NULL) == 1 && (hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY)) set_urgency(loc.monitor, loc.desktop, loc.node, xcb_icccm_wm_hints_get_urgency(&hints)); } else if (e->atom == XCB_ATOM_WM_NORMAL_HINTS) { client_t *c = loc.node->client; xcb_size_hints_t size_hints; if (xcb_icccm_get_wm_normal_hints_reply(dpy, xcb_icccm_get_wm_normal_hints(dpy, e->window), &size_hints, NULL) == 1 && (size_hints.flags & (XCB_ICCCM_SIZE_HINT_P_MIN_SIZE | XCB_ICCCM_SIZE_HINT_P_MAX_SIZE))) { c->min_width = size_hints.min_width; c->max_width = size_hints.max_width; c->min_height = size_hints.min_height; c->max_height = size_hints.max_height; int w = c->floating_rectangle.width; int h = c->floating_rectangle.height; restrain_floating_size(c, &w, &h); c->floating_rectangle.width = w; c->floating_rectangle.height = h; arrange(loc.monitor, loc.desktop); } } }