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>
|
|
|
|
|
|
|
|
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
|
2011-06-23 17:54:14 +00:00
|
|
|
#include <QtCore/QObject>
|
2011-06-24 14:20:40 +00:00
|
|
|
#include <QtCore/QVector>
|
2011-06-23 10:09:17 +00:00
|
|
|
#include "kwinglobals.h"
|
|
|
|
|
2011-06-23 17:54:14 +00:00
|
|
|
|
2011-06-23 10:09:17 +00:00
|
|
|
namespace KWin {
|
|
|
|
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* @short This class is used to handle the screen edges
|
|
|
|
* Screen Edge Window management. Screen Edges allow a user to change the virtual
|
|
|
|
* desktop or activate other features by moving the mouse pointer to the borders or
|
|
|
|
* corners of the screen. Technically this is done with input only windows.
|
|
|
|
*
|
|
|
|
* @author Arthur Arlt
|
|
|
|
* @since 4.8
|
|
|
|
*/
|
2012-05-10 14:09:36 +00:00
|
|
|
class ScreenEdge : public QObject {
|
2011-06-23 10:09:17 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ScreenEdge();
|
|
|
|
~ScreenEdge();
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Initialize the screen edges.
|
|
|
|
*/
|
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
|
2011-06-27 13:10:25 +00:00
|
|
|
*/
|
2012-06-14 20:40:12 +00:00
|
|
|
void check(const QPoint& pos, Time now, bool forceNoPushBack = false);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Restore the size of the specified screen edges
|
|
|
|
* @param border the screen edge to restore the size of
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
void restoreSize(ElectricBorder border);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Mark the specified screen edge as reserved in m_screenEdgeReserved
|
|
|
|
* @param border the screen edge to mark as reserved
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
void reserve(ElectricBorder border);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Mark the specified screen edge as unreserved in m_screenEdgeReserved
|
|
|
|
* @param border the screen edge to mark as unreserved
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
void unreserve(ElectricBorder border);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Reserve actions for screen edges, if reserve is true. Unreserve otherwise.
|
|
|
|
* @param reserve indicated weather actions should be reserved or unreseved
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
void reserveActions(bool isToReserve);
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Reserve desktop switching for screen edges, if reserve is true. Unreserve otherwise.
|
|
|
|
* @param reserve indicated weather desktop switching should be reserved or unreseved
|
|
|
|
*/
|
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.
|
|
|
|
*/
|
2011-07-04 10:55:58 +00:00
|
|
|
void ensureOnTop();
|
2012-06-13 19:44:59 +00:00
|
|
|
/**
|
|
|
|
* Raise FOREIGN border windows to the real top of the screen. We usually need
|
|
|
|
* to do this after an effect input window was active.
|
|
|
|
*/
|
|
|
|
void raisePanelProxies();
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Called when the user entered an electric border with the mouse.
|
|
|
|
* It may switch to another virtual desktop.
|
|
|
|
* @param e the X event which is passed to this method.
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
bool isEntered(XEvent * e);
|
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
|
|
|
|
*/
|
2011-06-28 11:50:24 +00:00
|
|
|
const QVector< Window >& windows();
|
2011-06-23 17:54:14 +00:00
|
|
|
public Q_SLOTS:
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Update the screen edge windows. Add new ones if the user specified
|
|
|
|
* a new action or enabled desktop switching. Remove, if user deleted
|
|
|
|
* actions or disabled desktop switching.
|
|
|
|
*/
|
2011-07-04 10:41:18 +00:00
|
|
|
void update(bool force=false);
|
2012-11-25 09:13:34 +00:00
|
|
|
/**
|
|
|
|
* Reconfigures the screen edges. That is reserves required borders.
|
|
|
|
**/
|
|
|
|
void reconfigure();
|
|
|
|
/**
|
|
|
|
* Reconfigures for virtual desktop switching, that is updates m_virtualDesktopSwitching.
|
|
|
|
**/
|
|
|
|
void reconfigureVirtualDesktopSwitching();
|
|
|
|
/**
|
|
|
|
* Updates the layout of virtual desktops, that is updates m_virtualDesktopLayout.
|
|
|
|
**/
|
|
|
|
void updateLayout();
|
2012-05-10 14:09:36 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Emitted when the @p border got activated and there is neither an effect nor a global
|
|
|
|
* action configured for this @p border.
|
|
|
|
* @param border The border which got activated
|
|
|
|
**/
|
|
|
|
void activated(ElectricBorder border);
|
2011-06-23 17:54:14 +00:00
|
|
|
private:
|
2011-06-27 13:10:25 +00:00
|
|
|
/**
|
|
|
|
* Switch the desktop if desktop switching is enabled and a screen edge
|
|
|
|
* is entered to trigger this action.
|
|
|
|
*/
|
2011-06-27 11:02:53 +00:00
|
|
|
void switchDesktop(ElectricBorder border, const QPoint& pos);
|
2011-06-23 10:09:17 +00:00
|
|
|
|
2011-06-28 11:50:24 +00:00
|
|
|
QVector< Window > m_screenEdgeWindows;
|
2011-06-28 12:00:47 +00:00
|
|
|
QVector< int > m_screenEdgeReserved; // Corners/edges used by something
|
2011-06-25 18:17:44 +00:00
|
|
|
ElectricBorder m_currentScreenEdge;
|
|
|
|
int m_screenEdgeLeft;
|
|
|
|
int m_screenEdgeRight;
|
|
|
|
int m_screenEdgeTop;
|
|
|
|
int m_screenEdgeBottom;
|
|
|
|
Time m_screenEdgeTimeFirst;
|
|
|
|
Time m_screenEdgeTimeLast;
|
|
|
|
Time m_screenEdgeTimeLastTrigger;
|
|
|
|
QPoint m_screenEdgePushPoint;
|
2012-11-25 09:13:34 +00:00
|
|
|
/**
|
|
|
|
* The virtual desktop switching mode when hitting screen edges. Either:
|
|
|
|
* @li never enabled
|
|
|
|
* @li enabled when moving windows
|
|
|
|
* @li always enabled
|
|
|
|
**/
|
|
|
|
int m_virtualDesktopSwitching;
|
|
|
|
/**
|
|
|
|
* Used to know whether desktop switching at top/bottom or left/right borders is supported
|
|
|
|
* by the layout of virtual desktops.
|
|
|
|
**/
|
|
|
|
Qt::Orientations m_virtualDesktopLayout;
|
2011-06-23 10:09:17 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // KWIN_SCREENEDGE_H
|