Adding a build option for KWin Scripting

It is possible that adding this build option broke the Scripting
component. This is something that should not happen. Unfortunately
by just ifdefing everything scripting related with scripting enabled
we have build errors. These are caused by the fact that the scripting
code includes e.g. client.h through "./../client.h". At one offending
place I changed that to "client.h", but there is also a client.h in
the scripting directory.

The includes and naming of the scripting files clearly have to be fixed!
This commit is contained in:
Martin Gräßlin 2011-07-10 10:48:25 +02:00
parent 062b117919
commit 32a82141f0
9 changed files with 66 additions and 15 deletions

View file

@ -5,6 +5,7 @@ OPTION(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
OPTION(KWIN_MOBILE_EFFECTS "Only build effects relevant for mobile devices" OFF)
OPTION(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
OPTION(KWIN_BUILD_SCREENEDGES "Enable building of KWin with screen edge support" ON)
OPTION(KWIN_BUILD_SCRIPTING "Enable building of KWin with scripting support" ON)
OPTION(KWIN_BUILD_XRENDER_COMPOSITING "Enable building of KWin with XRender Compositing support" ON)
OPTION(KWIN_PLASMA_ACTIVE "Enable building KWin for Plasma Active." OFF)
@ -13,6 +14,7 @@ if(KWIN_PLASMA_ACTIVE)
set(KWIN_BUILD_KCMS OFF)
set(KWIN_BUILD_TABBOX OFF)
set(KWIN_BUILD_SCREENEDGES OFF)
set(KWIN_BUILD_SCRIPTING OFF)
set(KWIN_BUILD_XRENDER_COMPOSITING OFF)
set(KWIN_MOBILE_EFFECTS ON)
set(KWIN_BUILD_WITH_OPENGLES ON)
@ -142,18 +144,6 @@ set(kwin_KDEINIT_SRCS
tilinglayout.cpp
tilinglayoutfactory.cpp
#load the scripting related functions
scripting/scripting.cpp
scripting/workspace.cpp
scripting/client.cpp
scripting/meta.cpp
scripting/toplevel.cpp
scripting/windowinfo.cpp
scripting/s_clientgroup.cpp
scripting/workspaceproxy.cpp
scripting/chelate.cpp
scripting/timer.cpp
# tiling layouts
# spiral
#tilinglayouts/spiral/spiralfactory.cpp
@ -167,6 +157,22 @@ set(kwin_KDEINIT_SRCS
tilinglayouts/floating/floating.cpp
)
if(KWIN_BUILD_SCRIPTING)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
scripting/scripting.cpp
scripting/workspace.cpp
scripting/client.cpp
scripting/meta.cpp
scripting/toplevel.cpp
scripting/windowinfo.cpp
scripting/s_clientgroup.cpp
scripting/workspaceproxy.cpp
scripting/chelate.cpp
scripting/timer.cpp
)
endif(KWIN_BUILD_SCRIPTING)
if(KWIN_BUILD_TABBOX)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
@ -198,7 +204,11 @@ qt4_add_resources( kwin_KDEINIT_SRCS resources.qrc )
kde4_add_kdeinit_executable( kwin ${kwin_KDEINIT_SRCS})
target_link_libraries(kdeinit_kwin ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTSCRIPT_LIBRARY} kephal kworkspace kdecorations kwineffects ${X11_LIBRARIES})
target_link_libraries(kdeinit_kwin ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} kephal kworkspace kdecorations kwineffects ${X11_LIBRARIES})
if(KWIN_BUILD_SCRIPTING)
target_link_libraries(kdeinit_kwin ${QT_QTSCRIPT_LIBRARY})
endif(KWIN_BUILD_SCRIPTING)
if(KWIN_BUILD_TABBOX)
target_link_libraries(kdeinit_kwin ${QT_QTXML_LIBRARY})

View file

@ -34,9 +34,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdlib.h>
#include <signal.h>
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/client.h"
#include "scripting/scripting.h"
#include "scripting/workspaceproxy.h"
#endif
#include "bridge.h"
#include "group.h"
@ -136,7 +138,9 @@ Client::Client(Workspace* ws)
{
// TODO: Do all as initialization
#ifdef KWIN_BUILD_SCRIPTING
scriptCache = new QHash<QScriptEngine*, ClientResolution>();
#endif
// Set the initial mapping state
mapping_state = Withdrawn;
@ -228,7 +232,9 @@ Client::~Client()
#ifdef KWIN_BUILD_TABBOX
delete m_tabBoxClient;
#endif
#ifdef KWIN_BUILD_SCRIPTING
delete scriptCache;
#endif
}
// Use destroyClient() or releaseWindow(), Client instances cannot be deleted directly
@ -915,6 +921,7 @@ void Client::minimize(bool avoid_animation)
if (!isMinimizable() || isMinimized())
return;
#ifdef KWIN_BUILD_SCRIPTING
//Scripting call. Does not use a signal/slot mechanism
//as ensuring connections was a bit difficult between
//so many clients and the workspace
@ -922,6 +929,7 @@ void Client::minimize(bool avoid_animation)
if (ws_wrap != 0) {
ws_wrap->sl_clientMinimized(this);
}
#endif
emit s_minimized();
@ -950,10 +958,12 @@ void Client::unminimize(bool avoid_animation)
if (!isMinimized())
return;
#ifdef KWIN_BUILD_SCRIPTING
SWrapper::WorkspaceProxy* ws_wrap = SWrapper::WorkspaceProxy::instance();
if (ws_wrap != 0) {
ws_wrap->sl_clientUnminimized(this);
}
#endif
emit s_unminimized();

View file

@ -35,8 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <X11/Xutil.h>
#include <fixx11h.h>
// TODO: QScriptValue should be in the ifdef, but it breaks the build
#include <QScriptValue>
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/client.h"
#endif
#include "utils.h"
#include "options.h"
@ -56,12 +59,14 @@ class QProcess;
class QTimer;
class KStartupInfoData;
#ifdef KWIN_BUILD_SCRIPTING
namespace SWrapper
{
class Client;
}
typedef QPair<SWrapper::Client*, QScriptValue> ClientResolution;
#endif
namespace KWin
{
@ -117,12 +122,14 @@ public:
bool isSpecialWindow() const;
bool hasNETSupport() const;
#ifdef KWIN_BUILD_SCRIPTING
/**
* This is a public object with no wrappers or anything to keep it fast,
* so in essence, direct access is allowed. Please be very careful while
* using this object
*/
QHash<QScriptEngine*, ClientResolution>* scriptCache;
#endif
QSize minSize() const;
QSize maxSize() const;
@ -711,7 +718,9 @@ private:
QuickTileMode electricMode;
friend bool performTransiencyCheck();
#ifdef KWIN_BUILD_SCRIPTING
friend class SWrapper::Client;
#endif
void checkActivities();
bool activitiesDefined; //whether the x property was actually set

View file

@ -3,3 +3,4 @@
#cmakedefine KWIN_BUILD_DECORATIONS 1
#cmakedefine KWIN_BUILD_TABBOX 1
#cmakedefine KWIN_BUILD_SCREENEDGES 1
#cmakedefine KWIN_BUILD_SCRIPTING 1

View file

@ -30,7 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "workspace.h"
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/workspaceproxy.h"
#endif
#include <kapplication.h>
#include <kglobal.h>
@ -2063,6 +2065,7 @@ void Client::maximize(MaximizeMode m)
*/
void Client::setMaximize(bool vertically, bool horizontally)
{
#ifdef KWIN_BUILD_SCRIPTING
//Scripting call. Does not use a signal/slot mechanism
//as ensuring connections was a bit difficult between
//so many clients and the workspace
@ -2070,6 +2073,7 @@ void Client::setMaximize(bool vertically, bool horizontally)
if (ws_wrap != 0) {
ws_wrap->sl_clientMaximizeSet(this, QPair<bool, bool>(vertically, horizontally));
}
#endif
emit maximizeSet(QPair<bool, bool>(vertically, horizontally));
@ -2357,10 +2361,12 @@ void Client::setFullScreen(bool set, bool user)
updateWindowRules();
workspace()->checkUnredirect();
#ifdef KWIN_BUILD_SCRIPTING
SWrapper::WorkspaceProxy* ws_object = SWrapper::WorkspaceProxy::instance();
if (ws_object != 0) {
ws_object->sl_clientFullScreenSet(this, set, user);
}
#endif
emit s_fullScreenSet(set, user);
}

View file

@ -42,7 +42,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdlib.h>
#include <QMessageBox>
#include <QEvent>
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/scripting.h"
#endif
#include <kdialog.h>
#include <kstandarddirs.h>
@ -469,7 +472,9 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
args.add("lock", ki18n("Disable configuration options"));
args.add("replace", ki18n("Replace already-running ICCCM2.0-compliant window manager"));
args.add("crashes <n>", ki18n("Indicate that KWin has recently crashed n times"));
#ifdef KWIN_BUILD_SCRIPTING
args.add("noscript", ki18n("Load the script testing dialog"));
#endif
KCmdLineArgs::addCmdLineOptions(args);
if (KDE_signal(SIGTERM, KWin::sighandler) == SIG_IGN)
@ -489,7 +494,9 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
org::kde::KSMServerInterface ksmserver("org.kde.ksmserver", "/KSMServer", QDBusConnection::sessionBus());
ksmserver.suspendStartup("kwin");
KWin::Application a;
#ifdef KWIN_BUILD_SCRIPTING
KWin::Scripting scripting;
#endif
ksmserver.resumeStartup("kwin");
KWin::SessionManager weAreIndeed;
@ -512,7 +519,9 @@ KDE_EXPORT int kdemain(int argc, char * argv[])
appname, QDBusConnectionInterface::DontQueueService);
KCmdLineArgs* sargs = KCmdLineArgs::parsedArgs();
#ifdef KWIN_BUILD_SCRIPTING
scripting.start();
#endif
return a.exec();
}

View file

@ -32,7 +32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "rules.h"
#include "group.h"
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/workspaceproxy.h"
#endif
namespace KWin
{
@ -46,6 +48,7 @@ bool Client::manage(Window w, bool isMapped)
{
StackingUpdatesBlocker stacking_blocker(workspace());
#ifdef KWIN_BUILD_SCRIPTING
//Scripting call. Does not use a signal/slot mechanism
//as ensuring connections was a bit difficult between
//so many clients and the workspace
@ -53,6 +56,7 @@ bool Client::manage(Window w, bool isMapped)
if (ws_wrap != 0) {
ws_wrap->sl_clientManaging(this);
}
#endif
grabXServer();

View file

@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QDebug>
#include <QScriptEngine>
#include "./../client.h"
#include "./../clientgroup.h"
#include "client.h"
#include "clientgroup.h"
namespace SWrapper
{

View file

@ -62,7 +62,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "overlaywindow.h"
#include "tilinglayout.h"
#ifdef KWIN_BUILD_SCRIPTING
#include "scripting/scripting.h"
#endif
#include <X11/extensions/shape.h>
#include <X11/keysym.h>