File indexing completed on 2024-05-19 05:32:28

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
0006     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 // cmake stuff
0014 #include "config-kwin.h"
0015 // kwin
0016 #include "effect/globals.h"
0017 #include "utils/version.h"
0018 // Qt
0019 #include <QList>
0020 #include <QLoggingCategory>
0021 #include <QMatrix4x4>
0022 #include <QPoint>
0023 #include <QRect>
0024 // system
0025 #include <climits>
0026 Q_DECLARE_LOGGING_CATEGORY(KWIN_CORE)
0027 Q_DECLARE_LOGGING_CATEGORY(KWIN_OPENGL)
0028 Q_DECLARE_LOGGING_CATEGORY(KWIN_QPAINTER)
0029 Q_DECLARE_LOGGING_CATEGORY(KWIN_VIRTUALKEYBOARD)
0030 namespace KWin
0031 {
0032 
0033 const QPoint invalidPoint(INT_MIN, INT_MIN);
0034 
0035 enum StrutArea {
0036     StrutAreaInvalid = 0, // Null
0037     StrutAreaTop = 1 << 0,
0038     StrutAreaRight = 1 << 1,
0039     StrutAreaBottom = 1 << 2,
0040     StrutAreaLeft = 1 << 3,
0041     StrutAreaAll = StrutAreaTop | StrutAreaRight | StrutAreaBottom | StrutAreaLeft,
0042 };
0043 Q_DECLARE_FLAGS(StrutAreas, StrutArea)
0044 
0045 class KWIN_EXPORT StrutRect : public QRect
0046 {
0047 public:
0048     explicit StrutRect(QRect rect = QRect(), StrutArea area = StrutAreaInvalid);
0049     StrutRect(int x, int y, int width, int height, StrutArea area = StrutAreaInvalid);
0050     StrutRect(const StrutRect &other);
0051     StrutRect &operator=(const StrutRect &other);
0052     inline StrutArea area() const
0053     {
0054         return m_area;
0055     }
0056 
0057 private:
0058     StrutArea m_area;
0059 };
0060 typedef QList<StrutRect> StrutRects;
0061 
0062 enum ShadeMode {
0063     ShadeNone, // not shaded
0064     ShadeNormal, // normally shaded - isShade() is true only here
0065     ShadeHover, // "shaded", but visible due to hover unshade
0066     ShadeActivated // "shaded", but visible due to alt+tab to the window
0067 };
0068 
0069 /**
0070  * Maximize mode. These values specify how a window is maximized.
0071  *
0072  * @note these values are written to session files, don't change the order
0073  */
0074 enum MaximizeMode {
0075     MaximizeRestore = 0, ///< The window is not maximized in any direction.
0076     MaximizeVertical = 1, ///< The window is maximized vertically.
0077     MaximizeHorizontal = 2, ///< The window is maximized horizontally.
0078     /// Equal to @p MaximizeVertical | @p MaximizeHorizontal
0079     MaximizeFull = MaximizeVertical | MaximizeHorizontal,
0080 };
0081 
0082 inline MaximizeMode operator^(MaximizeMode m1, MaximizeMode m2)
0083 {
0084     return MaximizeMode(int(m1) ^ int(m2));
0085 }
0086 
0087 // converting between X11 mouse/keyboard state mask and Qt button/keyboard states
0088 Qt::MouseButton x11ToQtMouseButton(int button);
0089 Qt::MouseButton KWIN_EXPORT x11ToQtMouseButton(int button);
0090 Qt::MouseButtons KWIN_EXPORT x11ToQtMouseButtons(int state);
0091 Qt::KeyboardModifiers KWIN_EXPORT x11ToQtKeyboardModifiers(int state);
0092 
0093 KWIN_EXPORT QPointF popupOffset(const QRectF &anchorRect, const Qt::Edges anchorEdge, const Qt::Edges gravity, const QSizeF popupSize);
0094 KWIN_EXPORT QRectF gravitateGeometry(const QRectF &rect, const QRectF &bounds, Gravity gravity);
0095 
0096 } // namespace
0097 
0098 // Must be outside namespace
0099 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::StrutAreas)
0100 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::QuickTileMode)