Merge KDecorationUnstable into KDecoration

Also KCommonDecorationUnstable is merged into KCommonDecoration.
This commit is contained in:
Martin Gräßlin 2013-08-20 11:58:02 +02:00
parent afcf6dbc41
commit a90072d753
12 changed files with 169 additions and 226 deletions

View file

@ -449,8 +449,7 @@ void Client::createDecoration(const QRect& oldgeom)
decoration->widget()->lower();
decoration->borders(border_left, border_right, border_top, border_bottom);
padding_left = padding_right = padding_top = padding_bottom = 0;
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
deco2->padding(padding_left, padding_right, padding_top, padding_bottom);
decoration->padding(padding_left, padding_right, padding_top, padding_bottom);
Xcb::moveWindow(decoration->widget()->winId(), -padding_left, -padding_top);
move(calculateGravitation(false));
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
@ -488,8 +487,7 @@ bool Client::checkBorderSizes(bool also_resize)
return false;
int new_left = 0, new_right = 0, new_top = 0, new_bottom = 0;
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
deco2->padding(new_left, new_right, new_top, new_bottom);
decoration->padding(new_left, new_right, new_top, new_bottom);
if (padding_left != new_left || padding_top != new_top)
Xcb::moveWindow(decoration->widget()->winId(), -new_left, -new_top);
padding_left = new_left;

View file

@ -238,7 +238,7 @@ AuroraeFactory *AuroraeFactory::s_instance = NULL;
* Client
*******************************************************/
AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *factory)
: KDecorationUnstable(bridge, factory)
: KDecoration(bridge, factory)
, m_view(NULL)
, m_scene(new QGraphicsScene(this))
, m_item(AuroraeFactory::instance()->createQmlDecoration(this))
@ -305,7 +305,7 @@ bool AuroraeClient::eventFilter(QObject *object, QEvent *event)
// TODO: remove in KDE5
// see BUG: 304248
if (object != widget() || event->type() != QEvent::Wheel) {
return KDecorationUnstable::eventFilter(object, event);
return KDecoration::eventFilter(object, event);
}
QWheelEvent *wheel = static_cast<QWheelEvent*>(event);
if (mousePosition(wheel->pos()) == PositionCenter) {
@ -548,12 +548,12 @@ int AuroraeClient::doubleClickInterval() const
void AuroraeClient::closeWindow()
{
QMetaObject::invokeMethod(qobject_cast< KDecorationUnstable* >(this), "doCloseWindow", Qt::QueuedConnection);
QMetaObject::invokeMethod(qobject_cast< KDecoration* >(this), "doCloseWindow", Qt::QueuedConnection);
}
void AuroraeClient::doCloseWindow()
{
KDecorationUnstable::closeWindow();
KDecoration::closeWindow();
}
void AuroraeClient::maximize(int button)
@ -561,7 +561,7 @@ void AuroraeClient::maximize(int button)
// a maximized window does not need to have a window decoration
// in that case we need to delay handling by one cycle
// BUG: 304870
QMetaObject::invokeMethod(qobject_cast< KDecorationUnstable* >(this),
QMetaObject::invokeMethod(qobject_cast< KDecoration* >(this),
"doMaximzie",
Qt::QueuedConnection,
Q_ARG(int, button));
@ -569,19 +569,19 @@ void AuroraeClient::maximize(int button)
void AuroraeClient::doMaximzie(int button)
{
KDecorationUnstable::maximize(static_cast<Qt::MouseButton>(button));
KDecoration::maximize(static_cast<Qt::MouseButton>(button));
}
void AuroraeClient::titlebarDblClickOperation()
{
// the double click operation can result in a window being maximized
// see maximize
QMetaObject::invokeMethod(qobject_cast< KDecorationUnstable* >(this), "doTitlebarDblClickOperation", Qt::QueuedConnection);
QMetaObject::invokeMethod(qobject_cast< KDecoration* >(this), "doTitlebarDblClickOperation", Qt::QueuedConnection);
}
void AuroraeClient::doTitlebarDblClickOperation()
{
KDecorationUnstable::titlebarDblClickOperation();
KDecoration::titlebarDblClickOperation();
}
QVariant AuroraeClient::readConfig(const QString &key, const QVariant &defaultValue)

View file

@ -82,7 +82,7 @@ private:
QString m_themeName;
};
class AuroraeClient : public KDecorationUnstable
class AuroraeClient : public KDecoration
{
Q_OBJECT
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)

View file

@ -55,7 +55,7 @@ namespace Oxygen
//___________________________________________
Client::Client(KDecorationBridge *b, Factory *f):
KCommonDecorationUnstable(b, f),
KCommonDecoration(b, f),
_factory( f ),
_sizeGrip( 0 ),
_glowAnimation( new Animation( 200, this ) ),
@ -140,7 +140,7 @@ namespace Oxygen
//___________________________________________
void Client::reset( unsigned long changed )
{
KCommonDecorationUnstable::reset( changed );
KCommonDecoration::reset( changed );
// update window mask when compositing is changed
if( !_initialized ) return;
@ -1240,7 +1240,7 @@ namespace Oxygen
void Client::activeChange( void )
{
KCommonDecorationUnstable::activeChange();
KCommonDecoration::activeChange();
_itemData.setDirty( true );
// reset animation
@ -1266,21 +1266,21 @@ namespace Oxygen
{
if( hasSizeGrip() ) sizeGrip().setVisible( !( isShade() || isMaximized() ) );
setAlphaEnabled(!isMaximized());
KCommonDecorationUnstable::maximizeChange();
KCommonDecoration::maximizeChange();
}
//_________________________________________________________
void Client::shadeChange( void )
{
if( hasSizeGrip() ) sizeGrip().setVisible( !( isShade() || isMaximized() ) );
KCommonDecorationUnstable::shadeChange();
KCommonDecoration::shadeChange();
}
//_________________________________________________________
void Client::captionChange( void )
{
KCommonDecorationUnstable::captionChange();
KCommonDecoration::captionChange();
_itemData.setDirty( true );
if( titleAnimationsEnabled() )
{ _titleAnimationData->setDirty( true ); }
@ -1401,7 +1401,7 @@ namespace Oxygen
default: break;
}
return state || KCommonDecorationUnstable::eventFilter( object, event );
return state || KCommonDecoration::eventFilter( object, event );
}
@ -1421,7 +1421,7 @@ namespace Oxygen
{ _pixmap = QPixmap( event->size() ); }
// base class implementation
KCommonDecorationUnstable::resizeEvent( event );
KCommonDecoration::resizeEvent( event );
}
//_________________________________________________________
@ -1901,7 +1901,7 @@ namespace Oxygen
{
if( event->timerId() != _dragStartTimer.timerId() )
{ return KCommonDecorationUnstable::timerEvent( event ); }
{ return KCommonDecoration::timerEvent( event ); }
_dragStartTimer.stop();

View file

@ -47,7 +47,7 @@ namespace Oxygen
{
class SizeGrip;
class Client : public KCommonDecorationUnstable
class Client : public KCommonDecoration
{
Q_OBJECT

View file

@ -1120,10 +1120,8 @@ bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int
return processDecorationButtonPress(button, state, x, y, x_root, y_root, true);
}
if (w == decorationId()) {
if (dynamic_cast<KDecorationUnstable*>(decoration))
// New API processes core events FIRST and only passes unused ones to the decoration
return processDecorationButtonPress(button, state, x, y, x_root, y_root, true);
return false;
// New API processes core events FIRST and only passes unused ones to the decoration
return processDecorationButtonPress(button, state, x, y, x_root, y_root, true);
}
if (w == frameId())
processDecorationButtonPress(button, state, x, y, x_root, y_root);

View file

@ -1354,93 +1354,77 @@ KDecoration* KCommonDecoration::decoration()
return wrapper;
}
KCommonDecorationUnstable::KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory)
: KCommonDecoration(bridge, factory)
{
Q_ASSERT(dynamic_cast<const KDecorationUnstable*>(decoration()));
}
KCommonDecorationUnstable::~KCommonDecorationUnstable()
{
}
// All copied from kdecoration.cpp
bool KCommonDecorationUnstable::compositingActive() const
bool KCommonDecoration::compositingActive() const
{
return static_cast<const KDecorationUnstable*>(decoration())->compositingActive();
return decoration()->compositingActive();
}
// Window tabbing
int KCommonDecorationUnstable::tabCount() const
int KCommonDecoration::tabCount() const
{
return static_cast<const KDecorationUnstable*>(decoration())->tabCount();
return decoration()->tabCount();
}
QString KCommonDecorationUnstable::caption(int idx) const
QString KCommonDecoration::caption(int idx) const
{
return static_cast<const KDecorationUnstable*>(decoration())->caption(idx);
return decoration()->caption(idx);
}
QIcon KCommonDecorationUnstable::icon(int idx) const
QIcon KCommonDecoration::icon(int idx) const
{
return static_cast<const KDecorationUnstable*>(decoration())->icon(idx);
return decoration()->icon(idx);
}
long KCommonDecorationUnstable::tabId(int idx) const
long KCommonDecoration::tabId(int idx) const
{
return static_cast<const KDecorationUnstable*>(decoration())->tabId(idx);
return decoration()->tabId(idx);
}
long KCommonDecorationUnstable::currentTabId() const
long KCommonDecoration::currentTabId() const
{
return static_cast<const KDecorationUnstable*>(decoration())->currentTabId();
return decoration()->currentTabId();
}
void KCommonDecorationUnstable::setCurrentTab(long id)
void KCommonDecoration::setCurrentTab(long id)
{
static_cast<KDecorationUnstable*>(decoration())->setCurrentTab(id);
decoration()->setCurrentTab(id);
}
void KCommonDecorationUnstable::tab_A_before_B(long A, long B)
void KCommonDecoration::tab_A_before_B(long A, long B)
{
static_cast<KDecorationUnstable*>(decoration())->tab_A_before_B(A, B);
decoration()->tab_A_before_B(A, B);
}
void KCommonDecorationUnstable::tab_A_behind_B(long A, long B)
void KCommonDecoration::tab_A_behind_B(long A, long B)
{
static_cast<KDecorationUnstable*>(decoration())->tab_A_behind_B(A, B);
decoration()->tab_A_behind_B(A, B);
}
void KCommonDecorationUnstable::untab(long id, const QRect& newGeom)
void KCommonDecoration::untab(long id, const QRect& newGeom)
{
static_cast<KDecorationUnstable*>(decoration())->untab(id, newGeom);
decoration()->untab(id, newGeom);
}
void KCommonDecorationUnstable::closeTab(long id)
void KCommonDecoration::closeTab(long id)
{
static_cast<KDecorationUnstable*>(decoration())->closeTab(id);
decoration()->closeTab(id);
}
void KCommonDecorationUnstable::closeTabGroup()
void KCommonDecoration::closeTabGroup()
{
static_cast<KDecorationUnstable*>(decoration())->closeTabGroup();
decoration()->closeTabGroup();
}
void KCommonDecorationUnstable::showWindowMenu(const QPoint &pos, long id)
void KCommonDecoration::showWindowMenu(const QPoint &pos, long id)
{
static_cast<KDecorationUnstable*>(decoration())->showWindowMenu(pos, id);
decoration()->showWindowMenu(pos, id);
}
KDecoration::WindowOperation KCommonDecorationUnstable::buttonToWindowOperation(Qt::MouseButtons button)
KDecoration::WindowOperation KCommonDecoration::buttonToWindowOperation(Qt::MouseButtons button)
{
return static_cast<KDecorationUnstable*>(decoration())->buttonToWindowOperation(button);
}
bool KCommonDecorationUnstable::eventFilter(QObject* o, QEvent* e)
{
return KCommonDecoration::eventFilter(o, e);
return decoration()->buttonToWindowOperation(button);
}
// kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;

View file

@ -324,6 +324,25 @@ public:
int width() const; // convenience
int height() const; // convenience
void processMousePressEvent(QMouseEvent* e);
bool compositingActive() const;
// Window tabbing
QString caption(int idx) const;
void closeTab(long id);
void closeTabGroup();
long currentTabId() const;
QIcon icon(int idx) const;
void setCurrentTab(long id);
void showWindowMenu(const QPoint &, long id);
void tab_A_before_B(long A, long B);
void tab_A_behind_B(long A, long B);
int tabCount() const;
long tabId(int idx) const;
void untab(long id, const QRect& newGeom);
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
Q_SIGNALS:
void keepAboveChanged(bool);
void keepBelowChanged(bool);
@ -416,34 +435,6 @@ private:
KCommonDecorationPrivate *d;
};
class KWIN_EXPORT KCommonDecorationUnstable
: public KCommonDecoration
{
Q_OBJECT
public:
KCommonDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory);
virtual ~KCommonDecorationUnstable();
bool compositingActive() const;
// Window tabbing
using KCommonDecoration::caption;
QString caption(int idx) const;
void closeTab(long id);
void closeTabGroup();
long currentTabId() const;
QIcon icon(int idx = 0) const;
void setCurrentTab(long id);
void showWindowMenu(const QPoint &, long id);
void tab_A_before_B(long A, long B);
void tab_A_behind_B(long A, long B);
int tabCount() const;
long tabId(int idx) const;
void untab(long id, const QRect& newGeom);
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
virtual bool eventFilter(QObject* o, QEvent* e);
};
/**
* Title bar buttons of KCommonDecoration need to inherit this class.
*/

View file

@ -32,7 +32,7 @@
#include "kcommondecoration_p.moc"
KCommonDecorationWrapper::KCommonDecorationWrapper(KCommonDecoration* deco, KDecorationBridge* bridge, KDecorationFactory* factory)
: KDecorationUnstable(bridge, factory)
: KDecoration(bridge, factory)
, decoration(deco)
{
}

View file

@ -38,7 +38,7 @@ class KDecorationFactory;
// wrapper all functionality that needs reimplementing in KDecoration and forward it to KCommonDecoration
class KCommonDecorationWrapper
: public KDecorationUnstable
: public KDecoration
{
Q_OBJECT
public:

View file

@ -420,90 +420,81 @@ bool KDecoration::isAlphaEnabled() const
return d->alphaEnabled;
}
KDecorationUnstable::KDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory)
: KDecoration(bridge, factory)
{
}
KDecorationUnstable::~KDecorationUnstable()
{
}
bool KDecorationUnstable::compositingActive() const
bool KDecoration::compositingActive() const
{
return bridge_->compositingActive();
}
void KDecorationUnstable::padding(int &left, int &right, int &top, int &bottom) const
void KDecoration::padding(int &left, int &right, int &top, int &bottom) const
{
left = right = top = bottom = 0;
}
//BEGIN Window tabbing
int KDecorationUnstable::tabCount() const
int KDecoration::tabCount() const
{
return bridge_->tabCount();
}
long KDecorationUnstable::tabId(int idx) const
long KDecoration::tabId(int idx) const
{
return bridge_->tabId(idx);
}
QString KDecorationUnstable::caption(int idx) const
QString KDecoration::caption(int idx) const
{
return bridge_->caption(idx);
}
QIcon KDecorationUnstable::icon(int idx) const
QIcon KDecoration::icon(int idx) const
{
return bridge_->icon(idx);
}
long KDecorationUnstable::currentTabId() const
long KDecoration::currentTabId() const
{
return bridge_->currentTabId();
}
void KDecorationUnstable::setCurrentTab(long id)
void KDecoration::setCurrentTab(long id)
{
bridge_->setCurrentTab(id);
}
void KDecorationUnstable::tab_A_before_B(long A, long B)
void KDecoration::tab_A_before_B(long A, long B)
{
bridge_->tab_A_before_B(A, B);
}
void KDecorationUnstable::tab_A_behind_B(long A, long B)
void KDecoration::tab_A_behind_B(long A, long B)
{
bridge_->tab_A_behind_B(A, B);
}
void KDecorationUnstable::untab(long id, const QRect& newGeom)
void KDecoration::untab(long id, const QRect& newGeom)
{
bridge_->untab(id, newGeom);
}
void KDecorationUnstable::closeTab(long id)
void KDecoration::closeTab(long id)
{
bridge_->closeTab(id);
}
void KDecorationUnstable::closeTabGroup()
void KDecoration::closeTabGroup()
{
bridge_->closeTabGroup();
}
void KDecorationUnstable::showWindowMenu(const QPoint &pos, long id)
void KDecoration::showWindowMenu(const QPoint &pos, long id)
{
bridge_->showWindowMenu(pos, id);
}
//END tabbing
KDecoration::WindowOperation KDecorationUnstable::buttonToWindowOperation(Qt::MouseButtons button)
KDecoration::WindowOperation KDecoration::buttonToWindowOperation(Qt::MouseButtons button)
{
return bridge_->buttonToWindowOperation(button);
}

View file

@ -822,6 +822,17 @@ public:
* @param changed Specifies which settings were changed, given by the SettingXXX masks
*/
virtual void reset(unsigned long changed);
/**
* This function can return additional padding values that are added outside the
* borders of the window, and can be used by the decoration if it wants to paint
* outside the frame.
*
* The typical use case is for drawing a drop shadow or glowing effect around the window.
*
* The area outside the frame cannot receive input, and when compositing is disabled,
* painting is clipped to the mask, or the window frame if no mask is defined.
*/
virtual void padding(int &left, int &right, int &top, int &bottom) const;
// special
@ -873,6 +884,77 @@ public:
* Ungrabs X server (if the number of ungrab attempts matches the number of grab attempts).
*/
void ungrabXServer();
/**
* Returns @a true if compositing--and therefore ARGB--is enabled.
*/
bool compositingActive() const;
/**
* Determine which action the user has mapped \p button to. Useful for determining whether
* a button press was for window tab dragging or for displaying the client menu.
*/
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
// Window tabbing
/**
* Returns whether or not this client group contains the active client.
*/
bool isInActiveTabGroup();
/**
* Return the amount of tabs in this group
*/
int tabCount() const;
/**
* Return the icon for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
QIcon icon(int idx) const;
/**
* Return the caption for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
QString caption(int idx) const;
/**
* Return the unique id for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
long tabId(int idx) const;
/**
* Returns the id of the currently active client in this group.
*/
long currentTabId() const;
/**
* Activate tab for the window with the id \p id.
*/
void setCurrentTab(long id);
/**
* Entab windw with id \p A beFORE the window with the id \p B.
*/
virtual void tab_A_before_B(long A, long B);
/**
* Entab windw with id \p A beHIND the window with the id \p B.
*/
virtual void tab_A_behind_B(long A, long B);
/**
* Remove the window with the id \p id from its tabgroup and place it at \p newGeom
*/
virtual void untab(long id, const QRect& newGeom);
/**
* Close the client with the id \p id.
*/
void closeTab(long id);
/**
* Close all windows in this group.
*/
void closeTabGroup();
/**
* Display the right-click client menu belonging to the client at index \p index at the
* global coordinates specified by \p pos.
*/
void showWindowMenu(const QPoint& pos, long id);
public: // invokables; runtime resolution
/**
@ -985,112 +1067,11 @@ private:
QWidget* w_;
KDecorationFactory* factory_;
friend class KDecorationOptions; // for options_
friend class KDecorationUnstable; // for bridge_
static KDecorationOptions* options_;
KDecorationPrivate* d;
};
/**
* @warning THIS CLASS IS UNSTABLE!
*/
class KWIN_EXPORT KDecorationUnstable
: public KDecoration
{
Q_OBJECT
public:
KDecorationUnstable(KDecorationBridge* bridge, KDecorationFactory* factory);
virtual ~KDecorationUnstable();
/**
* This function can return additional padding values that are added outside the
* borders of the window, and can be used by the decoration if it wants to paint
* outside the frame.
*
* The typical use case is for drawing a drop shadow or glowing effect around the window.
*
* The area outside the frame cannot receive input, and when compositing is disabled,
* painting is clipped to the mask, or the window frame if no mask is defined.
*/
virtual void padding(int &left, int &right, int &top, int &bottom) const;
/**
* Returns @a true if compositing--and therefore ARGB--is enabled.
*/
bool compositingActive() const;
// Window tabbing
/**
* Returns whether or not this client group contains the active client.
*/
bool isInActiveTabGroup();
/**
* Return the amount of tabs in this group
*/
int tabCount() const;
/**
* Return the icon for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
QIcon icon(int idx) const;
/**
* Return the caption for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
QString caption(int idx) const;
/**
* Return the unique id for the tab at index \p idx (\p idx must be smaller than tabCount())
*/
long tabId(int idx) const;
/**
* Returns the id of the currently active client in this group.
*/
long currentTabId() const;
/**
* Activate tab for the window with the id \p id.
*/
void setCurrentTab(long id);
/**
* Entab windw with id \p A beFORE the window with the id \p B.
*/
virtual void tab_A_before_B(long A, long B);
/**
* Entab windw with id \p A beHIND the window with the id \p B.
*/
virtual void tab_A_behind_B(long A, long B);
/**
* Remove the window with the id \p id from its tabgroup and place it at \p newGeom
*/
virtual void untab(long id, const QRect& newGeom);
/**
* Close the client with the id \p id.
*/
void closeTab(long id);
/**
* Close all windows in this group.
*/
void closeTabGroup();
/**
* Display the right-click client menu belonging to the client at index \p index at the
* global coordinates specified by \p pos.
*/
void showWindowMenu(const QPoint& pos, long id);
/**
* unshadow virtuals
*/
using KDecoration::caption;
using KDecoration::icon;
using KDecoration::showWindowMenu;
/**
* Determine which action the user has mapped \p button to. Useful for determining whether
* a button press was for window tab dragging or for displaying the client menu.
*/
WindowOperation buttonToWindowOperation(Qt::MouseButtons button);
};
inline
KDecorationDefines::MaximizeMode operator^(KDecorationDefines::MaximizeMode m1, KDecorationDefines::MaximizeMode m2)
{