add missing files

svn path=/trunk/KDE/kdebase/workspace/; revision=975744
icc-effect-5.14.5
Marco Martin 2009-05-30 21:49:08 +00:00
parent 65ccc73283
commit 81d5418f1a
4 changed files with 430 additions and 5 deletions

View File

@ -4,19 +4,19 @@
########### next target ###############
set(kwin3_web_PART_SRCS Web.cpp WebButton.cpp )
set(kwin3_mid_PART_SRCS mid.cpp)
kde4_add_plugin(kwin3_web ${kwin3_web_PART_SRCS})
kde4_add_plugin(kwin3_mid ${kwin3_mid_PART_SRCS})
target_link_libraries(kwin3_web ${KDE4_KDEUI_LIBS} kdecorations )
target_link_libraries(kwin3_mid ${KDE4_KDEUI_LIBS} kdecorations )
install(TARGETS kwin3_web DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kwin3_mid DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES web.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )
install( FILES mid.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )

334
clients/web/mid.cpp Normal file
View File

@ -0,0 +1,334 @@
/*
'Mid' fullscreen kwin client
Copyright (C) 2009 Marco Martin <notmart@gmail.com>
Adapted from Web by
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mid.h"
#include <QPainter>
#include <QPaintEvent>
#include <kconfiggroup.h>
#include <klocale.h>
#include <kdebug.h>
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
return new Mid::MidFactory();
}
}
namespace Mid {
MidClient::MidClient(KDecorationBridge* bridge, KDecorationFactory* factory)
: KCommonDecoration(bridge, factory)
{
}
MidClient::~MidClient()
{
// Empty.
}
QString MidClient::visibleName() const
{
return i18n("Mid");
}
QString MidClient::defaultButtonsLeft() const
{
return QString();
}
QString MidClient::defaultButtonsRight() const
{
return QString();
}
bool MidClient::decorationBehaviour(DecorationBehaviour behaviour) const
{
switch (behaviour) {
case DB_MenuClose:
return false;
case DB_WindowMask:
return true;
case DB_ButtonHide:
return true;
default:
return KCommonDecoration::decorationBehaviour(behaviour);
}
}
int MidClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{
if (maximizeMode() == MaximizeFull) {
return 0;
}
switch (lm) {
case LM_BorderLeft:
case LM_BorderRight:
case LM_BorderBottom:
return borderSize_;
case LM_TitleEdgeLeft:
case LM_TitleEdgeRight:
case LM_TitleEdgeTop:
case LM_TitleEdgeBottom:
return 0;
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return 0;
case LM_TitleHeight:
case LM_ButtonWidth:
case LM_ButtonHeight:
return borderSize_;
case LM_ButtonSpacing:
return 0;
default:
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
}
}
KCommonDecorationButton *MidClient::createButton(ButtonType type)
{
Q_UNUSED(type)
return 0;
}
void
MidClient::init()
{
// title height
const int textVMargin = 2;
QFontMetrics fm(options()->font(isActive(), isToolWindow()));
// border size
switch(options()->preferredBorderSize( factory())) {
case BorderLarge:
borderSize_ = 8;
break;
case BorderVeryLarge:
borderSize_ = 12;
break;
case BorderHuge:
borderSize_ = 18;
break;
case BorderVeryHuge:
borderSize_ = 27;
break;
case BorderOversized:
borderSize_ = 40;
break;
case BorderNormal:
default:
borderSize_ = 4;
}
shape_ = true;
KCommonDecoration::init();
KCommonDecoration::maximize(MaximizeFull);
}
void MidClient::reset( unsigned long changed )
{
if (changed & SettingColors) {
// repaint the whole thing
widget()->repaint();
} else if (changed & SettingFont) {
widget()->repaint();
}
KCommonDecoration::reset(changed);
}
void MidClient::maximizeChange()
{
shape_ = (maximizeMode() != MaximizeFull);
}
void MidClient::paintEvent(QPaintEvent * pe)
{
//FIXME: this should be elsewhere
KCommonDecoration::maximize(MaximizeFull);
if (maximizeMode() == MaximizeFull) {
return;
}
QPainter p(widget());
QPalette pal = options()->palette(ColorFrame, isActive());
pal.setCurrentColorGroup( QPalette::Active );
p.setBrush(pal.background());
p.setPen(pal.midlight().color());
p.drawRect(widget()->rect().adjusted(0,0,-1,-1));
if (shape_) {
int r(width());
int b(height());
// Draw edge of top-left corner inside the area removed by the mask.
p.drawPoint(3, 1);
p.drawPoint(4, 1);
p.drawPoint(2, 2);
p.drawPoint(1, 3);
p.drawPoint(1, 4);
// Draw edge of top-right corner inside the area removed by the mask.
p.drawPoint(r - 5, 1);
p.drawPoint(r - 4, 1);
p.drawPoint(r - 3, 2);
p.drawPoint(r - 2, 3);
p.drawPoint(r - 2, 4);
// Draw edge of bottom-left corner inside the area removed by the mask.
p.drawPoint(1, b - 5);
p.drawPoint(1, b - 4);
p.drawPoint(2, b - 3);
p.drawPoint(3, b - 2);
p.drawPoint(4, b - 2);
// Draw edge of bottom-right corner inside the area removed by the mask.
p.drawPoint(r - 2, b - 5);
p.drawPoint(r - 2, b - 4);
p.drawPoint(r - 3, b - 3);
p.drawPoint(r - 4, b - 2);
p.drawPoint(r - 5, b - 2);
}
}
void MidClient::updateWindowShape()
{
if (!shape_) {
return;
}
QRegion mask(0, 0, width(), height());
int r(width());
int b(height());
// Remove top-left corner.
mask -= QRegion(0, 0, 5, 1);
mask -= QRegion(0, 1, 3, 1);
mask -= QRegion(0, 2, 2, 1);
mask -= QRegion(0, 3, 1, 2);
// Remove top-right corner.
mask -= QRegion(r - 5, 0, 5, 1);
mask -= QRegion(r - 3, 1, 3, 1);
mask -= QRegion(r - 2, 2, 2, 1);
mask -= QRegion(r - 1, 3, 1, 2);
// Remove bottom-left corner.
mask -= QRegion(0, b - 5, 1, 3);
mask -= QRegion(0, b - 3, 2, 1);
mask -= QRegion(0, b - 2, 3, 1);
mask -= QRegion(0, b - 1, 5, 1);
// Remove bottom-right corner.
mask -= QRegion(r - 5, b - 1, 5, 1);
mask -= QRegion(r - 3, b - 2, 3, 1);
mask -= QRegion(r - 2, b - 3, 2, 1);
mask -= QRegion(r - 1, b - 5, 1, 2);
setMask(mask);
}
KDecoration* MidFactory::createDecoration( KDecorationBridge* b )
{
return(new MidClient(b, this))->decoration();
}
bool MidFactory::reset(unsigned long changed)
{
// Do we need to "hit the wooden hammer" ?
bool needHardReset = true;
if ((changed & ~(SettingColors | SettingFont | SettingButtons)) == 0 ) {
needHardReset = false;
}
if (needHardReset) {
return true;
} else {
resetDecorations(changed);
return false;
}
}
bool MidFactory::supports( Ability ability ) const
{
switch (ability) {
// announce
case AbilityAnnounceButtons:
case AbilityAnnounceColors:
// colors:
case AbilityColorTitleBack:
case AbilityColorTitleFore:
return true;
// buttons
case AbilityButtonOnAllDesktops:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonMenu:
case AbilityButtonAboveOthers:
case AbilityButtonBelowOthers:
case AbilityButtonShade:
case AbilityButtonSpacer:
default:
return false;
};
}
QList< MidFactory::BorderSize > MidFactory::borderSizes() const
{ // the list must be sorted
return QList< BorderSize >() << BorderNormal << BorderLarge <<
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
}
}
#include "mid.moc"

4
clients/web/mid.desktop Normal file
View File

@ -0,0 +1,4 @@
[Desktop Entry]
Name=Mid
X-KDE-Library=kwin3_mid

87
clients/web/mid.h Normal file
View File

@ -0,0 +1,87 @@
/*
'Mid' kwin client
Copyright (C) 2009 Marco Martin <notmart@gmail.com>
Adapted from Web by
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KWIN_MID_H
#define KWIN_MID_H
#include "kcommondecoration.h"
#include "kdecorationfactory.h"
namespace Mid
{
class MidClient : public KCommonDecoration
{
public:
MidClient(KDecorationBridge* bridge, KDecorationFactory* factory);
~MidClient();
virtual QString visibleName() const;
virtual QString defaultButtonsLeft() const;
virtual QString defaultButtonsRight() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
virtual void maximizeChange();
virtual void updateWindowShape();
virtual void init();
protected:
virtual void reset( unsigned long changed );
virtual void paintEvent(QPaintEvent *);
private:
int borderSize_;
bool shape_;
QBitmap _buttonBitmap(ButtonType t) const;
};
class MidFactory : public QObject, public KDecorationFactory
{
Q_OBJECT
public:
MidFactory() {}
virtual ~MidFactory() {}
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset( unsigned long changed );
virtual bool supports( Ability ability ) const;
virtual QList< BorderSize > borderSizes() const;
};
}
#endif
// vim:ts=2:sw=2:tw=78:set et:
// kate: indent-width 2; replace-tabs on; tab-width 2; space-indent on;