16#include <KDecoration2/Decoration>
23static const QByteArray s_skipClosePropertyName = QByteArrayLiteral(
"KWIN_SKIP_CLOSE_ANIMATION");
24static const QByteArray s_shadowEnabledPropertyName = QByteArrayLiteral(
"kwin_shadow_enabled");
31 , m_internalWindowFlags(handle->flags())
33 connect(m_handle, &QWindow::xChanged,
this, &InternalWindow::updateInternalWindowGeometry);
34 connect(m_handle, &QWindow::yChanged,
this, &InternalWindow::updateInternalWindowGeometry);
35 connect(m_handle, &QWindow::widthChanged,
this, &InternalWindow::updateInternalWindowGeometry);
36 connect(m_handle, &QWindow::heightChanged,
this, &InternalWindow::updateInternalWindowGeometry);
37 connect(m_handle, &QWindow::windowTitleChanged,
this, &InternalWindow::setCaption);
41 setCaption(m_handle->title());
42 setIcon(QIcon::fromTheme(QStringLiteral(
"kwin")));
50 commitGeometry(m_handle->geometry());
52 updateDecoration(
true);
54 m_handle->installEventFilter(
this);
63 return std::make_unique<WindowItemInternal>(
this, scene);
77 const QRegion mask = m_handle->mask();
78 if (!mask.isEmpty() && !mask.contains(
mapToLocal(point).toPoint())) {
80 }
else if (m_handle->property(
"outputOnly").toBool()) {
91 QEnterEvent enterEvent(
pos(),
pos(), globalPos);
92 QCoreApplication::sendEvent(m_handle, &enterEvent);
102 QEvent event(QEvent::Leave);
103 QCoreApplication::sendEvent(m_handle, &event);
108 if (watched == m_handle && event->type() == QEvent::DynamicPropertyChange) {
109 QDynamicPropertyChangeEvent *pe =
static_cast<QDynamicPropertyChangeEvent *
>(event);
110 if (pe->propertyName() == s_skipClosePropertyName) {
113 if (pe->propertyName() == s_shadowEnabledPropertyName) {
123 return m_handle->devicePixelRatio();
130 return m_captionNormal;
135 return m_captionSuffix;
140 return m_handle->minimumSize();
145 return m_handle->maximumSize();
163 return m_internalWindowFlags.testFlag(Qt::Popup);
185 return !m_internalWindowFlags.testFlag(Qt::BypassWindowManagerHint) && !m_internalWindowFlags.testFlag(Qt::Popup);
190 return !m_internalWindowFlags.testFlag(Qt::BypassWindowManagerHint) && !m_internalWindowFlags.testFlag(Qt::Popup);
200 return !m_internalWindowFlags.testFlag(Qt::BypassWindowManagerHint) && !m_internalWindowFlags.testFlag(Qt::Popup);
205 return m_userNoBorder || m_internalWindowFlags.testFlag(Qt::FramelessWindowHint) || m_internalWindowFlags.testFlag(Qt::Popup);
210 return !m_internalWindowFlags.testFlag(Qt::FramelessWindowHint) || m_internalWindowFlags.testFlag(Qt::Popup);
226 return m_handle->property(
"org_kde_ksld_emergency").toBool();
234 return m_handle->property(
"__kwin_outline").toBool();
257 commitGeometry(
rect);
259 requestGeometry(
rect);
278 if (m_userNoBorder == set) {
281 m_userNoBorder = set;
282 updateDecoration(
true);
285void InternalWindow::createDecoration(
const QRectF &oldGeometry)
291void InternalWindow::destroyDecoration()
298void InternalWindow::updateDecoration(
bool check_workspace_pos,
bool force)
312 createDecoration(oldFrameGeometry);
319 if (check_workspace_pos) {
326 updateDecoration(
true,
true);
331 m_handle->removeEventFilter(
this);
332 m_handle->disconnect(
this);
350 return !m_handle->flags().testFlag(Qt::WindowTransparentForInput) && m_handle->flags().testFlag(Qt::Popup) && !m_handle->flags().testFlag(Qt::ToolTip);
360 return m_graphicsBufferRef.
buffer();
365 return m_graphicsBufferOrigin;
376 commitGeometry(geometry);
379 m_graphicsBufferRef = frame.
buffer;
397 const InternalWindow *otherInternal = qobject_cast<const InternalWindow *>(other);
398 if (!otherInternal) {
401 if (otherInternal ==
this) {
415 if (m_captionSuffix != suffix) {
416 m_captionSuffix = suffix;
421void InternalWindow::requestGeometry(
const QRectF &rect)
428void InternalWindow::commitGeometry(
const QRectF &rect)
446 syncGeometryToInternalWindow();
460void InternalWindow::setCaption(
const QString &caption)
462 if (m_captionNormal ==
caption) {
471void InternalWindow::markAsMapped()
480void InternalWindow::syncGeometryToInternalWindow()
486 QTimer::singleShot(0,
this, [
this] {
491void InternalWindow::updateInternalWindowGeometry()
496 commitGeometry(
rect);
502#include "moc_internalwindow.cpp"
virtual QSize size() const =0
GraphicsBuffer * buffer() const
bool isLockScreen() const override
bool isResizable() const override
void doInteractiveResizeSync(const QRectF &rect) override
void killWindow() override
void pointerLeaveEvent() override
void popupDone() override
void invalidateDecoration() override
bool eventFilter(QObject *watched, QEvent *event) override
bool isPlaceable() const override
~InternalWindow() override
void destroyWindow() override
bool isClient() const override
bool isMovableAcrossScreens() const override
bool hasPopupGrab() const override
bool isCloseable() const override
void updateCaption() override
void setNoBorder(bool set) override
bool isOutline() const override
bool belongsToSameApplication(const Window *other, SameApplicationChecks checks) const override
void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) override
bool takeFocus() override
bool acceptsFocus() const override
NET::WindowType windowType() const override
QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &size) override
QString windowRole() const override
InternalWindow(QWindow *handle)
bool isMovable() const override
QSizeF minSize() const override
bool noBorder() const override
GraphicsBufferOrigin graphicsBufferOrigin() const
Window * findModal(bool allow_itself=false) override
GraphicsBuffer * graphicsBuffer() const
void pointerEnterEvent(const QPointF &globalPos) override
QSizeF maxSize() const override
bool userCanSetNoBorder() const override
QString captionSuffix() const override
bool wantsInput() const override
bool isInternal() const override
void present(const InternalWindowFrame &frame)
QString captionNormal() const override
qreal bufferScale() const
bool isPopupWindow() const override
std::unique_ptr< WindowItem > createItem(Scene *scene) override
bool hitTest(const QPointF &point) const override
void closeWindow() override
void addDamage(const QRegion ®ion)
void setOpacity(qreal opacity)
virtual QSizeF clientSizeToFrameSize(const QSizeF &size) const
void frameGeometryAboutToChange()
QPointF mapToLocal(const QPointF &point) const
QString shortcutCaptionSuffix() const
void moveResize(const QRectF &rect)
friend class GeometryUpdatesBlocker
void setDecoration(std::shared_ptr< KDecoration2::Decoration > decoration)
bool isInteractiveMoveResize() const
SurfaceItem * surfaceItem() const
virtual void pointerEnterEvent(const QPointF &globalPos)
virtual bool isPopupWindow() const
QRectF frameRectToClientRect(const QRectF &rect) const
void setOnAllDesktops(bool set)
void clientGeometryChanged(const QRectF &oldGeometry)
QSizeF clientSize() const
bool isInteractiveResize() const
void interactiveMoveResizeFinished()
virtual void pointerLeaveEvent()
QRectF clientRectToFrameRect(const QRectF &rect) const
virtual bool setupCompositing()
virtual void leaveInteractiveMoveResize()
QRectF moveResizeGeometry() const
void bufferGeometryChanged(const QRectF &oldGeometry)
void setMoveResizeGeometry(const QRectF &geo)
void setReadyForPainting()
void checkWorkspacePosition(QRectF oldGeometry=QRectF(), const VirtualDesktop *oldDesktop=nullptr)
void frameGeometryChanged(const QRectF &oldGeometry)
void captionNormalChanged()
void setIcon(const QIcon &icon)
virtual bool hitTest(const QPointF &point) const
void setSkipCloseAnimation(bool set)
bool areGeometryUpdatesBlocked() const
void setPendingMoveResizeMode(MoveResizeMode mode)
virtual QSizeF frameSizeToClientSize(const QSizeF &size) const
Gravity interactiveMoveResizeGravity() const
QRectF clientArea(clientAreaOption, const Output *output, const VirtualDesktop *desktop) const
void addInternalWindow(InternalWindow *window)
static Workspace * self()
void removeInternalWindow(InternalWindow *window)
Output * outputAt(const QPointF &pos) const
QRectF gravitateGeometry(const QRectF &rect, const QRectF &bounds, Gravity gravity)
GraphicsBufferOrigin bufferOrigin