2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_LIB_KWINGLOBALS_H
|
|
|
|
#define KWIN_LIB_KWINGLOBALS_H
|
|
|
|
|
2015-02-19 08:59:21 +00:00
|
|
|
#include <QCoreApplication>
|
2016-10-17 14:12:21 +00:00
|
|
|
#include <QImage>
|
|
|
|
#include <QPoint>
|
2015-02-19 08:59:21 +00:00
|
|
|
#include <QVariant>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-12-06 07:37:16 +00:00
|
|
|
#include <kwin_export.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-02-26 07:14:17 +00:00
|
|
|
#include <xcb/xcb.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-12-17 14:14:53 +00:00
|
|
|
#include <kwinconfig.h>
|
|
|
|
|
2013-07-22 14:15:42 +00:00
|
|
|
#define KWIN_QT5_PORTING 0
|
2008-01-16 18:13:24 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2019-11-01 17:14:55 +00:00
|
|
|
KWIN_EXPORT Q_NAMESPACE
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
enum CompositingType {
|
2007-04-29 17:35:43 +00:00
|
|
|
NoCompositing = 0,
|
2012-09-20 09:33:32 +00:00
|
|
|
/**
|
|
|
|
* Used as a flag whether OpenGL based compositing is used.
|
|
|
|
* The flag is or-ed to the enum values of the specific OpenGL types.
|
2014-02-25 10:02:32 +00:00
|
|
|
* The actual Compositors use the or @c OpenGL2Compositing
|
2012-09-20 09:33:32 +00:00
|
|
|
* flags. If you need to know whether OpenGL is used, either and the flag or
|
|
|
|
* use EffectsHandler::isOpenGLCompositing().
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-09-20 09:33:32 +00:00
|
|
|
OpenGLCompositing = 1,
|
|
|
|
XRenderCompositing = 1<<1,
|
2013-06-21 08:03:31 +00:00
|
|
|
QPainterCompositing = 1<< 2,
|
2012-09-20 09:33:32 +00:00
|
|
|
OpenGL2Compositing = 1<<3 | OpenGLCompositing
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
2012-09-29 11:19:35 +00:00
|
|
|
enum OpenGLPlatformInterface {
|
|
|
|
NoOpenGLPlatformInterface = 0,
|
|
|
|
GlxPlatformInterface,
|
|
|
|
EglPlatformInterface
|
|
|
|
};
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
enum clientAreaOption {
|
2007-04-29 17:35:43 +00:00
|
|
|
PlacementArea, // geometry where a window will be initially placed after being mapped
|
|
|
|
MovementArea, // ??? window movement snapping area? ignore struts
|
|
|
|
MaximizeArea, // geometry to which a window will be maximized
|
|
|
|
MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu
|
|
|
|
FullScreenArea, // area for fullscreen windows
|
|
|
|
// these below don't depend on xinerama settings
|
|
|
|
WorkArea, // whole workarea (all screens together)
|
|
|
|
FullArea, // whole area (all screens together), ignore struts
|
|
|
|
ScreenArea // one whole screen, ignore struts
|
|
|
|
};
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
enum ElectricBorder {
|
2007-04-29 17:35:43 +00:00
|
|
|
ElectricTop,
|
|
|
|
ElectricTopRight,
|
|
|
|
ElectricRight,
|
|
|
|
ElectricBottomRight,
|
|
|
|
ElectricBottom,
|
|
|
|
ElectricBottomLeft,
|
|
|
|
ElectricLeft,
|
|
|
|
ElectricTopLeft,
|
|
|
|
ELECTRIC_COUNT,
|
|
|
|
ElectricNone
|
|
|
|
};
|
|
|
|
|
2009-02-28 08:33:16 +00:00
|
|
|
// TODO: Hardcoding is bad, need to add some way of registering global actions to these.
|
|
|
|
// When designing the new system we must keep in mind that we have conditional actions
|
|
|
|
// such as "only when moving windows" desktop switching that the current global action
|
|
|
|
// system doesn't support.
|
2011-01-30 14:34:42 +00:00
|
|
|
enum ElectricBorderAction {
|
2009-02-28 08:33:16 +00:00
|
|
|
ElectricActionNone, // No special action, not set, desktop switch or an effect
|
2009-06-28 20:32:50 +00:00
|
|
|
ElectricActionShowDesktop, // Show desktop or restore
|
2010-03-10 22:25:20 +00:00
|
|
|
ElectricActionLockScreen, // Lock screen
|
2016-04-07 19:07:41 +00:00
|
|
|
ElectricActionKRunner, // Open KRunner
|
|
|
|
ElectricActionActivityManager, // Activity Manager
|
2016-08-10 13:07:54 +00:00
|
|
|
ElectricActionApplicationLauncher, // Application Launcher
|
2009-02-28 08:33:16 +00:00
|
|
|
ELECTRIC_ACTION_COUNT
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// DesktopMode and WindowsMode are based on the order in which the desktop
|
|
|
|
// or window were viewed.
|
|
|
|
// DesktopListMode lists them in the order created.
|
2011-01-30 14:34:42 +00:00
|
|
|
enum TabBoxMode {
|
2012-04-25 20:57:48 +00:00
|
|
|
TabBoxDesktopMode, // Focus chain of desktops
|
|
|
|
TabBoxDesktopListMode, // Static desktop order
|
|
|
|
TabBoxWindowsMode, // Primary window switching mode
|
|
|
|
TabBoxWindowsAlternativeMode, // Secondary window switching mode
|
|
|
|
TabBoxCurrentAppWindowsMode, // Same as primary window switching mode but only for windows of current application
|
2012-06-06 22:38:13 +00:00
|
|
|
TabBoxCurrentAppWindowsAlternativeMode // Same as secondary switching mode but only for windows of current application
|
2009-09-13 11:36:45 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-04-25 15:04:04 +00:00
|
|
|
enum KWinOption {
|
2013-01-30 12:36:37 +00:00
|
|
|
CloseButtonCorner,
|
|
|
|
SwitchDesktopOnScreenEdge,
|
|
|
|
SwitchDesktopOnScreenEdgeMovingWindows
|
2011-04-25 15:04:04 +00:00
|
|
|
};
|
|
|
|
|
2013-07-15 09:26:56 +00:00
|
|
|
/**
|
|
|
|
* @brief The direction in which a pointer axis is moved.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-15 09:26:56 +00:00
|
|
|
enum PointerAxisDirection {
|
|
|
|
PointerAxisUp,
|
|
|
|
PointerAxisDown,
|
|
|
|
PointerAxisLeft,
|
|
|
|
PointerAxisRight
|
|
|
|
};
|
|
|
|
|
2017-03-18 10:00:30 +00:00
|
|
|
/**
|
|
|
|
* @brief Directions for swipe gestures
|
|
|
|
* @since 5.10
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-03-18 10:00:30 +00:00
|
|
|
enum class SwipeDirection {
|
|
|
|
Invalid,
|
|
|
|
Down,
|
|
|
|
Left,
|
|
|
|
Up,
|
|
|
|
Right
|
|
|
|
};
|
|
|
|
|
2019-10-31 16:16:53 +00:00
|
|
|
/**
|
|
|
|
* Represents the state of the session running outside kwin
|
|
|
|
* Under Plasma this is managed by ksmserver
|
|
|
|
*/
|
|
|
|
enum class SessionState {
|
|
|
|
Normal,
|
|
|
|
Saving,
|
|
|
|
Quitting
|
|
|
|
};
|
2019-11-01 17:14:55 +00:00
|
|
|
Q_ENUM_NS(SessionState)
|
2019-10-31 16:16:53 +00:00
|
|
|
|
2012-03-26 15:14:04 +00:00
|
|
|
inline
|
|
|
|
KWIN_EXPORT xcb_connection_t *connection()
|
|
|
|
{
|
2020-07-20 08:07:08 +00:00
|
|
|
return reinterpret_cast<xcb_connection_t*>(qApp->property("x11Connection").value<void*>());
|
2012-03-26 15:14:04 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
2013-02-26 07:14:17 +00:00
|
|
|
KWIN_EXPORT xcb_window_t rootWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-07-20 08:07:08 +00:00
|
|
|
return qApp->property("x11RootWindow").value<quint32>();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
inline
|
2013-02-26 07:14:17 +00:00
|
|
|
KWIN_EXPORT xcb_timestamp_t xTime()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-02-19 08:59:21 +00:00
|
|
|
return qApp->property("x11Time").value<xcb_timestamp_t>();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2016-10-17 14:12:21 +00:00
|
|
|
/**
|
|
|
|
* Short wrapper for a cursor image provided by the Platform.
|
|
|
|
* @since 5.9
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-17 14:12:21 +00:00
|
|
|
class PlatformCursorImage {
|
|
|
|
public:
|
|
|
|
explicit PlatformCursorImage()
|
|
|
|
: m_image()
|
|
|
|
, m_hotSpot()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
explicit PlatformCursorImage(const QImage &image, const QPoint &hotSpot)
|
|
|
|
: m_image(image)
|
|
|
|
, m_hotSpot(hotSpot)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual ~PlatformCursorImage() = default;
|
|
|
|
|
2020-05-18 19:37:41 +00:00
|
|
|
bool isNull() const {
|
|
|
|
return m_image.isNull();
|
|
|
|
}
|
2016-10-17 14:12:21 +00:00
|
|
|
QImage image() const {
|
|
|
|
return m_image;
|
|
|
|
}
|
|
|
|
QPoint hotSpot() const {
|
|
|
|
return m_hotSpot;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QImage m_image;
|
|
|
|
QPoint m_hotSpot;
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
Q_DECLARE_METATYPE(std::chrono::nanoseconds)
|
|
|
|
|
2013-04-05 07:41:25 +00:00
|
|
|
#define KWIN_SINGLETON_VARIABLE(ClassName, variableName) \
|
|
|
|
public: \
|
2014-01-08 10:43:02 +00:00
|
|
|
static ClassName *create(QObject *parent = nullptr);\
|
2013-04-05 07:41:25 +00:00
|
|
|
static ClassName *self() { return variableName; }\
|
|
|
|
protected: \
|
2014-01-08 10:43:02 +00:00
|
|
|
explicit ClassName(QObject *parent = nullptr); \
|
2013-04-05 07:41:25 +00:00
|
|
|
private: \
|
|
|
|
static ClassName *variableName;
|
|
|
|
|
|
|
|
#define KWIN_SINGLETON(ClassName) KWIN_SINGLETON_VARIABLE(ClassName, s_self)
|
|
|
|
|
|
|
|
#define KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, variableName) \
|
2014-01-08 10:43:02 +00:00
|
|
|
ClassName *ClassName::variableName = nullptr; \
|
2013-04-05 07:41:25 +00:00
|
|
|
ClassName *ClassName::create(QObject *parent) \
|
|
|
|
{ \
|
|
|
|
Q_ASSERT(!variableName); \
|
|
|
|
variableName = new FactoredClassName(parent); \
|
|
|
|
return variableName; \
|
|
|
|
}
|
|
|
|
#define KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, variableName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, ClassName, variableName)
|
|
|
|
#define KWIN_SINGLETON_FACTORY_FACTORED(ClassName, FactoredClassName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, s_self)
|
|
|
|
#define KWIN_SINGLETON_FACTORY(ClassName) KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, s_self)
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|