From 2cd059894a13617a3593a9cd64e4bd17b4cb52be Mon Sep 17 00:00:00 2001 From: "Richard J. Moore" Date: Tue, 26 Jun 2001 23:30:52 +0000 Subject: [PATCH] Window grabbing stuff for linuxtag svn path=/trunk/kdebase/kwin/; revision=104070 --- kwinbindings.cpp | 3 +++ workspace.cpp | 33 +++++++++++++++++++++++++++++++++ workspace.h | 3 +++ 3 files changed, 39 insertions(+) diff --git a/kwinbindings.cpp b/kwinbindings.cpp index 8bb88e259b..60f750a050 100644 --- a/kwinbindings.cpp +++ b/kwinbindings.cpp @@ -113,3 +113,6 @@ This belongs in taskbar rather than here, so it'll have to wait until after 2.2 #endif keys->insertItem(i18n("Mouse Emulation"), "Mouse emulation", KKey("ALT+F12"), KKey()); keys->insertItem(i18n("Kill Window"), "Kill Window", KKey("CTRL+ALT+Escape"), KKey("Meta+Ctrl+Delete")); + keys->insertItem(i18n("Window Screenshot"), "Screenshot of active window", KKey("Print"), KKey()); + keys->insertItem(i18n("Desktop Screenshot"), "Screenshot of desktop", KKey("CTRL+PrtSc"), KKey()); + diff --git a/workspace.cpp b/workspace.cpp index 300a13f716..b10c7f0099 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -16,6 +16,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include #include #include +#include #include #include #include @@ -2572,6 +2573,10 @@ void Workspace::createKeybindings(){ keys->connectItem( "Mouse emulation", this, SLOT( slotMouseEmulation() ) ); keys->connectItem( "Kill Window", this, SLOT( slotKillWindow() ) ); + + keys->connectItem( "Screenshot of active window", this, SLOT( slotGrabWindow() ) ); + keys->connectItem( "Screenshot of desktop", this, SLOT( slotGrabDesktop() ) ); + keys->readSettings(); walkThroughDesktopsKeycode = keys->currentKey( "Walk through desktops" ); walkBackThroughDesktopsKeycode = keys->currentKey( "Walk back through desktops" ); @@ -2858,6 +2863,34 @@ void Workspace::killWindowAtPosition(int x, int y) } } +/*! + Takes a screenshot of the current window and puts it in the clipboard. +*/ +void Workspace::slotGrabWindow() +{ + qWarning( "grabbing window!!!\n" ); + + if ( active_client ) { + QPixmap p = QPixmap::grabWindow( active_client->window() ); + QClipboard *cb = QApplication::clipboard(); + cb->setPixmap( p ); + } + else + slotGrabDesktop(); +} + +/*! + Takes a screenshot of the whole desktop and puts it in the clipboard. +*/ +void Workspace::slotGrabDesktop() +{ + qWarning( "grabbing desktop!!!\n" ); + + QPixmap p = QPixmap::grabWindow( qt_xrootwin() ); + QClipboard *cb = QApplication::clipboard(); + cb->setPixmap( p ); +} + /*! Adjusts the desktop popup to the current values and the location of the popup client. diff --git a/workspace.h b/workspace.h index a17a5e93e8..120e4fd5cd 100644 --- a/workspace.h +++ b/workspace.h @@ -288,6 +288,9 @@ public slots: void slotKillWindow(); + void slotGrabWindow(); + void slotGrabDesktop(); + private slots: void desktopPopupAboutToShow(); void clientPopupAboutToShow();