generic: misc cleanups

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2015-11-23 05:13:07 +02:00
parent cbdb08b7df
commit 28f41fa146
9 changed files with 130 additions and 508 deletions

View file

@ -323,13 +323,6 @@ if(Q_WS_X11)
)
endif()
if(Q_WS_QWS)
set(kdeui_LIB_SRCS
${kdeui_LIB_SRCS}
windowmanagement/kwindowsystem_qws.cpp
)
endif()
if (Q_WS_X11 AND X11_Xkb_FOUND)
include_directories (
${X11_Xkb_INCLUDE_PATH}

View file

@ -81,57 +81,7 @@ QPixmap KFadeWidgetEffectPrivate::transition(const QPixmap &from, const QPixmap
p.end();
return under;
}
#if defined(Q_WS_X11) && defined(HAVE_XRENDER)
else if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) // We have Xrender support
{
// QX11PaintEngine doesn't implement CompositionMode_Plus in Qt 4.3,
// which we need to be able to do a transition from one pixmap to
// another.
//
// In order to avoid the overhead of converting the pixmaps to images
// and doing the operation entirely in software, this function has a
// specialized path for X11 that uses Xrender directly to do the
// transition. This operation can be fully accelerated in HW.
//
// This specialization can be removed when QX11PaintEngine supports
// CompositionMode_Plus.
QPixmap source(to), destination(from);
source.detach();
destination.detach();
Display *dpy = QX11Info::display();
XRenderPictFormat *format = XRenderFindStandardFormat(dpy, PictStandardA8);
XRenderPictureAttributes pa;
pa.repeat = 1; // RepeatNormal
// Create a 1x1 8 bit repeating alpha picture
Pixmap pixmap = XCreatePixmap(dpy, destination.handle(), 1, 1, 8);
Picture alpha = XRenderCreatePicture(dpy, pixmap, format, CPRepeat, &pa);
XFreePixmap(dpy, pixmap);
// Fill the alpha picture with the opacity value
XRenderColor xcolor;
xcolor.alpha = quint16(0xffff * amount);
XRenderFillRectangle(dpy, PictOpSrc, alpha, &xcolor, 0, 0, 1, 1);
// Reduce the alpha of the destination with 1 - opacity
XRenderComposite(dpy, PictOpOutReverse, alpha, None, destination.x11PictureHandle(),
0, 0, 0, 0, 0, 0, destination.width(), destination.height());
// Add source * opacity to the destination
XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha,
destination.x11PictureHandle(),
0, 0, 0, 0, 0, 0, destination.width(), destination.height());
XRenderFreePicture(dpy, alpha);
return destination;
}
#endif
else
{
} else {
// Fall back to using QRasterPaintEngine to do the transition.
QImage under = from.toImage();
QImage over = to.toImage();

View file

@ -643,8 +643,10 @@ private:
KWindowSystem() {}
enum { INFO_BASIC=1, // desktop info, not per-window
INFO_WINDOWS=2 }; // also per-window info
enum {
INFO_BASIC=1, // desktop info, not per-window
INFO_WINDOWS=2 // also per-window info
};
static void init(int);

View file

@ -1,274 +0,0 @@
/*
This file is part of the KDE libraries
Copyright (C) 2007 Laurent Montel (montel@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kwindowsystem.h"
#include <kiconloader.h>
#include <klocale.h>
#include <kxerrorhandler.h>
#include <QtGui/QBitmap>
#include <QDesktopWidget>
#include <QtGui/QDialog>
#include <QtDBus/QtDBus>
#include <kdebug.h>
class KWindowSystemStaticContainer {
public:
KWindowSystemStaticContainer() : d(0) {}
KWindowSystem kwm;
KWindowSystemPrivate* d;
};
K_GLOBAL_STATIC(KWindowSystemStaticContainer, g_kwmInstanceContainer)
KWindowSystem* KWindowSystem::self()
{
return &(g_kwmInstanceContainer->kwm);
}
int KWindowSystem::currentDesktop()
{
return 1;
}
int KWindowSystem::numberOfDesktops()
{
return 1;
}
void KWindowSystem::setCurrentDesktop( int desktop )
{
kDebug() << "KWindowSystem::setCurrentDesktop( int desktop ) isn't yet implemented!";
//TODO
}
void KWindowSystem::setOnAllDesktops( WId win, bool b )
{
kDebug() << "KWindowSystem::setOnAllDesktops( WId win, bool b ) isn't yet implemented!";
//TODO
}
void KWindowSystem::setOnDesktop( WId win, int desktop )
{
//TODO
kDebug() << "KWindowSystem::setOnDesktop( WId win, int desktop ) isn't yet implemented!";
}
WId KWindowSystem::activeWindow()
{
//return something
kDebug() << "WId KWindowSystem::activeWindow() isn't yet implemented!";
return 0;
}
void KWindowSystem::activateWindow( WId win, long time )
{
//TODO
kDebug() << "KWindowSystem::activateWindow( WId win, long time )isn't yet implemented!";
}
void KWindowSystem::forceActiveWindow( WId win, long time )
{
//TODO
kDebug() << "KWindowSystem::forceActiveWindow( WId win, long time ) isn't yet implemented!";
}
void KWindowSystem::demandAttention( WId win, bool set )
{
//TODO
kDebug() << "KWindowSystem::demandAttention( WId win, bool set ) isn't yet implemented!";
}
QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale )
{
kDebug() << "QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale ) isn't yet implemented!";
return QPixmap();
}
QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale, int flags )
{
kDebug() << "QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale, int flags ) isn't yet implemented!";
return QPixmap();
}
void KWindowSystem::setIcons( WId win, const QPixmap& icon, const QPixmap& miniIcon )
{
//TODO
kDebug() << "KWindowSystem::setIcons( WId win, const QPixmap& icon, const QPixmap& miniIcon ) isn't yet implemented!";
}
void KWindowSystem::setState( WId win, unsigned long state )
{
//TODO
kDebug() << "KWindowSystem::setState( WId win, unsigned long state ) isn't yet implemented!";
}
void KWindowSystem::clearState( WId win, unsigned long state )
{
//TODO
kDebug() << "KWindowSystem::clearState( WId win, unsigned long state ) isn't yet implemented!";
}
void KWindowSystem::minimizeWindow( WId win, bool animation)
{
//TODO
kDebug() << "KWindowSystem::minimizeWindow( WId win, bool animation) isn't yet implemented!";
}
void KWindowSystem::unminimizeWindow( WId win, bool animation )
{
//TODO
kDebug() << "KWindowSystem::unminimizeWindow( WId win, bool animation ) isn't yet implemented!";
}
void KWindowSystem::raiseWindow( WId win )
{
//TODO
kDebug() << "KWindowSystem::raiseWindow( WId win ) isn't yet implemented!";
}
void KWindowSystem::lowerWindow( WId win )
{
//TODO
kDebug() << "KWindowSystem::lowerWindow( WId win ) isn't yet implemented!";
}
bool KWindowSystem::compositingActive()
{
return false;
}
QRect KWindowSystem::workArea( int desktop )
{
//TODO
kDebug() << "QRect KWindowSystem::workArea( int desktop ) isn't yet implemented!";
return QRect();
}
QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop )
{
//TODO
kDebug() << "QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop ) isn't yet implemented!";
return QRect();
}
QString KWindowSystem::desktopName( int desktop )
{
return i18n("Desktop %1", desktop );
}
void KWindowSystem::setDesktopName( int desktop, const QString& name )
{
kDebug() << "KWindowSystem::setDesktopName( int desktop, const QString& name ) isn't yet implemented!";
//TODO
}
bool KWindowSystem::showingDesktop()
{
return false;
}
void KWindowSystem::setUserTime( WId win, long time )
{
kDebug() << "KWindowSystem::setUserTime( WId win, long time ) isn't yet implemented!";
//TODO
}
bool KWindowSystem::icccmCompliantMappingState()
{
return false;
}
void KWindowSystem::connectNotify( const char* signal )
{
kDebug() << "connectNotify( const char* signal ) isn't yet implemented!";
//TODO
}
void KWindowSystem::setExtendedStrut( WId win, int left_width, int left_start, int left_end,
int right_width, int right_start, int right_end, int top_width, int top_start, int top_end,
int bottom_width, int bottom_start, int bottom_end )
{
kDebug() << "KWindowSystem::setExtendedStrut isn't yet implemented!";
//TODO
}
void KWindowSystem::setStrut( WId win, int left, int right, int top, int bottom )
{
kDebug() << "KWindowSystem::setStrut isn't yet implemented!";
//TODO
}
QString KWindowSystem::readNameProperty( WId window, unsigned long atom )
{
//TODO
kDebug() << "QString KWindowSystem::readNameProperty( WId window, unsigned long atom ) isn't yet implemented!";
return QString();
}
void KWindowSystem::doNotManage( const QString& title )
{
//TODO
kDebug() << "KWindowSystem::doNotManage( const QString& title ) isn't yet implemented!";
}
QList<WId> KWindowSystem::stackingOrder()
{
//TODO
QList<WId> lst;
kDebug() << "QList<WId> KWindowSystem::stackingOrder() isn't yet implemented!";
return lst;
}
const QList<WId>& KWindowSystem::windows()
{
//TODO
static QList<WId> lst;
kDebug() << "const QList<WId>& KWindowSystem::windows() isn't yet implemented!";
return lst;
}
void KWindowSystem::setType( WId win, NET::WindowType windowType )
{
//TODO
kDebug() << "setType( WId win, NET::WindowType windowType ) isn't yet implemented!";
}
void KWindowSystem::setMainWindow( QWidget* subwindow, WId id )
{
//TODO
kDebug(240) << "KWindowSystem::setMainWindow( QWidget*, WId ) isn't yet implemented!";
}
void KWindowSystem::allowExternalProcessWindowActivation( int pid )
{
// TODO
kDebug() << "KWindowSystem::allowExternalProcessWindowActivation( int pid ) isn't yet implemented!";
}
void KWindowSystem::setBlockingCompositing( WId window, bool active )
{
//TODO
kDebug() << "setBlockingCompositing( WId window, bool active ) isn't yet implemented!";
}
#include "moc_kwindowsystem.cpp"

View file

@ -62,8 +62,14 @@ public:
Indexes for the properties array.
**/
// update also NETRootInfoPrivate::properties[] size when extending this
enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS,
PROPERTIES_SIZE };
enum {
PROTOCOLS,
WINDOW_TYPES,
STATES,
PROTOCOLS2,
ACTIONS,
PROPERTIES_SIZE
};
/**
Window Managers should use this constructor to create a NETRootInfo object,

View file

@ -30,7 +30,7 @@
KMainWindowInterface::KMainWindowInterface(KXmlGuiWindow * mainWindow)
: QDBusAbstractAdaptor(mainWindow)
{
m_MainWindow = mainWindow;
m_MainWindow = mainWindow;
}
KMainWindowInterface::~KMainWindowInterface()
@ -39,81 +39,81 @@ KMainWindowInterface::~KMainWindowInterface()
QStringList KMainWindowInterface::actions()
{
QStringList tmp_actions;
foreach( QAction* it, m_MainWindow->actionCollection()->actions() ) {
if (it->associatedWidgets().count()>0)
tmp_actions.append( it->objectName() );
}
return tmp_actions;
QStringList tmp_actions;
foreach( QAction* it, m_MainWindow->actionCollection()->actions() ) {
if (it->associatedWidgets().count()>0)
tmp_actions.append( it->objectName() );
}
return tmp_actions;
}
bool KMainWindowInterface::activateAction( const QString& action )
{
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->trigger();
return true;
}
else
return false;
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->trigger();
return true;
} else {
return false;
}
}
bool KMainWindowInterface::disableAction( const QString& action)
{
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->setEnabled(false);
return true;
}
else
return false;
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->setEnabled(false);
return true;
} else {
return false;
}
}
bool KMainWindowInterface::enableAction( const QString& action)
{
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->setEnabled(true);
return true;
}
else
return false;
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
tmp_Action->setEnabled(true);
return true;
} else {
return false;
}
}
bool KMainWindowInterface::actionIsEnabled( const QString& action)
{
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
return tmp_Action->isEnabled();
}
else
return false;
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
return tmp_Action->isEnabled();
} else {
return false;
}
}
QString KMainWindowInterface::actionToolTip( const QString& action)
{
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
return tmp_Action->toolTip().toUtf8();
}
else
return "Error no such object!";
QAction *tmp_Action = m_MainWindow->actionCollection()->action(action);
if (tmp_Action)
{
return tmp_Action->toolTip().toUtf8();
} else {
return "Error no such object!";
}
}
qlonglong KMainWindowInterface::winId()
{
return qlonglong(m_MainWindow->winId());
return qlonglong(m_MainWindow->winId());
}
void KMainWindowInterface::grabWindowToClipBoard()
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setPixmap(QPixmap::grabWidget(m_MainWindow));
QClipboard *clipboard = QApplication::clipboard();
clipboard->setPixmap(QPixmap::grabWidget(m_MainWindow));
}
#include "moc_kmainwindowiface_p.cpp"

View file

@ -37,83 +37,83 @@ class KXmlGuiWindow;
*/
class KMainWindowInterface : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KMainWindow")
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KMainWindow")
public:
/**
Construct a new interface object.
@param mainWindow - The parent KMainWindow object
that will provide us with the KAction objects.
*/
KMainWindowInterface( KXmlGuiWindow * mainWindow );
/**
Destructor
Cleans up the dcop action proxy object.
**/
~KMainWindowInterface();
/**
Construct a new interface object.
@param mainWindow - The parent KMainWindow object
that will provide us with the KAction objects.
*/
KMainWindowInterface( KXmlGuiWindow * mainWindow );
/**
Destructor
Cleans up the dcop action proxy object.
**/
~KMainWindowInterface();
public Q_SLOTS:
/**
Return a list of actions available to the application's window.
@return A QStringList containing valid names actions.
*/
QStringList actions();
/**
Return a list of actions available to the application's window.
@return A QStringList containing valid names actions.
*/
QStringList actions();
/**
Activates the requested action.
@param action The name of the action to activate. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool activateAction( const QString& action);
/**
Activates the requested action.
@param action The name of the action to activate. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool activateAction( const QString& action);
/**
Disables the requested action.
@param action The name of the action to disable. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool disableAction( const QString& action);
/**
Disables the requested action.
@param action The name of the action to disable. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool disableAction( const QString& action);
/**
Enables the requested action.
@param action The name of the action to enable. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool enableAction( const QString& action);
/**
Enables the requested action.
@param action The name of the action to enable. The names of valid
actions can be found by calling actions().
@return The success of the operation.
*/
bool enableAction( const QString& action);
/**
Returns the status of the requested action.
@param action The name of the action. The names of valid
actions can be found by calling actions().
@returns The state of the action, true - enabled, false - disabled.
*/
bool actionIsEnabled( const QString& action);
/**
Returns the status of the requested action.
@param action The name of the action. The names of valid
actions can be found by calling actions().
@returns The state of the action, true - enabled, false - disabled.
*/
bool actionIsEnabled( const QString& action);
/**
Returns the tool tip text of the requested action.
@param action The name of the action to activate. The names of valid
actions can be found by calling actions().
@return A QString containing the text of the action's tool tip.
*/
QString actionToolTip( const QString& action);
/**
Returns the tool tip text of the requested action.
@param action The name of the action to activate. The names of valid
actions can be found by calling actions().
@return A QString containing the text of the action's tool tip.
*/
QString actionToolTip( const QString& action);
/**
Returns the ID of the current main window.
This is useful for automated screen captures or other evil
widget fun.
@return A integer value of the main window's ID.
**/
qlonglong winId();
/**
Copies a pixmap representation of the current main window to
the clipboard.
**/
void grabWindowToClipBoard();
/**
Returns the ID of the current main window.
This is useful for automated screen captures or other evil
widget fun.
@return A integer value of the main window's ID.
**/
qlonglong winId();
/**
Copies a pixmap representation of the current main window to
the clipboard.
**/
void grabWindowToClipBoard();
private:
KXmlGuiWindow *m_MainWindow;
KXmlGuiWindow *m_MainWindow;
};
#endif // KMAINWINDOWIFACE_P_H

View file

@ -53,8 +53,6 @@ public:
private:
KXMLGUIBuilder *m_builder;
KSelectAction *m_toolbarAction;
};
} //END namespace KDEPrivate

View file

@ -617,12 +617,9 @@ QPixmap KFileItemDelegate::Private::transition(const QPixmap &from, const QPixma
QColor color;
color.setAlphaF(amount);
// FIXME: Somehow this doesn't work on Mac OS..
const bool usePixmap = from.paintEngine()->hasFeature(QPaintEngine::PorterDuff) &&
from.paintEngine()->hasFeature(QPaintEngine::BlendModes);
// If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus
if (usePixmap)
if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff) &&
from.paintEngine()->hasFeature(QPaintEngine::BlendModes))
{
QPixmap under = from;
QPixmap over = to;
@ -641,57 +638,7 @@ QPixmap KFileItemDelegate::Private::transition(const QPixmap &from, const QPixma
p.end();
return under;
}
#if defined(Q_WS_X11) && defined(HAVE_XRENDER)
else if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) // We have Xrender support
{
// QX11PaintEngine doesn't implement CompositionMode_Plus in Qt 4.3,
// which we need to be able to do a transition from one pixmap to
// another.
//
// In order to avoid the overhead of converting the pixmaps to images
// and doing the operation entirely in software, this function has a
// specialized path for X11 that uses Xrender directly to do the
// transition. This operation can be fully accelerated in HW.
//
// This specialization can be removed when QX11PaintEngine supports
// CompositionMode_Plus.
QPixmap source(to), destination(from);
source.detach();
destination.detach();
Display *dpy = QX11Info::display();
XRenderPictFormat *format = XRenderFindStandardFormat(dpy, PictStandardA8);
XRenderPictureAttributes pa;
pa.repeat = 1; // RepeatNormal
// Create a 1x1 8 bit repeating alpha picture
Pixmap pixmap = XCreatePixmap(dpy, destination.handle(), 1, 1, 8);
Picture alpha = XRenderCreatePicture(dpy, pixmap, format, CPRepeat, &pa);
XFreePixmap(dpy, pixmap);
// Fill the alpha picture with the opacity value
XRenderColor xcolor;
xcolor.alpha = quint16(0xffff * amount);
XRenderFillRectangle(dpy, PictOpSrc, alpha, &xcolor, 0, 0, 1, 1);
// Reduce the alpha of the destination with 1 - opacity
XRenderComposite(dpy, PictOpOutReverse, alpha, None, destination.x11PictureHandle(),
0, 0, 0, 0, 0, 0, destination.width(), destination.height());
// Add source * opacity to the destination
XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha,
destination.x11PictureHandle(),
0, 0, 0, 0, 0, 0, destination.width(), destination.height());
XRenderFreePicture(dpy, alpha);
return destination;
}
#endif
else
{
} else {
// Fall back to using QRasterPaintEngine to do the transition.
QImage under = from.toImage();
QImage over = to.toImage();