File indexing completed on 2024-04-28 05:30:21

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2019 Martin Flöser <mgraesslin@kde.org>
0006     SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 #pragma once
0011 
0012 #include "core/graphicsbuffer.h"
0013 #include "window.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 struct InternalWindowFrame
0019 {
0020     GraphicsBuffer *buffer = nullptr;
0021     QRegion bufferDamage;
0022     GraphicsBufferOrigin bufferOrigin = GraphicsBufferOrigin::TopLeft;
0023 };
0024 
0025 class KWIN_EXPORT InternalWindow : public Window
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit InternalWindow(QWindow *handle);
0031     ~InternalWindow() override;
0032 
0033     bool eventFilter(QObject *watched, QEvent *event) override;
0034 
0035     QString captionNormal() const override;
0036     QString captionSuffix() const override;
0037     QSizeF minSize() const override;
0038     QSizeF maxSize() const override;
0039     NET::WindowType windowType() const override;
0040     void killWindow() override;
0041     bool isClient() const override;
0042     bool isPopupWindow() const override;
0043     QString windowRole() const override;
0044     void closeWindow() override;
0045     bool isCloseable() const override;
0046     bool isMovable() const override;
0047     bool isMovableAcrossScreens() const override;
0048     bool isResizable() const override;
0049     bool isPlaceable() const override;
0050     bool noBorder() const override;
0051     bool userCanSetNoBorder() const override;
0052     bool wantsInput() const override;
0053     bool isInternal() const override;
0054     bool isLockScreen() const override;
0055     bool isOutline() const override;
0056     QRectF resizeWithChecks(const QRectF &geometry, const QSizeF &size) override;
0057     Window *findModal(bool allow_itself = false) override;
0058     bool takeFocus() override;
0059     void setNoBorder(bool set) override;
0060     void invalidateDecoration() override;
0061     void destroyWindow() override;
0062     bool hasPopupGrab() const override;
0063     void popupDone() override;
0064     bool hitTest(const QPointF &point) const override;
0065     void pointerEnterEvent(const QPointF &globalPos) override;
0066     void pointerLeaveEvent() override;
0067 
0068     GraphicsBuffer *graphicsBuffer() const;
0069     GraphicsBufferOrigin graphicsBufferOrigin() const;
0070 
0071     void present(const InternalWindowFrame &frame);
0072     qreal bufferScale() const;
0073     QWindow *handle() const;
0074 
0075 protected:
0076     bool acceptsFocus() const override;
0077     bool belongsToSameApplication(const Window *other, SameApplicationChecks checks) const override;
0078     void doInteractiveResizeSync(const QRectF &rect) override;
0079     void updateCaption() override;
0080     void moveResizeInternal(const QRectF &rect, MoveResizeMode mode) override;
0081     std::unique_ptr<WindowItem> createItem(Scene *scene) override;
0082 
0083 private:
0084     void requestGeometry(const QRectF &rect);
0085     void commitGeometry(const QRectF &rect);
0086     void setCaption(const QString &caption);
0087     void markAsMapped();
0088     void syncGeometryToInternalWindow();
0089     void updateInternalWindowGeometry();
0090     void updateDecoration(bool check_workspace_pos, bool force = false);
0091     void createDecoration(const QRectF &oldGeometry);
0092     void destroyDecoration();
0093 
0094     QWindow *m_handle = nullptr;
0095     QString m_captionNormal;
0096     QString m_captionSuffix;
0097     Qt::WindowFlags m_internalWindowFlags = Qt::WindowFlags();
0098     bool m_userNoBorder = false;
0099     GraphicsBufferRef m_graphicsBufferRef;
0100     GraphicsBufferOrigin m_graphicsBufferOrigin;
0101 
0102     Q_DISABLE_COPY(InternalWindow)
0103 };
0104 
0105 }