+++ /dev/null
-/********************************************************************
- KWin - the KDE window manager
- This file is part of the KDE project.
-
- Copyright (C) 2010 Martin Gräßlin <mgraesslin@kde.org>
- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-
-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/>.
-*********************************************************************/
-#include "screenshot.h"
-#include <kwinglutils.h>
-#include <kwinxrenderutils.h>
-#include <KDE/KDebug>
-#include <KDE/KTemporaryFile>
-#include <QtDBus/QDBusConnection>
-#include <QVarLengthArray>
-#include <QtGui/QPainter>
-#include <QMatrix4x4>
-#include <xcb/xcb_image.h>
-
-namespace KWin
-{
-
-KWIN_EFFECT(screenshot, ScreenShotEffect)
-KWIN_EFFECT_SUPPORTED(screenshot, ScreenShotEffect::supported())
-
-bool ScreenShotEffect::supported()
-{
- return effects->compositingType() == XRenderCompositing ||
- (effects->isOpenGLCompositing() && GLRenderTarget::supported());
-}
-
-ScreenShotEffect::ScreenShotEffect()
- : m_scheduledScreenshot(0)
-{
- connect ( effects, SIGNAL(windowClosed(KWin::EffectWindow*)), SLOT(windowClosed(KWin::EffectWindow*)) );
- QDBusConnection::sessionBus().registerObject("/Screenshot", this, QDBusConnection::ExportScriptableContents);
- QDBusConnection::sessionBus().registerService("org.kde.kwin.Screenshot");
-}
-
-ScreenShotEffect::~ScreenShotEffect()
-{
- QDBusConnection::sessionBus().unregisterObject("/Screenshot");
- QDBusConnection::sessionBus().unregisterService("org.kde.kwin.Screenshot");
-}
-
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
-static QImage xPictureToImage(xcb_render_picture_t srcPic, const QRect &geometry, xcb_image_t **xImage)
-{
- xcb_pixmap_t xpix = xcb_generate_id(connection());
- xcb_create_pixmap(connection(), 32, xpix, rootWindow(), geometry.width(), geometry.height());
- XRenderPicture pic(xpix, 32);
- xcb_render_composite(connection(), XCB_RENDER_PICT_OP_SRC, srcPic, XCB_RENDER_PICTURE_NONE, pic,
- geometry.x(), geometry.y(), 0, 0, 0, 0, geometry.width(), geometry.height());
- xcb_flush(connection());
- *xImage = xcb_image_get(connection(), xpix, 0, 0, geometry.width(), geometry.height(), ~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
- QImage img((*xImage)->data, (*xImage)->width, (*xImage)->height, (*xImage)->stride, QImage::Format_ARGB32_Premultiplied);
- // TODO: byte order might need swapping
- xcb_free_pixmap(connection(), xpix);
- return img;
-}
-#endif
-
-void ScreenShotEffect::postPaintScreen()
-{
- effects->postPaintScreen();
- if (m_scheduledScreenshot) {
- WindowPaintData d(m_scheduledScreenshot);
- double left = 0;
- double top = 0;
- double right = m_scheduledScreenshot->width();
- double bottom = m_scheduledScreenshot->height();
- if (m_scheduledScreenshot->hasDecoration() && m_type & INCLUDE_DECORATION) {
- foreach (const WindowQuad & quad, d.quads) {
- // we need this loop to include the decoration padding
- left = qMin(left, quad.left());
- top = qMin(top, quad.top());
- right = qMax(right, quad.right());
- bottom = qMax(bottom, quad.bottom());
- }
- } else if (m_scheduledScreenshot->hasDecoration()) {
- WindowQuadList newQuads;
- left = m_scheduledScreenshot->width();
- top = m_scheduledScreenshot->height();
- right = 0;
- bottom = 0;
- foreach (const WindowQuad & quad, d.quads) {
- if (quad.type() == WindowQuadContents) {
- newQuads << quad;
- left = qMin(left, quad.left());
- top = qMin(top, quad.top());
- right = qMax(right, quad.right());
- bottom = qMax(bottom, quad.bottom());
- }
- }
- d.quads = newQuads;
- }
- const int width = right - left;
- const int height = bottom - top;
- bool validTarget = true;
- QScopedPointer<GLTexture> offscreenTexture;
- QScopedPointer<GLRenderTarget> target;
- if (effects->isOpenGLCompositing()) {
- int w = width;
- int h = height;
- if (!GLTexture::NPOTTextureSupported()) {
- w = nearestPowerOfTwo(w);
- h = nearestPowerOfTwo(h);
- }
- offscreenTexture.reset(new GLTexture(w, h));
- offscreenTexture->setFilter(GL_LINEAR);
- offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
- target.reset(new GLRenderTarget(*offscreenTexture));
- validTarget = target->valid();
- }
- if (validTarget) {
- d.setXTranslation(-m_scheduledScreenshot->x() - left);
- d.setYTranslation(-m_scheduledScreenshot->y() - top);
-
- // render window into offscreen texture
- int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT;
- QImage img;
- if (effects->isOpenGLCompositing()) {
- GLRenderTarget::pushRenderTarget(target.data());
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glClearColor(0.0, 0.0, 0.0, 1.0);
- setMatrix(offscreenTexture->width(), offscreenTexture->height());
- effects->drawWindow(m_scheduledScreenshot, mask, infiniteRegion(), d);
- restoreMatrix();
- // copy content from framebuffer into image
- img = QImage(QSize(width, height), QImage::Format_ARGB32);
- glReadnPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, img.byteCount(), (GLvoid*)img.bits());
- GLRenderTarget::popRenderTarget();
- ScreenShotEffect::convertFromGLImage(img, width, height);
- }
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- xcb_image_t *xImage = NULL;
- if (effects->compositingType() == XRenderCompositing) {
- setXRenderOffscreen(true);
- effects->drawWindow(m_scheduledScreenshot, mask, QRegion(0, 0, width, height), d);
- if (xRenderOffscreenTarget()) {
- img = xPictureToImage(xRenderOffscreenTarget(), QRect(0, 0, width, height), &xImage);
- }
- setXRenderOffscreen(false);
- }
-#endif
-
- if (m_type & INCLUDE_CURSOR) {
- grabPointerImage(img, m_scheduledScreenshot->x() + left, m_scheduledScreenshot->y() + top);
- }
-
- const int depth = img.depth();
- xcb_pixmap_t xpix = xcb_generate_id(connection());
- xcb_create_pixmap(connection(), depth, xpix, rootWindow(), img.width(), img.height());
-
- xcb_gcontext_t cid = xcb_generate_id(connection());
- xcb_create_gc(connection(), cid, xpix, 0, NULL);
- xcb_put_image(connection(), XCB_IMAGE_FORMAT_Z_PIXMAP, xpix, cid, img.width(), img.height(),
- 0, 0, 0, depth, img.byteCount(), img.constBits());
- xcb_free_gc(connection(), cid);
- xcb_flush(connection());
- emit screenshotCreated(xpix);
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- if (xImage) {
- xcb_image_destroy(xImage);
- }
-#endif
- }
- m_scheduledScreenshot = NULL;
- }
-}
-
-static QMatrix4x4 s_origProjection;
-static QMatrix4x4 s_origModelview;
-
-void ScreenShotEffect::setMatrix(int width, int height)
-{
- QMatrix4x4 projection;
- QMatrix4x4 identity;
- projection.ortho(QRect(0, 0, width, height));
- if (effects->compositingType() == OpenGL2Compositing) {
- ShaderBinder binder(ShaderManager::GenericShader);
- GLShader *shader = binder.shader();
- s_origProjection = shader->getUniformMatrix4x4("projection");
- s_origModelview = shader->getUniformMatrix4x4("modelview");
- shader->setUniform(GLShader::ProjectionMatrix, projection);
- shader->setUniform(GLShader::ModelViewMatrix, identity);
- } else if (effects->compositingType() == OpenGL1Compositing) {
-#ifdef KWIN_HAVE_OPENGL_1
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- loadMatrix(projection);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-#endif
- }
-}
-
-void ScreenShotEffect::restoreMatrix()
-{
- if (effects->compositingType() == OpenGL2Compositing) {
- ShaderBinder binder(ShaderManager::GenericShader);
- GLShader *shader = binder.shader();
- shader->setUniform(GLShader::ProjectionMatrix, s_origProjection);
- shader->setUniform(GLShader::ModelViewMatrix, s_origModelview);
- } else if (effects->compositingType() == OpenGL1Compositing) {
-#ifdef KWIN_HAVE_OPENGL_1
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-#endif
- }
-}
-
-void ScreenShotEffect::screenshotWindowUnderCursor(int mask)
-{
- m_type = (ScreenShotType)mask;
- const QPoint cursor = effects->cursorPos();
- EffectWindowList order = effects->stackingOrder();
- EffectWindowList::const_iterator it = order.constEnd(), first = order.constBegin();
- while( it != first ) {
- m_scheduledScreenshot = *(--it);
- if (m_scheduledScreenshot->isOnCurrentDesktop() &&
- !m_scheduledScreenshot->isMinimized() && !m_scheduledScreenshot->isDeleted() &&
- m_scheduledScreenshot->geometry().contains(cursor))
- break;
- m_scheduledScreenshot = 0;
- }
- if (m_scheduledScreenshot) {
- m_scheduledScreenshot->addRepaintFull();
- }
-}
-
-void ScreenShotEffect::screenshotForWindow(qulonglong winid, int mask)
-{
- m_type = (ScreenShotType) mask;
- EffectWindow* w = effects->findWindow(winid);
- if(w && !w->isMinimized() && !w->isDeleted()) {
- m_scheduledScreenshot = w;
- m_scheduledScreenshot->addRepaintFull();
- }
-}
-
-QString ScreenShotEffect::screenshotFullscreen()
-{
- return blitScreenshot(QRect(0, 0, displayWidth(), displayHeight()));
-}
-
-QString ScreenShotEffect::screenshotScreen(int screen)
-{
- return blitScreenshot(effects->clientArea(FullScreenArea, screen, 0));
-}
-
-QString ScreenShotEffect::screenshotArea(int x, int y, int width, int height)
-{
- return blitScreenshot(QRect(x, y, width, height));
-}
-
-QString ScreenShotEffect::blitScreenshot(const QRect &geometry)
-{
-#ifdef KWIN_HAVE_OPENGLES
- Q_UNUSED(geometry)
- kDebug(1212) << "Framebuffer Blit not supported";
- return QString();
-#else
- QImage img;
- if (effects->isOpenGLCompositing())
- {
- if (!GLRenderTarget::blitSupported()) {
- kDebug(1212) << "Framebuffer Blit not supported";
- return QString();
- }
- GLTexture tex(geometry.width(), geometry.height());
- GLRenderTarget target(tex);
- target.blitFromFramebuffer(geometry);
- // copy content from framebuffer into image
- tex.bind();
- img = QImage(geometry.size(), QImage::Format_ARGB32);
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)img.bits());
- tex.unbind();
- ScreenShotEffect::convertFromGLImage(img, geometry.width(), geometry.height());
- }
-
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- xcb_image_t *xImage = NULL;
-#endif
- if (effects->compositingType() == XRenderCompositing) {
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- img = xPictureToImage(effects->xrenderBufferPicture(), geometry, &xImage);
-#endif
- }
-
- KTemporaryFile temp;
- temp.setSuffix(".png");
- temp.setAutoRemove(false);
- if (!temp.open()) {
- return QString();
- }
- img.save(&temp);
-#ifdef KWIN_HAVE_XRENDER_COMPOSITING
- if (xImage) {
- xcb_image_destroy(xImage);
- }
-#endif
- temp.close();
- return temp.fileName();
-#endif
-}
-
-void ScreenShotEffect::grabPointerImage(QImage& snapshot, int offsetx, int offsety)
-// Uses the X11_EXTENSIONS_XFIXES_H extension to grab the pointer image, and overlays it onto the snapshot.
-{
- QScopedPointer<xcb_xfixes_get_cursor_image_reply_t, QScopedPointerPodDeleter> cursor(
- xcb_xfixes_get_cursor_image_reply(connection(),
- xcb_xfixes_get_cursor_image_unchecked(connection()),
- NULL));
- if (cursor.isNull())
- return;
-
- QImage qcursorimg((uchar *) xcb_xfixes_get_cursor_image_cursor_image(cursor.data()), cursor->width, cursor->height,
- QImage::Format_ARGB32_Premultiplied);
-
- QPainter painter(&snapshot);
- painter.drawImage(QPointF(cursor->x - cursor->xhot - offsetx, cursor->y - cursor ->yhot - offsety), qcursorimg);
-}
-
-void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h)
-{
- // from QtOpenGL/qgl.cpp
- // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- // see http://qt.gitorious.org/qt/qt/blobs/master/src/opengl/qgl.cpp
- if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
- // OpenGL gives RGBA; Qt wants ARGB
- uint *p = (uint*)img.bits();
- uint *end = p + w * h;
- while (p < end) {
- uint a = *p << 24;
- *p = (*p >> 8) | a;
- p++;
- }
- } else {
- // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB
- for (int y = 0; y < h; y++) {
- uint *q = (uint*)img.scanLine(y);
- for (int x = 0; x < w; ++x) {
- const uint pixel = *q;
- *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff)
- | (pixel & 0xff00ff00);
-
- q++;
- }
- }
-
- }
- img = img.mirrored();
-}
-
-bool ScreenShotEffect::isActive() const
-{
- return m_scheduledScreenshot != NULL && !effects->isScreenLocked();
-}
-
-void ScreenShotEffect::windowClosed( EffectWindow* w )
-{
- if (w == m_scheduledScreenshot) {
- m_scheduledScreenshot = NULL;
- screenshotWindowUnderCursor(m_type);
- }
-}
-
-} // namespace
+++ /dev/null
-[Desktop Entry]
-Name=Screenshot
-Name[ar]=لقطة شاشة
-Name[ast]=Captura de pantalla
-Name[bg]=Снимка на екрана
-Name[bs]=Snimak ekrana
-Name[ca]=Captura de pantalla
-Name[ca@valencia]=Captura de pantalla
-Name[cs]=Snímek obrazovky
-Name[da]=Skærmbillede
-Name[de]=Bildschirmfoto
-Name[el]=Στιγμιότυπο
-Name[en_GB]=Screenshot
-Name[es]=Captura de pantalla
-Name[et]=Ekraanipilt
-Name[eu]=Pantaila-argazkia
-Name[fa]=عکس صفحه
-Name[fi]=Kuvankaappaus
-Name[ga]=Seat den Scáileán
-Name[gl]=Captura de pantalla
-Name[he]=צילום מסך
-Name[hi]=स्क्रीन चित्र
-Name[hr]=Uslikan ekran
-Name[hu]=Képernyőkép
-Name[ia]=Instantanee de schermo
-Name[is]=Skjámynd
-Name[kk]=Экраннан түсіргені
-Name[km]=រូបថតអេក្រង់
-Name[kn]=ತೆರೆಚಿತ್ರ
-Name[ko]=스크린샷
-Name[lt]=Nuotrauka
-Name[lv]=Ekrānattēls
-Name[mr]=स्क्रीनशॉट
-Name[nb]=Skjermbilde
-Name[nds]=Schirmfoto
-Name[nl]=Schermafdruk
-Name[nn]=Skjermbilete
-Name[pa]=ਸਕਰੀਨ-ਸ਼ਾਟ
-Name[pl]=Zrzut ekranu
-Name[pt]=Captura do Ecrã
-Name[pt_BR]=Captura de tela
-Name[ro]=Captură de ecran
-Name[ru]=Снимок экрана
-Name[sk]=Snímka obrazovky
-Name[sl]=Zaslonska slika
-Name[sr]=Снимак екрана
-Name[sr@ijekavian]=Снимак екрана
-Name[sr@ijekavianlatin]=Snimak ekrana
-Name[sr@latin]=Snimak ekrana
-Name[sv]=Skärmbild
-Name[tg]=Сурати экран
-Name[th]=จับภาพหน้าจอ
-Name[tr]=Ekran Görüntüsü
-Name[ug]=ئېكران كەسمىسى
-Name[uk]=Знімок вікна
-Name[wa]=Waitroûlêye
-Name[x-test]=xxScreenshotxx
-Name[zh_CN]=屏幕截图
-Name[zh_TW]=螢幕快照
-Icon=preferences-system-windows-effect-screenshot
-Comment=Saves screenshot of active window into the home directory
-Comment[ar]=يحفظ لقطة شاشة للنافذة الحالية إلى مجلد المنزل
-Comment[ast]=Guarda una captura de la ventana activa na carpeta personal
-Comment[bg]=Запазване снимка на активния прозорец в домашната папка
-Comment[bs]=Upisuje snimak aktivnog prozora u domaću fasciklu
-Comment[ca]=Desa una captura de pantalla de la finestra activa en el directori personal
-Comment[ca@valencia]=Guarda una captura de pantalla de la finestra activa en el directori personal
-Comment[cs]=Ukládá snímky obrazovky aktivního okna do domovského adresáře
-Comment[da]=Gemmer et skærmbillede af det aktive vindue i hjemmemappen
-Comment[de]=Speichert ein Bildschirmfoto des aktiven Fensters im Persönlichen Ordner.
-Comment[el]=Αποθηκεύει ένα στιγμιότυπο του τρέχοντος παραθύρου στον προσωπικό κατάλογο
-Comment[en_GB]=Saves screenshot of active window into the home directory
-Comment[es]=Guarda una captura de la ventana activa en la carpeta personal
-Comment[et]=Aktiivse akna ekraanipildi salvestamine kodukataloogi
-Comment[eu]=Leiho aktiboaren pantaila-argazkia etxeko direktorioan gordetzen du
-Comment[fi]=Tallentaa kuvankaappauksen aktiivisesta ikkunasta kotikansioon
-Comment[gl]=Garda no cartafol persoal unha captura de pantalla da xanela activa
-Comment[he]=משמש לשמירת צילום מסך של החלון הפעיל כתמונה בתיקיית הבית
-Comment[hr]=Sprema uslikan ekran aktivnog prozora u osobnu mapu
-Comment[hu]=Elmenti az aktív ablak képernyőképét a saját könyvtárba
-Comment[ia]=Salveguarda instantanee de schermo del fenestra active in le directorio domo
-Comment[is]=Vistar skjámynd af virkum glugga í heimamöppuna
-Comment[kk]=Назардағы экранды түсіріп, мекен каталогына сақтау
-Comment[km]=រក្សាទុករូបថតអេក្រង់នៃបង្អួចសកម្មនៅក្នុងថតផ្ទះ
-Comment[ko]=홈 디렉터리에 활성 창의 스크린샷을 저장합니다
-Comment[lt]=Išsaugo aktyvaus lango nuotrauką namų aplanke
-Comment[lv]=Saglabā aktīvā loga ekrānattēlu mājas mapē
-Comment[mr]=सक्रिय चौकटीचा स्क्रीनशॉट मुख्य संचयीकेत साठवा
-Comment[nb]=Lagrer skjermbilde av det aktive vinduet i hjemmemappa
-Comment[nds]=Sekert en Schirmfoto vun dat aktive Finster na den Tohuusorner
-Comment[nl]=Slaat schermafdruk van actief venster op in de persoonlijke map
-Comment[nn]=Lagrar eit skjermbilete av det aktive vindauget i heimemappa
-Comment[pa]=ਐਕਟਿਵ ਵਿੰਡੋ ਦਾ ਸਕਰੀਨਸ਼ਾਟ ਘਰ ਡਾਇਰੈਕਟਰੀ ਵਿੱਚ ਸੰਭਾਲੋ
-Comment[pl]=Zapisuje zrzut aktywnego okna w katalogu domowym
-Comment[pt]=Captura uma imagem da janela activa para a pasta pessoal
-Comment[pt_BR]=Captura uma imagem da janela ativa para a pasta do usuário
-Comment[ro]=Salvează captura ferestrei active în dosarul personal
-Comment[ru]=Сохраняет снимок активного окна в домашний каталог
-Comment[sk]=Uloží snímku obrazovky aktívneho okna do domovského adresára
-Comment[sl]=V domačo mapo shrani zaslonsko sliko dejavnega okna
-Comment[sr]=Уписује снимак активног прозора у домаћу фасциклу
-Comment[sr@ijekavian]=Уписује снимак активног прозора у домаћу фасциклу
-Comment[sr@ijekavianlatin]=Upisuje snimak aktivnog prozora u domaću fasciklu
-Comment[sr@latin]=Upisuje snimak aktivnog prozora u domaću fasciklu
-Comment[sv]=Sparar en skärmbild av det aktiva fönstret i hemkatalogen
-Comment[th]=บันทึกการจับภาพหน้าจอของหน้าต่างที่ทำงานอยู่ไปเก็บไว้ในไดเรกทอรีพื้นที่ส่วนตัว
-Comment[tr]=Etkin pencerenin ekran görüntüsünü ev dizinine kaydeder
-Comment[ug]=ئاكتىپ كۆزنەكنىڭ ئېكران كەسمىسىنى ماكان مۇندەرىجىسىگە ساقلايدۇ
-Comment[uk]=Зберігає знімок активного вікна до домашнього каталогу
-Comment[x-test]=xxSaves screenshot of active window into the home directoryxx
-Comment[zh_CN]=将活动窗口的截图保存到主目录
-Comment[zh_TW]=將目前作用中視窗的快照儲存到家目錄中
-
-Type=Service
-X-KDE-ServiceTypes=KWin/Effect
-X-KDE-PluginInfo-Author=Martin Gräßlin
-X-KDE-PluginInfo-Email=mgraesslin@kde.org
-X-KDE-PluginInfo-Name=kwin4_effect_screenshot
-X-KDE-PluginInfo-Version=0.1.0
-X-KDE-PluginInfo-Category=Appearance
-X-KDE-PluginInfo-Depends=
-X-KDE-PluginInfo-License=GPL
-X-KDE-PluginInfo-EnabledByDefault=true
-X-KDE-Library=kwin4_effect_builtins
-X-KDE-Ordering=50
+++ /dev/null
-/********************************************************************
- KWin - the KDE window manager
- This file is part of the KDE project.
-
- Copyright (C) 2010 Martin Gräßlin <mgraesslin@kde.org>
-
-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>
-#include <QImage>
-
-namespace KWin
-{
-
-class ScreenShotEffect : public Effect
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Screenshot")
-public:
- enum ScreenShotType {
- INCLUDE_DECORATION = 1 << 0,
- INCLUDE_CURSOR = 1 << 1
- };
- ScreenShotEffect();
- virtual ~ScreenShotEffect();
- virtual void postPaintScreen();
- virtual bool isActive() const;
-
- static bool supported();
- static void convertFromGLImage(QImage &img, int w, int h);
-public Q_SLOTS:
- Q_SCRIPTABLE void screenshotForWindow(qulonglong winid, int mask = 0);
- Q_SCRIPTABLE void screenshotWindowUnderCursor(int mask = 0);
- /**
- * 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.
- * @param screen Number of screen as numbered by QDesktopWidget
- * @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);
-
-Q_SIGNALS:
- Q_SCRIPTABLE void screenshotCreated(qulonglong handle);
-
-private slots:
- void windowClosed( KWin::EffectWindow* w );
-
-private:
- void grabPointerImage(QImage& snapshot, int offsetx, int offsety);
- QString blitScreenshot(const QRect &geometry);
- void setMatrix(int width, int height);
- void restoreMatrix();
- EffectWindow *m_scheduledScreenshot;
- ScreenShotType m_type;
-};
-
-} // namespace
-
-#endif // KWIN_SCREENSHOT_H