kwin: Port most of Workspace::init() to xcb
parent
36f05628f8
commit
c679ec6508
|
@ -803,12 +803,15 @@ void Workspace::unclutterDesktop()
|
||||||
// When kwin crashes, windows will not be gravitated back to their original position
|
// When kwin crashes, windows will not be gravitated back to their original position
|
||||||
// and will remain offset by the size of the decoration. So when restarting, fix this
|
// and will remain offset by the size of the decoration. So when restarting, fix this
|
||||||
// (the property with the size of the frame remains on the window after the crash).
|
// (the property with the size of the frame remains on the window after the crash).
|
||||||
void Workspace::fixPositionAfterCrash(Window w, const XWindowAttributes& attr)
|
void Workspace::fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geometry)
|
||||||
{
|
{
|
||||||
NETWinInfo i(display(), w, rootWindow(), NET::WMFrameExtents);
|
NETWinInfo i(display(), w, rootWindow(), NET::WMFrameExtents);
|
||||||
NETStrut frame = i.frameExtents();
|
NETStrut frame = i.frameExtents();
|
||||||
if (frame.left != 0 || frame.top != 0)
|
|
||||||
XMoveWindow(display(), w, attr.x - frame.left, attr.y - frame.top);
|
if (frame.left != 0 || frame.top != 0) {
|
||||||
|
const uint32_t values[] = { geometry->x - frame.left, geometry->y - frame.top };
|
||||||
|
xcb_configure_window(connection(), w, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//********************************************
|
//********************************************
|
||||||
|
|
|
@ -397,26 +397,50 @@ void Workspace::init()
|
||||||
// Begin updates blocker block
|
// Begin updates blocker block
|
||||||
StackingUpdatesBlocker blocker(this);
|
StackingUpdatesBlocker blocker(this);
|
||||||
|
|
||||||
unsigned int i, nwins;
|
|
||||||
Window root_return, parent_return;
|
|
||||||
Window* wins;
|
|
||||||
XQueryTree(display(), rootWindow(), &root_return, &parent_return, &wins, &nwins);
|
|
||||||
bool fixoffset = KCmdLineArgs::parsedArgs()->getOption("crashes").toInt() > 0;
|
bool fixoffset = KCmdLineArgs::parsedArgs()->getOption("crashes").toInt() > 0;
|
||||||
for (i = 0; i < nwins; i++) {
|
xcb_connection_t *conn = connection();
|
||||||
XWindowAttributes attr;
|
|
||||||
XGetWindowAttributes(display(), wins[i], &attr);
|
xcb_query_tree_reply_t *tree = xcb_query_tree_reply(conn,
|
||||||
if (attr.override_redirect) {
|
xcb_query_tree_unchecked(conn, rootWindow()), 0);
|
||||||
createUnmanaged(wins[i]);
|
xcb_window_t *wins = xcb_query_tree_children(tree);
|
||||||
|
|
||||||
|
QVector<xcb_get_window_attributes_cookie_t> attr_cookies;
|
||||||
|
QVector<xcb_get_geometry_cookie_t> geom_cookies;
|
||||||
|
|
||||||
|
attr_cookies.reserve(tree->children_len);
|
||||||
|
geom_cookies.reserve(tree->children_len);
|
||||||
|
|
||||||
|
// Request the attributes and geometries of all toplevel windows
|
||||||
|
for (int i = 0; i < tree->children_len; i++) {
|
||||||
|
attr_cookies << xcb_get_window_attributes(conn, wins[i]);
|
||||||
|
geom_cookies << xcb_get_geometry(conn, wins[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the replies
|
||||||
|
for (int i = 0; i < tree->children_len; i++) {
|
||||||
|
ScopedCPointer<xcb_get_window_attributes_reply_t> attr
|
||||||
|
= xcb_get_window_attributes_reply(conn, attr_cookies[i], 0);
|
||||||
|
ScopedCPointer<xcb_get_geometry_reply_t> geometry
|
||||||
|
= xcb_get_geometry_reply(conn, geom_cookies[i], 0);
|
||||||
|
|
||||||
|
if (!attr || !geometry)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (attr.map_state != IsUnmapped) {
|
if (attr->override_redirect) {
|
||||||
|
if (attr->map_state == XCB_MAP_STATE_VIEWABLE &&
|
||||||
|
attr->_class != XCB_WINDOW_CLASS_INPUT_ONLY)
|
||||||
|
// ### This will request the attributes again
|
||||||
|
createUnmanaged(wins[i]);
|
||||||
|
} else if (attr->map_state != XCB_MAP_STATE_UNMAPPED) {
|
||||||
if (fixoffset)
|
if (fixoffset)
|
||||||
fixPositionAfterCrash(wins[ i ], attr);
|
fixPositionAfterCrash(wins[i], geometry);
|
||||||
|
|
||||||
|
// ### This will request the attributes again
|
||||||
createClient(wins[i], true);
|
createClient(wins[i], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wins)
|
|
||||||
XFree((void*)(wins));
|
free(tree);
|
||||||
|
|
||||||
// Propagate clients, will really happen at the end of the updates blocker block
|
// Propagate clients, will really happen at the end of the updates blocker block
|
||||||
updateStackingOrder(true);
|
updateStackingOrder(true);
|
||||||
|
|
|
@ -694,7 +694,7 @@ private:
|
||||||
bool keepTransientAbove(const Client* mainwindow, const Client* transient);
|
bool keepTransientAbove(const Client* mainwindow, const Client* transient);
|
||||||
void blockStackingUpdates(bool block);
|
void blockStackingUpdates(bool block);
|
||||||
void updateToolWindows(bool also_hide);
|
void updateToolWindows(bool also_hide);
|
||||||
void fixPositionAfterCrash(Window w, const XWindowAttributes& attr);
|
void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom);
|
||||||
void saveOldScreenSizes();
|
void saveOldScreenSizes();
|
||||||
|
|
||||||
/// This is the right way to create a new client
|
/// This is the right way to create a new client
|
||||||
|
|
Loading…
Reference in New Issue