2010-07-31 20:55:48 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2010 Martin Gräßlin <kde@martin-graesslin.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_SCREENSHOT_H
|
|
|
|
#define KWIN_SCREENSHOT_H
|
|
|
|
|
|
|
|
#include <kwineffects.h>
|
|
|
|
#include <QObject>
|
2010-09-14 19:52:44 +00:00
|
|
|
#include <QImage>
|
2010-07-31 20:55:48 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-02-25 19:25:21 +00:00
|
|
|
class ScreenShotEffect : public Effect
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-31 20:55:48 +00:00
|
|
|
Q_OBJECT
|
2010-09-14 19:52:44 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Screenshot")
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
enum ScreenShotType {
|
|
|
|
INCLUDE_DECORATION = 1 << 0,
|
|
|
|
INCLUDE_CURSOR = 1 << 1
|
2010-07-31 20:55:48 +00:00
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
ScreenShotEffect();
|
|
|
|
virtual ~ScreenShotEffect();
|
|
|
|
virtual void postPaintScreen();
|
2011-08-27 09:21:31 +00:00
|
|
|
virtual bool isActive() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
static bool supported();
|
|
|
|
static void convertFromGLImage(QImage &img, int w, int h);
|
|
|
|
public Q_SLOTS:
|
|
|
|
Q_SCRIPTABLE void screenshotWindowUnderCursor(int mask = 0);
|
2011-08-17 17:20:15 +00:00
|
|
|
/**
|
|
|
|
* Saves a screenshot of all screen into a file and returns the path to the file.
|
|
|
|
* Functionality requires hardware support, if not available a null string is returned.
|
|
|
|
* @returns Path to stored screenshot, or null string in failure case.
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QString screenshotFullscreen();
|
|
|
|
/**
|
|
|
|
* Saves a screenshot of the screen identified by @p screen into a file and returns the path to the file.
|
|
|
|
* Functionality requires hardware support, if not available a null string is returned.
|
2012-03-27 17:14:53 +00:00
|
|
|
* @param screen Number of screen as numbered by QDesktopWidget
|
2011-08-17 17:20:15 +00:00
|
|
|
* @returns Path to stored screenshot, or null string in failure case.
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QString screenshotScreen(int screen);
|
|
|
|
/**
|
|
|
|
* Saves a screenshot of the selected geometry into a file and returns the path to the file.
|
|
|
|
* Functionality requires hardware support, if not available a null string is returned.
|
|
|
|
* @param x Left upper x coord of region
|
|
|
|
* @param y Left upper y coord of region
|
|
|
|
* @param width Width of the region to screenshot
|
|
|
|
* @param height Height of the region to screenshot
|
|
|
|
* @returns Path to stored screenshot, or null string in failure case.
|
|
|
|
**/
|
|
|
|
Q_SCRIPTABLE QString screenshotArea(int x, int y, int width, int height);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
Q_SCRIPTABLE void screenshotCreated(qulonglong handle);
|
|
|
|
|
2011-12-07 14:04:11 +00:00
|
|
|
private slots:
|
2012-01-29 11:29:24 +00:00
|
|
|
void windowClosed( KWin::EffectWindow* w );
|
2011-12-07 14:04:11 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
void grabPointerImage(QImage& snapshot, int offsetx, int offsety);
|
2011-08-17 17:20:15 +00:00
|
|
|
QString blitScreenshot(const QRect &geometry);
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow *m_scheduledScreenshot;
|
|
|
|
ScreenShotType m_type;
|
|
|
|
QPixmap m_lastScreenshot;
|
|
|
|
};
|
2010-07-31 20:55:48 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif // KWIN_SCREENSHOT_H
|