Start to port it to new dbus interface

svn path=/trunk/KDE/kdebase/workspace/; revision=549046
This commit is contained in:
Laurent Montel 2006-06-07 09:05:46 +00:00
parent e8bcbc84d3
commit f7de3f2974
6 changed files with 472 additions and 78 deletions

View file

@ -19,7 +19,8 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}
########### next target ###############
set(kwin_KDEINIT_SRCS
set(kwin_KDEINIT_SRCS
kwinadaptor.cpp
workspace.cpp
client.cpp
placement.cpp
@ -60,7 +61,6 @@ install(TARGETS kwin DESTINATION bin)
install_files( ${KCFG_INSTALL_DIR} FILES kwin.kcfg )
install_files( ${DATA_INSTALL_DIR}/kwin FILES eventsrc )
install_files( /include FILES KWinInterface.h )
kde4_install_icons( ${ICON_INSTALL_DIR} crystalsvg )

213
kwinadaptor.cpp Normal file
View file

@ -0,0 +1,213 @@
/*
* This file was generated by dbusidl2cpp version 0.5
* when processing input file org.kde.kwin.Kwin.xml
*
* dbusidl2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved.
*
* This is an auto-generated file.
*/
#include "kwinadaptor.h"
#include <QtCore/QMetaObject>
#include <QtCore/QByteArray>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
/*
* Implementation of adaptor class KWinAdaptor
*/
KWinAdaptor::KWinAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}
KWinAdaptor::~KWinAdaptor()
{
// destructor
}
void KWinAdaptor::cascadeDesktop()
{
// handle method call org.kde.kwin.KWin.cascadeDesktop
QMetaObject::invokeMethod(parent(), "cascadeDesktop");
// Alternative:
//static_cast<YourObjectType *>(parent())->cascadeDesktop();
}
void KWinAdaptor::circulateDesktopApplications()
{
// handle method call org.kde.kwin.KWin.circulateDesktopApplications
QMetaObject::invokeMethod(parent(), "circulateDesktopApplications");
// Alternative:
//static_cast<YourObjectType *>(parent())->circulateDesktopApplications();
}
int KWinAdaptor::currentDesktop()
{
// handle method call org.kde.kwin.KWin.currentDesktop
int out0;
QMetaObject::invokeMethod(parent(), "currentDesktop", Q_RETURN_ARG(int, out0));
// Alternative:
//out0 = static_cast<YourObjectType *>(parent())->currentDesktop();
return out0;
}
void KWinAdaptor::doNotManage(const QString &name)
{
// handle method call org.kde.kwin.KWin.doNotManage
QMetaObject::invokeMethod(parent(), "doNotManage", Q_ARG(QString, name));
// Alternative:
//static_cast<YourObjectType *>(parent())->doNotManage(name);
}
void KWinAdaptor::killWindow()
{
// handle method call org.kde.kwin.KWin.killWindow
QMetaObject::invokeMethod(parent(), "killWindow");
// Alternative:
//static_cast<YourObjectType *>(parent())->killWindow();
}
bool KWinAdaptor::kompmgrIsRunning()
{
// handle method call org.kde.kwin.KWin.kompmgrIsRunning
bool out0;
QMetaObject::invokeMethod(parent(), "kompmgrIsRunning", Q_RETURN_ARG(bool, out0));
// Alternative:
//out0 = static_cast<YourObjectType *>(parent())->kompmgrIsRunning();
return out0;
}
void KWinAdaptor::nextDesktop()
{
// handle method call org.kde.kwin.KWin.nextDesktop
QMetaObject::invokeMethod(parent(), "nextDesktop");
// Alternative:
//static_cast<YourObjectType *>(parent())->nextDesktop();
}
void KWinAdaptor::previousDesktop()
{
// handle method call org.kde.kwin.KWin.previousDesktop
QMetaObject::invokeMethod(parent(), "previousDesktop");
// Alternative:
//static_cast<YourObjectType *>(parent())->previousDesktop();
}
void KWinAdaptor::reconfigure()
{
// handle method call org.kde.kwin.KWin.reconfigure
QMetaObject::invokeMethod(parent(), "reconfigure");
// Alternative:
//static_cast<YourObjectType *>(parent())->reconfigure();
}
void KWinAdaptor::refresh()
{
// handle method call org.kde.kwin.KWin.refresh
QMetaObject::invokeMethod(parent(), "refresh");
// Alternative:
//static_cast<YourObjectType *>(parent())->refresh();
}
bool KWinAdaptor::setCurrentDesktop(int desktop)
{
// handle method call org.kde.kwin.KWin.setCurrentDesktop
bool out0;
QMetaObject::invokeMethod(parent(), "setCurrentDesktop", Q_RETURN_ARG(bool, out0), Q_ARG(int, desktop));
// Alternative:
//out0 = static_cast<YourObjectType *>(parent())->setCurrentDesktop(desktop);
return out0;
}
void KWinAdaptor::setDesktopLayout(int orientation, int x, int y)
{
// handle method call org.kde.kwin.KWin.setDesktopLayout
QMetaObject::invokeMethod(parent(), "setDesktopLayout", Q_ARG(int, orientation), Q_ARG(int, x), Q_ARG(int, y));
// Alternative:
//static_cast<YourObjectType *>(parent())->setDesktopLayout(orientation, x, y);
}
void KWinAdaptor::setOpacity(int winId, int opacityPercent)
{
// handle method call org.kde.kwin.KWin.setOpacity
QMetaObject::invokeMethod(parent(), "setOpacity", Q_ARG(int, winId), Q_ARG(int, opacityPercent));
// Alternative:
//static_cast<YourObjectType *>(parent())->setOpacity(winId, opacityPercent);
}
void KWinAdaptor::setShadowSize(int winId, int shadowSizePercent)
{
// handle method call org.kde.kwin.KWin.setShadowSize
QMetaObject::invokeMethod(parent(), "setShadowSize", Q_ARG(int, winId), Q_ARG(int, shadowSizePercent));
// Alternative:
//static_cast<YourObjectType *>(parent())->setShadowSize(winId, shadowSizePercent);
}
void KWinAdaptor::setUnshadowed(int winId)
{
// handle method call org.kde.kwin.KWin.setUnshadowed
QMetaObject::invokeMethod(parent(), "setUnshadowed", Q_ARG(int, winId));
// Alternative:
//static_cast<YourObjectType *>(parent())->setUnshadowed(winId);
}
void KWinAdaptor::showWindowMenuAt(int winId, int x, int y)
{
// handle method call org.kde.kwin.KWin.showWindowMenuAt
QMetaObject::invokeMethod(parent(), "showWindowMenuAt", Q_ARG(int, winId), Q_ARG(int, x), Q_ARG(int, y));
// Alternative:
//static_cast<YourObjectType *>(parent())->showWindowMenuAt(winId, x, y);
}
void KWinAdaptor::startKompmgr()
{
// handle method call org.kde.kwin.KWin.startKompmgr
QMetaObject::invokeMethod(parent(), "startKompmgr");
// Alternative:
//static_cast<YourObjectType *>(parent())->startKompmgr();
}
void KWinAdaptor::stopKompmgr()
{
// handle method call org.kde.kwin.KWin.stopKompmgr
QMetaObject::invokeMethod(parent(), "stopKompmgr");
// Alternative:
//static_cast<YourObjectType *>(parent())->stopKompmgr();
}
void KWinAdaptor::unclutterDesktop()
{
// handle method call org.kde.kwin.KWin.unclutterDesktop
QMetaObject::invokeMethod(parent(), "unclutterDesktop");
// Alternative:
//static_cast<YourObjectType *>(parent())->unclutterDesktop();
}
#include "kwinadaptor.moc"

119
kwinadaptor.h Normal file
View file

@ -0,0 +1,119 @@
/*
* This file was generated by dbusidl2cpp version 0.5
* when processing input file org.kde.kwin.Kwin.xml
*
* dbusidl2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved.
*
* This is an auto-generated file.
*/
#ifndef KWINADAPTOR_H_93481149670720
#define KWINADAPTOR_H_93481149670720
#include <QtCore/QObject>
#include <dbus/qdbus.h>
class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
/*
* Adaptor class for interface org.kde.kwin.KWin
*/
class KWinAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.KWin")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"org.kde.kwin.KWin\" >\n"
" <method name=\"cascadeDesktop\" >\n"
" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\" />\n"
" </method>\n"
" <method name=\"unclutterDesktop\" >\n"
" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\" />\n"
" </method>\n"
" <method name=\"reconfigure\" >\n"
" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\" />\n"
" </method>\n"
" <method name=\"killWindow\" >\n"
" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\" />\n"
" </method>\n"
" <method name=\"refresh\" />\n"
" <method name=\"doNotManage\" >\n"
" <arg direction=\"in\" type=\"s\" name=\"name\" />\n"
" </method>\n"
" <method name=\"showWindowMenuAt\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"winId\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"x\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"y\" />\n"
" </method>\n"
" <method name=\"setDesktopLayout\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"orientation\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"x\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"y\" />\n"
" </method>\n"
" <method name=\"setCurrentDesktop\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"desktop\" />\n"
" <arg direction=\"out\" type=\"b\" />\n"
" </method>\n"
" <method name=\"currentDesktop\" >\n"
" <arg direction=\"out\" type=\"i\" />\n"
" </method>\n"
" <method name=\"nextDesktop\" />\n"
" <method name=\"previousDesktop\" />\n"
" <method name=\"circulateDesktopApplications\" />\n"
" <method name=\"startKompmgr\" />\n"
" <method name=\"stopKompmgr\" />\n"
" <method name=\"kompmgrIsRunning\" >\n"
" <arg direction=\"out\" type=\"b\" />\n"
" </method>\n"
" <method name=\"setOpacity\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"winId\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"opacityPercent\" />\n"
" </method>\n"
" <method name=\"setShadowSize\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"winId\" />\n"
" <arg direction=\"in\" type=\"i\" name=\"shadowSizePercent\" />\n"
" </method>\n"
" <method name=\"setUnshadowed\" >\n"
" <arg direction=\"in\" type=\"i\" name=\"winId\" />\n"
" </method>\n"
" <signal name=\"kompmgrStarted\" />\n"
" <signal name=\"kompmgrStopped\" />\n"
" <signal name=\"dcopResetAllClients\" />\n"
" </interface>\n"
"")
public:
KWinAdaptor(QObject *parent);
virtual ~KWinAdaptor();
public: // PROPERTIES
public Q_SLOTS: // METHODS
Q_ASYNC void cascadeDesktop();
void circulateDesktopApplications();
int currentDesktop();
void doNotManage(const QString &name);
Q_ASYNC void killWindow();
bool kompmgrIsRunning();
void nextDesktop();
void previousDesktop();
Q_ASYNC void reconfigure();
void refresh();
bool setCurrentDesktop(int desktop);
void setDesktopLayout(int orientation, int x, int y);
void setOpacity(int winId, int opacityPercent);
void setShadowSize(int winId, int shadowSizePercent);
void setUnshadowed(int winId);
void showWindowMenuAt(int winId, int x, int y);
void startKompmgr();
void stopKompmgr();
Q_ASYNC void unclutterDesktop();
Q_SIGNALS: // SIGNALS
void dcopResetAllClients();
void kompmgrStarted();
void kompmgrStopped();
};
#endif

61
org.kde.kwin.Kwin.xml Normal file
View file

@ -0,0 +1,61 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.kwin.KWin">
<method name="cascadeDesktop">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="unclutterDesktop">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="reconfigure">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="killWindow">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<method name="refresh"/>
<method name="doNotManage">
<arg name="name" type="s" direction="in"/>
</method>
<method name="showWindowMenuAt">
<arg name="winId" type="i" direction="in"/>
<arg name="x" type="i" direction="in"/>
<arg name="y" type="i" direction="in"/>
</method>
<method name="setDesktopLayout">
<arg name="orientation" type="i" direction="in"/>
<arg name="x" type="i" direction="in"/>
<arg name="y" type="i" direction="in"/>
</method>
<method name="setCurrentDesktop">
<arg name="desktop" type="i" direction="in"/>
<arg type="b" direction="out"/>
</method>
<method name="currentDesktop">
<arg type="i" direction="out"/>
</method>
<method name="nextDesktop"/>
<method name="previousDesktop"/>
<method name="circulateDesktopApplications"/>
<method name="startKompmgr"/>
<method name="stopKompmgr"/>
<method name="kompmgrIsRunning">
<arg type="b" direction="out"/>
</method>
<method name="setOpacity">
<arg name="winId" type="i" direction="in"/>
<arg name="opacityPercent" type="i" direction="in"/>
</method>
<method name="setShadowSize">
<arg name="winId" type="i" direction="in"/>
<arg name="shadowSizePercent" type="i" direction="in"/>
</method>
<method name="setUnshadowed">
<arg name="winId" type="i" direction="in"/>
</method>
<signal name="kompmgrStarted"/>
<signal name="kompmgrStopped"/>
<signal name="dcopResetAllClients"/>
</interface>
</node>

View file

@ -26,12 +26,12 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kmenubar.h>
#include <kprocess.h>
#include <kglobalaccel.h>
#include <dcopclient.h>
#include <QDesktopWidget>
#include <QToolButton>
#include <kipc.h>
#include <kactioncollection.h>
#include <kaction.h>
#include <dbus/qdbus.h>
#include "plugins.h"
#include "client.h"
@ -71,8 +71,7 @@ bool allowKompmgrRestart = true;
// lines are not too much. It's the task that is complex, not the
// code.
Workspace::Workspace( bool restore )
: DCOPObject ("KWinInterface"),
QObject (0),
: QObject (0),
current_desktop (0),
number_of_desktops(0),
active_popup( NULL ),
@ -128,7 +127,10 @@ Workspace::Workspace( bool restore )
block_stacking_updates( 0 ),
forced_global_mouse_grab( false )
{
new KWinAdaptor(this);
QDBus::sessionBus().registerObject("/KWinInterface", this);
setObjectName( "workspace" );
_self = this;
mgr = new PluginMgr;
root = QX11Info::appRootWindow();
@ -142,8 +144,8 @@ Workspace::Workspace( bool restore )
updateXTime(); // needed for proper initialization of user_time in Client ctor
delayFocusTimer = 0;
delayFocusTimer = 0;
electric_time_first = QX11Info::appTime();
electric_time_last = QX11Info::appTime();
@ -214,7 +216,7 @@ void Workspace::init()
// not used yet
// topDock = 0L;
// maximizedWindowCounter = 0;
supportWindow = new QWidget;
XLowerWindow( QX11Info::display(), supportWindow->winId()); // see usage in layers.cpp
@ -326,7 +328,7 @@ void Workspace::init()
reconfigureTimer.setSingleShot( true );
updateToolWindowsTimer.setSingleShot( true );
connect(&reconfigureTimer, SIGNAL(timeout()), this,
SLOT(slotReconfigure()));
connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows()));
@ -361,7 +363,7 @@ void Workspace::init()
unsigned int i, nwins;
Window root_return, parent_return, *wins;
XQueryTree(QX11Info::display(), root, &root_return, &parent_return, &wins, &nwins);
for (i = 0; i < nwins; i++)
for (i = 0; i < nwins; i++)
{
XWindowAttributes attr;
XGetWindowAttributes(QX11Info::display(), wins[i], &attr);
@ -369,12 +371,12 @@ void Workspace::init()
continue;
if( topmenu_space && topmenu_space->winId() == wins[ i ] )
continue;
if (attr.map_state != IsUnmapped)
if (attr.map_state != IsUnmapped)
{
if ( addSystemTrayWin( wins[i] ) )
continue;
Client* c = createClient( wins[i], true );
if ( c != NULL && root != QX11Info::appRootWindow() )
if ( c != NULL && root != QX11Info::appRootWindow() )
{ // TODO what is this?
// TODO may use QWidget:.create
XReparentWindow( QX11Info::display(), c->frameId(), root, 0, 0 );
@ -468,7 +470,7 @@ Workspace::~Workspace()
delete rules.front();
rules.pop_front();
}
foreach ( SessionInfo* s, session )
foreach ( SessionInfo* s, session )
delete s;
XDestroyWindow( QX11Info::display(), null_focus_window );
// TODO ungrabXServer();
@ -504,7 +506,7 @@ void Workspace::addClient( Client* c, allowed_t )
c->setOpacity(options->translucentDocks, options->dockOpacity);
}
}
//------------------------------------------------
//------------------------------------------------
Group* grp = findGroup( c->window());
if( grp != NULL )
grp->gotLeader( c );
@ -752,7 +754,7 @@ void Workspace::updateCurrentTopMenu()
}
// ... then hide the other ones. Avoids flickers.
for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
{
if( (*it)->isTopMenu() && (*it) != menubar )
(*it)->hideClient( true );
@ -869,7 +871,7 @@ void Workspace::updateColormap()
Colormap cmap = default_colormap;
if ( activeClient() && activeClient()->colormap() != None )
cmap = activeClient()->colormap();
if ( cmap != installed_colormap )
if ( cmap != installed_colormap )
{
XInstallColormap(QX11Info::display(), cmap );
installed_colormap = cmap;
@ -989,7 +991,7 @@ void Workspace::loadDesktopSettings()
desktop_focus_chain.resize( n );
// make it +1, so that it can be accessed as [1..numberofdesktops]
focus_chain.resize( n + 1 );
for(int i = 1; i <= n; i++)
for(int i = 1; i <= n; i++)
{
QString s = group.readEntry(QString("Name_%1").arg(i),
i18n("Desktop %1", i));
@ -1009,21 +1011,21 @@ void Workspace::saveDesktopSettings()
KConfigGroup group(c,groupname);
group.writeEntry("Number", number_of_desktops );
for(int i = 1; i <= number_of_desktops; i++)
for(int i = 1; i <= number_of_desktops; i++)
{
QString s = desktopName( i );
QString defaultvalue = i18n("Desktop %1", i);
if ( s.isEmpty() )
if ( s.isEmpty() )
{
s = defaultvalue;
rootInfo->setDesktopName( i, s.toUtf8().data() );
}
if (s != defaultvalue)
if (s != defaultvalue)
{
group.writeEntry( QString("Name_%1").arg(i), s );
}
else
else
{
QString currentvalue = group.readEntry(QString("Name_%1").arg(i), QString());
if (currentvalue != defaultvalue)
@ -1061,10 +1063,10 @@ void Workspace::doNotManage( QString title )
*/
bool Workspace::isNotManaged( const QString& title )
{
for ( QStringList::Iterator it = doNotManageList.begin(); it != doNotManageList.end(); ++it )
for ( QStringList::Iterator it = doNotManageList.begin(); it != doNotManageList.end(); ++it )
{
QRegExp r( (*it) );
if (r.indexIn(title) != -1)
if (r.indexIn(title) != -1)
{
doNotManageList.erase( it );
return true;
@ -1076,7 +1078,7 @@ bool Workspace::isNotManaged( const QString& title )
/*!
Refreshes all the client windows
*/
void Workspace::refresh()
void Workspace::refresh()
{
QWidget w;
w.setGeometry( QApplication::desktop()->geometry() );
@ -1113,7 +1115,7 @@ void ObscuringWindows::create( Client* c )
Window obs_win;
XWindowChanges chngs;
int mask = CWSibling | CWStackMode;
if( cached->count() > 0 )
if( cached->count() > 0 )
{
cached->removeAll( obs_win = cached->first());
chngs.x = c->x();
@ -1122,7 +1124,7 @@ void ObscuringWindows::create( Client* c )
chngs.height = c->height();
mask |= CWX | CWY | CWWidth | CWHeight;
}
else
else
{
XSetWindowAttributes a;
a.background_pixmap = None;
@ -1143,7 +1145,7 @@ ObscuringWindows::~ObscuringWindows()
max_cache_size = qMax( ( int )max_cache_size, obscuring_windows.count() + 4 ) - 1;
for( QList<Window>::ConstIterator it = obscuring_windows.begin();
it != obscuring_windows.end();
++it )
++it )
{
XUnmapWindow( QX11Info::display(), *it );
if( cached->count() < ( int )max_cache_size )
@ -1171,7 +1173,7 @@ bool Workspace::setCurrentDesktop( int new_desktop )
StackingUpdatesBlocker blocker( this );
int old_desktop = current_desktop;
if (new_desktop != current_desktop)
if (new_desktop != current_desktop)
{
++block_showing_desktop;
/*
@ -1210,7 +1212,7 @@ bool Workspace::setCurrentDesktop( int new_desktop )
--block_focus;
Client* c = 0;
if ( options->focusPolicyIsReasonable())
if ( options->focusPolicyIsReasonable())
{
// Search in focus chain
if ( movingClient != NULL && active_client == movingClient
@ -1219,7 +1221,7 @@ bool Workspace::setCurrentDesktop( int new_desktop )
{
c = active_client; // the requestFocus below will fail, as the client is already active
}
if( !c )
if( !c )
{
for( int i = focus_chain[ currentDesktop() ].size() - 1;
i >= 0;
@ -1244,12 +1246,12 @@ bool Workspace::setCurrentDesktop( int new_desktop )
if( c != active_client )
setActiveClient( NULL, Allowed );
if ( c )
if ( c )
requestFocus( c );
else
else
focusToNull();
if( !desktops.isEmpty() )
if( !desktops.isEmpty() )
{
Window w_tmp;
int i_tmp;
@ -1301,7 +1303,7 @@ int Workspace::desktopToRight( int desktop ) const
if (layoutOrientation == Qt::Vertical)
{
dt += y;
if ( dt >= numberOfDesktops() )
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
@ -1312,7 +1314,7 @@ int Workspace::desktopToRight( int desktop ) const
else
{
int d = (dt % x) + 1;
if ( d >= x )
if ( d >= x )
{
if ( options->rollOverDesktops )
d -= x;
@ -1332,7 +1334,7 @@ int Workspace::desktopToLeft( int desktop ) const
if (layoutOrientation == Qt::Vertical)
{
dt -= y;
if ( dt < 0 )
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
@ -1343,7 +1345,7 @@ int Workspace::desktopToLeft( int desktop ) const
else
{
int d = (dt % x) - 1;
if ( d < 0 )
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += x;
@ -1363,7 +1365,7 @@ int Workspace::desktopUp( int desktop ) const
if (layoutOrientation == Qt::Horizontal)
{
dt -= x;
if ( dt < 0 )
if ( dt < 0 )
{
if ( options->rollOverDesktops )
dt += numberOfDesktops();
@ -1374,7 +1376,7 @@ int Workspace::desktopUp( int desktop ) const
else
{
int d = (dt % y) - 1;
if ( d < 0 )
if ( d < 0 )
{
if ( options->rollOverDesktops )
d += y;
@ -1394,7 +1396,7 @@ int Workspace::desktopDown( int desktop ) const
if (layoutOrientation == Qt::Horizontal)
{
dt += x;
if ( dt >= numberOfDesktops() )
if ( dt >= numberOfDesktops() )
{
if ( options->rollOverDesktops )
dt -= numberOfDesktops();
@ -1405,7 +1407,7 @@ int Workspace::desktopDown( int desktop ) const
else
{
int d = (dt % y) + 1;
if ( d >= y )
if ( d >= y )
{
if ( options->rollOverDesktops )
d -= y;
@ -1433,7 +1435,7 @@ void Workspace::setNumberOfDesktops( int n )
// if increasing the number, do the resizing now,
// otherwise after the moving of windows to still existing desktops
if( old_number_of_desktops < number_of_desktops )
if( old_number_of_desktops < number_of_desktops )
{
rootInfo->setNumberOfDesktops( number_of_desktops );
NETPoint* viewports = new NETPoint[ number_of_desktops ];
@ -1445,17 +1447,17 @@ void Workspace::setNumberOfDesktops( int n )
// if the number of desktops decreased, move all
// windows that would be hidden to the last visible desktop
if( old_number_of_desktops > number_of_desktops )
if( old_number_of_desktops > number_of_desktops )
{
for( ClientList::ConstIterator it = clients.begin();
it != clients.end();
++it)
++it)
{
if( !(*it)->isOnAllDesktops() && (*it)->desktop() > numberOfDesktops())
sendClientToDesktop( *it, numberOfDesktops(), true );
}
}
if( old_number_of_desktops > number_of_desktops )
if( old_number_of_desktops > number_of_desktops )
{
rootInfo->setNumberOfDesktops( number_of_desktops );
NETPoint* viewports = new NETPoint[ number_of_desktops ];
@ -1495,7 +1497,7 @@ void Workspace::sendClientToDesktop( Client* c, int desk, bool dont_activate )
else
restackClientUnderActive( c );
}
else
else
{
raiseClient( c );
}
@ -1598,7 +1600,7 @@ void Workspace::propagateSystemTrayWins()
Window *cl = new Window[ systemTrayWins.count()];
int i = 0;
for ( SystemTrayWindowList::ConstIterator it = systemTrayWins.begin(); it != systemTrayWins.end(); ++it )
for ( SystemTrayWindowList::ConstIterator it = systemTrayWins.begin(); it != systemTrayWins.end(); ++it )
{
cl[i++] = (*it).win;
}
@ -1614,7 +1616,7 @@ void Workspace::killWindowId( Window window_to_kill )
return;
Window window = window_to_kill;
Client* client = NULL;
for(;;)
for(;;)
{
client = findClient( FrameIdMatchPredicate( window ));
if( client != NULL ) // found the client
@ -1653,12 +1655,12 @@ void Workspace::sendTakeActivity( Client* c, Time timestamp, long flags )
*/
void Workspace::slotGrabWindow()
{
if ( active_client )
if ( active_client )
{
QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() );
//No XShape - no work.
if( Shape::available())
if( Shape::available())
{
//As the first step, get the mask from XShape.
int count, order;
@ -1668,7 +1670,7 @@ void Workspace::slotGrabWindow()
//ShapeBounding - ShapeClipping is defined to be the border.
//Since the border area is part of the window, we use bounding
// to limit our work region
if (rects)
if (rects)
{
//Create a QRegion from the rectangles describing the bounding mask.
QRegion contents;
@ -1719,7 +1721,7 @@ void Workspace::slotGrabDesktop()
void Workspace::slotMouseEmulation()
{
if ( mouse_emulation )
if ( mouse_emulation )
{
XUngrabKeyboard(QX11Info::display(), QX11Info::appTime());
mouse_emulation = false;
@ -1729,7 +1731,7 @@ void Workspace::slotMouseEmulation()
if ( XGrabKeyboard(QX11Info::display(),
root, false,
GrabModeAsync, GrabModeAsync,
QX11Info::appTime()) == GrabSuccess )
QX11Info::appTime()) == GrabSuccess )
{
mouse_emulation = true;
mouse_emulation_state = 0;
@ -1751,7 +1753,7 @@ WId Workspace::getMouseEmulationWindow()
uint state;
Window w;
Client * c = 0;
do
do
{
w = child;
if (!c)
@ -1773,12 +1775,12 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t
if ( !w )
return state;
QWidget* widget = QWidget::find( w );
if ( (!widget || qobject_cast<QToolButton*>(widget)) && !findClient( WindowMatchPredicate( w )) )
if ( (!widget || qobject_cast<QToolButton*>(widget)) && !findClient( WindowMatchPredicate( w )) )
{
int x, y;
Window xw;
XTranslateCoordinates( QX11Info::display(), QX11Info::appRootWindow(), w, pos.x(), pos.y(), &x, &y, &xw );
if ( type == EmuMove )
if ( type == EmuMove )
{ // motion notify events
XMotionEvent e;
e.type = MotionNotify;
@ -1794,7 +1796,7 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t
e.is_hint = NotifyNormal;
XSendEvent( QX11Info::display(), w, true, ButtonMotionMask, (XEvent*)&e );
}
else
else
{
XButtonEvent e;
e.type = type == EmuRelease ? ButtonRelease : ButtonPress;
@ -1810,9 +1812,9 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t
e.button = button;
XSendEvent( QX11Info::display(), w, true, ButtonPressMask, (XEvent*)&e );
if ( type == EmuPress )
if ( type == EmuPress )
{
switch ( button )
switch ( button )
{
case 2:
state |= Button2Mask;
@ -1825,9 +1827,9 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t
break;
}
}
else
else
{
switch ( button )
switch ( button )
{
case 2:
state &= ~Button2Mask;
@ -1861,7 +1863,7 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev )
int delta = is_control?1:is_alt?32:8;
QPoint pos = QCursor::pos();
switch ( kc )
switch ( kc )
{
case XK_Left:
case XK_KP_Left:
@ -1906,16 +1908,16 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev )
case XK_Return:
case XK_space:
case XK_KP_Enter:
case XK_KP_Space:
case XK_KP_Space:
{
if ( !mouse_emulation_state )
if ( !mouse_emulation_state )
{
// nothing was pressed, fake a LMB click
mouse_emulation_window = getMouseEmulationWindow();
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state );
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state );
}
else
else
{ // release all
if ( mouse_emulation_state & Button1Mask )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state );
@ -1957,7 +1959,7 @@ void Workspace::delayFocus()
requestFocus( delayfocus_client );
cancelDelayFocus();
}
void Workspace::requestDelayFocus( Client* c )
{
delayfocus_client = c;
@ -1967,7 +1969,7 @@ void Workspace::requestDelayFocus( Client* c )
delayFocusTimer->setSingleShot( true );
delayFocusTimer->start( options->delayFocusInterval );
}
void Workspace::cancelDelayFocus()
{
delete delayFocusTimer;
@ -1985,7 +1987,7 @@ void Workspace::checkElectricBorders( bool force )
{
if( force )
destroyBorderWindows();
electric_current_border = 0;
QRect r = QApplication::desktop()->geometry();
@ -2140,7 +2142,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now)
{
case 1:
slotSwitchDesktopLeft();
if (currentDesktop() != desk_before)
if (currentDesktop() != desk_before)
{
offset = r.width() / 5;
QCursor::setPos(r.width() - offset, pos.y());
@ -2149,7 +2151,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now)
case 2:
slotSwitchDesktopRight();
if (currentDesktop() != desk_before)
if (currentDesktop() != desk_before)
{
offset = r.width() / 5;
QCursor::setPos(offset, pos.y());
@ -2158,7 +2160,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now)
case 3:
slotSwitchDesktopUp();
if (currentDesktop() != desk_before)
if (currentDesktop() != desk_before)
{
offset = r.height() / 5;
QCursor::setPos(pos.x(), r.height() - offset);
@ -2167,7 +2169,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now)
case 4:
slotSwitchDesktopDown();
if (currentDesktop() != desk_before)
if (currentDesktop() != desk_before)
{
offset = r.height() / 5;
QCursor::setPos(pos.x(), offset);
@ -2177,7 +2179,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now)
return;
}
}
else
else
{
electric_current_border = border;
electric_time_first = now;
@ -2413,7 +2415,7 @@ void Workspace::helperDialog( const QString& message, const Client* c )
// kompmgr stuff
void Workspace::startKompmgr()
{
if (!kompmgr || kompmgr->isRunning())
@ -2536,8 +2538,8 @@ void Workspace::handleKompmgrOutput( KProcess* , char *buffer, int buflen)
proc.start(KProcess::DontCare);
}
}
void Workspace::setOpacity(unsigned long winId, unsigned int opacityPercent)
{
if (opacityPercent > 100) opacityPercent = 100;

View file

@ -19,7 +19,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <netwm.h>
#include <kxmessages.h>
#include "KWinInterface.h"
#include "utils.h"
#include "kdecoration.h"
#include "sm.h"
@ -70,7 +69,7 @@ class SystemTrayWindow
typedef QList<SystemTrayWindow> SystemTrayWindowList;
class Workspace : public QObject, public KWinInterface, public KDecorationDefines
class Workspace : public QObject, public KDecorationDefines
{
Q_OBJECT
public: