2011-06-23 10:09:17 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
|
2013-01-21 08:04:06 +00:00
|
|
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
2011-06-23 10:09:17 +00:00
|
|
|
|
|
|
|
Since the functionality provided in this class has been moved from
|
|
|
|
class Workspace, it is not clear who exactly has written the code.
|
|
|
|
The list below contains the copyright holders of the class Workspace.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_SCREENEDGE_H
|
|
|
|
#define KWIN_SCREENEDGE_H
|
2013-01-21 08:04:06 +00:00
|
|
|
// KWin
|
|
|
|
#include "kwinglobals.h"
|
|
|
|
// KDE includes
|
2014-03-18 13:37:01 +00:00
|
|
|
#include <KSharedConfig>
|
2013-01-21 08:04:06 +00:00
|
|
|
// Qt
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QVector>
|
2013-01-21 08:04:06 +00:00
|
|
|
#include <QDateTime>
|
2016-04-15 11:47:56 +00:00
|
|
|
#include <QRect>
|
2011-06-23 17:54:14 +00:00
|
|
|
|
2017-03-31 05:41:21 +00:00
|
|
|
class QAction;
|
2016-02-11 14:51:25 +00:00
|
|
|
class QMouseEvent;
|
|
|
|
|
2011-06-23 10:09:17 +00:00
|
|
|
namespace KWin {
|
|
|
|
|
2016-09-15 19:03:40 +00:00
|
|
|
class AbstractClient;
|
2017-03-19 10:40:03 +00:00
|
|
|
class GestureRecognizer;
|
2013-01-21 08:04:06 +00:00
|
|
|
class ScreenEdges;
|
2017-03-19 10:40:03 +00:00
|
|
|
class SwipeGesture;
|
2013-01-21 08:04:06 +00:00
|
|
|
|
2016-04-15 11:47:56 +00:00
|
|
|
class KWIN_EXPORT Edge : public QObject
|
2013-01-21 08:04:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit Edge(ScreenEdges *parent);
|
|
|
|
virtual ~Edge();
|
|
|
|
bool isLeft() const;
|
|
|
|
bool isTop() const;
|
|
|
|
bool isRight() const;
|
|
|
|
bool isBottom() const;
|
|
|
|
bool isCorner() const;
|
|
|
|
bool isScreenEdge() const;
|
|
|
|
bool triggersFor(const QPoint &cursorPos) const;
|
2014-02-20 11:39:23 +00:00
|
|
|
bool check(const QPoint &cursorPos, const QDateTime &triggerTime, bool forceNoPushBack = false);
|
|
|
|
void markAsTriggered(const QPoint &cursorPos, const QDateTime &triggerTime);
|
2013-01-21 08:04:06 +00:00
|
|
|
bool isReserved() const;
|
2013-01-26 10:50:14 +00:00
|
|
|
const QRect &approachGeometry() const;
|
2013-01-21 08:04:06 +00:00
|
|
|
|
|
|
|
ElectricBorder border() const;
|
2013-01-22 11:47:06 +00:00
|
|
|
void reserve(QObject *object, const char *slot);
|
|
|
|
const QHash<QObject *, QByteArray> &callBacks() const;
|
2017-03-31 05:41:21 +00:00
|
|
|
void reserveTouchCallBack(QAction *action);
|
|
|
|
void unreserveTouchCallBack(QAction *action);
|
|
|
|
QVector<QAction *> touchCallBacks() const {
|
|
|
|
return m_touchActions;
|
|
|
|
}
|
2013-01-26 10:50:14 +00:00
|
|
|
void startApproaching();
|
|
|
|
void stopApproaching();
|
2013-06-26 08:25:17 +00:00
|
|
|
bool isApproaching() const;
|
2016-09-15 19:03:40 +00:00
|
|
|
void setClient(AbstractClient *client);
|
|
|
|
AbstractClient *client() const;
|
2016-02-11 14:51:25 +00:00
|
|
|
const QRect &geometry() const;
|
2017-03-30 05:08:38 +00:00
|
|
|
void setTouchAction(ElectricBorderAction action);
|
|
|
|
|
|
|
|
bool activatesForPointer() const;
|
|
|
|
bool activatesForTouchGesture() const;
|
2013-01-21 08:04:06 +00:00
|
|
|
|
2016-04-15 11:19:22 +00:00
|
|
|
/**
|
|
|
|
* The window id of the native window representing the edge.
|
|
|
|
* Default implementation returns @c 0, which means no window.
|
|
|
|
**/
|
|
|
|
virtual quint32 window() const;
|
|
|
|
/**
|
|
|
|
* The approach window is a special window to notice when get close to the screen border but
|
|
|
|
* not yet triggering the border.
|
|
|
|
*
|
|
|
|
* The default implementation returns @c 0, which means no window.
|
|
|
|
**/
|
|
|
|
virtual quint32 approachWindow() const;
|
|
|
|
|
2013-01-21 08:04:06 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
void reserve();
|
|
|
|
void unreserve();
|
2013-01-22 11:47:06 +00:00
|
|
|
void unreserve(QObject *object);
|
2013-01-21 08:04:06 +00:00
|
|
|
void setBorder(ElectricBorder border);
|
|
|
|
void setAction(ElectricBorderAction action);
|
|
|
|
void setGeometry(const QRect &geometry);
|
2013-01-26 10:50:14 +00:00
|
|
|
void updateApproaching(const QPoint &point);
|
2013-01-31 16:25:03 +00:00
|
|
|
void checkBlocking();
|
2013-01-26 10:50:14 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void approaching(ElectricBorder border, qreal factor, const QRect &geometry);
|
2017-03-30 05:08:38 +00:00
|
|
|
void activatesForTouchGestureChanged();
|
2013-01-21 08:04:06 +00:00
|
|
|
protected:
|
|
|
|
ScreenEdges *edges();
|
|
|
|
const ScreenEdges *edges() const;
|
2013-01-31 16:25:03 +00:00
|
|
|
bool isBlocked() const;
|
2013-01-21 08:04:06 +00:00
|
|
|
virtual void doGeometryUpdate();
|
2017-03-19 10:40:03 +00:00
|
|
|
virtual void doActivate();
|
|
|
|
virtual void doDeactivate();
|
2013-01-26 10:50:14 +00:00
|
|
|
virtual void doStartApproaching();
|
|
|
|
virtual void doStopApproaching();
|
2013-01-31 16:25:03 +00:00
|
|
|
virtual void doUpdateBlocking();
|
2013-01-21 08:04:06 +00:00
|
|
|
private:
|
2017-03-19 10:40:03 +00:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
2013-01-21 08:04:06 +00:00
|
|
|
bool canActivate(const QPoint &cursorPos, const QDateTime &triggerTime);
|
|
|
|
void handle(const QPoint &cursorPos);
|
2017-03-30 05:08:38 +00:00
|
|
|
bool handleAction(ElectricBorderAction action);
|
|
|
|
bool handlePointerAction() {
|
|
|
|
return handleAction(m_action);
|
|
|
|
}
|
|
|
|
bool handleTouchAction() {
|
|
|
|
return handleAction(m_touchAction);
|
|
|
|
}
|
2013-01-22 11:47:06 +00:00
|
|
|
bool handleByCallback();
|
2017-03-31 05:41:21 +00:00
|
|
|
void handleTouchCallback();
|
2013-01-21 08:04:06 +00:00
|
|
|
void switchDesktop(const QPoint &cursorPos);
|
|
|
|
void pushCursorBack(const QPoint &cursorPos);
|
|
|
|
ScreenEdges *m_edges;
|
|
|
|
ElectricBorder m_border;
|
|
|
|
ElectricBorderAction m_action;
|
2017-03-30 05:08:38 +00:00
|
|
|
ElectricBorderAction m_touchAction = ElectricActionNone;
|
2013-01-21 08:04:06 +00:00
|
|
|
int m_reserved;
|
|
|
|
QRect m_geometry;
|
2013-01-26 10:50:14 +00:00
|
|
|
QRect m_approachGeometry;
|
2013-01-21 08:04:06 +00:00
|
|
|
QDateTime m_lastTrigger;
|
|
|
|
QDateTime m_lastReset;
|
|
|
|
QPoint m_triggeredPoint;
|
2013-01-22 11:47:06 +00:00
|
|
|
QHash<QObject *, QByteArray> m_callBacks;
|
2013-01-26 10:50:14 +00:00
|
|
|
bool m_approaching;
|
2013-04-14 18:04:05 +00:00
|
|
|
int m_lastApproachingFactor;
|
2013-01-31 16:25:03 +00:00
|
|
|
bool m_blocked;
|
2014-08-27 19:48:23 +00:00
|
|
|
bool m_pushBackBlocked;
|
2016-09-15 19:03:40 +00:00
|
|
|
AbstractClient *m_client;
|
2017-03-19 10:40:03 +00:00
|
|
|
SwipeGesture *m_gesture;
|
2017-03-31 05:41:21 +00:00
|
|
|
QVector<QAction *> m_touchActions;
|
2013-01-21 08:04:06 +00:00
|
|
|
};
|
|
|
|
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* @short Class for controlling screen edges.
|
|
|
|
*
|
|
|
|
* The screen edge functionality is split into three parts:
|
|
|
|
* @li This manager class ScreenEdges
|
2018-12-03 21:40:12 +00:00
|
|
|
* @li abstract class @ref Edge
|
2019-01-11 13:36:17 +00:00
|
|
|
* @li specific implementation of @ref Edge, e.g. WindowBasedEdge
|
2011-06-27 13:10:25 +00:00
|
|
|
*
|
2018-12-03 21:40:12 +00:00
|
|
|
* The ScreenEdges creates an @ref Edge for each screen edge which is also an edge in the
|
2013-01-21 08:04:06 +00:00
|
|
|
* combination of all screens. E.g. if there are two screens, no Edge is created between the screens,
|
|
|
|
* but at all other edges even if the screens have a different dimension.
|
|
|
|
*
|
2018-12-03 21:40:12 +00:00
|
|
|
* In addition at each corner of the overall display geometry an one-pixel large @ref Edge is
|
2013-01-21 08:04:06 +00:00
|
|
|
* created. No matter how many screens there are, there will only be exactly four of these corner
|
|
|
|
* edges. This is motivated by Fitts's Law which show that it's easy to trigger such a corner, but
|
|
|
|
* it would be very difficult to trigger a corner between two screens (one pixel target not visually
|
|
|
|
* outlined).
|
|
|
|
*
|
|
|
|
* The ScreenEdges are used for one of the following functionality:
|
2018-12-03 21:40:12 +00:00
|
|
|
* @li switch virtual desktop (see property @ref desktopSwitching)
|
|
|
|
* @li switch virtual desktop when moving a window (see property @ref desktopSwitchingMovingClients)
|
|
|
|
* @li trigger a pre-defined action (see properties @ref actionTop and similar)
|
|
|
|
* @li trigger an externally configured action (e.g. Effect, Script, see @ref reserve, @ref unreserve)
|
2013-01-21 08:04:06 +00:00
|
|
|
*
|
2018-12-03 21:40:12 +00:00
|
|
|
* An @ref Edge is only active if there is at least one of the possible actions "reserved" for this
|
2013-01-21 08:04:06 +00:00
|
|
|
* edge. The idea is to not block the screen edge if nothing could be triggered there, so that the
|
|
|
|
* user e.g. can configure nothing on the top edge, which tends to interfere with full screen apps
|
2018-12-03 21:40:12 +00:00
|
|
|
* having a hidden panel there. On X11 (currently only supported backend) the @ref Edge is
|
2019-01-13 07:22:11 +00:00
|
|
|
* represented by a WindowBasedEdge which creates an input only window for the geometry and
|
2013-01-21 08:04:06 +00:00
|
|
|
* reacts on enter notify events. If the edge gets reserved for the first time a window is created
|
|
|
|
* and mapped, once the edge gets unreserved again, the window gets destroyed.
|
|
|
|
*
|
|
|
|
* When the mouse enters one of the screen edges the following values are used to determine whether
|
|
|
|
* the action should be triggered or the cursor be pushed back
|
|
|
|
* @li Time difference between two entering events is not larger than a certain threshold
|
2018-12-03 21:40:12 +00:00
|
|
|
* @li Time difference between two entering events is larger than @ref timeThreshold
|
|
|
|
* @li Time difference between two activations is larger than @ref reActivateThreshold
|
2013-01-21 08:04:06 +00:00
|
|
|
* @li Distance between two enter events is not larger than a defined pixel distance
|
2018-12-03 21:40:12 +00:00
|
|
|
* These checks are performed in @ref Edge
|
2013-01-21 08:04:06 +00:00
|
|
|
*
|
|
|
|
* @todo change way how Effects/Scripts can reserve an edge and are notified.
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2016-02-02 12:50:13 +00:00
|
|
|
class KWIN_EXPORT ScreenEdges : public QObject
|
2013-01-21 08:04:06 +00:00
|
|
|
{
|
2011-06-23 10:09:17 +00:00
|
|
|
Q_OBJECT
|
2013-01-21 08:04:06 +00:00
|
|
|
Q_PROPERTY(bool desktopSwitching READ isDesktopSwitching)
|
|
|
|
Q_PROPERTY(bool desktopSwitchingMovingClients READ isDesktopSwitchingMovingClients)
|
|
|
|
Q_PROPERTY(QSize cursorPushBackDistance READ cursorPushBackDistance)
|
|
|
|
Q_PROPERTY(int timeThreshold READ timeThreshold)
|
|
|
|
Q_PROPERTY(int reActivateThreshold READ reActivationThreshold)
|
|
|
|
Q_PROPERTY(int actionTopLeft READ actionTopLeft)
|
|
|
|
Q_PROPERTY(int actionTop READ actionTop)
|
|
|
|
Q_PROPERTY(int actionTopRight READ actionTopRight)
|
|
|
|
Q_PROPERTY(int actionRight READ actionRight)
|
|
|
|
Q_PROPERTY(int actionBottomRight READ actionBottomRight)
|
|
|
|
Q_PROPERTY(int actionBottom READ actionBottom)
|
|
|
|
Q_PROPERTY(int actionBottomLeft READ actionBottomLeft)
|
|
|
|
Q_PROPERTY(int actionLeft READ actionLeft)
|
2011-06-23 10:09:17 +00:00
|
|
|
public:
|
2013-01-21 08:04:06 +00:00
|
|
|
virtual ~ScreenEdges();
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
**/
|
|
|
|
void setConfig(KSharedConfig::Ptr config);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Initialize the screen edges.
|
2013-01-21 08:04:06 +00:00
|
|
|
* @internal
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2011-06-25 18:08:51 +00:00
|
|
|
void init();
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Check, if a screen edge is entered and trigger the appropriate action
|
|
|
|
* if one is enabled for the current region and the timeout is satisfied
|
|
|
|
* @param pos the position of the mouse pointer
|
|
|
|
* @param now the time when the function is called
|
2012-06-14 20:40:12 +00:00
|
|
|
* @param forceNoPushBack needs to be called to workaround some DnD clients, don't use unless you want to chek on a DnD event
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-01-21 08:04:06 +00:00
|
|
|
void check(const QPoint& pos, const QDateTime &now, bool forceNoPushBack = false);
|
2013-04-14 18:04:05 +00:00
|
|
|
/**
|
|
|
|
* The (dpi dependent) length, reserved for the active corners of each edge - 1/3"
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-04-14 18:04:05 +00:00
|
|
|
int cornerOffset() const;
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Mark the specified screen edge as reserved. This method is provided for external activation
|
|
|
|
* like effects and scripts. When the effect/script does no longer need the edge it is supposed
|
2018-12-03 21:40:12 +00:00
|
|
|
* to call @ref unreserve.
|
2011-06-27 13:10:25 +00:00
|
|
|
* @param border the screen edge to mark as reserved
|
2013-01-22 11:47:06 +00:00
|
|
|
* @param object The object on which the @p callback needs to be invoked
|
|
|
|
* @param callback The method name to be invoked - uses QMetaObject::invokeMethod
|
2013-01-21 08:04:06 +00:00
|
|
|
* @see unreserve
|
|
|
|
* @todo: add pointer to script/effect
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-01-22 11:47:06 +00:00
|
|
|
void reserve(ElectricBorder border, QObject *object, const char *callback);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Mark the specified screen edge as unreserved. This method is provided for external activation
|
2018-12-03 21:40:12 +00:00
|
|
|
* like effects and scripts. This method is only allowed to be called if @ref reserve had been
|
2013-01-21 08:04:06 +00:00
|
|
|
* called before for the same @p border. An unbalanced calling of reserve/unreserve leads to the
|
|
|
|
* edge never being active or never being able to deactivate again.
|
2011-06-27 13:10:25 +00:00
|
|
|
* @param border the screen edge to mark as unreserved
|
2013-01-22 11:47:06 +00:00
|
|
|
* @param object the object on which the callback had been invoked
|
|
|
|
* @see reserve
|
2013-01-21 08:04:06 +00:00
|
|
|
* @todo: add pointer to script/effect
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-01-22 11:47:06 +00:00
|
|
|
void unreserve(ElectricBorder border, QObject *object);
|
2014-02-20 11:39:23 +00:00
|
|
|
/**
|
|
|
|
* Reserves an edge for the @p client. The idea behind this is to show the @p client if the
|
|
|
|
* screen edge which the @p client borders gets triggered.
|
|
|
|
*
|
|
|
|
* When first called it is tried to create an Edge for the client. This is only done if the
|
|
|
|
* client borders with a screen edge specified by @p border. If the client doesn't border the
|
|
|
|
* screen edge, no Edge gets created and the client is shown again. Otherwise there would not
|
|
|
|
* be a possibility to show the client again.
|
|
|
|
*
|
|
|
|
* On subsequent calls for the client no new Edge is created, but the existing one gets reused
|
|
|
|
* and if the client is already hidden, the Edge gets reserved.
|
|
|
|
*
|
|
|
|
* Once the Edge for the client triggers, the client gets shown again and the Edge unreserved.
|
|
|
|
* The idea is that the Edge can only get activated if the client is currently hidden.
|
|
|
|
*
|
|
|
|
* To make sure that the client can always be shown again the implementation also starts to
|
|
|
|
* track geometry changes and shows the Client again. The same for screen geometry changes.
|
|
|
|
*
|
|
|
|
* The Edge gets automatically destroyed if the client gets released.
|
|
|
|
* @param client The Client for which an Edge should be reserved
|
|
|
|
* @param border The border which the client wants to use, only proper borders are supported (no corners)
|
|
|
|
**/
|
2016-09-15 19:03:40 +00:00
|
|
|
void reserve(KWin::AbstractClient *client, ElectricBorder border);
|
2017-03-31 05:41:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mark the specified screen edge as reserved for touch gestures. This method is provided for
|
|
|
|
* external activation like effects and scripts.
|
|
|
|
* When the effect/script does no longer need the edge it is supposed
|
2018-12-03 21:40:12 +00:00
|
|
|
* to call @ref unreserveTouch.
|
2017-03-31 05:41:21 +00:00
|
|
|
* @param border the screen edge to mark as reserved
|
|
|
|
* @param action The action which gets triggered
|
|
|
|
* @see unreserveTouch
|
|
|
|
* @since 5.10
|
|
|
|
**/
|
|
|
|
void reserveTouch(ElectricBorder border, QAction *action);
|
|
|
|
/**
|
|
|
|
* Unreserves the specified @p border from activating the @p action for touch gestures.
|
|
|
|
* @see reserveTouch
|
|
|
|
* @since 5.10
|
|
|
|
**/
|
|
|
|
void unreserveTouch(ElectricBorder border, QAction *action);
|
|
|
|
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Reserve desktop switching for screen edges, if @p isToReserve is @c true. Unreserve otherwise.
|
2018-12-03 21:40:12 +00:00
|
|
|
* @param isToReserve indicated whether desktop switching should be reserved or unreseved
|
2019-01-13 07:22:11 +00:00
|
|
|
* @param o Qt orientations
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2012-05-03 17:48:20 +00:00
|
|
|
void reserveDesktopSwitching(bool isToReserve, Qt::Orientations o);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Raise electric border windows to the real top of the screen. We only need
|
|
|
|
* to do this if an effect input window is active.
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2011-07-04 10:55:58 +00:00
|
|
|
void ensureOnTop();
|
2016-02-11 14:51:25 +00:00
|
|
|
bool isEntered(QMouseEvent *event);
|
2013-01-21 08:04:06 +00:00
|
|
|
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Returns a QVector of all existing screen edge windows
|
|
|
|
* @return all existing screen edge windows in a QVector
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-01-21 08:04:06 +00:00
|
|
|
QVector< xcb_window_t > windows() const;
|
|
|
|
|
|
|
|
bool isDesktopSwitching() const;
|
|
|
|
bool isDesktopSwitchingMovingClients() const;
|
|
|
|
const QSize &cursorPushBackDistance() const;
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Minimum time between the push back of the cursor and the activation by re-entering the edge.
|
|
|
|
**/
|
|
|
|
int timeThreshold() const;
|
2012-11-25 09:13:34 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Minimum time between triggers
|
2012-11-25 09:13:34 +00:00
|
|
|
**/
|
2013-01-21 08:04:06 +00:00
|
|
|
int reActivationThreshold() const;
|
|
|
|
ElectricBorderAction actionTopLeft() const;
|
|
|
|
ElectricBorderAction actionTop() const;
|
|
|
|
ElectricBorderAction actionTopRight() const;
|
|
|
|
ElectricBorderAction actionRight() const;
|
|
|
|
ElectricBorderAction actionBottomRight() const;
|
|
|
|
ElectricBorderAction actionBottom() const;
|
|
|
|
ElectricBorderAction actionBottomLeft() const;
|
|
|
|
ElectricBorderAction actionLeft() const;
|
2013-01-25 09:15:00 +00:00
|
|
|
|
2017-03-19 10:40:03 +00:00
|
|
|
GestureRecognizer *gestureRecognizer() const {
|
|
|
|
return m_gestureRecognizer;
|
|
|
|
}
|
|
|
|
|
2017-08-19 08:58:05 +00:00
|
|
|
bool handleDndNotify(xcb_window_t window, const QPoint &point);
|
|
|
|
bool handleEnterNotifiy(xcb_window_t window, const QPoint &point, const QDateTime ×tamp);
|
|
|
|
|
2013-01-21 08:04:06 +00:00
|
|
|
public Q_SLOTS:
|
2012-11-25 09:13:34 +00:00
|
|
|
void reconfigure();
|
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Updates the layout of virtual desktops and adjust the reserved borders in case of
|
|
|
|
* virtual desktop switching on edges.
|
2012-11-25 09:13:34 +00:00
|
|
|
**/
|
2013-01-21 08:04:06 +00:00
|
|
|
void updateLayout();
|
2012-11-25 09:13:34 +00:00
|
|
|
/**
|
2013-01-21 08:04:06 +00:00
|
|
|
* Recreates all edges e.g. after the screen size changes.
|
2012-11-25 09:13:34 +00:00
|
|
|
**/
|
2013-01-21 08:04:06 +00:00
|
|
|
void recreateEdges();
|
2013-01-26 10:50:14 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Signal emitted during approaching of mouse towards @p border. The @p factor indicates how
|
|
|
|
* far away the mouse is from the approaching area. The values are clamped into [0.0,1.0] with
|
|
|
|
* @c 0.0 meaning far away from the border, @c 1.0 in trigger distance.
|
|
|
|
**/
|
|
|
|
void approaching(ElectricBorder border, qreal factor, const QRect &geometry);
|
2013-01-31 16:25:03 +00:00
|
|
|
void checkBlocking();
|
2013-01-26 10:50:14 +00:00
|
|
|
|
2011-06-23 17:54:14 +00:00
|
|
|
private:
|
2013-01-21 08:04:06 +00:00
|
|
|
enum { ElectricDisabled = 0, ElectricMoveOnly = 1, ElectricAlways = 2 };
|
|
|
|
void setDesktopSwitching(bool enable);
|
|
|
|
void setDesktopSwitchingMovingClients(bool enable);
|
|
|
|
void setCursorPushBackDistance(const QSize &distance);
|
|
|
|
void setTimeThreshold(int threshold);
|
|
|
|
void setReActivationThreshold(int threshold);
|
|
|
|
void createHorizontalEdge(ElectricBorder border, const QRect &screen, const QRect &fullArea);
|
|
|
|
void createVerticalEdge(ElectricBorder border, const QRect &screen, const QRect &fullArea);
|
2013-06-26 08:25:17 +00:00
|
|
|
Edge *createEdge(ElectricBorder border, int x, int y, int width, int height, bool createAction = true);
|
2013-01-21 08:04:06 +00:00
|
|
|
void setActionForBorder(ElectricBorder border, ElectricBorderAction *oldValue, ElectricBorderAction newValue);
|
2017-03-30 05:08:38 +00:00
|
|
|
void setActionForTouchBorder(ElectricBorder border, ElectricBorderAction newValue);
|
2013-01-21 08:04:06 +00:00
|
|
|
ElectricBorderAction actionForEdge(Edge *edge) const;
|
2017-03-30 05:08:38 +00:00
|
|
|
ElectricBorderAction actionForTouchEdge(Edge *edge) const;
|
2016-09-15 19:03:40 +00:00
|
|
|
void createEdgeForClient(AbstractClient *client, ElectricBorder border);
|
|
|
|
void deleteEdgeForClient(AbstractClient *client);
|
2013-01-21 08:04:06 +00:00
|
|
|
bool m_desktopSwitching;
|
|
|
|
bool m_desktopSwitchingMovingClients;
|
|
|
|
QSize m_cursorPushBackDistance;
|
|
|
|
int m_timeThreshold;
|
|
|
|
int m_reactivateThreshold;
|
2012-11-25 09:13:34 +00:00
|
|
|
Qt::Orientations m_virtualDesktopLayout;
|
2013-06-26 08:25:17 +00:00
|
|
|
QList<Edge*> m_edges;
|
2013-01-21 08:04:06 +00:00
|
|
|
KSharedConfig::Ptr m_config;
|
|
|
|
ElectricBorderAction m_actionTopLeft;
|
|
|
|
ElectricBorderAction m_actionTop;
|
|
|
|
ElectricBorderAction m_actionTopRight;
|
|
|
|
ElectricBorderAction m_actionRight;
|
|
|
|
ElectricBorderAction m_actionBottomRight;
|
|
|
|
ElectricBorderAction m_actionBottom;
|
|
|
|
ElectricBorderAction m_actionBottomLeft;
|
|
|
|
ElectricBorderAction m_actionLeft;
|
2017-03-30 05:08:38 +00:00
|
|
|
QMap<ElectricBorder, ElectricBorderAction> m_touchActions;
|
2013-04-14 18:04:05 +00:00
|
|
|
int m_cornerOffset;
|
2017-03-19 10:40:03 +00:00
|
|
|
GestureRecognizer *m_gestureRecognizer;
|
2013-01-25 09:15:00 +00:00
|
|
|
|
2013-04-05 07:41:25 +00:00
|
|
|
KWIN_SINGLETON(ScreenEdges)
|
2011-06-23 10:09:17 +00:00
|
|
|
};
|
2013-01-21 08:04:06 +00:00
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* Inlines Edge
|
|
|
|
*********************************************************/
|
|
|
|
|
|
|
|
inline bool Edge::isBottom() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricBottom || m_border == ElectricBottomLeft || m_border == ElectricBottomRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isLeft() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricLeft || m_border == ElectricTopLeft || m_border == ElectricBottomLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isRight() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricRight || m_border == ElectricTopRight || m_border == ElectricBottomRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isTop() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricTop || m_border == ElectricTopLeft || m_border == ElectricTopRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isCorner() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricTopLeft
|
|
|
|
|| m_border == ElectricTopRight
|
|
|
|
|| m_border == ElectricBottomRight
|
|
|
|
|| m_border == ElectricBottomLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isScreenEdge() const
|
|
|
|
{
|
|
|
|
return m_border == ElectricLeft
|
|
|
|
|| m_border == ElectricRight
|
|
|
|
|| m_border == ElectricTop
|
|
|
|
|| m_border == ElectricBottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Edge::isReserved() const
|
|
|
|
{
|
|
|
|
return m_reserved != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Edge::setAction(ElectricBorderAction action)
|
|
|
|
{
|
|
|
|
m_action = action;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ScreenEdges *Edge::edges()
|
|
|
|
{
|
|
|
|
return m_edges;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const ScreenEdges *Edge::edges() const
|
|
|
|
{
|
|
|
|
return m_edges;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const QRect &Edge::geometry() const
|
|
|
|
{
|
|
|
|
return m_geometry;
|
|
|
|
}
|
|
|
|
|
2013-01-26 10:50:14 +00:00
|
|
|
inline const QRect &Edge::approachGeometry() const
|
2013-01-21 08:04:06 +00:00
|
|
|
{
|
2013-01-26 10:50:14 +00:00
|
|
|
return m_approachGeometry;
|
2013-01-21 08:04:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline ElectricBorder Edge::border() const
|
|
|
|
{
|
|
|
|
return m_border;
|
|
|
|
}
|
|
|
|
|
2013-01-22 11:47:06 +00:00
|
|
|
inline const QHash< QObject *, QByteArray > &Edge::callBacks() const
|
|
|
|
{
|
|
|
|
return m_callBacks;
|
|
|
|
}
|
|
|
|
|
2013-01-31 16:25:03 +00:00
|
|
|
inline bool Edge::isBlocked() const
|
|
|
|
{
|
|
|
|
return m_blocked;
|
|
|
|
}
|
|
|
|
|
2016-09-15 19:03:40 +00:00
|
|
|
inline AbstractClient *Edge::client() const
|
2014-02-20 11:39:23 +00:00
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
|
2013-06-26 08:25:17 +00:00
|
|
|
inline bool Edge::isApproaching() const
|
|
|
|
{
|
|
|
|
return m_approaching;
|
|
|
|
}
|
|
|
|
|
2013-01-21 08:04:06 +00:00
|
|
|
/**********************************************************
|
|
|
|
* Inlines ScreenEdges
|
|
|
|
*********************************************************/
|
|
|
|
inline void ScreenEdges::setConfig(KSharedConfig::Ptr config)
|
|
|
|
{
|
|
|
|
m_config = config;
|
|
|
|
}
|
|
|
|
|
2013-04-14 18:04:05 +00:00
|
|
|
inline int ScreenEdges::cornerOffset() const {
|
|
|
|
return m_cornerOffset;
|
|
|
|
}
|
|
|
|
|
2013-01-21 08:04:06 +00:00
|
|
|
inline const QSize &ScreenEdges::cursorPushBackDistance() const
|
|
|
|
{
|
|
|
|
return m_cursorPushBackDistance;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ScreenEdges::isDesktopSwitching() const
|
|
|
|
{
|
|
|
|
return m_desktopSwitching;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool ScreenEdges::isDesktopSwitchingMovingClients() const
|
|
|
|
{
|
|
|
|
return m_desktopSwitchingMovingClients;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int ScreenEdges::reActivationThreshold() const
|
|
|
|
{
|
|
|
|
return m_reactivateThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int ScreenEdges::timeThreshold() const
|
|
|
|
{
|
|
|
|
return m_timeThreshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScreenEdges::setCursorPushBackDistance(const QSize &distance)
|
|
|
|
{
|
|
|
|
m_cursorPushBackDistance = distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScreenEdges::setDesktopSwitching(bool enable)
|
|
|
|
{
|
|
|
|
if (enable == m_desktopSwitching) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_desktopSwitching = enable;
|
|
|
|
reserveDesktopSwitching(enable, m_virtualDesktopLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScreenEdges::setDesktopSwitchingMovingClients(bool enable)
|
|
|
|
{
|
|
|
|
m_desktopSwitchingMovingClients = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScreenEdges::setReActivationThreshold(int threshold)
|
|
|
|
{
|
2015-09-10 19:03:53 +00:00
|
|
|
Q_ASSERT(threshold >= m_timeThreshold);
|
2013-01-21 08:04:06 +00:00
|
|
|
m_reactivateThreshold = threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void ScreenEdges::setTimeThreshold(int threshold)
|
|
|
|
{
|
|
|
|
m_timeThreshold = threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ACTION( name ) \
|
|
|
|
inline ElectricBorderAction ScreenEdges::name() const \
|
|
|
|
{ \
|
|
|
|
return m_##name; \
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTION(actionTopLeft)
|
|
|
|
ACTION(actionTop)
|
|
|
|
ACTION(actionTopRight)
|
|
|
|
ACTION(actionRight)
|
|
|
|
ACTION(actionBottomRight)
|
|
|
|
ACTION(actionBottom)
|
|
|
|
ACTION(actionBottomLeft)
|
|
|
|
ACTION(actionLeft)
|
|
|
|
|
|
|
|
#undef ACTION
|
|
|
|
|
2011-06-23 10:09:17 +00:00
|
|
|
}
|
|
|
|
#endif // KWIN_SCREENEDGE_H
|