Dump the old taskbar thumbnail effect, replace it with a new one

that renders the thumbnail directly into another window (taskbar's tooltip).


svn path=/trunk/KDE/kdebase/workspace/; revision=756636
icc-effect-5.14.5
Luboš Luňák 2008-01-03 14:00:13 +00:00
parent 41c2b3923d
commit 52e8207d5f
5 changed files with 144 additions and 179 deletions

View File

@ -35,7 +35,6 @@ install( FILES kwineffect.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
# sources
SET(kwin4_effect_builtins_sources
boxswitch.cpp
demo_taskbarthumbnail.cpp
desktopgrid.cpp
dialogparent.cpp
diminactive.cpp
@ -47,13 +46,13 @@ SET(kwin4_effect_builtins_sources
minimizeanimation.cpp
presentwindows.cpp
scalein.cpp
taskbarthumbnail.cpp
thumbnailaside.cpp
zoom.cpp
)
# their .desktop files
install( FILES
boxswitch.desktop
demo_taskbarthumbnail.desktop
desktopgrid.desktop
dialogparent.desktop
diminactive.desktop
@ -65,6 +64,7 @@ install( FILES
minimizeanimation.desktop
presentwindows.desktop
scalein.desktop
taskbarthumbnail.desktop
thumbnailaside.desktop
zoom.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

View File

@ -1,123 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
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 "demo_taskbarthumbnail.h"
#include <limits.h>
namespace KWin
{
KWIN_EFFECT( demo_taskbarthumbnail, TaskbarThumbnailEffect )
TaskbarThumbnailEffect::TaskbarThumbnailEffect()
{
mLastCursorPos = QPoint(-1, -1);
}
void TaskbarThumbnailEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
// We might need to paint thumbnails if cursor has moved since last
// painting or some thumbnails were painted the last time
QPoint cpos = cursorPos();
if(cpos != mLastCursorPos || mThumbnails.count() > 0)
{
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
mThumbnails.clear();
mLastCursorPos = cpos;
}
effects->prePaintScreen(data, time);
}
void TaskbarThumbnailEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
{
QRect iconGeo = w->iconGeometry();
if(iconGeo.contains( mLastCursorPos ))
mThumbnails.append( w );
effects->prePaintWindow( w, data, time );
}
void TaskbarThumbnailEffect::postPaintScreen()
{
// Paint the thumbnails. They need to be painted after other windows
// because we want them on top of everything else
int space = 4;
foreach( EffectWindow* w, mThumbnails )
{
QRect thumb = getThumbnailPosition( w, &space);
WindowPaintData thumbdata( w );
thumbdata.xTranslate = thumb.x() - w->x();
thumbdata.yTranslate = thumb.y() - w->y();
thumbdata.xScale = thumb.width() / (double)w->width();
thumbdata.yScale = thumb.height() / (double)w->height();
// From Scene::Window::infiniteRegion()
QRegion infRegion = QRegion( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
effects->paintWindow( w, PAINT_WINDOW_TRANSFORMED, infRegion, thumbdata );
}
// Call the next effect.
effects->postPaintScreen();
}
QRect TaskbarThumbnailEffect::getThumbnailPosition( EffectWindow* c, int* space ) const
{
QRect thumb;
QRect icon = c->iconGeometry();
// Try to figure out if taskbar is horizontal or vertical
if( icon.right() < 40 || ( displayWidth() - icon.left()) < 40 )
{
// Vertical taskbar...
double scale = qMin(qMax(icon.height(), 100) / (double)c->height(), 200.0 / c->width());
thumb.setSize( QSize( int(scale * c->width()),int(scale * c->height()) ));
if( icon.right() < 40 ) // ...on the left
thumb.moveTopLeft( QPoint( icon.right() + *space, icon.top() ));
else // ...on the right
thumb.moveTopRight( QPoint( icon.left() - *space, icon.top()));
*space += thumb.width() + 8;
}
else
{
// Horizontal taskbar...
double scale = qMin(qMax(icon.width(), 75) / (double)c->width(), 200.0 / c->height());
thumb.setSize( QSize( int(scale * c->width()),int(scale * c->height()) ));
if( icon.top() < ( displayHeight() - icon.bottom())) // ...at the top
thumb.moveTopLeft( QPoint( icon.left(), icon.bottom() + *space ));
else // ...at the bottom
thumb.moveBottomLeft( QPoint( icon.left(), icon.top() - *space ));
*space += thumb.height() + 8;
}
return thumb;
}
void TaskbarThumbnailEffect::mouseChanged( const QPoint& pos, const QPoint&,
Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers )
{
// this should check if the mouse position change actually means something
// (just like it should be done in prePaintScreen()), but since this effect
// will be replaced in the future, just trigger a repaint
if( pos != mLastCursorPos )
effects->addRepaintFull();
}
} // namespace

View File

@ -0,0 +1,123 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
Copyright (C) 2007 Lubos Lunak <l.lunak@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/>.
*********************************************************************/
#include "taskbarthumbnail.h"
#include <kdebug.h>
// This effect shows a preview inside a window that has a special property set
// on it that says which window and where to render. It is used by the taskbar
// to show window previews in tooltips.
namespace KWin
{
KWIN_EFFECT( taskbarthumbnail, TaskbarThumbnailEffect )
TaskbarThumbnailEffect::TaskbarThumbnailEffect()
{
atom = XInternAtom( display(), "_KDE_WINDOW_PREVIEW", False );
effects->registerPropertyType( atom, true );
// TODO hackish way to announce support, make better after 4.0
unsigned char dummy = 0;
XChangeProperty( display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1 );
}
TaskbarThumbnailEffect::~TaskbarThumbnailEffect()
{
XDeleteProperty( display(), rootWindow(), atom );
effects->registerPropertyType( atom, false );
}
void TaskbarThumbnailEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
// if( thumbnails.count() > 0 )
// // TODO this should not be needed (it causes whole screen repaint)
// data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time);
}
void TaskbarThumbnailEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
{
// TODO what if of the windows is translucent and one not? change data.mask?
effects->prePaintWindow( w, data, time );
}
void TaskbarThumbnailEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
effects->paintWindow( w, mask, region, data ); // paint window first
if( thumbnails.contains( w ))
{ // paint thumbnails on it
foreach( const Data thumb, thumbnails.values( w ))
{
EffectWindow* thumbw = effects->findWindow( thumb.window );
WindowPaintData data( thumbw );
QRect r;
setPositionTransformations( data, r,
thumbw, thumb.rect.translated( w->pos()), Qt::KeepAspectRatio );
effects->drawWindow( thumbw,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSFORMED,
r, data );
}
}
}
void TaskbarThumbnailEffect::windowAdded( EffectWindow* w )
{
propertyNotify( w, atom ); // read initial value
}
void TaskbarThumbnailEffect::windowRemoved( EffectWindow* w )
{
thumbnails.remove( w );
}
void TaskbarThumbnailEffect::propertyNotify( EffectWindow* w, long a )
{
if( a != atom )
return;
thumbnails.remove( w );
QByteArray data = w->readProperty( atom, atom, 32 );
if( data.length() < 1 )
return;
long* d = reinterpret_cast< long* >( data.data());
int len = data.length() / 4;
int pos = 0;
int cnt = d[ 0 ];
++pos;
for( int i = 0;
i < cnt;
++i )
{
int size = d[ pos ];
if( len - pos < size )
return; // format error
++pos;
Data data;
data.window = d[ pos ];
data.rect = QRect( d[ pos + 1 ], d[ pos + 2 ], d[ pos + 3 ], d[ pos + 4 ] );
thumbnails.insert( w, data );
pos += size;
}
}
} // namespace

View File

@ -8,10 +8,7 @@ Name[eo]=Taskobretaj miniaturoj
Name[es]=Miniaturas de la barra de tareas
Name[et]=Tegumiriba pisipildid
Name[eu]=Ataza-barraren koadro txikiak
Name[fr]=Aperçus du gestionnaire des tâches
Name[fy]=Taakbalke miniatueren
Name[ga]=Mionsamhlacha sa Tascbharra
Name[gl]=Miniaturas da barra de tarefas
Name[hu]=Feladatsáv-ablaktartalom
Name[ja]=タスクバーのサムネイル
Name[km]=រូបភាព​តូចៗ​របារ​ភារកិច្ច
@ -24,19 +21,14 @@ Name[pa]=ਟਾਸਕਬਾਰ ਥੰਮਨੇਲ
Name[pl]=Miniaturki w pasku zadań
Name[pt]=Miniaturas da Barra de Tarefas
Name[pt_BR]=Miniaturas da Barra de Tarefas
Name[se]=Bargoholgga minigovat
Name[sl]=Sličice za opravilno vrstico
Name[sr]=Сличице у траци задатака
Name[sr@latin]=Sličice u traci zadataka
Name[sv]=Miniatyrbilder i aktivitetsfält
Name[uk]=Мініатюри панелі задач
Name[wa]=Prévoeyaedjes båre des bouyes
Name[x-test]=xxTaskbar Thumbnailsxx
Name[zh_CN]=任务栏缩略图
Name[zh_TW]=工作列縮圖
Icon=preferences-system-windows-effect-taskbarthumbnail
Comment=Shows window thumbnails when cursor is on their taskbar entry
Comment[bg]=Показване на умалени копия, когато курсора е върху лентата с инструменти
Comment[ca]=Mostra una miniatura de la finestra quan el cursor està sobre la seva entrada de la barra de tasques
Comment[de]=Zeigt Fenster-Vorschaubilder an, wenn sich der Mauszeiger über dem Fensterleisten-Eintrag befindet.
Comment[el]=Εμφάνιση εικόνας επισκόπησης παραθύρου όταν το ποντίκι περνάει πάνω από την καταχώρησή του στη γραμμή εργασιών
@ -44,10 +36,7 @@ Comment[eo]=Kiam la muso ŝvebas super taskobreta ero, miniaturo de tiu fenestro
Comment[es]=Muestra miniaturas de la ventana cuando el cursor está en la entrada de su barra de tareas
Comment[et]=Akende pisipiltide näitamine, kui kursor on nende tegumiriba kirje kohal
Comment[fi]=Näyttää ikkunan esikatselukuvan, kun kohdistin osoittaa ohjelmaa tehtävärivillä.
Comment[fr]=Affiche les aperçus des fenêtres lorsque le curseur est sur leur icône dans le gestionnaire des tâches
Comment[fy]=Finsterrminiateuren sjen litte as it rinnerke op syn taakbalke setten wurdt
Comment[ga]=Taispeáin mionsamhail d'fhuinneog nuair atá an cúrsóir os a cionn sa tascbharra
Comment[gl]=Mostra miniaturas das fiestras cando o cursor está sobra a súa entrada na barra de tarefas
Comment[hu]=Megmutatja a feladatokhoz tartozó ablakok kicsinyített képét
Comment[ja]=タスクバーエントリの上にマウスが来たときに、そのウィンドウのサムネイルを表示します
Comment[km]=បង្ហាញ​រូបភាព​តូចៗ​របស់​បង្អួច នៅ​ពេល​ទស្សន៍​នៅ​លើ​ធាតុ​របារ​ភារកិច្ច​របស់​ពួកវា
@ -56,59 +45,41 @@ Comment[nb]=Viser minibilder av vinduene når pekeren er over oppgavelinja
Comment[nds]=Wiest Vöransichten vun de Finstern, wenn Du mit de Muus op ehr Programmbalken-Indrääg wiest.
Comment[nl]=Vensterminiaturen tonen als cursor op bijhorende taakbalkknop wordt geplaatst
Comment[nn]=Vis miniatyrbilete av vindauge når peikaren er over ikona deira på oppgåvelinja
Comment[pa]=ਵਿੰਡੋ ਥੰਮਨੇਲ ਵੇਖੋ, ਜਦੋਂ ਕਿ ਕਰਸਰ ਉਸ ਦੀ ਟਾਸਕਬਾਰ ਐਂਟਰੀ ਉੱਤੇ ਹੋਵੇ।
Comment[pl]=Pokazuje miniaturki okien, kiedy kursor znajduje się na ich pozycji w pasku zadań
Comment[pt]=Mostra as miniaturas das janelas quando o cursor está no seu item da barra de tarefas
Comment[pt_BR]=Mostra miniaturas das janelas quando o cursor está nas suas entradas na barra de tarefas
Comment[se]=Čájeha govaža láses go seaván lea dan ikona bajábealde
Comment[sl]=Ko je kazalec nad gumbom v opravilni vrstici , se prikaže sličica okna
Comment[sr]=Сличице прозора како показивач преко ставки у траци задатака
Comment[sr@latin]=Sličice prozora kako pokazivač preko stavki u traci zadataka
Comment[sv]=Visar miniatyrbilder av fönster när markören är över deras post i aktivitetsfältet
Comment[uk]=Показує мініатюри вікон, коли курсор знаходиться над елементом панелі задач
Comment[x-test]=xxShows window thumbnails when cursor is on their taskbar entryxx
Comment[zh_CN]=当鼠标指针指向任务栏时显示窗口缩略图
Comment[zh_TW]=當游標停在工作列的按鈕上面時,顯示視窗的縮圖
Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Rivo Laks
X-KDE-PluginInfo-Email=rivolaks@hot.ee
X-KDE-PluginInfo-Name=kwin4_effect_demo_taskbarthumbnail
X-KDE-PluginInfo-Author=Lubos Lunak
X-KDE-PluginInfo-Email=l.lunak@kde.org
X-KDE-PluginInfo-Name=kwin4_effect_taskbarthumbnail
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Window Management
X-KDE-PluginInfo-Category[bg]=Управление на прозорците
X-KDE-PluginInfo-Category[ca]=Gestió de les finestres
X-KDE-PluginInfo-Category[de]=Fensterverwaltung
X-KDE-PluginInfo-Category[el]=Διαχείριση παραθύρων
X-KDE-PluginInfo-Category[eo]=Fenestra administrado
X-KDE-PluginInfo-Category[es]=Administración de ventanas
X-KDE-PluginInfo-Category[et]=Akende haldus
X-KDE-PluginInfo-Category[fr]=Gestion des fenêtres
X-KDE-PluginInfo-Category[ga]=Bainisteoireacht Fuinneog
X-KDE-PluginInfo-Category[hu]=Ablakkezelés
X-KDE-PluginInfo-Category[ja]=ウィンドウマネージメント
X-KDE-PluginInfo-Category[km]=ការ​គ្រប់គ្រង​បង្អួច
X-KDE-PluginInfo-Category[lv]=Logu pārvaldība
X-KDE-PluginInfo-Category[nb]=Vindusbehandling
X-KDE-PluginInfo-Category[nds]=Finsterpleeg
X-KDE-PluginInfo-Category[nl]=Vensterbeheer
X-KDE-PluginInfo-Category[oc]=Gestion de las fenèstras
X-KDE-PluginInfo-Category[pa]=ਵਿੰਡੋ ਮੈਨਿਜਮੈਂਟ
X-KDE-PluginInfo-Category[pl]=Zarządzanie oknami
X-KDE-PluginInfo-Category[pt]=Gestão de Janelas
X-KDE-PluginInfo-Category[pt_BR]=Gerenciamento de Janelas
X-KDE-PluginInfo-Category[se]=Lásegieđaheapmi
X-KDE-PluginInfo-Category[sl]=Upravljanje z okni
X-KDE-PluginInfo-Category[sr]=Управљање прозорима
X-KDE-PluginInfo-Category[sr@latin]=Upravljanje prozorima
X-KDE-PluginInfo-Category[sv]=Fönsterhantering
X-KDE-PluginInfo-Category[uk]=Керування вікнами
X-KDE-PluginInfo-Category[wa]=Manaedjmint d' purnea
X-KDE-PluginInfo-Category[x-test]=xxWindow Managementxx
X-KDE-PluginInfo-Category[zh_CN]=窗口管理
X-KDE-PluginInfo-Category[zh_TW]=視窗管理
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-Library=kwin4_effect_builtins

View File

@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
Copyright (C) 2007 Lubos Lunak <l.lunak@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
@ -18,42 +19,35 @@ 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_DEMO_TASKBARTHUMBNAIL_H
#define KWIN_DEMO_TASKBARTHUMBNAIL_H
#ifndef KWIN_TASKBARTHUMBNAIL_H
#define KWIN_TASKBARTHUMBNAIL_H
// Include with base class for effects.
#include <kwineffects.h>
namespace KWin
{
/**
* Render small thumbnail of window next to it's taskbar entry when the cursor
* is above the taskbar entry.
* Note that this functionality will be replaced in the future so that taskbar
* itself can request a thumbnail to be rendered in a give location with a
* given size.
**/
class TaskbarThumbnailEffect
: public Effect
{
public:
TaskbarThumbnailEffect();
virtual ~TaskbarThumbnailEffect();
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
virtual void postPaintScreen();
virtual void mouseChanged( const QPoint& pos, const QPoint& old,
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void windowAdded( EffectWindow* w );
virtual void windowRemoved( EffectWindow* w );
virtual void propertyNotify( EffectWindow* w, long atom );
protected:
QRect getThumbnailPosition( EffectWindow* c, int* space ) const;
private:
QList< EffectWindow* > mThumbnails;
QPoint mLastCursorPos;
struct Data
{
Window window; // thumbnail of this window
QRect rect;
};
long atom;
QMultiHash< EffectWindow*, Data > thumbnails;
};
} // namespace