diff --git a/src/composite.cpp b/src/composite.cpp index 2f375a15f1..3a77e12b61 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -94,7 +94,7 @@ class CompositorSelectionOwner : public KSelectionOwner Q_OBJECT public: CompositorSelectionOwner(const char *selection) - : KSelectionOwner(selection, kwinApp()->x11Connection(), rootWindow()) + : KSelectionOwner(selection, kwinApp()->x11Connection(), kwinApp()->x11RootWindow()) , m_owning(false) { connect (this, &CompositorSelectionOwner::lostOwnership, diff --git a/src/effects.h b/src/effects.h index effacfef20..bb18a6e545 100644 --- a/src/effects.h +++ b/src/effects.h @@ -632,7 +632,7 @@ QList EffectsHandlerImpl::elevatedWindows() const inline xcb_window_t EffectsHandlerImpl::x11RootWindow() const { - return rootWindow(); + return kwinApp()->x11RootWindow(); } inline diff --git a/src/events.cpp b/src/events.cpp index 2d57f9c86c..e4ed633bb2 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -156,7 +156,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) // events that should be handled before Clients can get them switch (eventType) { case XCB_CONFIGURE_NOTIFY: - if (reinterpret_cast(e)->event == rootWindow()) + if (reinterpret_cast(e)->event == kwinApp()->x11RootWindow()) markXStackingOrderAsDirty(); break; }; @@ -184,7 +184,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) switch (eventType) { case XCB_CREATE_NOTIFY: { const auto *event = reinterpret_cast(e); - if (event->parent == rootWindow() && + if (event->parent == kwinApp()->x11RootWindow() && !QWidget::find(event->window) && !event->override_redirect) { // see comments for allowClientActivation() @@ -251,7 +251,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) case XCB_CONFIGURE_REQUEST: { const auto *event = reinterpret_cast(e); - if (event->parent == rootWindow()) { + if (event->parent == kwinApp()->x11RootWindow()) { uint32_t values[5] = { 0, 0, 0, 0, 0}; const uint32_t value_mask = event->value_mask & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH); @@ -278,13 +278,13 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) } case XCB_FOCUS_IN: { const auto *event = reinterpret_cast(e); - if (event->event == rootWindow() + if (event->event == kwinApp()->x11RootWindow() && (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) { Xcb::CurrentInput currentInput; updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp) // it seems we can "loose" focus reversions when the closing client hold a grab // => catch the typical pattern (though we don't want the focus on the root anyway) #348935 - const bool lostFocusPointerToRoot = currentInput->focus == rootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR; + const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR; if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) { //kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ; AbstractClient *c = mostRecentlyActivatedClient(); @@ -357,7 +357,7 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) setOpacity(info->opacityF()); } else { // forward to the frame if there's possibly another compositing manager running - NETWinInfo i(kwinApp()->x11Connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2()); + NETWinInfo i(kwinApp()->x11Connection(), frameId(), kwinApp()->x11RootWindow(), NET::Properties(), NET::Properties2()); i.setOpacity(info->opacity()); } } @@ -535,7 +535,7 @@ void X11Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e) if (e->event != wrapperId()) { // most probably event from root window when initially reparenting bool ignore = true; - if (e->event == rootWindow() && (e->response_type & 0x80)) + if (e->event == kwinApp()->x11RootWindow() && (e->response_type & 0x80)) ignore = false; // XWithdrawWindow() if (ignore) return; diff --git a/src/group.cpp b/src/group.cpp index 2ba52f3e21..843259f7ac 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -34,7 +34,7 @@ Group::Group(xcb_window_t leader_P) { if (leader_P != XCB_WINDOW_NONE) { leader_client = workspace()->findClient(Predicate::WindowMatch, leader_P); - leader_info = new NETWinInfo(kwinApp()->x11Connection(), leader_P, rootWindow(), + leader_info = new NETWinInfo(kwinApp()->x11Connection(), leader_P, kwinApp()->x11RootWindow(), NET::Properties(), NET::WM2StartupId); } effect_group = new EffectWindowGroupImpl(this); @@ -53,7 +53,7 @@ QIcon Group::icon() const return leader_client->icon(); else if (leader_wid != XCB_WINDOW_NONE) { QIcon ic; - NETWinInfo info(kwinApp()->x11Connection(), leader_wid, rootWindow(), NET::WMIcon, NET::WM2IconPixmap); + NETWinInfo info(kwinApp()->x11Connection(), leader_wid, kwinApp()->x11RootWindow(), NET::WMIcon, NET::WM2IconPixmap); auto readIcon = [&ic, &info, this](int size, bool scale = true) { const QPixmap pix = KWindowSystem::icon(leader_wid, size, size, scale, KWindowSystem::NETWM | KWindowSystem::WMHints, &info); if (!pix.isNull()) { diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 8c6a1a8eb8..d6084debcf 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -192,7 +192,7 @@ void ApplicationX11::lostSelection() destroyCompositor(); destroyWorkspace(); // Remove windowmanager privileges - Xcb::selectInput(rootWindow(), XCB_EVENT_MASK_PROPERTY_CHANGE); + Xcb::selectInput(kwinApp()->x11RootWindow(), XCB_EVENT_MASK_PROPERTY_CHANGE); removeNativeX11EventFilter(); quit(); } @@ -240,7 +240,7 @@ void ApplicationX11::performStartup() const uint32_t maskValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT}; ScopedCPointer redirectCheck(xcb_request_check(kwinApp()->x11Connection(), xcb_change_window_attributes_checked(kwinApp()->x11Connection(), - rootWindow(), + kwinApp()->x11RootWindow(), XCB_CW_EVENT_MASK, maskValues))); if (!redirectCheck.isNull()) { diff --git a/src/netinfo.cpp b/src/netinfo.cpp index 75892f8c5c..5b1a85d7b7 100644 --- a/src/netinfo.cpp +++ b/src/netinfo.cpp @@ -29,7 +29,7 @@ RootInfo *RootInfo::create() Q_ASSERT(!s_self); xcb_window_t supportWindow = xcb_generate_id(kwinApp()->x11Connection()); const uint32_t values[] = {true}; - xcb_create_window(kwinApp()->x11Connection(), XCB_COPY_FROM_PARENT, supportWindow, KWin::rootWindow(), + xcb_create_window(kwinApp()->x11Connection(), XCB_COPY_FROM_PARENT, supportWindow, kwinApp()->x11RootWindow(), 0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT, XCB_CW_OVERRIDE_REDIRECT, values); const uint32_t lowerValues[] = { XCB_STACK_MODE_BELOW }; // See usage in layers.cpp diff --git a/src/unmanaged.cpp b/src/unmanaged.cpp index 689e2e98e9..3c02ccf012 100644 --- a/src/unmanaged.cpp +++ b/src/unmanaged.cpp @@ -104,7 +104,7 @@ bool Unmanaged::track(xcb_window_t w) checkOutput(); m_visual = attr->visual; bit_depth = geo->depth; - info = new NETWinInfo(kwinApp()->x11Connection(), w, rootWindow(), + info = new NETWinInfo(kwinApp()->x11Connection(), w, kwinApp()->x11RootWindow(), NET::WMWindowType | NET::WMPid, NET::WM2Opacity | NET::WM2WindowRole | diff --git a/src/workspace.cpp b/src/workspace.cpp index a8b0a8604b..adc618c8e5 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -312,7 +312,10 @@ void Workspace::initializeX11() // Compatibility int32_t data = 1; - xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_APPEND, rootWindow(), atoms->kwin_running, + xcb_change_property(kwinApp()->x11Connection(), + XCB_PROP_MODE_APPEND, + kwinApp()->x11RootWindow(), + atoms->kwin_running, atoms->kwin_running, 32, 1, &data); if (kwinApp()->operationMode() == Application::OperationModeX11) { @@ -352,7 +355,7 @@ void Workspace::initializeX11() // Begin updates blocker block StackingUpdatesBlocker blocker(this); - Xcb::Tree tree(rootWindow()); + Xcb::Tree tree(kwinApp()->x11RootWindow()); xcb_window_t *wins = xcb_query_tree_children(tree.data()); QVector windowAttributes(tree->children_len); @@ -1241,12 +1244,12 @@ void Workspace::slotDesktopRemoved(VirtualDesktop *desktop) void Workspace::selectWmInputEventMask() { uint32_t presentMask = 0; - Xcb::WindowAttributes attr(rootWindow()); + Xcb::WindowAttributes attr(kwinApp()->x11RootWindow()); if (!attr.isNull()) { presentMask = attr->your_event_mask; } - Xcb::selectInput(rootWindow(), + Xcb::selectInput(kwinApp()->x11RootWindow(), presentMask | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_PROPERTY_CHANGE | @@ -1319,7 +1322,7 @@ bool Workspace::isOnCurrentHead() return !is_multihead; } - return rootWindow() == geometry->root; + return kwinApp()->x11RootWindow() == geometry->root; } void Workspace::sendClientToOutput(AbstractClient *client, AbstractOutput *output) @@ -2866,7 +2869,7 @@ void Workspace::setMoveResizeClient(AbstractClient *c) // (the property with the size of the frame remains on the window after the crash). void Workspace::fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geometry) { - NETWinInfo i(kwinApp()->x11Connection(), w, rootWindow(), NET::WMFrameExtents, NET::Properties2()); + NETWinInfo i(kwinApp()->x11Connection(), w, kwinApp()->x11RootWindow(), NET::WMFrameExtents, NET::Properties2()); NETStrut frame = i.frameExtents(); if (frame.left != 0 || frame.top != 0) { diff --git a/src/x11client.cpp b/src/x11client.cpp index e824771fab..0f78da2ab3 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -297,7 +297,7 @@ void X11Client::releaseWindow(bool on_shutdown) m_client.deleteProperty(atoms->kde_net_wm_user_creation_time); m_client.deleteProperty(atoms->net_frame_extents); m_client.deleteProperty(atoms->kde_net_wm_frame_strut); - m_client.reparent(rootWindow(), m_bufferGeometry.x(), m_bufferGeometry.y()); + m_client.reparent(kwinApp()->x11RootWindow(), m_bufferGeometry.x(), m_bufferGeometry.y()); xcb_change_save_set(c, XCB_SET_MODE_DELETE, m_client); m_client.selectInput(XCB_EVENT_MASK_NO_EVENT); if (on_shutdown) @@ -420,7 +420,7 @@ bool X11Client::manage(xcb_window_t w, bool isMapped) m_geometryHints.init(window()); m_motif.init(window()); - info = new WinInfo(this, m_client, rootWindow(), properties, properties2); + info = new WinInfo(this, m_client, kwinApp()->x11RootWindow(), properties, properties2); if (isDesktop() && bit_depth == 32) { // force desktop windows to be opaque. It's a desktop after all, there is no window below @@ -953,7 +953,7 @@ bool X11Client::manage(xcb_window_t w, bool isMapped) if (opacity() == 1.0) { return; } - NETWinInfo info(kwinApp()->x11Connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2()); + NETWinInfo info(kwinApp()->x11Connection(), frameId(), kwinApp()->x11RootWindow(), NET::Properties(), NET::Properties2()); info.setOpacityF(opacity()); } ); @@ -1014,7 +1014,7 @@ void X11Client::embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colorma // Create the frame window xcb_window_t frame = xcb_generate_id(conn); - xcb_create_window(conn, depth, frame, rootWindow(), 0, 0, 1, 1, 0, + xcb_create_window(conn, depth, frame, kwinApp()->x11RootWindow(), 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualid, cw_mask, cw_values); m_frame.reset(frame); @@ -1752,7 +1752,7 @@ void X11Client::sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t proto ev.data.data32[3] = data2; ev.data.data32[4] = data3; uint32_t eventMask = 0; - if (w == rootWindow()) { + if (w == kwinApp()->x11RootWindow()) { eventMask = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; // Magic! } xcb_send_event(kwinApp()->x11Connection(), false, w, eventMask, reinterpret_cast(&ev)); @@ -3113,24 +3113,24 @@ xcb_window_t X11Client::verifyTransientFor(xcb_window_t new_transient_for, bool // make sure splashscreens are shown above all their app's windows, even though // they're in Normal layer if (isSplash() && new_transient_for == XCB_WINDOW_NONE) - new_transient_for = rootWindow(); + new_transient_for = kwinApp()->x11RootWindow(); if (new_transient_for == XCB_WINDOW_NONE) { if (set) // sometimes WM_TRANSIENT_FOR is set to None, instead of root window - new_property_value = new_transient_for = rootWindow(); + new_property_value = new_transient_for = kwinApp()->x11RootWindow(); else return XCB_WINDOW_NONE; } if (new_transient_for == window()) { // pointing to self // also fix the property itself qCWarning(KWIN_CORE) << "Client " << this << " has WM_TRANSIENT_FOR poiting to itself." ; - new_property_value = new_transient_for = rootWindow(); + new_property_value = new_transient_for = kwinApp()->x11RootWindow(); } // The transient_for window may be embedded in another application, // so kwin cannot see it. Try to find the managed client for the // window and fix the transient_for property if possible. xcb_window_t before_search = new_transient_for; while (new_transient_for != XCB_WINDOW_NONE - && new_transient_for != rootWindow() + && new_transient_for != kwinApp()->x11RootWindow() && !workspace()->findClient(Predicate::WindowMatch, new_transient_for)) { Xcb::Tree tree(new_transient_for); if (tree.isNull()) { @@ -3151,20 +3151,20 @@ xcb_window_t X11Client::verifyTransientFor(xcb_window_t new_transient_for, bool // windows in the group int count = 20; xcb_window_t loop_pos = new_transient_for; - while (loop_pos != XCB_WINDOW_NONE && loop_pos != rootWindow()) { + while (loop_pos != XCB_WINDOW_NONE && loop_pos != kwinApp()->x11RootWindow()) { X11Client *pos = workspace()->findClient(Predicate::WindowMatch, loop_pos); if (pos == nullptr) break; loop_pos = pos->m_transientForId; if (--count == 0 || pos == this) { qCWarning(KWIN_CORE) << "Client " << this << " caused WM_TRANSIENT_FOR loop." ; - new_transient_for = rootWindow(); + new_transient_for = kwinApp()->x11RootWindow(); } } - if (new_transient_for != rootWindow() + if (new_transient_for != kwinApp()->x11RootWindow() && workspace()->findClient(Predicate::WindowMatch, new_transient_for) == nullptr) { // it's transient for a specific window, but that window is not mapped - new_transient_for = rootWindow(); + new_transient_for = kwinApp()->x11RootWindow(); } if (new_property_value != m_originalTransientForId) Xcb::setTransientFor(window(), new_property_value); @@ -3195,7 +3195,7 @@ void X11Client::removeTransient(AbstractClient* cl) if (X11Client *c = dynamic_cast(cl)) { c->m_transientForId = XCB_WINDOW_NONE; c->setTransientFor(nullptr); // SELI -// SELI cl->setTransient( rootWindow()); +// SELI cl->setTransient( kwinApp()->x11RootWindow()); c->setTransient(XCB_WINDOW_NONE); } } @@ -4524,7 +4524,7 @@ bool X11Client::doStartInteractiveMoveResize() // something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug* // (https://lists.kde.org/?t=107302193400001&r=1&w=2) QRect r = workspace()->clientArea(FullArea, this); - m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, nullptr, rootWindow()); + m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, nullptr, kwinApp()->x11RootWindow()); m_moveResizeGrabWindow.map(); m_moveResizeGrabWindow.raise(); updateXTime(); diff --git a/src/x11client.h b/src/x11client.h index b523044d3d..17cb56c61e 100644 --- a/src/x11client.h +++ b/src/x11client.h @@ -542,14 +542,14 @@ inline bool X11Client::isClientSideDecorated() const inline bool X11Client::groupTransient() const { - return m_transientForId == rootWindow(); + return m_transientForId == kwinApp()->x11RootWindow(); } // Needed because verifyTransientFor() may set transient_for_id to root window, // if the original value has a problem (window doesn't exist, etc.) inline bool X11Client::wasOriginallyGroupTransient() const { - return m_originalTransientForId == rootWindow(); + return m_originalTransientForId == kwinApp()->x11RootWindow(); } inline bool X11Client::isTransient() const diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index 3257d9bd02..611053df64 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -443,7 +443,7 @@ void Xwayland::handleXwaylandReady() void Xwayland::updatePrimary(AbstractOutput *primaryOutput) { - Xcb::RandR::ScreenResources resources(rootWindow()); + Xcb::RandR::ScreenResources resources(kwinApp()->x11RootWindow()); xcb_randr_crtc_t *crtcs = resources.crtcs(); if (!crtcs) { return; @@ -456,7 +456,7 @@ void Xwayland::updatePrimary(AbstractOutput *primaryOutput) auto outputs = crtcInfo.outputs(); if (outputs && crtcInfo->num_outputs > 0) { qCDebug(KWIN_XWL) << "Setting primary" << primaryOutput << outputs[0]; - xcb_randr_set_output_primary(kwinApp()->x11Connection(), rootWindow(), outputs[0]); + xcb_randr_set_output_primary(kwinApp()->x11Connection(), kwinApp()->x11RootWindow(), outputs[0]); break; } }