kwin/libkwineffects/kwinglobals.h

218 lines
6.1 KiB
C
Raw Normal View History

2020-08-03 01:22:19 +03:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
2020-08-03 01:22:19 +03:00
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
2020-08-03 01:22:19 +03:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_LIB_KWINGLOBALS_H
#define KWIN_LIB_KWINGLOBALS_H
#include <QCoreApplication>
#include <QImage>
#include <QPoint>
#include <QVariant>
#include <kwin_export.h>
#include <xcb/xcb.h>
#include <kwinconfig.h>
#define KWIN_QT5_PORTING 0
namespace KWin
{
KWIN_EXPORT Q_NAMESPACE
2011-01-30 17:34:42 +03:00
enum CompositingType {
NoCompositing = 0,
/**
* Used as a flag whether OpenGL based compositing is used.
* The flag is or-ed to the enum values of the specific OpenGL types.
* The actual Compositors use the or @c OpenGL2Compositing
* flags. If you need to know whether OpenGL is used, either and the flag or
* use EffectsHandler::isOpenGLCompositing().
*/
OpenGLCompositing = 1,
XRenderCompositing = 1<<1,
QPainterCompositing = 1<< 2,
OpenGL2Compositing = 1<<3 | OpenGLCompositing
};
enum OpenGLPlatformInterface {
NoOpenGLPlatformInterface = 0,
GlxPlatformInterface,
EglPlatformInterface
};
2011-01-30 17:34:42 +03:00
enum clientAreaOption {
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 17:34:42 +03:00
enum ElectricBorder {
ElectricTop,
ElectricTopRight,
ElectricRight,
ElectricBottomRight,
ElectricBottom,
ElectricBottomLeft,
ElectricLeft,
ElectricTopLeft,
ELECTRIC_COUNT,
ElectricNone
};
// 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 17:34:42 +03:00
enum ElectricBorderAction {
ElectricActionNone, // No special action, not set, desktop switch or an effect
ElectricActionShowDesktop, // Show desktop or restore
ElectricActionLockScreen, // Lock screen
ElectricActionKRunner, // Open KRunner
ElectricActionActivityManager, // Activity Manager
ElectricActionApplicationLauncher, // Application Launcher
ELECTRIC_ACTION_COUNT
};
// 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 17:34:42 +03:00
enum TabBoxMode {
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-07 02:38:13 +04:00
TabBoxCurrentAppWindowsAlternativeMode // Same as secondary switching mode but only for windows of current application
};
enum KWinOption {
CloseButtonCorner,
SwitchDesktopOnScreenEdge,
SwitchDesktopOnScreenEdgeMovingWindows
};
/**
* @brief The direction in which a pointer axis is moved.
*/
enum PointerAxisDirection {
PointerAxisUp,
PointerAxisDown,
PointerAxisLeft,
PointerAxisRight
};
Add support for global touchpad swipe gestures Summary: This change adds global touchpad swipe gestures to the GlobalShortcutsManager and hooks up the swipe gestures as defined at the Plasma Affenfels sprint: * swipe up: Desktop Grid * swipe down: Present Windows * swipe left: previous virtual desktop * swipe right: next virtual desktop The main work is handled by two new classes: SwipeGesture and GestureRecognizer. This is implemented in a way that it can be extended to also recognize touch screen gestures and pinch gestures. The SwipeGesture defines what is required for the gesture to trigger. Currently this includes the minimum and maximum number of fingers participating in the gesture and the direction. The gesture gets registered in the GestureRecognizer. The events for the gesture are fed into the GestureRecognizer. It evaluates which gestures could trigger and tracks them for every update of the gesture. In the process of the gesture tracking the GestureRecognizer emits signals on the Gesture: * started: when the Gesture gets considered for a sequence * cancelled: the Gesture no longer matches the sequence * triggered: the sequence ended and the Gesture still matches The remaining changes are related to hook up the existing shortcut framework with the new touchpad gestures. The GlobalShortcutManager gained support for it, InputRedirection and EffectsHandler offer methods to register a QAction. VirtualDesktopManager, PresentWindows and DesktopGrid are adjusted to support the gesture. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel Tags: #plasma_on_wayland Differential Revision: https://phabricator.kde.org/D5097
2017-03-18 13:00:30 +03:00
/**
* @brief Directions for swipe gestures
* @since 5.10
*/
Add support for global touchpad swipe gestures Summary: This change adds global touchpad swipe gestures to the GlobalShortcutsManager and hooks up the swipe gestures as defined at the Plasma Affenfels sprint: * swipe up: Desktop Grid * swipe down: Present Windows * swipe left: previous virtual desktop * swipe right: next virtual desktop The main work is handled by two new classes: SwipeGesture and GestureRecognizer. This is implemented in a way that it can be extended to also recognize touch screen gestures and pinch gestures. The SwipeGesture defines what is required for the gesture to trigger. Currently this includes the minimum and maximum number of fingers participating in the gesture and the direction. The gesture gets registered in the GestureRecognizer. The events for the gesture are fed into the GestureRecognizer. It evaluates which gestures could trigger and tracks them for every update of the gesture. In the process of the gesture tracking the GestureRecognizer emits signals on the Gesture: * started: when the Gesture gets considered for a sequence * cancelled: the Gesture no longer matches the sequence * triggered: the sequence ended and the Gesture still matches The remaining changes are related to hook up the existing shortcut framework with the new touchpad gestures. The GlobalShortcutManager gained support for it, InputRedirection and EffectsHandler offer methods to register a QAction. VirtualDesktopManager, PresentWindows and DesktopGrid are adjusted to support the gesture. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel Tags: #plasma_on_wayland Differential Revision: https://phabricator.kde.org/D5097
2017-03-18 13:00:30 +03:00
enum class SwipeDirection {
Invalid,
Down,
Left,
Up,
Right
};
/**
* Represents the state of the session running outside kwin
* Under Plasma this is managed by ksmserver
*/
enum class SessionState {
Normal,
Saving,
Quitting
};
Q_ENUM_NS(SessionState)
inline
KWIN_EXPORT xcb_connection_t *connection()
{
return reinterpret_cast<xcb_connection_t*>(qApp->property("x11Connection").value<void*>());
}
inline
KWIN_EXPORT xcb_window_t rootWindow()
2011-01-30 17:34:42 +03:00
{
return qApp->property("x11RootWindow").value<quint32>();
2011-01-30 17:34:42 +03:00
}
inline
KWIN_EXPORT xcb_timestamp_t xTime()
2011-01-30 17:34:42 +03:00
{
return qApp->property("x11Time").value<xcb_timestamp_t>();
2011-01-30 17:34:42 +03:00
}
/**
* Short wrapper for a cursor image provided by the Platform.
* @since 5.9
*/
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;
bool isNull() const {
return m_image.isNull();
}
QImage image() const {
return m_image;
}
QPoint hotSpot() const {
return m_hotSpot;
}
private:
QImage m_image;
QPoint m_hotSpot;
};
} // namespace
#define KWIN_SINGLETON_VARIABLE(ClassName, variableName) \
public: \
static ClassName *create(QObject *parent = nullptr);\
static ClassName *self() { return variableName; }\
protected: \
explicit ClassName(QObject *parent = nullptr); \
private: \
static ClassName *variableName;
#define KWIN_SINGLETON(ClassName) KWIN_SINGLETON_VARIABLE(ClassName, s_self)
#define KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, variableName) \
ClassName *ClassName::variableName = nullptr; \
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)
#endif