x11: Prefer kwinApp()->x11Connection() over connection()

With connection(), we will look up the x11 connection property on
kwinApp() object, which is less efficient than just calling a method on
the app object.
This commit is contained in:
Vlad Zahorodnii 2022-02-09 00:22:38 +02:00
parent b62630c8ac
commit ec7198ee33
14 changed files with 71 additions and 70 deletions

View file

@ -8,6 +8,7 @@
*/
// own
#include "client_machine.h"
#include "main.h"
#include "utils/common.h"
// KF5
#include <NETWM>

View file

@ -94,7 +94,7 @@ class CompositorSelectionOwner : public KSelectionOwner
Q_OBJECT
public:
CompositorSelectionOwner(const char *selection)
: KSelectionOwner(selection, connection(), rootWindow())
: KSelectionOwner(selection, kwinApp()->x11Connection(), rootWindow())
, m_owning(false)
{
connect (this, &CompositorSelectionOwner::lostOwnership,

View file

@ -638,7 +638,7 @@ xcb_window_t EffectsHandlerImpl::x11RootWindow() const
inline
xcb_connection_t *EffectsHandlerImpl::xcbConnection() const
{
return connection();
return kwinApp()->x11Connection();
}
inline

View file

@ -190,7 +190,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
// see comments for allowClientActivation()
updateXTime();
const xcb_timestamp_t t = xTime();
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, event->window, atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 32, 1, &t);
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, event->window, atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 32, 1, &t);
}
break;
}
@ -221,9 +221,9 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
// NOTICE: The save-set support in X11Client::mapRequestEvent() actually requires that
// this code doesn't check the parent to be root.
if (!createClient(event->window, false)) {
xcb_map_window(connection(), event->window);
xcb_map_window(kwinApp()->x11Connection(), event->window);
const uint32_t values[] = { XCB_STACK_MODE_ABOVE };
xcb_configure_window(connection(), event->window, XCB_CONFIG_WINDOW_STACK_MODE, values);
xcb_configure_window(kwinApp()->x11Connection(), event->window, XCB_CONFIG_WINDOW_STACK_MODE, values);
}
}
return true;
@ -271,7 +271,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e)
if (value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
values[i++] = event->border_width;
}
xcb_configure_window(connection(), event->window, value_mask, values);
xcb_configure_window(kwinApp()->x11Connection(), event->window, value_mask, values);
return true;
}
break;
@ -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(connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2());
NETWinInfo i(kwinApp()->x11Connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2());
i.setOpacity(info->opacity());
}
}
@ -787,7 +787,7 @@ void X11Client::updateMouseGrab()
return;
}
xcb_ungrab_button(connection(), XCB_BUTTON_INDEX_ANY, m_wrapper, XCB_MOD_MASK_ANY);
xcb_ungrab_button(kwinApp()->x11Connection(), XCB_BUTTON_INDEX_ANY, m_wrapper, XCB_MOD_MASK_ANY);
if (TabBox::TabBox::self()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
@ -854,7 +854,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
}
if (isInteractiveMoveResizePointerButtonDown()) {
if (w == wrapperId())
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
return true;
}
@ -868,7 +868,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
// hide splashwindow if the user clicks on it
hideClient();
if (w == wrapperId())
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
return true;
}
@ -907,13 +907,13 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i
replay = true;
if (w == wrapperId()) // these can come only from a grab
xcb_allow_events(connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
xcb_allow_events(kwinApp()->x11Connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
return true;
}
}
if (w == wrapperId()) { // these can come only from a grab
xcb_allow_events(connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
return true;
}
if (w == inputId()) {
@ -986,7 +986,7 @@ bool X11Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x,
}
}
if (w == wrapperId()) {
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
return true;
}
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())

View file

@ -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(connection(), leader_P, rootWindow(),
leader_info = new NETWinInfo(kwinApp()->x11Connection(), leader_P, rootWindow(),
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(connection(), leader_wid, rootWindow(), NET::WMIcon, NET::WM2IconPixmap);
NETWinInfo info(kwinApp()->x11Connection(), leader_wid, rootWindow(), 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()) {

View file

@ -41,7 +41,7 @@ void KillWindow::start()
if (AbstractClient *c = qobject_cast<AbstractClient*>(t)) {
c->killWindow();
} else if (Unmanaged *u = qobject_cast<Unmanaged*>(t)) {
xcb_kill_client(connection(), u->window());
xcb_kill_client(kwinApp()->x11Connection(), u->window());
}
}, QByteArrayLiteral("pirate")
);

View file

@ -112,7 +112,7 @@ private:
bool genericReply(xcb_atom_t target_P, xcb_atom_t property_P, xcb_window_t requestor_P) override {
if (target_P == xa_version) {
int32_t version[] = { 2, 0 };
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, requestor_P,
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, requestor_P,
property_P, XCB_ATOM_INTEGER, 32, 2, version);
} else
return KSelectionOwner::genericReply(target_P, property_P, requestor_P);
@ -123,7 +123,7 @@ private:
KSelectionOwner::replyTargets(property_P, requestor_P);
xcb_atom_t atoms[ 1 ] = { xa_version };
// PropModeAppend !
xcb_change_property(connection(), XCB_PROP_MODE_APPEND, requestor_P,
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_APPEND, requestor_P,
property_P, XCB_ATOM_ATOM, 32, 1, atoms);
}
@ -132,8 +132,8 @@ private:
if (xa_version == XCB_ATOM_NONE) {
const QByteArray name(QByteArrayLiteral("VERSION"));
ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(
connection(),
xcb_intern_atom_unchecked(connection(), false, name.length(), name.constData()),
kwinApp()->x11Connection(),
xcb_intern_atom_unchecked(kwinApp()->x11Connection(), false, name.length(), name.constData()),
nullptr));
if (!atom.isNull()) {
xa_version = atom->atom;
@ -147,8 +147,8 @@ private:
QByteArray screen(QByteArrayLiteral("WM_S"));
screen.append(QByteArray::number(screen_P));
ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(
connection(),
xcb_intern_atom_unchecked(connection(), false, screen.length(), screen.constData()),
kwinApp()->x11Connection(),
xcb_intern_atom_unchecked(kwinApp()->x11Connection(), false, screen.length(), screen.constData()),
nullptr));
if (atom.isNull()) {
return XCB_ATOM_NONE;
@ -238,8 +238,8 @@ void ApplicationX11::performStartup()
// Check whether another windowmanager is running
const uint32_t maskValues[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};
ScopedCPointer<xcb_generic_error_t> redirectCheck(xcb_request_check(connection(),
xcb_change_window_attributes_checked(connection(),
ScopedCPointer<xcb_generic_error_t> redirectCheck(xcb_request_check(kwinApp()->x11Connection(),
xcb_change_window_attributes_checked(kwinApp()->x11Connection(),
rootWindow(),
XCB_CW_EVENT_MASK,
maskValues)));

View file

@ -27,15 +27,15 @@ RootInfo *RootInfo::s_self = nullptr;
RootInfo *RootInfo::create()
{
Q_ASSERT(!s_self);
xcb_window_t supportWindow = xcb_generate_id(connection());
xcb_window_t supportWindow = xcb_generate_id(kwinApp()->x11Connection());
const uint32_t values[] = {true};
xcb_create_window(connection(), XCB_COPY_FROM_PARENT, supportWindow, KWin::rootWindow(),
xcb_create_window(kwinApp()->x11Connection(), XCB_COPY_FROM_PARENT, supportWindow, KWin::rootWindow(),
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
// we need to do the lower window with a roundtrip, otherwise NETRootInfo is not functioning
ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(connection(),
xcb_configure_window_checked(connection(), supportWindow, XCB_CONFIG_WINDOW_STACK_MODE, lowerValues)));
ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(kwinApp()->x11Connection(),
xcb_configure_window_checked(kwinApp()->x11Connection(), supportWindow, XCB_CONFIG_WINDOW_STACK_MODE, lowerValues)));
if (!error.isNull()) {
qCDebug(KWIN_CORE) << "Error occurred while lowering support window: " << error->error_code;
}
@ -127,12 +127,12 @@ void RootInfo::destroy()
xcb_window_t supportWindow = s_self->supportWindow();
delete s_self;
s_self = nullptr;
xcb_destroy_window(connection(), supportWindow);
xcb_destroy_window(kwinApp()->x11Connection(), supportWindow);
}
RootInfo::RootInfo(xcb_window_t w, const char *name, NET::Properties properties, NET::WindowTypes types,
NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr)
: NETRootInfo(connection(), w, name, properties, types, states, properties2, actions, scr)
: NETRootInfo(kwinApp()->x11Connection(), w, name, properties, types, states, properties2, actions, scr)
, m_activeWindow(activeWindow())
, m_eventFilter(std::make_unique<RootInfoFilter>(this))
{
@ -237,7 +237,7 @@ void RootInfo::setActiveClient(AbstractClient *client)
WinInfo::WinInfo(X11Client *c, xcb_window_t window,
xcb_window_t rwin, NET::Properties properties, NET::Properties2 properties2)
: NETWinInfo(connection(), window, rwin, properties, properties2, NET::WindowManager), m_client(c)
: NETWinInfo(kwinApp()->x11Connection(), window, rwin, properties, properties2, NET::WindowManager), m_client(c)
{
}

View file

@ -147,13 +147,13 @@ bool Shadow::init(const QVector< uint32_t > &data)
{
QVector<Xcb::WindowGeometry> pixmapGeometries(ShadowElementsCount);
QVector<xcb_get_image_cookie_t> getImageCookies(ShadowElementsCount);
auto *c = connection();
auto *c = kwinApp()->x11Connection();
for (int i = 0; i < ShadowElementsCount; ++i) {
pixmapGeometries[i] = Xcb::WindowGeometry(data[i]);
}
auto discardReplies = [&getImageCookies](int start) {
for (int i = start; i < getImageCookies.size(); ++i) {
xcb_discard_reply(connection(), getImageCookies.at(i).sequence);
xcb_discard_reply(kwinApp()->x11Connection(), getImageCookies.at(i).sequence);
}
};
for (int i = 0; i < ShadowElementsCount; ++i) {

View file

@ -491,8 +491,8 @@ QRegion Toplevel::shapeRegion() const
const QRect bufferGeometry = this->bufferGeometry();
if (shape()) {
auto cookie = xcb_shape_get_rectangles_unchecked(connection(), frameId(), XCB_SHAPE_SK_BOUNDING);
ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(connection(), cookie, nullptr));
auto cookie = xcb_shape_get_rectangles_unchecked(kwinApp()->x11Connection(), frameId(), XCB_SHAPE_SK_BOUNDING);
ScopedCPointer<xcb_shape_get_rectangles_reply_t> reply(xcb_shape_get_rectangles_reply(kwinApp()->x11Connection(), cookie, nullptr));
if (!reply.isNull()) {
m_shapeRegion = QRegion();
const xcb_rectangle_t *rects = xcb_shape_get_rectangles_rectangles(reply.data());

View file

@ -104,7 +104,7 @@ bool Unmanaged::track(xcb_window_t w)
checkOutput();
m_visual = attr->visual;
bit_depth = geo->depth;
info = new NETWinInfo(connection(), w, rootWindow(),
info = new NETWinInfo(kwinApp()->x11Connection(), w, rootWindow(),
NET::WMWindowType | NET::WMPid,
NET::WM2Opacity |
NET::WM2WindowRole |
@ -115,7 +115,7 @@ bool Unmanaged::track(xcb_window_t w)
getWmClientLeader();
getWmClientMachine();
if (Xcb::Extensions::self()->isShapeAvailable())
xcb_shape_select_input(connection(), w, true);
xcb_shape_select_input(kwinApp()->x11Connection(), w, true);
detectShape(w);
getWmOpaqueRegion();
getSkipCloseAnimation();
@ -138,7 +138,7 @@ void Unmanaged::release(ReleaseReason releaseReason)
finishCompositing(releaseReason);
if (!QWidget::find(window()) && releaseReason != ReleaseReason::Destroyed) { // don't affect our own windows
if (Xcb::Extensions::self()->isShapeAvailable())
xcb_shape_select_input(connection(), window(), false);
xcb_shape_select_input(kwinApp()->x11Connection(), window(), false);
Xcb::selectInput(window(), XCB_EVENT_MASK_NO_EVENT);
}
workspace()->removeUnmanaged(this);

View file

@ -97,7 +97,7 @@ void ColorMapper::update()
}
}
if (cmap != m_installed) {
xcb_install_colormap(connection(), cmap);
xcb_install_colormap(kwinApp()->x11Connection(), cmap);
m_installed = cmap;
}
}
@ -312,7 +312,7 @@ void Workspace::initializeX11()
// Compatibility
int32_t data = 1;
xcb_change_property(connection(), XCB_PROP_MODE_APPEND, rootWindow(), atoms->kwin_running,
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_APPEND, rootWindow(), atoms->kwin_running,
atoms->kwin_running, 32, 1, &data);
if (kwinApp()->operationMode() == Application::OperationModeX11) {
@ -335,7 +335,7 @@ void Workspace::initializeX11()
// TODO: only in X11 mode
// Extra NETRootInfo instance in Client mode is needed to get the values of the properties
NETRootInfo client_info(connection(), NET::ActiveWindow | NET::CurrentDesktop);
NETRootInfo client_info(kwinApp()->x11Connection(), NET::ActiveWindow | NET::CurrentDesktop);
if (!qApp->isSessionRestored()) {
m_initialDesktop = client_info.currentDesktop();
vds->setCurrent(m_initialDesktop);
@ -2866,7 +2866,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(connection(), w, rootWindow(), NET::WMFrameExtents, NET::Properties2());
NETWinInfo i(kwinApp()->x11Connection(), w, rootWindow(), NET::WMFrameExtents, NET::Properties2());
NETStrut frame = i.frameExtents();
if (frame.left != 0 || frame.top != 0) {
@ -2874,7 +2874,7 @@ void Workspace::fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_rep
const uint32_t left = frame.left;
const uint32_t top = frame.top;
const uint32_t values[] = { geometry->x - left, geometry->y - top };
xcb_configure_window(connection(), w, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
xcb_configure_window(kwinApp()->x11Connection(), w, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
}
}

View file

@ -91,7 +91,7 @@ X11DecorationRenderer::X11DecorationRenderer(Decoration::DecoratedClientImpl *cl
X11DecorationRenderer::~X11DecorationRenderer()
{
if (m_gc != XCB_NONE) {
xcb_free_gc(connection(), m_gc);
xcb_free_gc(kwinApp()->x11Connection(), m_gc);
}
}
@ -221,7 +221,7 @@ X11Client::X11Client()
m_decoInputExtent.defineCursor(nativeCursor);
if (isInteractiveMoveResize()) {
// changing window attributes doesn't change cursor if there's pointer grab active
xcb_change_active_pointer_grab(connection(), nativeCursor, xTime(),
xcb_change_active_pointer_grab(kwinApp()->x11Connection(), nativeCursor, xTime(),
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW);
}
});
@ -240,7 +240,7 @@ X11Client::~X11Client()
m_killHelperPID = 0;
}
if (m_syncRequest.alarm != XCB_NONE) {
xcb_sync_destroy_alarm(connection(), m_syncRequest.alarm);
xcb_sync_destroy_alarm(kwinApp()->x11Connection(), m_syncRequest.alarm);
}
Q_ASSERT(!isInteractiveMoveResize());
Q_ASSERT(m_client == XCB_WINDOW_NONE);
@ -293,7 +293,7 @@ void X11Client::releaseWindow(bool on_shutdown)
info->setDesktop(0);
info->setState(NET::States(), info->state()); // Reset all state flags
}
xcb_connection_t *c = connection();
xcb_connection_t *c = kwinApp()->x11Connection();
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);
@ -446,7 +446,7 @@ bool X11Client::manage(xcb_window_t w, bool isMapped)
connect(this, &X11Client::windowClassChanged, this, &X11Client::evaluateWindowRules);
if (Xcb::Extensions::self()->isShapeAvailable())
xcb_shape_select_input(connection(), window(), true);
xcb_shape_select_input(kwinApp()->x11Connection(), window(), true);
detectShape(window());
detectNoBorder();
fetchIconicName();
@ -953,7 +953,7 @@ bool X11Client::manage(xcb_window_t w, bool isMapped)
if (opacity() == 1.0) {
return;
}
NETWinInfo info(connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2());
NETWinInfo info(kwinApp()->x11Connection(), frameId(), rootWindow(), NET::Properties(), NET::Properties2());
info.setOpacityF(opacity());
}
);
@ -975,7 +975,7 @@ void X11Client::embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colorma
const uint32_t zero_value = 0;
xcb_connection_t *conn = connection();
xcb_connection_t *conn = kwinApp()->x11Connection();
// We don't want the window to be destroyed when we quit
xcb_change_save_set(conn, XCB_SET_MODE_INSERT, m_client);
@ -1095,7 +1095,7 @@ void X11Client::updateInputWindow()
}
const QVector<xcb_rectangle_t> rects = Xcb::regionToRects(region);
xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
xcb_shape_rectangles(kwinApp()->x11Connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
m_decoInputExtent, 0, 0, rects.count(), rects.constData());
}
@ -1324,11 +1324,11 @@ void X11Client::updateShape()
updateDecoration(true);
}
if (!isDecorated()) {
xcb_shape_combine(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
xcb_shape_combine(kwinApp()->x11Connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
frameId(), clientPos().x(), clientPos().y(), window());
}
} else if (app_noborder) {
xcb_shape_mask(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, frameId(), 0, 0, XCB_PIXMAP_NONE);
xcb_shape_mask(kwinApp()->x11Connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, frameId(), 0, 0, XCB_PIXMAP_NONE);
detectNoBorder();
app_noborder = noborder;
noborder = rules()->checkNoBorder(noborder || m_motif.noBorder());
@ -1370,7 +1370,7 @@ void X11Client::updateInputShape()
if (!shape_helper_window.isValid())
shape_helper_window.create(QRect(0, 0, 1, 1));
shape_helper_window.resize(m_bufferGeometry.size());
xcb_connection_t *c = connection();
xcb_connection_t *c = kwinApp()->x11Connection();
xcb_shape_combine(c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_BOUNDING,
shape_helper_window, 0, 0, frameId());
xcb_shape_combine(c, XCB_SHAPE_SO_SUBTRACT, XCB_SHAPE_SK_INPUT, XCB_SHAPE_SK_BOUNDING,
@ -1725,7 +1725,7 @@ void X11Client::updateHiddenPreview()
if (hiddenPreview()) {
workspace()->forceRestacking();
if (Xcb::Extensions::self()->isShapeInputAvailable()) {
xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
xcb_shape_rectangles(kwinApp()->x11Connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
XCB_CLIP_ORDERING_UNSORTED, frameId(), 0, 0, 0, nullptr);
}
} else {
@ -1755,8 +1755,8 @@ void X11Client::sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t proto
if (w == rootWindow()) {
eventMask = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT; // Magic!
}
xcb_send_event(connection(), false, w, eventMask, reinterpret_cast<const char*>(&ev));
xcb_flush(connection());
xcb_send_event(kwinApp()->x11Connection(), false, w, eventMask, reinterpret_cast<const char*>(&ev));
xcb_flush(kwinApp()->x11Connection());
}
/**
@ -1958,10 +1958,10 @@ QStringList X11Client::activities() const
bool X11Client::takeFocus()
{
if (rules()->checkAcceptFocus(info->input())) {
xcb_void_cookie_t cookie = xcb_set_input_focus_checked(connection(),
xcb_void_cookie_t cookie = xcb_set_input_focus_checked(kwinApp()->x11Connection(),
XCB_INPUT_FOCUS_POINTER_ROOT,
window(), XCB_TIME_CURRENT_TIME);
ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(connection(), cookie));
ScopedCPointer<xcb_generic_error_t> error(xcb_request_check(kwinApp()->x11Connection(), cookie));
if (error) {
qCWarning(KWIN_CORE, "Failed to focus 0x%x (error %d)", window(), error->error_code);
return false;
@ -2027,9 +2027,9 @@ void X11Client::fetchName()
static inline QString readNameProperty(xcb_window_t w, xcb_atom_t atom)
{
const auto cookie = xcb_icccm_get_text_property_unchecked(connection(), w, atom);
const auto cookie = xcb_icccm_get_text_property_unchecked(kwinApp()->x11Connection(), w, atom);
xcb_icccm_get_text_property_reply_t reply;
if (xcb_icccm_get_wm_name_reply(connection(), cookie, &reply, nullptr)) {
if (xcb_icccm_get_wm_name_reply(kwinApp()->x11Connection(), cookie, &reply, nullptr)) {
QString retVal;
if (reply.encoding == atoms->utf8_string) {
retVal = QString::fromUtf8(QByteArray(reply.name, reply.name_len));
@ -2251,7 +2251,7 @@ void X11Client::getSyncCounter()
m_syncRequest.counter = counter;
m_syncRequest.value.hi = 0;
m_syncRequest.value.lo = 0;
auto *c = connection();
auto *c = kwinApp()->x11Connection();
xcb_sync_set_counter(c, m_syncRequest.counter, m_syncRequest.value);
if (m_syncRequest.alarm == XCB_NONE) {
const uint32_t mask = XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE | XCB_SYNC_CA_TEST_TYPE | XCB_SYNC_CA_EVENTS;
@ -2699,7 +2699,7 @@ void X11Client::readShowOnScreenEdge(Xcb::Property &property)
} else if (!property.isNull() && property->type != XCB_ATOM_NONE) {
// property value is incorrect, delete the property
// so that the client knows that it is not hidden
xcb_delete_property(connection(), window(), atoms->kde_screen_edge_show);
xcb_delete_property(kwinApp()->x11Connection(), window(), atoms->kde_screen_edge_show);
} else {
// restore
// TODO: add proper unreserve
@ -2722,7 +2722,7 @@ void X11Client::showOnScreenEdge()
showClient();
setKeepBelow(false);
xcb_delete_property(connection(), window(), atoms->kde_screen_edge_show);
xcb_delete_property(kwinApp()->x11Connection(), window(), atoms->kde_screen_edge_show);
}
bool X11Client::belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const
@ -3675,8 +3675,8 @@ void X11Client::sendSyntheticConfigureNotify()
u.event.border_width = 0;
u.event.above_sibling = XCB_WINDOW_NONE;
u.event.override_redirect = 0;
xcb_send_event(connection(), true, c.event, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast<const char*>(&u));
xcb_flush(connection());
xcb_send_event(kwinApp()->x11Connection(), true, c.event, XCB_EVENT_MASK_STRUCTURE_NOTIFY, reinterpret_cast<const char*>(&u));
xcb_flush(kwinApp()->x11Connection());
}
QPoint X11Client::gravityAdjustment(xcb_gravity_t gravity) const
@ -4528,11 +4528,11 @@ bool X11Client::doStartInteractiveMoveResize()
m_moveResizeGrabWindow.map();
m_moveResizeGrabWindow.raise();
updateXTime();
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow,
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(kwinApp()->x11Connection(), false, m_moveResizeGrabWindow,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursors::self()->mouse()->x11Cursor(cursor()), xTime());
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(connection(), cookie, nullptr));
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(kwinApp()->x11Connection(), cookie, nullptr));
if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) {
has_grab = true;
}
@ -4561,7 +4561,7 @@ void X11Client::leaveInteractiveMoveResize()
ungrabXKeyboard();
}
move_resize_has_keyboard_grab = false;
xcb_ungrab_pointer(connection(), xTime());
xcb_ungrab_pointer(kwinApp()->x11Connection(), xTime());
m_moveResizeGrabWindow.reset();
}
AbstractClient::leaveInteractiveMoveResize();

View file

@ -50,7 +50,7 @@ bool XwaylandClient::wantsSyncCounter() const
// With the addition of multiple window buffers in Xwayland 1.21, X11 clients
// are no longer able to destroy the buffer after it's been committed and not
// released by the compositor yet.
static const quint32 xwaylandVersion = xcb_get_setup(connection())->release_number;
static const quint32 xwaylandVersion = xcb_get_setup(kwinApp()->x11Connection())->release_number;
return xwaylandVersion >= 12100000;
}