Commit 9236254d authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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.
parent 01752895
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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();
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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();
......
......@@ -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
......
......@@ -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)
......
......@@ -2794,7 +2794,6 @@ void X11Client::addDamage(const QRegion &damage)
setupWindowManagementInterface();
}
}
addRepaint(damage.translated(bufferGeometry().topLeft() - frameGeometry().topLeft()));
Toplevel::addDamage(damage);
}
......
......@@ -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();
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment