Port Client::manage away from XGetWindowAttributes

Replaced by Xcb::WindowAttributes and Xcb::WindowGeometry. Also arguments
of Client::embedClient are adjusted to take the required values directly.
This commit is contained in:
Martin Gräßlin 2014-04-25 13:42:52 +02:00
parent 0ac4e4e419
commit 75f80e88ed
2 changed files with 13 additions and 13 deletions

View file

@ -826,7 +826,7 @@ private:
static void sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol, static void sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol,
long data1 = 0, long data2 = 0, long data3 = 0); long data1 = 0, long data2 = 0, long data3 = 0);
void embedClient(xcb_window_t w, const XWindowAttributes& attr); void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth);
void detectNoBorder(); void detectNoBorder();
void destroyDecoration(); void destroyDecoration();
void updateFrameExtents(); void updateFrameExtents();

View file

@ -54,8 +54,9 @@ bool Client::manage(xcb_window_t w, bool isMapped)
grabXServer(); grabXServer();
XWindowAttributes attr; Xcb::WindowAttributes attr(w);
if (!XGetWindowAttributes(display(), w, &attr)) { Xcb::WindowGeometry windowGeometry(w);
if (attr.isNull() || windowGeometry.isNull()) {
ungrabXServer(); ungrabXServer();
return false; return false;
} }
@ -64,10 +65,10 @@ bool Client::manage(xcb_window_t w, bool isMapped)
block_geometry_updates = 1; block_geometry_updates = 1;
pending_geometry_update = PendingGeometryForced; // Force update when finishing with geometry changes pending_geometry_update = PendingGeometryForced; // Force update when finishing with geometry changes
embedClient(w, attr); embedClient(w, attr->visual, attr->colormap, windowGeometry->depth);
m_visual = attr.visual->visualid; m_visual = attr->visual;
bit_depth = attr.depth; bit_depth = windowGeometry->depth;
// SELI TODO: Order all these things in some sane manner // SELI TODO: Order all these things in some sane manner
@ -103,7 +104,7 @@ bool Client::manage(xcb_window_t w, bool isMapped)
info = new WinInfo(this, m_client, rootWindow(), properties, properties2); info = new WinInfo(this, m_client, rootWindow(), properties, properties2);
m_colormap = attr.colormap; m_colormap = attr->colormap;
getResourceClass(); getResourceClass();
getWmClientLeader(); getWmClientLeader();
@ -230,7 +231,7 @@ bool Client::manage(xcb_window_t w, bool isMapped)
if (!activitiesList.isEmpty()) if (!activitiesList.isEmpty())
setOnActivities(activitiesList.split(QStringLiteral(","))); setOnActivities(activitiesList.split(QStringLiteral(",")));
QRect geom(attr.x, attr.y, attr.width, attr.height); QRect geom(windowGeometry.rect());
bool placementDone = false; bool placementDone = false;
if (session) if (session)
@ -631,14 +632,13 @@ bool Client::manage(xcb_window_t w, bool isMapped)
} }
// Called only from manage() // Called only from manage()
void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr) void Client::embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth)
{ {
assert(m_client == XCB_WINDOW_NONE); assert(m_client == XCB_WINDOW_NONE);
assert(frameId() == XCB_WINDOW_NONE); assert(frameId() == XCB_WINDOW_NONE);
assert(m_wrapper == XCB_WINDOW_NONE); assert(m_wrapper == XCB_WINDOW_NONE);
m_client.reset(w, false); m_client.reset(w, false);
const xcb_visualid_t visualid = XVisualIDFromVisual(attr.visual);
const uint32_t zero_value = 0; const uint32_t zero_value = 0;
xcb_connection_t *conn = connection(); xcb_connection_t *conn = connection();
@ -654,7 +654,7 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr)
const uint32_t cw_values[] = { const uint32_t cw_values[] = {
0, // back_pixmap 0, // back_pixmap
0, // border_pixel 0, // border_pixel
static_cast<uint32_t>(attr.colormap), // colormap colormap, // colormap
Cursor::x11Cursor(Qt::ArrowCursor) Cursor::x11Cursor(Qt::ArrowCursor)
}; };
@ -680,7 +680,7 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr)
// Create the frame window // Create the frame window
xcb_window_t frame = xcb_generate_id(conn); xcb_window_t frame = xcb_generate_id(conn);
xcb_create_window(conn, attr.depth, frame, rootWindow(), 0, 0, 1, 1, 0, xcb_create_window(conn, depth, frame, rootWindow(), 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values);
m_frame.reset(frame); m_frame.reset(frame);
@ -688,7 +688,7 @@ void Client::embedClient(xcb_window_t w, const XWindowAttributes& attr)
// Create the wrapper window // Create the wrapper window
xcb_window_t wrapperId = xcb_generate_id(conn); xcb_window_t wrapperId = xcb_generate_id(conn);
xcb_create_window(conn, attr.depth, wrapperId, frame, 0, 0, 1, 1, 0, xcb_create_window(conn, depth, wrapperId, frame, 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values);
m_wrapper.reset(wrapperId); m_wrapper.reset(wrapperId);