Ported client to kwin_iii

svn path=/trunk/kdebase/kwin/; revision=251777
icc-effect-5.14.5
Luciano Montanaro 2003-09-17 08:53:04 +00:00
parent 586b2c8fd2
commit 6becc8bb5f
4 changed files with 280 additions and 149 deletions

View File

@ -1,21 +1,17 @@
INCLUDES = $(all_includes)
INCLUDES = -I$(srcdir)/../../lib $(all_includes)
kde_module_LTLIBRARIES = kwin_laptop.la
kde_module_LTLIBRARIES = kwin3_laptop.la
kwin_laptop_la_SOURCES = laptopclient.cpp
#kwin_laptop_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
kwin_laptop_la_LDFLAGS = $(all_libraries) -avoid-version -module $(KDE_RPATH) $(KDE_MT_LDFLAGS)
kwin3_laptop_la_SOURCES = laptopclient.cpp
kwin3_laptop_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
kwin3_laptop_la_LIBADD = ../../lib/libkwin.la
METASOURCES = AUTO
noinst_HEADERS = laptopclient.h
lnkdir = $(kde_datadir)/kwin/
lnkdir = $(kde_datadir)/kwin
lnk_DATA = laptop.desktop
EXTRA_DIST = $(lnk_DATA)
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

View File

@ -5,6 +5,7 @@ Name[af]=Draagbare rekenaar
Name[az]=Dizüstü
Name[br]=Hezoug
Name[ca]=Portàtil
Name[cy]=Gluniadur
Name[da]=Bærbar
Name[el]=Φορητό
Name[eo]=Portkomputilo
@ -18,20 +19,26 @@ Name[is]=Ferðavél
Name[it]=Portatile
Name[ja]=ラップトップ
Name[ko]=랩탑
Name[lo]=ແລບທອບ
Name[lv]=Laptops
Name[mn]=Лаптоп
Name[nb]=Bærbar
Name[nl]=Schootcomputer
Name[nn]=Bærbar
Name[oc]=Portatil
Name[pt]=Portátil
Name[sl]=Prenosnik
Name[sr]=Лаптоп
Name[sv]=Bärbar dator
Name[th]=แลปทอป
Name[tr]=Dizüstü
Name[uk]=Мобільний комп'ютер (лептоп)
Name[ven]=Khomupwutha pfarwa
Name[wa]=Poirtåve
Name[wen]=laptop
Name[xh]=Umphezulu osongiweyo
Name[xx]=xxLaptopxx
Name[zh_CN]=膝上计算机
Name[zh_TW]=膝上型的電腦
Name[zu]=Ikhomputha ephathwayo eyisicaba
X-KDE-Library=kwin_laptop
X-KDE-Library=kwin3_laptop

View File

@ -1,3 +1,5 @@
// Port to KDE 3.2: Luciano Montanaro <mikelima@virgilio.it>
//
#include <kconfig.h> // up here to avoid X11 header conflict :P
#include "laptopclient.h"
@ -9,11 +11,8 @@
#include <kapplication.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
using namespace KWinInternal;
#include <qtooltip.h>
#include <qlabel.h>
namespace Laptop {
@ -54,10 +53,14 @@ static QColor btnForeground;
static bool pixmaps_created = false;
static int titleHeight = 14; // configurable title height not implemented yet
static int titleHeight = 14;
static int btnWidth1 = 17;
static int btnWidth2 = 27;
static inline const KDecorationOptions* options()
{
return KDecoration::options();
}
static void drawButtonFrame(KPixmap *pix, const QColorGroup &g, bool sunken)
{
@ -89,6 +92,10 @@ static void create_pixmaps()
return;
pixmaps_created = true;
titleHeight = QFontMetrics(options()->font(true)).height() + 2;
titleHeight &= ~1; // Make title height even
if (titleHeight < 14) titleHeight = 14;
// titlebar
QPainter p;
QPainter maskPainter;
@ -102,10 +109,10 @@ static void create_pixmaps()
maskPainter.setPen(Qt::color1);
for(i=0, y=2; i < 3; ++i, y+=4){
for(x=1; x <= 33; x+=3){
p.setPen(options->color(Options::TitleBar, true).light(150));
p.setPen(options()->color(KDecoration::ColorTitleBar, true).light(150));
p.drawPoint(x, y);
maskPainter.drawPoint(x, y);
p.setPen(options->color(Options::TitleBar, true).dark(150));
p.setPen(options()->color(KDecoration::ColorTitleBar, true).dark(150));
p.drawPoint(x+1, y+1);
maskPainter.drawPoint(x+1, y+1);
}
@ -119,19 +126,19 @@ static void create_pixmaps()
aUpperGradient->resize(32, titleHeight+2);
iUpperGradient = new KPixmap;
iUpperGradient->resize(32, titleHeight+2);
QColor bgColor = options->color(Options::TitleBar, true);
QColor bgColor = options()->color(KDecoration::ColorTitleBar, true);
KPixmapEffect::gradient(*aUpperGradient,
bgColor.light(120),
bgColor.dark(120),
KPixmapEffect::VerticalGradient);
bgColor = options->color(Options::TitleBar, false);
bgColor = options()->color(KDecoration::ColorTitleBar, false);
KPixmapEffect::gradient(*iUpperGradient,
bgColor.light(120),
bgColor.dark(120),
KPixmapEffect::VerticalGradient);
}
// buttons (active/inactive, sunken/unsunken, 2 sizes each)
QColorGroup g = options->colorGroup(Options::ButtonBg, true);
QColorGroup g = options()->colorGroup(KDecoration::ColorButtonBg, true);
QColor c = g.background();
btnPix1 = new KPixmap;
btnPix1->resize(btnWidth1, titleHeight);
@ -158,7 +165,7 @@ static void create_pixmaps()
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*btnDownPix2, c.dark(130), c.light(120),
KPixmapEffect::DiagonalGradient);
g = options->colorGroup(Options::ButtonBg, false);
g = options()->colorGroup(KDecoration::ColorButtonBg, false);
c = g.background();
KPixmapEffect::gradient(*iBtnPix1, c.light(120), c.dark(130),
KPixmapEffect::DiagonalGradient);
@ -174,27 +181,27 @@ static void create_pixmaps()
btnDownPix1->fill(c.rgb());
btnPix2->fill(c.rgb());
btnDownPix2->fill(c.rgb());
g = options->colorGroup(Options::ButtonBg, false);
g = options()->colorGroup(KDecoration::ColorButtonBg, false);
c = g.background();
iBtnPix1->fill(c.rgb());
iBtnDownPix1->fill(c.rgb());
iBtnPix2->fill(c.rgb());
iBtnDownPix2->fill(c.rgb());
}
g = options->colorGroup(Options::ButtonBg, true);
g = options()->colorGroup(KDecoration::ColorButtonBg, true);
c = g.background();
drawButtonFrame(btnPix1, g, false);
drawButtonFrame(btnDownPix1, g, true);
drawButtonFrame(btnPix2, g, false);
drawButtonFrame(btnDownPix2, g, true);
g = options->colorGroup(Options::ButtonBg, false);
g = options()->colorGroup(KDecoration::ColorButtonBg, false);
c = g.background();
drawButtonFrame(iBtnPix1, g, false);
drawButtonFrame(iBtnDownPix1, g, true);
drawButtonFrame(iBtnPix2, g, false);
drawButtonFrame(iBtnDownPix2, g, true);
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
if(qGray(options()->color(KDecoration::ColorButtonBg, true).rgb()) > 128)
btnForeground = Qt::black;
else
btnForeground = Qt::white;
@ -218,19 +225,22 @@ static void delete_pixmaps()
pixmaps_created = false;
}
// =====================================
LaptopClientButton::LaptopClientButton(int w, int h, Client *parent,
LaptopClientButton::LaptopClientButton(int w, int h, LaptopClient *parent,
const char *name, const unsigned char *bitmap,
const QString& tip)
: KWinButton(parent, name, tip)
: QButton(parent->widget(), name), client(parent)
{
client = parent;
defaultSize = QSize(w, h);
setFixedHeight(h);
resize(defaultSize);
if(bitmap)
setBitmap(bitmap);
//setBackgroundMode(QWidget::NoBackground);
QToolTip::add(this, tip);
}
QSize LaptopClientButton::sizeHint() const
@ -268,7 +278,7 @@ void LaptopClientButton::drawButton(QPainter *p)
}
}
else{
QColorGroup g = options->colorGroup(Options::ButtonBg,
QColorGroup g = options()->colorGroup(KDecoration::ColorButtonBg,
client->isActive());
int w = width();
int h = height();
@ -287,34 +297,49 @@ void LaptopClientButton::drawButton(QPainter *p)
p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, deco);
}
void LaptopClient::slotReset()
// =====================================
void LaptopClient::reset(unsigned long)
{
int i;
for(i=0; i < 5; ++i){
if(button[i])
for (int i = 0; i < 5; ++i) {
if (button[i])
button[i]->reset();
}
repaint();
widget()->repaint();
}
LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase | WStaticContents )
LaptopClient::LaptopClient(KDecorationBridge *b, KDecorationFactory *f)
: KDecoration(b, f)
{
}
void LaptopClient::init()
{
createMainWidget(WResizeNoErase | WStaticContents);
widget()->installEventFilter(this);
lastButtonWidth = 0;
lastBufferWidth = 0;
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
// XXX Check how to do this...
// connect(options(), SIGNAL(resetClients()), this, SLOT(slotReset()));
bool help = providesContextHelp();
QGridLayout* g = new QGridLayout(this, 0, 0, 0);
g = new QGridLayout(widget(), 0, 0, 0);
g->setResizeMode(QLayout::FreeResize);
g->addRowSpacing(0, 3);
g->addRowSpacing(2, 1);
g->addWidget(windowWrapper(), 3, 1);
if (isPreview())
g->addWidget(new QLabel(i18n("<center><b></b>Laptop preview</center>"),
widget()), 3, 1);
else
g->addWidget(new QWidget(widget()), 3, 1 );
g->setRowStretch(3, 10);
g->addRowSpacing(4, 8); // bottom handles
spacer = new QSpacerItem(10, isResizable() && (!isTool()) ? 8 : 4,
QSizePolicy::Expanding, QSizePolicy::Minimum);
g->addItem(spacer, 4, 1);
//g->addRowSpacing(4, 8); // bottom handles
g->addColSpacing(0, 4);
g->addColSpacing(2, 4);
@ -326,7 +351,7 @@ LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent,
close_bits, i18n("Close"));
button[BtnSticky] = new LaptopClientButton(17, th, this, "sticky",
NULL, i18n("Sticky"));
if(isSticky())
if(isOnAllDesktops())
button[BtnSticky]->setBitmap(unsticky_bits);
else
button[BtnSticky]->setBitmap(sticky_bits);
@ -378,21 +403,25 @@ LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent,
void LaptopClient::slotMaximize()
{
if ( button[BtnMax]->last_button == MidButton )
maximize( MaximizeVertical );
else if ( button[BtnMax]->last_button == RightButton )
maximize( MaximizeHorizontal );
else
maximize();
switch (button[BtnMax]->last_button) {
case MidButton:
maximize( maximizeMode() ^ MaximizeVertical );
break;
case RightButton:
maximize( maximizeMode() ^ MaximizeHorizontal );
break;
case LeftButton:
default:
maximize(maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull);
break;
}
}
void LaptopClient::resizeEvent( QResizeEvent* e)
void LaptopClient::resizeEvent(QResizeEvent* e)
{
Client::resizeEvent( e );
doShape();
calcHiddenButtons();
if ( isVisibleToTLW() ) {
if ( widget()->isVisibleToTLW() ) {
int dx = 0;
int dy = 0;
if ( e->oldSize().width() != width() )
@ -400,29 +429,29 @@ void LaptopClient::resizeEvent( QResizeEvent* e)
if ( e->oldSize().height() != height() )
dy = 8 + QABS( e->oldSize().height() - height() );
if ( dy )
update( 0, height() - dy + 1, width(), dy );
widget()->update( 0, height() - dy + 1, width(), dy );
if ( dx ) {
update( width() - dx + 1, 0, dx, height() );
update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) );
update( QRect( titlebar->geometry().topRight(), QPoint( width() - 4, titlebar->geometry().bottom() ) ) );
widget()->update( width() - dx + 1, 0, dx, height() );
widget()->update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) );
widget()->update( QRect( titlebar->geometry().topRight(), QPoint( width() - 4, titlebar->geometry().bottom() ) ) );
// titlebar needs no background
QApplication::postEvent( this, new QPaintEvent( titlebar->geometry(), FALSE ) );
}
}
}
void LaptopClient::captionChange( const QString& )
void LaptopClient::captionChange()
{
bufferDirty = true;
repaint( titlebar->geometry(), false );
widget()->repaint(titlebar->geometry(), false);
}
void LaptopClient::paintEvent( QPaintEvent* )
{
QPainter p(this);
QColorGroup g = options->colorGroup(Options::Frame, isActive());
QPainter p(widget());
QColorGroup g = options()->colorGroup(KDecoration::ColorFrame, isActive());
QRect r(rect());
QRect r(widget()->rect());
p.setPen(Qt::black);
p.drawRect(r);
// outer frame
@ -434,14 +463,18 @@ void LaptopClient::paintEvent( QPaintEvent* )
p.drawLine(r.x()+1, r.bottom()-1, r.right()-1, r.bottom()-1);
int th = titleHeight;
int bb = 10; // Bottom border
if (!isResizable() || isTool())
bb -= 4;
if ( isTool() )
th -= 2;
// inner rect
p.drawRect(r.x()+3, r.y()+th+3, r.width()-6,
r.height()-th-10);
r.height()-th-bb);
// handles
if(r.width() > 44){
if (!isResizable() || isTool()) {
} else if (r.width() > 44) {
qDrawShadePanel(&p, r.x()+1, r.bottom()-6, 20,
6, g, false, 1, &g.brush(QColorGroup::Mid));
qDrawShadePanel(&p, r.x()+21, r.bottom()-6, r.width()-42, 6,
@ -470,11 +503,11 @@ void LaptopClient::paintEvent( QPaintEvent* )
*iUpperGradient);
else
p.fillRect(r.x(), r.y(), r.width(), r.height()-1,
options->color(Options::TitleBar, false));
options()->color(KDecoration::ColorTitleBar, false));
p.setFont(options->font(false, isTool() ));
QFontMetrics fm(options->font(false));
g = options->colorGroup(Options::TitleBar, false);
p.setFont(options()->font(false, isTool() ));
QFontMetrics fm(options()->font(false));
g = options()->colorGroup(KDecoration::ColorTitleBar, false);
if(iUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
@ -489,10 +522,10 @@ void LaptopClient::paintEvent( QPaintEvent* )
p.setPen(g.button());
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options->color(Options::Font, false));
p.setPen(options()->color(KDecoration::ColorFont, false));
p.drawText(r.x(), r.y(), r.width(), r.height()-1,
AlignCenter, caption() );
g = options->colorGroup(Options::Frame, true);
g = options()->colorGroup(KDecoration::ColorFrame, true);
p.setPen(g.background());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
@ -513,44 +546,46 @@ void LaptopClient::doShape()
setMask(mask);
}
void LaptopClient::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint();
}
void LaptopClient::windowWrapperShowEvent( QShowEvent* )
void LaptopClient::showEvent(QShowEvent *)
{
doShape();
widget()->repaint();
}
void LaptopClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
workspace()->performWindowOperation( this, options->operationTitlebarDblClick() );
titlebarDblClickOperation();
}
void LaptopClient::stickyChange(bool on)
void LaptopClient::iconChange()
{
// There is no icon support in this theme
}
void LaptopClient::desktopChange()
{
bool on = isOnAllDesktops();
button[BtnSticky]->setBitmap(on ? unsticky_bits : sticky_bits);
button[BtnSticky]->setTipText(on ? i18n("Un-Sticky") : i18n("Sticky"));
QToolTip::remove(button[BtnSticky]);
QToolTip::add(button[BtnSticky],
on ? i18n("Not On All Desktops") : i18n("On All Desktops"));
}
void LaptopClient::maximizeChange(bool m)
void LaptopClient::maximizeChange()
{
bool m = (maximizeMode() == MaximizeFull);
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
button[BtnMax]->setTipText(m ? i18n("Restore") : i18n("Maximize"));
QToolTip::remove(button[BtnMax]);
QToolTip::add(button[BtnMax], m ? i18n("Restore") : i18n("Maximize"));
spacer->changeSize(10, isResizable() ? 8 : 4,
QSizePolicy::Expanding, QSizePolicy::Minimum);
g->activate();
}
void LaptopClient::init()
void LaptopClient::activeChange()
{
//
}
void LaptopClient::activeChange(bool)
{
repaint(false);
widget()->repaint(false);
int i;
for(i=0; i < 5; ++i){
if(button[i])
@ -592,7 +627,7 @@ void LaptopClient::calcHiddenButtons()
if(button[i]->sizeHint().width() + totalSize <= width()){
totalSize+=button[i]->sizeHint().width();
if(button[i]->isHidden() &&
( !isTransient() || !isTransient() || i != BtnSticky ) &&
( !isTransient() || i != BtnSticky ) &&
( isMinimizable() || i != BtnIconify ) &&
( isMaximizable() || ( i != BtnIconify && i != BtnSticky && i != BtnMax ) )
@ -630,14 +665,14 @@ void LaptopClient::updateActiveBuffer( )
p.drawTiledPixmap(r, *aUpperGradient);
}
else{
p.fillRect(r, options->color(Options::TitleBar, true));
p.fillRect(r, options()->color(KDecoration::ColorTitleBar, true));
}
if(titlePix)
p.drawTiledPixmap(r, *titlePix);
p.setFont(options->font(true, isTool() ));
QFontMetrics fm(options->font(true));
QColorGroup g = options->colorGroup(Options::TitleBar, true);
p.setFont(options()->font(true, isTool() ));
QFontMetrics fm(options()->font(true));
QColorGroup g = options()->colorGroup(KDecoration::ColorTitleBar, true);
if(aUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
@ -652,10 +687,10 @@ void LaptopClient::updateActiveBuffer( )
p.setPen(g.button());
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options->color(Options::Font, true));
p.setPen(options()->color(KDecoration::ColorFont, true));
p.drawText(r.x(), r.y(), r.width(), r.height()-1,
AlignCenter, caption() );
g = options->colorGroup(Options::Frame, true);
g = options()->colorGroup(KDecoration::ColorFrame, true);
p.setPen(g.background());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
@ -663,49 +698,122 @@ void LaptopClient::updateActiveBuffer( )
p.end();
}
Client::MousePosition
LaptopClient::mousePosition( const QPoint& p ) const
LaptopClient::MousePosition LaptopClient::mousePosition(const QPoint & p) const
{
MousePosition m = Nowhere;
if (p.y() < (height() - 7))
m = Client::mousePosition(p);
m = KDecoration::mousePosition(p);
else {
if (p.x() >= (width() - 20))
m = BottomRight;
m = BottomRight2;
else if (p.x() <= 20)
m = BottomLeft;
m = BottomLeft2;
else
m = Bottom;
}
return m;
}
void LaptopClient::borders(int &left, int &right, int &top, int &bottom) const
{
left = right = 4;
top = 2 + 2 + titlebar->geometry().height(); // FRAME is this ok?
top = titleHeight + 4;
bottom = isResizable() ? 8 : 4;
}
extern "C"
void LaptopClient::shadeChange()
{
Client *allocate(Workspace *ws, WId w, int)
{
return(new Laptop::LaptopClient(ws, w));
}
void init()
{
Laptop::create_pixmaps();
}
void reset()
{
Laptop::delete_pixmaps();
Laptop::create_pixmaps();
// Ensure change in tooltip state gets applied
Workspace::self()->slotResetAllClientsDelayed();
}
void deinit()
{
Laptop::delete_pixmaps();
}
QSize LaptopClient::minimumSize() const
{
return QSize(100, 50); // FRAME
}
void LaptopClient::resize(const QSize& s)
{
widget()->resize(s);
}
static const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask |
NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask |
NET::DialogMask | NET::OverrideMask | NET::TopMenuMask |
NET::UtilityMask | NET::SplashMask;
bool LaptopClient::isTransient() const
{
NET::WindowType type = windowType(SUPPORTED_WINDOW_TYPES_MASK);
return type == NET::Dialog;
}
bool LaptopClient::isTool() const
{
NET::WindowType type = windowType(SUPPORTED_WINDOW_TYPES_MASK);
return type == NET::Toolbar || type == NET::Utility || type == NET::Menu;
}
bool LaptopClient::eventFilter(QObject *o, QEvent *e)
{
if (o != widget())
return false;
switch (e->type()) {
case QEvent::Resize:
resizeEvent(static_cast< QResizeEvent* >( e ));
return true;
case QEvent::Paint:
paintEvent(static_cast< QPaintEvent* >( e ));
return true;
case QEvent::MouseButtonDblClick:
mouseDoubleClickEvent(static_cast< QMouseEvent* >( e ));
return true;
case QEvent::MouseButtonPress:
processMousePressEvent(static_cast< QMouseEvent* >( e ));
return true;
case QEvent::Show:
showEvent(static_cast< QShowEvent* >( e ));
return true;
default:
break;
}
return false;
}
// =====================================
LaptopClientFactory::LaptopClientFactory()
{
create_pixmaps();
}
LaptopClientFactory::~LaptopClientFactory()
{
delete_pixmaps();
}
KDecoration *LaptopClientFactory::createDecoration(KDecorationBridge *b)
{
return new Laptop::LaptopClient(b, this);
}
bool LaptopClientFactory::reset(unsigned long /*changed*/)
{
// TODO Do not recreate decorations if it is not needed. Look at
// ModernSystem for how to do that
Laptop::delete_pixmaps();
Laptop::create_pixmaps();
// For now just return true.
return true;
}
} // Laptop namespace
extern "C" KDecorationFactory* create_factory()
{
return new Laptop::LaptopClientFactory();
}
#include "laptopclient.moc"
// vim: sw=4

View File

@ -1,22 +1,25 @@
#ifndef __KDECLIENT_H
#define __KDECLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
#include "../../kwinbutton.h"
#include <kdecoration.h>
#include <kdecorationfactory.h>
class QLabel;
class QSpacerItem;
class QBoxLayout;
class QGridLayout;
namespace Laptop {
using namespace KWinInternal;
class LaptopClient;
class LaptopClientButton : public KWinButton
class LaptopClientButton : public QButton
{
public:
LaptopClientButton(int w, int h, Client *parent=0, const char *name=0,
LaptopClientButton(int w, int h, LaptopClient *parent=0, const char *name=0,
const unsigned char *bitmap=NULL, const QString& tip=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
@ -28,58 +31,75 @@ protected:
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
KWinButton::mousePressEvent( &me );
QButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
KWinButton::mouseReleaseEvent( &me );
QButton::mouseReleaseEvent( &me );
}
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *) {}
LaptopClient *client;
QSize defaultSize;
QBitmap deco;
Client *client;
};
class LaptopClient : public KWinInternal::Client
class LaptopClient : public KDecoration
{
Q_OBJECT
public:
enum Buttons{BtnHelp=0, BtnSticky, BtnMax, BtnIconify, BtnClose};
LaptopClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
LaptopClient( KDecorationBridge* b, KDecorationFactory* f );
~LaptopClient() {}
void init();
protected:
bool eventFilter( QObject* o, QEvent* e );
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent* );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void maximizeChange(bool m);
void captionChange();
void maximizeChange();
void doShape();
void activeChange(bool);
void activeChange();
MousePosition mousePosition(const QPoint &) const;
void desktopChange();
void shadeChange();
void iconChange();
QSize minimumSize() const;
void resize( const QSize& );
void borders( int&, int&, int&, int& ) const;
void reset( unsigned long );
void calcHiddenButtons();
void updateActiveBuffer();
MousePosition mousePosition(const QPoint &) const;
private:
bool isTool() const;
bool isTransient() const;
protected slots:
void slotReset();
void slotMaximize();
private:
LaptopClientButton* button[5];
int lastButtonWidth;
QSpacerItem* titlebar;
bool hiddenItems;
QGridLayout *g;
QBoxLayout* hb;
QSpacerItem* titlebar;
QSpacerItem* spacer;
KPixmap activeBuffer;
bool bufferDirty;
int lastButtonWidth;
int lastBufferWidth;
bool hiddenItems;
bool bufferDirty;
};
class LaptopClientFactory : public QObject, public KDecorationFactory
{
Q_OBJECT
public:
LaptopClientFactory();
virtual ~LaptopClientFactory();
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset( unsigned long changed );
};
}