Move Window::{depth,hasAlpha,visual} to X11Window

This commit is contained in:
Vlad Zahorodnii 2023-03-29 10:54:54 +03:00
parent 87bfdcf1d6
commit 46d0c04f91
6 changed files with 29 additions and 48 deletions

View file

@ -409,7 +409,6 @@ void InternalWindow::present(const std::shared_ptr<QOpenGLFramebufferObject> fbo
m_fbo = fbo; m_fbo = fbo;
setDepth(32);
surfaceItem()->addDamage(surfaceItem()->rect().toAlignedRect()); surfaceItem()->addDamage(surfaceItem()->rect().toAlignedRect());
} }
@ -428,7 +427,6 @@ void InternalWindow::present(const QImage &image, const QRegion &damage)
m_image = image; m_image = image;
setDepth(32);
surfaceItem()->addDamage(damage); surfaceItem()->addDamage(damage);
} }

View file

@ -38,7 +38,6 @@ WaylandWindow::WaylandWindow(SurfaceInterface *surface)
: m_isScreenLocker(surface->client() == waylandServer()->screenLockerClientConnection()) : m_isScreenLocker(surface->client() == waylandServer()->screenLockerClientConnection())
{ {
setSurface(surface); setSurface(surface);
setDepth(32);
connect(surface, &SurfaceInterface::shadowChanged, connect(surface, &SurfaceInterface::shadowChanged,
this, &WaylandWindow::updateShadow); this, &WaylandWindow::updateShadow);

View file

@ -66,8 +66,6 @@ std::shared_ptr<Decoration::DecorationPalette> Window::s_defaultPalette;
Window::Window() Window::Window()
: m_output(workspace()->activeOutput()) : m_output(workspace()->activeOutput())
, m_visual(XCB_NONE)
, bit_depth(24)
, info(nullptr) , info(nullptr)
, ready_for_painting(false) , ready_for_painting(false)
, m_internalId(QUuid::createUuid()) , m_internalId(QUuid::createUuid())
@ -555,18 +553,6 @@ QString Window::windowRole() const
return QString::fromLatin1(info->windowRole()); return QString::fromLatin1(info->windowRole());
} }
void Window::setDepth(int depth)
{
if (bit_depth == depth) {
return;
}
const bool oldAlpha = hasAlpha();
bit_depth = depth;
if (oldAlpha != hasAlpha()) {
Q_EMIT hasAlphaChanged();
}
}
QRegion Window::inputShape() const QRegion Window::inputShape() const
{ {
if (m_surface) { if (m_surface) {

View file

@ -684,12 +684,9 @@ public:
static bool resourceMatch(const Window *c1, const Window *c2); static bool resourceMatch(const Window *c1, const Window *c2);
bool readyForPainting() const; // true if the window has been already painted its contents bool readyForPainting() const; // true if the window has been already painted its contents
xcb_visualid_t visual() const;
QRegion inputShape() const; QRegion inputShape() const;
void setOpacity(qreal opacity); void setOpacity(qreal opacity);
qreal opacity() const; qreal opacity() const;
int depth() const;
bool hasAlpha() const;
virtual bool setupCompositing(); virtual bool setupCompositing();
virtual void finishCompositing(); virtual void finishCompositing();
EffectWindowImpl *effectWindow(); EffectWindowImpl *effectWindow();
@ -1403,10 +1400,6 @@ Q_SIGNALS:
* @since 5.0 * @since 5.0
*/ */
void windowClassChanged(); void windowClassChanged();
/**
* @since 5.4
*/
void hasAlphaChanged();
/** /**
* Emitted whenever the Surface for this Window changes. * Emitted whenever the Surface for this Window changes.
@ -1510,14 +1503,11 @@ protected:
Xcb::Property fetchSkipCloseAnimation() const; Xcb::Property fetchSkipCloseAnimation() const;
void readSkipCloseAnimation(Xcb::Property &prop); void readSkipCloseAnimation(Xcb::Property &prop);
void getSkipCloseAnimation(); void getSkipCloseAnimation();
void setDepth(int depth);
Output *m_output = nullptr; Output *m_output = nullptr;
QRectF m_frameGeometry; QRectF m_frameGeometry;
QRectF m_clientGeometry; QRectF m_clientGeometry;
QRectF m_bufferGeometry; QRectF m_bufferGeometry;
xcb_visualid_t m_visual;
int bit_depth;
NETWinInfo *info; NETWinInfo *info;
bool ready_for_painting; bool ready_for_painting;
@ -2030,11 +2020,6 @@ inline bool Window::readyForPainting() const
return ready_for_painting; return ready_for_painting;
} }
inline xcb_visualid_t Window::visual() const
{
return m_visual;
}
inline bool Window::isDesktop() const inline bool Window::isDesktop() const
{ {
return windowType() == NET::Desktop; return windowType() == NET::Desktop;
@ -2140,16 +2125,6 @@ inline bool Window::isInternal() const
return false; return false;
} }
inline int Window::depth() const
{
return bit_depth;
}
inline bool Window::hasAlpha() const
{
return depth() == 32;
}
inline const QRegion &Window::opaqueRegion() const inline const QRegion &Window::opaqueRegion() const
{ {
return opaque_region; return opaque_region;

View file

@ -197,13 +197,15 @@ void X11DecorationRenderer::render(const QRegion &region)
return; return;
} }
xcb_connection_t *c = kwinApp()->x11Connection(); xcb_connection_t *c = kwinApp()->x11Connection();
X11Window *window = static_cast<X11Window *>(client()->window());
if (m_gc == XCB_NONE) { if (m_gc == XCB_NONE) {
m_gc = xcb_generate_id(c); m_gc = xcb_generate_id(c);
xcb_create_gc(c, m_gc, client()->window()->frameId(), 0, nullptr); xcb_create_gc(c, m_gc, window->frameId(), 0, nullptr);
} }
QRectF left, top, right, bottom; QRectF left, top, right, bottom;
client()->window()->layoutDecorationRects(left, top, right, bottom); window->layoutDecorationRects(left, top, right, bottom);
const QRect geometry = region.boundingRect(); const QRect geometry = region.boundingRect();
left = left.intersected(geometry); left = left.intersected(geometry);
@ -211,14 +213,14 @@ void X11DecorationRenderer::render(const QRegion &region)
right = right.intersected(geometry); right = right.intersected(geometry);
bottom = bottom.intersected(geometry); bottom = bottom.intersected(geometry);
auto renderPart = [this, c](const QRect &geo) { auto renderPart = [this, c, window](const QRect &geo) {
if (!geo.isValid()) { if (!geo.isValid()) {
return; return;
} }
// Guess the pixel format of the X pixmap into which the QImage will be copied. // Guess the pixel format of the X pixmap into which the QImage will be copied.
QImage::Format format; QImage::Format format;
const int depth = client()->window()->depth(); const int depth = window->depth();
switch (depth) { switch (depth) {
case 30: case 30:
format = QImage::Format_A2RGB30_Premultiplied; format = QImage::Format_A2RGB30_Premultiplied;
@ -241,8 +243,8 @@ void X11DecorationRenderer::render(const QRegion &region)
p.setClipRect(geo); p.setClipRect(geo);
renderToPainter(&p, geo); renderToPainter(&p, geo);
xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, client()->window()->frameId(), m_gc, xcb_put_image(c, XCB_IMAGE_FORMAT_Z_PIXMAP, window->frameId(), m_gc,
image.width(), image.height(), geo.x(), geo.y(), 0, client()->window()->depth(), image.width(), image.height(), geo.x(), geo.y(), 0, window->depth(),
image.sizeInBytes(), image.constBits()); image.sizeInBytes(), image.constBits());
}; };
renderPart(left.toRect()); renderPart(left.toRect());

View file

@ -90,6 +90,10 @@ public:
QRectF frameRectToBufferRect(const QRectF &rect) const; QRectF frameRectToBufferRect(const QRectF &rect) const;
QSizeF implicitSize() const; QSizeF implicitSize() const;
xcb_visualid_t visual() const;
int depth() const;
bool hasAlpha() const;
QMatrix4x4 inputTransformation() const override; QMatrix4x4 inputTransformation() const override;
bool isTransient() const override; bool isTransient() const override;
@ -477,6 +481,8 @@ private:
SyncRequest m_syncRequest; SyncRequest m_syncRequest;
static bool check_active_modal; ///< \see X11Window::checkActiveModal() static bool check_active_modal; ///< \see X11Window::checkActiveModal()
int sm_stacking_order; int sm_stacking_order;
xcb_visualid_t m_visual = XCB_NONE;
int bit_depth = 24;
friend struct ResetupRulesProcedure; friend struct ResetupRulesProcedure;
friend bool performTransiencyCheck(); friend bool performTransiencyCheck();
@ -509,6 +515,21 @@ private:
quint64 m_surfaceSerial = 0; quint64 m_surfaceSerial = 0;
}; };
inline xcb_visualid_t X11Window::visual() const
{
return m_visual;
}
inline int X11Window::depth() const
{
return bit_depth;
}
inline bool X11Window::hasAlpha() const
{
return depth() == 32;
}
inline xcb_window_t X11Window::wrapperId() const inline xcb_window_t X11Window::wrapperId() const
{ {
return m_wrapper; return m_wrapper;