Schedule a repaint when a window is damaged

Currently, if an X11 or Wayland window is damaged, we will schedule a
repaint. This results in some code duplication that this change intends
to get rid of.
icc-effect-5.26.4
Vlad Zahorodnii 2020-11-20 11:29:36 +02:00
parent 017528956b
commit 9236254d5c
13 changed files with 13 additions and 46 deletions

View File

@ -36,7 +36,6 @@ InputPanelV1Client::InputPanelV1Client(InputPanelSurfaceV1Interface *panelSurfac
connect(surface(), &SurfaceInterface::aboutToBeDestroyed, this, &InputPanelV1Client::destroyClient);
connect(surface(), &SurfaceInterface::sizeChanged, this, &InputPanelV1Client::reposition);
connect(surface(), &SurfaceInterface::mapped, this, &InputPanelV1Client::updateDepth);
connect(surface(), &SurfaceInterface::damaged, this, QOverload<const QRegion &>::of(&WaylandClient::addRepaint));
connect(panelSurface, &InputPanelSurfaceV1Interface::topLevel, this, &InputPanelV1Client::showTopLevel);
connect(panelSurface, &InputPanelSurfaceV1Interface::overlayPanel, this, &InputPanelV1Client::showOverlayPanel);

View File

@ -404,7 +404,6 @@ void InternalClient::present(const QSharedPointer<QOpenGLFramebufferObject> fbo)
setDepth(32);
addDamageFull();
addRepaintFull();
}
void InternalClient::present(const QImage &image, const QRegion &damage)
@ -424,7 +423,6 @@ void InternalClient::present(const QImage &image, const QRegion &damage)
setDepth(32);
addDamage(damage);
addRepaint(damage.translated(borderLeft(), borderTop()));
}
QWindow *InternalClient::internalWindow() const

View File

@ -216,12 +216,6 @@ bool LayerShellV1Client::acceptsFocus() const
return m_shellSurface->acceptsFocus();
}
void LayerShellV1Client::addDamage(const QRegion &region)
{
addRepaint(region);
WaylandClient::addDamage(region);
}
void LayerShellV1Client::requestGeometry(const QRect &rect)
{
WaylandClient::requestGeometry(rect);

View File

@ -48,7 +48,6 @@ protected:
Layer belongsToLayer() const override;
bool acceptsFocus() const override;
void requestGeometry(const QRect &rect) override;
void addDamage(const QRegion &region) override;
private:
void handleSizeChanged();

View File

@ -1144,6 +1144,7 @@ void Scene::Window::addRepaint(const QRegion &region)
for (int screen = 0; screen < m_repaints.count(); ++screen) {
m_repaints[screen] += region;
}
Compositor::self()->scheduleRepaint();
}
void Scene::Window::addLayerRepaint(const QRegion &region)
@ -1151,6 +1152,7 @@ void Scene::Window::addLayerRepaint(const QRegion &region)
for (int screen = 0; screen < m_layerRepaints.count(); ++screen) {
m_layerRepaints[screen] += region;
}
Compositor::self()->scheduleRepaint();
}
QRegion Scene::Window::repaints(int screen) const

View File

@ -44,7 +44,6 @@ Toplevel::Toplevel()
, m_screen(0)
, m_skipCloseAnimation(false)
{
connect(this, &Toplevel::damaged, this, &Toplevel::needsRepaint);
connect(screens(), &Screens::changed, this, &Toplevel::checkScreen);
connect(screens(), &Screens::countChanged, this, &Toplevel::checkScreen);
setupCheckScreenConnection();
@ -325,6 +324,9 @@ void Toplevel::damageNotifyEvent()
{
m_isDamaged = true;
// The damaged region will be fetched at the next compositing cycle.
Compositor::self()->scheduleRepaint();
// Note: The damage is supposed to specify the damage extents,
// but we don't know it at this point. No one who connects
// to this signal uses the rect however.
@ -398,14 +400,9 @@ void Toplevel::getDamageRegionReply()
} else
region += QRect(reply->extents.x, reply->extents.y,
reply->extents.width, reply->extents.height);
const QRect bufferRect = bufferGeometry();
const QRect frameRect = frameGeometry();
damage_region += region;
addRepaint(region.translated(bufferRect.topLeft() - frameRect.topLeft()));
free(reply);
addDamage(region);
}
void Toplevel::addDamageFull()
@ -448,7 +445,6 @@ void Toplevel::addRepaint(const QRegion &region)
return;
}
effectWindow()->sceneWindow()->addRepaint(region);
emit needsRepaint();
}
void Toplevel::addLayerRepaint(const QRect &rect)
@ -467,7 +463,6 @@ void Toplevel::addLayerRepaint(const QRegion &region)
return;
}
effectWindow()->sceneWindow()->addLayerRepaint(region);
emit needsRepaint();
}
void Toplevel::addRepaintFull()
@ -746,8 +741,13 @@ void Toplevel::setSurface(KWaylandServer::SurfaceInterface *surface)
void Toplevel::addDamage(const QRegion &damage)
{
const QRect bufferRect = bufferGeometry();
const QRect frameRect = frameGeometry();
m_isDamaged = true;
damage_region += damage;
addRepaint(damage.translated(bufferRect.topLeft() - frameRect.topLeft()));
emit damaged(this, damage);
}

View File

@ -616,11 +616,6 @@ Q_SIGNALS:
* decoration.
*/
void shapedChanged();
/**
* Emitted whenever the state changes in a way, that the Compositor should
* schedule a repaint of the scene.
*/
void needsRepaint();
/**
* Emitted whenever the Toplevel's screen changes. This can happen either in consequence to
* a screen being removed/added or if the Toplevel's geometry changes.

View File

@ -163,12 +163,6 @@ bool Unmanaged::isOutline() const
return m_outline;
}
void Unmanaged::addDamage(const QRegion &damage)
{
addRepaint(damage);
Toplevel::addDamage(damage);
}
QWindow *Unmanaged::findInternalWindow() const
{
const QWindowList windows = kwinApp()->topLevelWindows();

View File

@ -42,8 +42,7 @@ public:
public Q_SLOTS:
void release(ReleaseReason releaseReason = ReleaseReason::Release);
protected:
void addDamage(const QRegion &damage) override;
private:
~Unmanaged() override; // use release()
// handlers for X11 events

View File

@ -534,7 +534,6 @@ Workspace::~Workspace()
void Workspace::setupClientConnections(AbstractClient *c)
{
connect(c, &Toplevel::needsRepaint, m_compositor, &Compositor::scheduleRepaint);
connect(c, &AbstractClient::desktopPresenceChanged, this, &Workspace::desktopPresenceChanged);
connect(c, &AbstractClient::minimizedChanged, this, std::bind(&Workspace::clientMinimizedChanged, this, c));
}
@ -573,7 +572,6 @@ Unmanaged* Workspace::createUnmanaged(xcb_window_t w)
Unmanaged::deleteUnmanaged(c);
return nullptr;
}
connect(c, &Unmanaged::needsRepaint, m_compositor, &Compositor::scheduleRepaint);
addUnmanaged(c);
emit unmanagedAdded(c);
return c;
@ -693,7 +691,6 @@ void Workspace::addDeleted(Deleted* c, Toplevel *orig)
stacking_order.append(c);
}
markXStackingOrderAsDirty();
connect(c, &Deleted::needsRepaint, m_compositor, &Compositor::scheduleRepaint);
}
void Workspace::removeDeleted(Deleted* c)

View File

@ -2794,7 +2794,6 @@ void X11Client::addDamage(const QRegion &damage)
setupWindowManagementInterface();
}
}
addRepaint(damage.translated(bufferGeometry().topLeft() - frameGeometry().topLeft()));
Toplevel::addDamage(damage);
}

View File

@ -315,14 +315,6 @@ QRect XdgSurfaceClient::frameRectToBufferRect(const QRect &rect) const
return QRect(QPoint(left, top), surface()->size());
}
void XdgSurfaceClient::addDamage(const QRegion &damage)
{
const int offsetX = bufferGeometry().x() - frameGeometry().x();
const int offsetY = bufferGeometry().y() - frameGeometry().y();
addRepaint(damage.translated(offsetX, offsetY));
Toplevel::addDamage(damage);
}
void XdgSurfaceClient::destroyClient()
{
markAsZombie();

View File

@ -64,7 +64,6 @@ public:
protected:
void requestGeometry(const QRect &rect) override;
void addDamage(const QRegion &damage) override;
virtual XdgSurfaceConfigure *sendRoleConfigure() const = 0;
virtual void handleRoleCommit();