window: use std::unique_ptr to manage the windowitem
This commit is contained in:
parent
797bcb8bda
commit
2525109f1a
12 changed files with 20 additions and 28 deletions
|
@ -47,10 +47,9 @@ Deleted::~Deleted()
|
|||
if (workspace()) {
|
||||
workspace()->removeDeleted(this);
|
||||
}
|
||||
deleteItem();
|
||||
}
|
||||
|
||||
WindowItem *Deleted::createItem(Scene *scene)
|
||||
std::unique_ptr<WindowItem> Deleted::createItem(Scene *scene)
|
||||
{
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
{ /* nothing to do */
|
||||
return geometry;
|
||||
}
|
||||
WindowItem *createItem(Scene *scene) override;
|
||||
std::unique_ptr<WindowItem> createItem(Scene *scene) override;
|
||||
|
||||
/**
|
||||
* Returns whether the client was a popup.
|
||||
|
|
|
@ -67,9 +67,9 @@ InternalWindow::~InternalWindow()
|
|||
{
|
||||
}
|
||||
|
||||
WindowItem *InternalWindow::createItem(Scene *scene)
|
||||
std::unique_ptr<WindowItem> InternalWindow::createItem(Scene *scene)
|
||||
{
|
||||
return new WindowItemInternal(this, scene);
|
||||
return std::make_unique<WindowItemInternal>(this, scene);
|
||||
}
|
||||
|
||||
bool InternalWindow::isClient() const
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
void doInteractiveResizeSync(const QRectF &rect) override;
|
||||
void updateCaption() override;
|
||||
void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) override;
|
||||
WindowItem *createItem(Scene *scene) override;
|
||||
std::unique_ptr<WindowItem> createItem(Scene *scene) override;
|
||||
|
||||
private:
|
||||
void requestGeometry(const QRectF &rect);
|
||||
|
|
|
@ -71,9 +71,9 @@ Unmanaged::~Unmanaged()
|
|||
{
|
||||
}
|
||||
|
||||
WindowItem *Unmanaged::createItem(Scene *scene)
|
||||
std::unique_ptr<WindowItem> Unmanaged::createItem(Scene *scene)
|
||||
{
|
||||
return new WindowItemX11(this, scene);
|
||||
return std::make_unique<WindowItemX11>(this, scene);
|
||||
}
|
||||
|
||||
void Unmanaged::associate()
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
{ /* nothing to do */
|
||||
return geometry;
|
||||
}
|
||||
WindowItem *createItem(Scene *scene) override;
|
||||
std::unique_ptr<WindowItem> createItem(Scene *scene) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
void release(ReleaseReason releaseReason = ReleaseReason::Release);
|
||||
|
|
|
@ -53,9 +53,9 @@ WaylandWindow::WaylandWindow(SurfaceInterface *surface)
|
|||
updateIcon();
|
||||
}
|
||||
|
||||
WindowItem *WaylandWindow::createItem(Scene *scene)
|
||||
std::unique_ptr<WindowItem> WaylandWindow::createItem(Scene *scene)
|
||||
{
|
||||
return new WindowItemWayland(this, scene);
|
||||
return std::make_unique<WindowItemWayland>(this, scene);
|
||||
}
|
||||
|
||||
QString WaylandWindow::captionNormal() const
|
||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
|||
bool belongsToDesktop() const override;
|
||||
void doSetActive() override;
|
||||
void updateCaption() override;
|
||||
WindowItem *createItem(Scene *scene) override;
|
||||
std::unique_ptr<WindowItem> createItem(Scene *scene) override;
|
||||
|
||||
void cleanGrouping();
|
||||
void updateGeometry(const QRectF &rect);
|
||||
|
|
|
@ -189,7 +189,7 @@ void Window::copyToDeleted(Window *c)
|
|||
if (m_effectWindow != nullptr) {
|
||||
m_effectWindow->setWindow(this);
|
||||
}
|
||||
m_windowItem = std::exchange(c->m_windowItem, nullptr);
|
||||
m_windowItem = std::move(c->m_windowItem);
|
||||
m_shadow = std::move(c->m_shadow);
|
||||
if (m_shadow) {
|
||||
m_shadow->setWindow(this);
|
||||
|
@ -349,7 +349,7 @@ bool Window::setupCompositing()
|
|||
updateShadow();
|
||||
|
||||
m_windowItem = createItem(scene);
|
||||
m_effectWindow->setWindowItem(m_windowItem);
|
||||
m_effectWindow->setWindowItem(m_windowItem.get());
|
||||
|
||||
connect(windowItem(), &WindowItem::positionChanged, this, &Window::visibleGeometryChanged);
|
||||
connect(windowItem(), &WindowItem::boundingRectChanged, this, &Window::visibleGeometryChanged);
|
||||
|
@ -367,7 +367,7 @@ void Window::finishCompositing(ReleaseReason releaseReason)
|
|||
}
|
||||
m_shadow.reset();
|
||||
m_effectWindow.reset();
|
||||
deleteItem();
|
||||
m_windowItem.reset();
|
||||
}
|
||||
|
||||
void Window::addWorkspaceRepaint(int x, int y, int w, int h)
|
||||
|
@ -399,12 +399,6 @@ void Window::setReadyForPainting()
|
|||
}
|
||||
}
|
||||
|
||||
void Window::deleteItem()
|
||||
{
|
||||
delete m_windowItem;
|
||||
m_windowItem = nullptr;
|
||||
}
|
||||
|
||||
int Window::screen() const
|
||||
{
|
||||
return workspace()->outputs().indexOf(m_output);
|
||||
|
|
|
@ -1580,8 +1580,7 @@ protected:
|
|||
void getWmOpaqueRegion();
|
||||
void discardShapeRegion();
|
||||
|
||||
virtual WindowItem *createItem(Scene *scene) = 0;
|
||||
void deleteItem();
|
||||
virtual std::unique_ptr<WindowItem> createItem(Scene *scene) = 0;
|
||||
|
||||
void getResourceClass();
|
||||
void setResourceClass(const QString &name, const QString &className = QString());
|
||||
|
@ -1919,7 +1918,7 @@ private:
|
|||
Xcb::Window m_client;
|
||||
bool is_shape;
|
||||
std::unique_ptr<EffectWindowImpl> m_effectWindow;
|
||||
WindowItem *m_windowItem = nullptr;
|
||||
std::unique_ptr<WindowItem> m_windowItem;
|
||||
std::unique_ptr<Shadow> m_shadow;
|
||||
QString resource_name;
|
||||
QString resource_class;
|
||||
|
@ -2265,7 +2264,7 @@ inline const EffectWindowImpl *Window::effectWindow() const
|
|||
|
||||
inline WindowItem *Window::windowItem() const
|
||||
{
|
||||
return m_windowItem;
|
||||
return m_windowItem.get();
|
||||
}
|
||||
|
||||
inline bool Window::isOnAllDesktops() const
|
||||
|
|
|
@ -316,9 +316,9 @@ X11Window::~X11Window()
|
|||
Q_ASSERT(!check_active_modal);
|
||||
}
|
||||
|
||||
WindowItem *X11Window::createItem(Scene *scene)
|
||||
std::unique_ptr<WindowItem> X11Window::createItem(Scene *scene)
|
||||
{
|
||||
return new WindowItemX11(this, scene);
|
||||
return std::make_unique<WindowItemX11>(this, scene);
|
||||
}
|
||||
|
||||
// Use destroyWindow() or releaseWindow(), Client instances cannot be deleted directly
|
||||
|
|
|
@ -357,7 +357,7 @@ protected:
|
|||
QSizeF resizeIncrements() const override;
|
||||
bool acceptsFocus() const override;
|
||||
void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) override;
|
||||
WindowItem *createItem(Scene *scene) override;
|
||||
std::unique_ptr<WindowItem> createItem(Scene *scene) override;
|
||||
|
||||
// Signals for the scripting interface
|
||||
// Signals make an excellent way for communication
|
||||
|
|
Loading…
Reference in a new issue