File indexing completed on 2024-04-28 16:49:39

0001 /*
0002  *   SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *   SPDX-FileCopyrightText: 2018 Drew DeVault <sir@cmpwn.com>
0004  *
0005  *   SPDX-License-Identifier: LGPL-3.0-or-later
0006  */
0007 
0008 #ifndef LAYERSHELLQTWINDOW_H
0009 #define LAYERSHELLQTWINDOW_H
0010 
0011 #include <QObject>
0012 #include <QScreen>
0013 #include <QWindow>
0014 
0015 #include "layershellqt_export.h"
0016 
0017 namespace LayerShellQt
0018 {
0019 class WindowPrivate;
0020 
0021 class LAYERSHELLQT_EXPORT Window : public QObject
0022 {
0023     Q_OBJECT
0024 public:
0025     ~Window() override;
0026 
0027     enum Anchor {
0028         AnchorTop = 1, ///< The top edge of the anchor rectangle
0029         AnchorBottom = 2, ///< The bottom edge of the anchor rectangle
0030         AnchorLeft = 4, ///< The left edge of the anchor rectangle
0031         AnchorRight = 8, ///< The right edge of the anchor rectangle
0032     };
0033     Q_ENUM(Anchor);
0034     Q_DECLARE_FLAGS(Anchors, Anchor)
0035 
0036     /**
0037      * This enum type is used to specify the layer where a surface can be put in.
0038      */
0039     enum Layer {
0040         LayerBackground = 0,
0041         LayerBottom = 1,
0042         LayerTop = 2,
0043         LayerOverlay = 3,
0044     };
0045     Q_ENUM(Layer)
0046 
0047     /**
0048      * This enum type is used to specify how the layer surface handles keyboard focus.
0049      */
0050     enum KeyboardInteractivity {
0051         KeyboardInteractivityNone = 0,
0052         KeyboardInteractivityExclusive = 1,
0053         KeyboardInteractivityOnDemand = 2,
0054     };
0055     Q_ENUM(KeyboardInteractivity)
0056 
0057     void setAnchors(Anchors anchor);
0058     Anchors anchors() const;
0059 
0060     void setExclusiveZone(int32_t zone);
0061     int32_t exclusionZone() const;
0062 
0063     void setMargins(const QMargins &margins);
0064     QMargins margins() const;
0065 
0066     void setKeyboardInteractivity(KeyboardInteractivity interactivity);
0067     KeyboardInteractivity keyboardInteractivity() const;
0068 
0069     void setLayer(Layer layer);
0070     Layer layer() const;
0071 
0072     /**
0073      * If set, the compositor will try to put the window on the given screen.
0074      * If its not set, then the compositor will decide where to put the window.
0075      * Under normal circumstances, this should be the active output.
0076      */
0077     void setDesiredOutput(QScreen *output);
0078     QScreen *desiredOutput() const;
0079 
0080     /**
0081      * Sets a string based identifier for this window.
0082      * This may be used by a compositor to determine stacking
0083      * order within a given layer.
0084      *
0085      * May also be referred to as a role
0086      */
0087     void setScope(const QString &scope);
0088     QString scope() const;
0089 
0090     /**
0091      * Gets the LayerShell Window for a given Qt Window
0092      * Ownership is not transferred
0093      */
0094     static Window *get(QWindow *window);
0095 
0096 Q_SIGNALS:
0097     void anchorsChanged();
0098     void exclusionZoneChanged();
0099     void marginsChanged();
0100     void keyboardInteractivityChanged();
0101     void layerChanged();
0102 
0103 private:
0104     Window(QWindow *window);
0105     QScopedPointer<WindowPrivate> d;
0106 };
0107 
0108 }
0109 
0110 #endif