diff --git a/activation.cpp b/activation.cpp --- a/activation.cpp +++ b/activation.cpp @@ -35,7 +35,6 @@ #include "activities.h" #endif -#include #include #include #include @@ -634,7 +633,7 @@ } // Low or medium FSP, usertime comparism is possible - Time user_time = ac->userTime(); + const xcb_timestamp_t user_time = ac->userTime(); qCDebug(KWIN_CORE) << "Activation, compared:" << c << ":" << time << ":" << user_time << ":" << (NET::timestampCompare(time, user_time) >= 0); return NET::timestampCompare(time, user_time) >= 0; // time >= user_time @@ -844,7 +843,7 @@ workspace()->sendClientToDesktop(this, desktop, true); if (asn_data.xinerama() != -1) workspace()->sendClientToScreen(this, asn_data.xinerama()); - Time timestamp = asn_id.timestamp(); + const xcb_timestamp_t timestamp = asn_id.timestamp(); if (timestamp != 0) { bool activate = workspace()->allowClientActivation(this, timestamp); if (asn_data.desktop() != 0 && !isOnCurrentDesktop()) diff --git a/client.cpp b/client.cpp --- a/client.cpp +++ b/client.cpp @@ -53,9 +53,7 @@ #include #include #include -// XLib -#include -#include +// xcb #include // system #include @@ -246,7 +244,7 @@ // Grab X during the release to make removing of properties, setting to withdrawn state // and repareting to root an atomic operation (https://lists.kde.org/?l=kde-devel&m=116448102901184&w=2) grabXServer(); - exportMappingState(WithdrawnState); + exportMappingState(XCB_ICCCM_WM_STATE_WITHDRAWN); setModal(false); // Otherwise its mainwindow wouldn't get focus hidden = true; // So that it's not considered visible anymore (can't use hideClient(), it would set flags) if (!on_shutdown) @@ -853,7 +851,7 @@ m_wrapper.unmap(); m_client.unmap(); m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); - exportMappingState(IconicState); + exportMappingState(XCB_ICCCM_WM_STATE_ICONIC); plainResize(s); shade_geometry_change = false; if (was_shade_mode == ShadeHover) { @@ -892,7 +890,7 @@ } m_wrapper.map(); m_client.map(); - exportMappingState(NormalState); + exportMappingState(XCB_ICCCM_WM_STATE_NORMAL); if (isActive()) workspace()->requestFocus(this); } @@ -981,12 +979,12 @@ void Client::exportMappingState(int s) { Q_ASSERT(m_client != XCB_WINDOW_NONE); - Q_ASSERT(!deleting || s == WithdrawnState); - if (s == WithdrawnState) { + Q_ASSERT(!deleting || s == XCB_ICCCM_WM_STATE_WITHDRAWN); + if (s == XCB_ICCCM_WM_STATE_WITHDRAWN) { m_client.deleteProperty(atoms->wm_state); return; } - Q_ASSERT(s == NormalState || s == IconicState); + Q_ASSERT(s == XCB_ICCCM_WM_STATE_NORMAL || s == XCB_ICCCM_WM_STATE_ICONIC); int32_t data[2]; data[0] = s; @@ -1058,9 +1056,9 @@ m_wrapper.map(); m_client.map(); m_decoInputExtent.map(); - exportMappingState(NormalState); + exportMappingState(XCB_ICCCM_WM_STATE_NORMAL); } else - exportMappingState(IconicState); + exportMappingState(XCB_ICCCM_WM_STATE_ICONIC); addLayerRepaint(visibleRect()); } @@ -1081,7 +1079,7 @@ m_client.unmap(); m_decoInputExtent.unmap(); m_wrapper.selectInput(ClientWinMask | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); - exportMappingState(IconicState); + exportMappingState(XCB_ICCCM_WM_STATE_ICONIC); } /** diff --git a/geometry.cpp b/geometry.cpp --- a/geometry.cpp +++ b/geometry.cpp @@ -1603,47 +1603,47 @@ // dx, dy specify how the client window moves to make space for the frame switch(gravity) { - case NorthWestGravity: // move down right + case XCB_GRAVITY_NORTH_WEST: // move down right default: dx = borderLeft(); dy = borderTop(); break; - case NorthGravity: // move right + case XCB_GRAVITY_NORTH: // move right dx = 0; dy = borderTop(); break; - case NorthEastGravity: // move down left + case XCB_GRAVITY_NORTH_EAST: // move down left dx = -borderRight(); dy = borderTop(); break; - case WestGravity: // move right + case XCB_GRAVITY_WEST: // move right dx = borderLeft(); dy = 0; break; - case CenterGravity: + case XCB_GRAVITY_CENTER: break; // will be handled specially - case StaticGravity: // don't move + case XCB_GRAVITY_STATIC: // don't move dx = 0; dy = 0; break; - case EastGravity: // move left + case XCB_GRAVITY_EAST: // move left dx = -borderRight(); dy = 0; break; - case SouthWestGravity: // move up right + case XCB_GRAVITY_SOUTH_WEST: // move up right dx = borderLeft() ; dy = -borderBottom(); break; - case SouthGravity: // move up + case XCB_GRAVITY_SOUTH: // move up dx = 0; dy = -borderBottom(); break; - case SouthEastGravity: // move up left + case XCB_GRAVITY_SOUTH_EAST: // move up left dx = -borderRight(); dy = -borderBottom(); break; } - if (gravity != CenterGravity) { + if (gravity != XCB_GRAVITY_CENTER) { // translate from client movement to frame movement dx -= borderLeft(); dy -= borderTop(); @@ -1660,9 +1660,13 @@ void Client::configureRequest(int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool) { + const int configurePositionMask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y; + const int configureSizeMask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; + const int configureGeometryMask = configurePositionMask | configureSizeMask; + // "maximized" is a user setting -> we do not allow the client to resize itself // away from this & against the users explicit wish - qCDebug(KWIN_CORE) << this << bool(value_mask & (CWX|CWWidth|CWY|CWHeight)) << + qCDebug(KWIN_CORE) << this << bool(value_mask & configureGeometryMask) << bool(maximizeMode() & MaximizeVertical) << bool(maximizeMode() & MaximizeHorizontal); @@ -1684,10 +1688,10 @@ ignore = rules()->checkIgnoreGeometry(false); if (!ignore) { // the user is not interested, so we fix up dimensions if (maximizeMode() == MaximizeVertical) - value_mask &= ~(CWY|CWHeight); + value_mask &= ~(XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_HEIGHT); if (maximizeMode() == MaximizeHorizontal) - value_mask &= ~(CWX|CWWidth); - if (!(value_mask & (CWX|CWWidth|CWY|CWHeight))) { + value_mask &= ~(XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_WIDTH); + if (!(value_mask & configureGeometryMask)) { ignore = true; // the modification turned the request void } } @@ -1698,33 +1702,37 @@ return; // nothing to (left) to do for use - bugs #158974, #252314, #321491 } - qCDebug(KWIN_CORE) << "PERMITTED" << this << bool(value_mask & (CWX|CWWidth|CWY|CWHeight)); + qCDebug(KWIN_CORE) << "PERMITTED" << this << bool(value_mask & configureGeometryMask); if (gravity == 0) // default (nonsense) value for the argument gravity = m_geometryHints.windowGravity(); - if (value_mask & (CWX | CWY)) { + if (value_mask & configurePositionMask) { QPoint new_pos = calculateGravitation(true, gravity); // undo gravitation - if (value_mask & CWX) + if (value_mask & XCB_CONFIG_WINDOW_X) { new_pos.setX(rx); - if (value_mask & CWY) + } + if (value_mask & XCB_CONFIG_WINDOW_Y) { new_pos.setY(ry); + } // clever(?) workaround for applications like xv that want to set // the location to the current location but miscalculate the // frame size due to kwin being a double-reparenting window // manager if (new_pos.x() == x() + clientPos().x() && new_pos.y() == y() + clientPos().y() - && gravity == NorthWestGravity && !from_tool) { + && gravity == XCB_GRAVITY_NORTH_WEST && !from_tool) { new_pos.setX(x()); new_pos.setY(y()); } int nw = clientSize().width(); int nh = clientSize().height(); - if (value_mask & CWWidth) + if (value_mask & XCB_CONFIG_WINDOW_WIDTH) { nw = rw; - if (value_mask & CWHeight) + } + if (value_mask & XCB_CONFIG_WINDOW_HEIGHT) { nh = rh; + } QSize ns = sizeForClientSize(QSize(nw, nh)); // enforces size if needed new_pos = rules()->checkPosition(new_pos); int newScreen = screens()->number(QRect(new_pos, ns).center()); @@ -1749,14 +1757,15 @@ workspace() -> updateClientArea(); } - if (value_mask & (CWWidth | CWHeight) - && !(value_mask & (CWX | CWY))) { // pure resize + if (value_mask & configureSizeMask && !(value_mask & configurePositionMask)) { // pure resize int nw = clientSize().width(); int nh = clientSize().height(); - if (value_mask & CWWidth) + if (value_mask & XCB_CONFIG_WINDOW_WIDTH) { nw = rw; - if (value_mask & CWHeight) + } + if (value_mask & XCB_CONFIG_WINDOW_HEIGHT) { nh = rh; + } QSize ns = sizeForClientSize(QSize(nw, nh)); if (ns != size()) { // don't restore if some app sets its own size again @@ -1804,37 +1813,37 @@ gravity = m_geometryHints.windowGravity(); } switch(gravity) { - case NorthWestGravity: // top left corner doesn't move + case XCB_GRAVITY_NORTH_WEST: // top left corner doesn't move default: break; - case NorthGravity: // middle of top border doesn't move + case XCB_GRAVITY_NORTH: // middle of top border doesn't move newx = (newx + width() / 2) - (w / 2); break; - case NorthEastGravity: // top right corner doesn't move + case XCB_GRAVITY_NORTH_EAST: // top right corner doesn't move newx = newx + width() - w; break; - case WestGravity: // middle of left border doesn't move + case XCB_GRAVITY_WEST: // middle of left border doesn't move newy = (newy + height() / 2) - (h / 2); break; - case CenterGravity: // middle point doesn't move + case XCB_GRAVITY_CENTER: // middle point doesn't move newx = (newx + width() / 2) - (w / 2); newy = (newy + height() / 2) - (h / 2); break; - case StaticGravity: // top left corner of _client_ window doesn't move + case XCB_GRAVITY_STATIC: // top left corner of _client_ window doesn't move // since decoration doesn't change, equal to NorthWestGravity break; - case EastGravity: // // middle of right border doesn't move + case XCB_GRAVITY_EAST: // // middle of right border doesn't move newx = newx + width() - w; newy = (newy + height() / 2) - (h / 2); break; - case SouthWestGravity: // bottom left corner doesn't move + case XCB_GRAVITY_SOUTH_WEST: // bottom left corner doesn't move newy = newy + height() - h; break; - case SouthGravity: // middle of bottom border doesn't move + case XCB_GRAVITY_SOUTH: // middle of bottom border doesn't move newx = (newx + width() / 2) - (w / 2); newy = newy + height() - h; break; - case SouthEastGravity: // bottom right corner doesn't move + case XCB_GRAVITY_SOUTH_EAST: // bottom right corner doesn't move newx = newx + width() - w; newy = newy + height() - h; break; @@ -1847,14 +1856,18 @@ { int gravity = flags & 0xff; int value_mask = 0; - if (flags & (1 << 8)) - value_mask |= CWX; - if (flags & (1 << 9)) - value_mask |= CWY; - if (flags & (1 << 10)) - value_mask |= CWWidth; - if (flags & (1 << 11)) - value_mask |= CWHeight; + if (flags & (1 << 8)) { + value_mask |= XCB_CONFIG_WINDOW_X; + } + if (flags & (1 << 9)) { + value_mask |= XCB_CONFIG_WINDOW_Y; + } + if (flags & (1 << 10)) { + value_mask |= XCB_CONFIG_WINDOW_WIDTH; + } + if (flags & (1 << 11)) { + value_mask |= XCB_CONFIG_WINDOW_HEIGHT; + } configureRequest(value_mask, x, y, width, height, gravity, true); } diff --git a/group.h b/group.h --- a/group.h +++ b/group.h @@ -23,8 +23,6 @@ #define KWIN_GROUP_H #include "utils.h" -#include -#include #include namespace KWin @@ -36,9 +34,9 @@ class Group { public: - Group(Window leader); + Group(xcb_window_t leader); ~Group(); - Window leader() const; + xcb_window_t leader() const; const Client* leaderClient() const; Client* leaderClient(); const ClientList& members() const; @@ -56,14 +54,14 @@ void startupIdChanged(); ClientList _members; Client* leader_client; - Window leader_wid; + xcb_window_t leader_wid; NETWinInfo* leader_info; xcb_timestamp_t user_time; int refcount; EffectWindowGroupImpl* effect_group; }; -inline Window Group::leader() const +inline xcb_window_t Group::leader() const { return leader_wid; } diff --git a/group.cpp b/group.cpp --- a/group.cpp +++ b/group.cpp @@ -50,14 +50,14 @@ // Group //******************************************** -Group::Group(Window leader_P) +Group::Group(xcb_window_t leader_P) : leader_client(NULL), leader_wid(leader_P), leader_info(NULL), user_time(-1U), refcount(0) { - if (leader_P != None) { + if (leader_P != XCB_WINDOW_NONE) { leader_client = workspace()->findClient(Predicate::WindowMatch, leader_P); leader_info = new NETWinInfo(connection(), leader_P, rootWindow(), 0, NET::WM2StartupId); @@ -76,7 +76,7 @@ { if (leader_client != NULL) return leader_client->icon(); - else if (leader_wid != None) { + else if (leader_wid != XCB_WINDOW_NONE) { QIcon ic; NETWinInfo info(connection(), leader_wid, rootWindow(), NET::WMIcon, NET::WM2IconPixmap); auto readIcon = [&ic, &info, this](int size, bool scale = true) { @@ -153,7 +153,7 @@ Group* Workspace::findGroup(xcb_window_t leader) const { - Q_ASSERT(leader != None); + Q_ASSERT(leader != XCB_WINDOW_NONE); for (GroupList::ConstIterator it = groups.constBegin(); it != groups.constEnd(); ++it) @@ -809,7 +809,7 @@ // try creating group with other windows with the same client leader Group* new_group = workspace()->findClientLeaderGroup(this); if (new_group == NULL) - new_group = new Group(None); + new_group = new Group(XCB_WINDOW_NONE); if (new_group != in_group) { if (in_group != NULL) in_group->removeMember(this); @@ -826,7 +826,7 @@ in_group = NULL; } if (new_group == NULL) - new_group = new Group(None); + new_group = new Group(XCB_WINDOW_NONE); if (in_group != new_group) { in_group = new_group; in_group->addMember(this); diff --git a/netinfo.cpp b/netinfo.cpp --- a/netinfo.cpp +++ b/netinfo.cpp @@ -162,7 +162,7 @@ { Workspace *workspace = Workspace::self(); if (Client* c = workspace->findClient(Predicate::WindowMatch, w)) { - if (timestamp == CurrentTime) + if (timestamp == XCB_CURRENT_TIME) timestamp = c->userTime(); if (src != NET::FromApplication && src != FromTool) src = NET::FromTool; @@ -175,7 +175,7 @@ if (workspace->allowClientActivation(c, timestamp, false, true)) workspace->activateClient(c); // if activation of the requestor's window would be allowed, allow activation too - else if (active_window != None + else if (active_window != XCB_WINDOW_NONE && (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != NULL && workspace->allowClientActivation(c2, timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) { @@ -189,7 +189,7 @@ void RootInfo::restackWindow(xcb_window_t w, RequestSource src, xcb_window_t above, int detail, xcb_timestamp_t timestamp) { if (Client* c = Workspace::self()->findClient(Predicate::WindowMatch, w)) { - if (timestamp == CurrentTime) + if (timestamp == XCB_CURRENT_TIME) timestamp = c->userTime(); if (src != NET::FromApplication && src != FromTool) src = NET::FromTool; diff --git a/rules.cpp b/rules.cpp --- a/rules.cpp +++ b/rules.cpp @@ -20,7 +20,6 @@ #include "rules.h" -#include #include #include #include diff --git a/sm.cpp b/sm.cpp --- a/sm.cpp +++ b/sm.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "workspace.h" diff --git a/toplevel.h b/toplevel.h --- a/toplevel.h +++ b/toplevel.h @@ -35,9 +35,6 @@ // xcb #include #include -// XLib -#include -#include // c++ #include @@ -350,7 +347,7 @@ QByteArray wmClientMachine(bool use_localhost) const; const ClientMachine *clientMachine() const; virtual bool isLocalhost() const; - Window wmClientLeader() const; + xcb_window_t wmClientLeader() const; virtual pid_t pid() const; static bool resourceMatch(const Toplevel* c1, const Toplevel* c2); @@ -589,7 +586,7 @@ protected: ~Toplevel() override; void setWindowHandles(xcb_window_t client); - void detectShape(Window id); + void detectShape(xcb_window_t id); virtual void propertyNotifyEvent(xcb_property_notify_event_t *e); virtual void damageNotifyEvent(); virtual void clientMessageEvent(xcb_client_message_event_t *e); @@ -644,7 +641,7 @@ QByteArray resource_name; QByteArray resource_class; ClientMachine *m_clientMachine; - WId wmClientLeaderWin; + xcb_window_t m_wmClientLeader; bool m_damageReplyPending; QRegion opaque_region; xcb_xfixes_fetch_region_cookie_t m_regionCookie; diff --git a/toplevel.cpp b/toplevel.cpp --- a/toplevel.cpp +++ b/toplevel.cpp @@ -47,11 +47,11 @@ , m_isDamaged(false) , m_internalId(QUuid::createUuid()) , m_client() - , damage_handle(None) + , damage_handle(XCB_NONE) , is_shape(false) , effect_window(NULL) , m_clientMachine(new ClientMachine(this)) - , wmClientLeaderWin(0) + , m_wmClientLeader(XCB_WINDOW_NONE) , m_damageReplyPending(false) , m_screen(0) , m_skipCloseAnimation(false) @@ -64,7 +64,7 @@ Toplevel::~Toplevel() { - Q_ASSERT(damage_handle == None); + Q_ASSERT(damage_handle == XCB_NONE); delete info; } @@ -97,7 +97,7 @@ return rect(); } -void Toplevel::detectShape(Window id) +void Toplevel::detectShape(xcb_window_t id) { const bool wasShape = is_shape; is_shape = Xcb::Extensions::self()->hasShape(id); @@ -116,7 +116,7 @@ info = c->info; m_client.reset(c->m_client, false); ready_for_painting = c->ready_for_painting; - damage_handle = None; + damage_handle = XCB_NONE; damage_region = c->damage_region; repaints_region = c->repaints_region; layer_repaints_region = c->layer_repaints_region; @@ -128,7 +128,7 @@ resource_class = c->resourceClass(); m_clientMachine = c->m_clientMachine; m_clientMachine->setParent(this); - wmClientLeaderWin = c->wmClientLeader(); + m_wmClientLeader = c->wmClientLeader(); opaque_region = c->opaqueRegion(); m_screen = c->m_screen; m_skipCloseAnimation = c->m_skipCloseAnimation; @@ -158,7 +158,7 @@ void Toplevel::readWmClientLeader(Xcb::Property &prop) { - wmClientLeaderWin = prop.value(window()); + m_wmClientLeader = prop.value(window()); } void Toplevel::getWmClientLeader() @@ -174,8 +174,9 @@ QByteArray Toplevel::sessionId() const { QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id); - if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window()) - result = Xcb::StringProperty(wmClientLeaderWin, atoms->sm_client_id); + if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { + result = Xcb::StringProperty(m_wmClientLeader, atoms->sm_client_id); + } return result; } @@ -186,8 +187,9 @@ QByteArray Toplevel::wmCommand() { QByteArray result = Xcb::StringProperty(window(), XCB_ATOM_WM_COMMAND); - if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window()) - result = Xcb::StringProperty(wmClientLeaderWin, XCB_ATOM_WM_COMMAND); + if (result.isEmpty() && m_wmClientLeader && m_wmClientLeader != window()) { + result = Xcb::StringProperty(m_wmClientLeader, XCB_ATOM_WM_COMMAND); + } result.replace(0, ' '); return result; } @@ -218,10 +220,11 @@ * Returns client leader window for this client. * Returns the client window itself if no leader window is defined. */ -Window Toplevel::wmClientLeader() const +xcb_window_t Toplevel::wmClientLeader() const { - if (wmClientLeaderWin) - return wmClientLeaderWin; + if (m_wmClientLeader != XCB_WINDOW_NONE) { + return m_wmClientLeader; + } return window(); } diff --git a/unmanaged.h b/unmanaged.h --- a/unmanaged.h +++ b/unmanaged.h @@ -35,7 +35,7 @@ public: explicit Unmanaged(); bool windowEvent(xcb_generic_event_t *e); - bool track(Window w); + bool track(xcb_window_t w); static void deleteUnmanaged(Unmanaged* c); int desktop() const override; QStringList activities() const override; diff --git a/unmanaged.cpp b/unmanaged.cpp --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -47,7 +47,7 @@ { } -bool Unmanaged::track(Window w) +bool Unmanaged::track(xcb_window_t w) { GRAB_SERVER_DURING_CONTEXT Xcb::WindowAttributes attr(w); diff --git a/utils.cpp b/utils.cpp --- a/utils.cpp +++ b/utils.cpp @@ -34,8 +34,6 @@ #include #include -#include - #include "atoms.h" #include "platform.h" #include "workspace.h"