2010-09-21 14:31:40 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2010 Rohan Prabhu <rohan@rohanprabhu.com>
|
2012-01-21 16:48:07 +00:00
|
|
|
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
2012-01-22 11:38:03 +00:00
|
|
|
#ifndef KWIN_SCRIPTING_WORKSPACE_WRAPPER_H
|
|
|
|
#define KWIN_SCRIPTING_WORKSPACE_WRAPPER_H
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QStringList>
|
2013-02-26 07:02:27 +00:00
|
|
|
#include <QRect>
|
2012-01-26 21:56:24 +00:00
|
|
|
#include <kwinglobals.h>
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2012-01-22 11:38:03 +00:00
|
|
|
namespace KWin
|
2010-09-21 14:31:40 +00:00
|
|
|
{
|
2012-01-22 11:38:03 +00:00
|
|
|
// forward declarations
|
2015-03-06 11:38:07 +00:00
|
|
|
class AbstractClient;
|
2012-01-22 11:38:03 +00:00
|
|
|
class Client;
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2012-01-22 11:38:03 +00:00
|
|
|
class WorkspaceWrapper : public QObject
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-01-26 21:56:24 +00:00
|
|
|
Q_ENUMS(ClientAreaOption)
|
2012-05-10 14:09:36 +00:00
|
|
|
Q_ENUMS(ElectricBorder)
|
2012-01-21 16:48:07 +00:00
|
|
|
Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY currentDesktopChanged)
|
2015-03-06 12:37:56 +00:00
|
|
|
Q_PROPERTY(KWin::AbstractClient *activeClient READ activeClient WRITE setActiveClient NOTIFY clientActivated)
|
2012-01-21 16:48:07 +00:00
|
|
|
// TODO: write and notify?
|
2013-02-14 08:36:00 +00:00
|
|
|
Q_PROPERTY(QSize desktopGridSize READ desktopGridSize NOTIFY desktopLayoutChanged)
|
|
|
|
Q_PROPERTY(int desktopGridWidth READ desktopGridWidth NOTIFY desktopLayoutChanged)
|
|
|
|
Q_PROPERTY(int desktopGridHeight READ desktopGridHeight NOTIFY desktopLayoutChanged)
|
2012-01-21 16:48:07 +00:00
|
|
|
Q_PROPERTY(int workspaceWidth READ workspaceWidth)
|
|
|
|
Q_PROPERTY(int workspaceHeight READ workspaceHeight)
|
|
|
|
Q_PROPERTY(QSize workspaceSize READ workspaceSize)
|
2012-01-26 07:22:54 +00:00
|
|
|
/**
|
|
|
|
* The number of desktops currently used. Minimum number of desktops is 1, maximum 20.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged)
|
2012-01-26 15:53:07 +00:00
|
|
|
/**
|
|
|
|
* The same of the display, that is all screens.
|
2014-02-27 08:55:45 +00:00
|
|
|
* @deprecated since 5.0 use virtualScreenSize
|
2012-01-26 15:53:07 +00:00
|
|
|
**/
|
|
|
|
Q_PROPERTY(QSize displaySize READ displaySize)
|
|
|
|
/**
|
|
|
|
* The width of the display, that is width of all combined screens.
|
2014-02-27 08:55:45 +00:00
|
|
|
* @deprecated since 5.0 use virtualScreenSize
|
2012-01-26 15:53:07 +00:00
|
|
|
**/
|
|
|
|
Q_PROPERTY(int displayWidth READ displayWidth)
|
|
|
|
/**
|
|
|
|
* The height of the display, that is height of all combined screens.
|
2014-02-27 08:55:45 +00:00
|
|
|
* @deprecated since 5.0 use virtualScreenSize
|
2012-01-26 15:53:07 +00:00
|
|
|
**/
|
|
|
|
Q_PROPERTY(int displayHeight READ displayHeight)
|
2012-02-19 14:42:18 +00:00
|
|
|
Q_PROPERTY(int activeScreen READ activeScreen)
|
2012-03-27 17:43:04 +00:00
|
|
|
Q_PROPERTY(int numScreens READ numScreens NOTIFY numberScreensChanged)
|
2012-06-21 18:37:23 +00:00
|
|
|
Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY currentActivityChanged)
|
|
|
|
Q_PROPERTY(QStringList activities READ activityList NOTIFY activitiesChanged)
|
2014-02-27 08:55:45 +00:00
|
|
|
/**
|
|
|
|
* The bounding size of all screens combined. Overlapping areas
|
|
|
|
* are not counted multiple times.
|
|
|
|
* @see virtualScreenGeometry
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(QSize virtualScreenSize READ virtualScreenSize NOTIFY virtualScreenSizeChanged)
|
|
|
|
/**
|
|
|
|
* The bounding geometry of all outputs combined. Always starts at (0,0) and has
|
|
|
|
* virtualScreenSize as it's size.
|
|
|
|
* @see virtualScreenSize
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(QRect virtualScreenGeometry READ virtualScreenGeometry NOTIFY virtualScreenGeometryChanged)
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
private:
|
2012-01-22 11:38:03 +00:00
|
|
|
Q_DISABLE_COPY(WorkspaceWrapper)
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2013-07-22 14:07:39 +00:00
|
|
|
Q_SIGNALS:
|
2015-03-13 10:48:08 +00:00
|
|
|
void desktopPresenceChanged(KWin::AbstractClient *client, int desktop);
|
2015-03-06 11:38:07 +00:00
|
|
|
void currentDesktopChanged(int desktop, KWin::AbstractClient *client);
|
2012-03-21 17:55:32 +00:00
|
|
|
void clientAdded(KWin::Client *client);
|
2015-04-30 08:51:58 +00:00
|
|
|
void clientRemoved(KWin::AbstractClient *client);
|
2012-03-21 17:55:32 +00:00
|
|
|
void clientManaging(KWin::Client *client);
|
2015-03-13 13:45:21 +00:00
|
|
|
void clientMinimized(KWin::AbstractClient *client);
|
|
|
|
void clientUnminimized(KWin::AbstractClient *client);
|
2012-03-21 17:55:32 +00:00
|
|
|
void clientRestored(KWin::Client *client);
|
2015-06-07 01:17:34 +00:00
|
|
|
void clientMaximizeSet(KWin::AbstractClient *client, bool h, bool v);
|
2012-03-21 17:55:32 +00:00
|
|
|
void killWindowCalled(KWin::Client *client);
|
2015-03-06 12:58:24 +00:00
|
|
|
void clientActivated(KWin::AbstractClient *client);
|
2012-03-21 17:55:32 +00:00
|
|
|
void clientFullScreenSet(KWin::Client *client, bool fullScreen, bool user);
|
|
|
|
void clientSetKeepAbove(KWin::Client *client, bool keepAbove);
|
2012-01-26 07:22:54 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted whenever the number of desktops changed.
|
|
|
|
* To get the current number of desktops use the property desktops.
|
|
|
|
* @param oldNumberOfDesktops The previous number of desktops.
|
|
|
|
**/
|
2012-11-16 07:23:47 +00:00
|
|
|
void numberDesktopsChanged(uint oldNumberOfDesktops);
|
2013-02-14 08:36:00 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted whenever the layout of virtual desktops changed.
|
|
|
|
* That is desktopGrid(Size/Width/Height) will have new values.
|
|
|
|
* @since 4.11
|
|
|
|
**/
|
|
|
|
void desktopLayoutChanged();
|
2012-03-09 09:17:19 +00:00
|
|
|
/**
|
|
|
|
* The demands attention state for Client @p c changed to @p set.
|
|
|
|
* @param c The Client for which demands attention changed
|
|
|
|
* @param set New value of demands attention
|
|
|
|
**/
|
2015-03-13 10:13:29 +00:00
|
|
|
void clientDemandsAttentionChanged(KWin::AbstractClient *client, bool set);
|
2012-03-27 17:43:04 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted when the number of screens changes.
|
|
|
|
* @param count The new number of screens
|
|
|
|
**/
|
|
|
|
void numberScreensChanged(int count);
|
2012-04-09 21:01:04 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when the size of @p screen changes.
|
|
|
|
* Don't forget to fetch an updated client area.
|
|
|
|
**/
|
|
|
|
void screenResized(int screen);
|
2012-06-21 18:37:23 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted whenever the current activity changed.
|
2012-07-06 16:13:39 +00:00
|
|
|
* @param id id of the new activity
|
2012-06-21 18:37:23 +00:00
|
|
|
**/
|
2012-07-06 16:13:39 +00:00
|
|
|
void currentActivityChanged(const QString &id);
|
2012-06-21 18:37:23 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted whenever the list of activities changed.
|
|
|
|
* @param id id of the new activity
|
|
|
|
**/
|
|
|
|
void activitiesChanged(const QString &id);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when a new activity is added
|
|
|
|
* @param id id of the new activity
|
|
|
|
*/
|
|
|
|
void activityAdded(const QString &id);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the activity
|
|
|
|
* is removed
|
|
|
|
* @param id id of the removed activity
|
|
|
|
*/
|
|
|
|
void activityRemoved(const QString &id);
|
2014-02-27 08:55:45 +00:00
|
|
|
/**
|
|
|
|
* Emitted whenever the virtualScreenSize changes.
|
|
|
|
* @see virtualScreenSize()
|
|
|
|
* @since 5.0
|
|
|
|
**/
|
|
|
|
void virtualScreenSizeChanged();
|
|
|
|
/**
|
|
|
|
* Emitted whenever the virtualScreenGeometry changes.
|
|
|
|
* @see virtualScreenGeometry()
|
|
|
|
* @since 5.0
|
|
|
|
**/
|
|
|
|
void virtualScreenGeometryChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
public:
|
2012-01-26 21:56:24 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//enums copy&pasted from kwinglobals.h because qtscript is evil
|
|
|
|
|
|
|
|
enum ClientAreaOption {
|
|
|
|
///< geometry where a window will be initially placed after being mapped
|
|
|
|
PlacementArea,
|
|
|
|
///< window movement snapping area? ignore struts
|
|
|
|
MovementArea,
|
|
|
|
///< geometry to which a window will be maximized
|
|
|
|
MaximizeArea,
|
|
|
|
///< like MaximizeArea, but ignore struts - used e.g. for topmenu
|
|
|
|
MaximizeFullArea,
|
|
|
|
///< area for fullscreen windows
|
|
|
|
FullScreenArea,
|
|
|
|
///< whole workarea (all screens together)
|
|
|
|
WorkArea,
|
|
|
|
///< whole area (all screens together), ignore struts
|
|
|
|
FullArea,
|
|
|
|
///< one whole screen, ignore struts
|
|
|
|
ScreenArea
|
|
|
|
};
|
2012-05-10 14:09:36 +00:00
|
|
|
enum ElectricBorder {
|
|
|
|
ElectricTop,
|
|
|
|
ElectricTopRight,
|
|
|
|
ElectricRight,
|
|
|
|
ElectricBottomRight,
|
|
|
|
ElectricBottom,
|
|
|
|
ElectricBottomLeft,
|
|
|
|
ElectricLeft,
|
|
|
|
ElectricTopLeft,
|
|
|
|
ELECTRIC_COUNT,
|
|
|
|
ElectricNone
|
|
|
|
};
|
2012-01-26 21:56:24 +00:00
|
|
|
|
2014-02-24 15:33:40 +00:00
|
|
|
explicit WorkspaceWrapper(QObject* parent = nullptr);
|
2012-01-26 07:22:54 +00:00
|
|
|
#define GETTERSETTERDEF( rettype, getter, setter ) \
|
|
|
|
rettype getter() const; \
|
|
|
|
void setter( rettype val );
|
|
|
|
GETTERSETTERDEF(int, numberOfDesktops, setNumberOfDesktops)
|
2012-01-26 07:33:21 +00:00
|
|
|
GETTERSETTERDEF(int, currentDesktop, setCurrentDesktop)
|
2015-03-06 12:37:56 +00:00
|
|
|
GETTERSETTERDEF(KWin::AbstractClient*, activeClient, setActiveClient)
|
2012-01-26 07:22:54 +00:00
|
|
|
#undef GETTERSETTERDEF
|
2012-01-21 16:48:07 +00:00
|
|
|
QSize desktopGridSize() const;
|
|
|
|
int desktopGridWidth() const;
|
|
|
|
int desktopGridHeight() const;
|
|
|
|
int workspaceWidth() const;
|
|
|
|
int workspaceHeight() const;
|
|
|
|
QSize workspaceSize() const;
|
2012-01-26 15:53:07 +00:00
|
|
|
int displayWidth() const;
|
|
|
|
int displayHeight() const;
|
|
|
|
QSize displaySize() const;
|
2012-02-19 14:42:18 +00:00
|
|
|
int activeScreen() const;
|
|
|
|
int numScreens() const;
|
2012-06-21 18:37:23 +00:00
|
|
|
QString currentActivity() const;
|
|
|
|
QStringList activityList() const;
|
2014-02-27 08:55:45 +00:00
|
|
|
QSize virtualScreenSize() const;
|
|
|
|
QRect virtualScreenGeometry() const;
|
2012-01-21 16:48:07 +00:00
|
|
|
|
2012-03-27 20:21:06 +00:00
|
|
|
/**
|
|
|
|
* List of Clients currently managed by KWin.
|
|
|
|
**/
|
2012-01-21 16:48:07 +00:00
|
|
|
Q_INVOKABLE QList< KWin::Client* > clientList() const;
|
2012-01-26 21:56:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the geometry a Client can use with the specified option.
|
|
|
|
* This method should be preferred over other methods providing screen sizes as the
|
|
|
|
* various options take constraints such as struts set on panels into account.
|
|
|
|
* This method is also multi screen aware, but there are also options to get full areas.
|
|
|
|
* @param option The type of area which should be considered
|
|
|
|
* @param screen The screen for which the area should be considered
|
|
|
|
* @param desktop The desktop for which the area should be considered, in general there should not be a difference
|
|
|
|
* @returns The specified screen geometry
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QRect clientArea(ClientAreaOption option, int screen, int desktop) const;
|
|
|
|
/**
|
|
|
|
* Overloaded method for convenience.
|
|
|
|
* @param option The type of area which should be considered
|
|
|
|
* @param point The coordinates which have to be included in the area
|
|
|
|
* @param desktop The desktop for which the area should be considered, in general there should not be a difference
|
|
|
|
* @returns The specified screen geometry
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QRect clientArea(ClientAreaOption option, const QPoint& point, int desktop) const;
|
|
|
|
/**
|
|
|
|
* Overloaded method for convenience.
|
|
|
|
* @param client The Client for which the area should be retrieved
|
|
|
|
* @returns The specified screen geometry
|
|
|
|
**/
|
2012-03-09 17:20:50 +00:00
|
|
|
Q_SCRIPTABLE QRect clientArea(ClientAreaOption option, const KWin::Client* client) const;
|
2012-02-19 15:45:44 +00:00
|
|
|
/**
|
|
|
|
* Returns the name for the given @p desktop.
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QString desktopName(int desktop) const;
|
2012-03-04 14:13:22 +00:00
|
|
|
/**
|
|
|
|
* Provides support information about the currently running KWin instance.
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QString supportInformation() const;
|
2012-06-22 07:51:27 +00:00
|
|
|
/**
|
|
|
|
* Finds the Client with the given @p windowId.
|
|
|
|
* @param windowId The window Id of the Client
|
|
|
|
* @return The found Client or @c null
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE KWin::Client *getClient(qulonglong windowId);
|
2012-01-21 09:51:22 +00:00
|
|
|
|
2012-01-27 06:35:40 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
// all the available key bindings
|
|
|
|
void slotSwitchDesktopNext();
|
|
|
|
void slotSwitchDesktopPrevious();
|
|
|
|
void slotSwitchDesktopRight();
|
|
|
|
void slotSwitchDesktopLeft();
|
|
|
|
void slotSwitchDesktopUp();
|
|
|
|
void slotSwitchDesktopDown();
|
|
|
|
|
|
|
|
void slotSwitchToNextScreen();
|
|
|
|
void slotWindowToNextScreen();
|
|
|
|
void slotToggleShowDesktop();
|
|
|
|
|
|
|
|
void slotWindowMaximize();
|
|
|
|
void slotWindowMaximizeVertical();
|
|
|
|
void slotWindowMaximizeHorizontal();
|
|
|
|
void slotWindowMinimize();
|
|
|
|
void slotWindowShade();
|
|
|
|
void slotWindowRaise();
|
|
|
|
void slotWindowLower();
|
|
|
|
void slotWindowRaiseOrLower();
|
|
|
|
void slotActivateAttentionWindow();
|
|
|
|
void slotWindowPackLeft();
|
|
|
|
void slotWindowPackRight();
|
|
|
|
void slotWindowPackUp();
|
|
|
|
void slotWindowPackDown();
|
|
|
|
void slotWindowGrowHorizontal();
|
|
|
|
void slotWindowGrowVertical();
|
|
|
|
void slotWindowShrinkHorizontal();
|
|
|
|
void slotWindowShrinkVertical();
|
|
|
|
void slotWindowQuickTileLeft();
|
|
|
|
void slotWindowQuickTileRight();
|
2015-03-31 09:09:57 +00:00
|
|
|
void slotWindowQuickTileTop();
|
|
|
|
void slotWindowQuickTileBottom();
|
2012-01-27 06:35:40 +00:00
|
|
|
void slotWindowQuickTileTopLeft();
|
|
|
|
void slotWindowQuickTileTopRight();
|
|
|
|
void slotWindowQuickTileBottomLeft();
|
|
|
|
void slotWindowQuickTileBottomRight();
|
|
|
|
|
|
|
|
void slotSwitchWindowUp();
|
|
|
|
void slotSwitchWindowDown();
|
|
|
|
void slotSwitchWindowRight();
|
|
|
|
void slotSwitchWindowLeft();
|
|
|
|
|
|
|
|
void slotIncreaseWindowOpacity();
|
|
|
|
void slotLowerWindowOpacity();
|
|
|
|
|
|
|
|
void slotWindowOperations();
|
|
|
|
void slotWindowClose();
|
|
|
|
void slotWindowMove();
|
|
|
|
void slotWindowResize();
|
|
|
|
void slotWindowAbove();
|
|
|
|
void slotWindowBelow();
|
|
|
|
void slotWindowOnAllDesktops();
|
|
|
|
void slotWindowFullScreen();
|
|
|
|
void slotWindowNoBorder();
|
|
|
|
|
|
|
|
void slotWindowToNextDesktop();
|
|
|
|
void slotWindowToPreviousDesktop();
|
|
|
|
void slotWindowToDesktopRight();
|
|
|
|
void slotWindowToDesktopLeft();
|
|
|
|
void slotWindowToDesktopUp();
|
|
|
|
void slotWindowToDesktopDown();
|
|
|
|
|
2012-04-10 18:56:13 +00:00
|
|
|
/**
|
|
|
|
* Shows an outline at the specified @p geometry.
|
|
|
|
* If an outline is already shown the outline is moved to the new position.
|
|
|
|
* Use @link hideOutline to remove the outline again.
|
|
|
|
**/
|
|
|
|
void showOutline(const QRect &geometry);
|
|
|
|
/**
|
|
|
|
* Overloaded method for convenience.
|
|
|
|
**/
|
|
|
|
void showOutline(int x, int y, int width, int height);
|
|
|
|
/**
|
|
|
|
* Hides the outline previously shown by @link showOutline.
|
|
|
|
**/
|
|
|
|
void hideOutline();
|
|
|
|
|
2012-01-21 09:51:22 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void setupClientConnections(KWin::Client* client);
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2010-09-21 14:31:40 +00:00
|
|
|
|
2010-12-12 18:22:09 +00:00
|
|
|
}
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
#endif
|