Drop the WorkspaceProxy in Scripting
Unlike stated at several places in the code it is not difficult to setup the connections to all Clients. It would have been nice if the failed attempts to connect the Clients would not have made it into the code as emitted signals which are nowhere used. Not to mention that like in all places the signals to inform that a state changed were emitted before the state changed was performed.icc-effect-5.14.5
parent
49b24e4940
commit
507ff411d6
|
@ -123,7 +123,6 @@ if(KWIN_BUILD_SCRIPTING)
|
|||
scripting/scripting.cpp
|
||||
scripting/workspace.cpp
|
||||
scripting/meta.cpp
|
||||
scripting/workspaceproxy.cpp
|
||||
scripting/timer.cpp
|
||||
)
|
||||
endif(KWIN_BUILD_SCRIPTING)
|
||||
|
|
24
client.cpp
24
client.cpp
|
@ -34,11 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef KWIN_BUILD_SCRIPTING
|
||||
#include "scripting/scripting.h"
|
||||
#include "scripting/workspaceproxy.h"
|
||||
#endif
|
||||
|
||||
#include "bridge.h"
|
||||
#include "group.h"
|
||||
#include "workspace.h"
|
||||
|
@ -985,16 +980,6 @@ void Client::minimize(bool avoid_animation)
|
|||
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
|
||||
info->setState(0, NET::Shaded);
|
||||
|
||||
#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
|
||||
SWrapper::WorkspaceProxy* ws_wrap = SWrapper::WorkspaceProxy::instance();
|
||||
if (ws_wrap != 0) {
|
||||
ws_wrap->sl_clientMinimized(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
Notify::raise(Notify::Minimize);
|
||||
|
||||
minimized = true;
|
||||
|
@ -1025,15 +1010,6 @@ void Client::unminimize(bool avoid_animation)
|
|||
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
|
||||
info->setState(NET::Shaded, NET::Shaded);
|
||||
|
||||
#ifdef KWIN_BUILD_SCRIPTING
|
||||
SWrapper::WorkspaceProxy* ws_wrap = SWrapper::WorkspaceProxy::instance();
|
||||
if (ws_wrap != 0) {
|
||||
ws_wrap->sl_clientUnminimized(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
emit s_unminimized();
|
||||
|
||||
Notify::raise(Notify::UnMinimize);
|
||||
minimized = false;
|
||||
updateVisibility();
|
||||
|
|
4
client.h
4
client.h
|
@ -626,9 +626,9 @@ private slots:
|
|||
//calls
|
||||
signals:
|
||||
void clientManaging(KWin::Client*);
|
||||
void s_unminimized();
|
||||
void maximizeSet(QPair<bool, bool>);
|
||||
void clientFullScreenSet(KWin::Client*, bool, bool);
|
||||
void clientMaximizedStateChanged(KWin::Client*, KDecorationDefines::MaximizeMode);
|
||||
void clientMaximizedStateChanged(KWin::Client* c, bool h, bool v);
|
||||
void clientMinimized(KWin::Client* client, bool animate);
|
||||
void clientUnminimized(KWin::Client* client, bool animate);
|
||||
void clientStartUserMovedResized(KWin::Client*);
|
||||
|
|
25
geometry.cpp
25
geometry.cpp
|
@ -30,10 +30,6 @@ 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>
|
||||
#include <kwindowsystem.h>
|
||||
|
@ -2098,24 +2094,13 @@ 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
|
||||
SWrapper::WorkspaceProxy* ws_wrap = SWrapper::WorkspaceProxy::instance();
|
||||
if (ws_wrap != 0) {
|
||||
ws_wrap->sl_clientMaximizeSet(this, vertically, horizontally);
|
||||
}
|
||||
#endif
|
||||
|
||||
emit maximizeSet(QPair<bool, bool>(vertically, horizontally));
|
||||
|
||||
// changeMaximize() flips the state, so change from set->flip
|
||||
changeMaximize(
|
||||
max_mode & MaximizeVertical ? !vertically : vertically,
|
||||
max_mode & MaximizeHorizontal ? !horizontally : horizontally,
|
||||
false);
|
||||
emit clientMaximizedStateChanged(this, max_mode);
|
||||
emit clientMaximizedStateChanged(this, vertically, horizontally);
|
||||
|
||||
// Update states of all other windows in this group
|
||||
if (clientGroup())
|
||||
|
@ -2416,14 +2401,8 @@ 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
|
||||
|
||||
if (was_fs != isFullScreen()) {
|
||||
emit clientFullScreenSet(this, set, user);
|
||||
emit fullScreenChanged();
|
||||
}
|
||||
}
|
||||
|
|
15
manage.cpp
15
manage.cpp
|
@ -32,10 +32,6 @@ 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
|
||||
{
|
||||
|
||||
|
@ -48,16 +44,6 @@ 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
|
||||
SWrapper::WorkspaceProxy* ws_wrap = SWrapper::WorkspaceProxy::instance();
|
||||
if (ws_wrap != 0) {
|
||||
ws_wrap->sl_clientManaging(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
grabXServer();
|
||||
|
||||
XWindowAttributes attr;
|
||||
|
@ -617,6 +603,7 @@ bool Client::manage(Window w, bool isMapped)
|
|||
// TODO: there's a small problem here - isManaged() depends on the mapping state,
|
||||
// but this client is not yet in Workspace's client list at this point, will
|
||||
// be only done in addClient()
|
||||
emit clientManaging(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QDir>
|
||||
|
||||
#include "workspace.h"
|
||||
#include "workspaceproxy.h"
|
||||
|
||||
class QScriptEngine;
|
||||
class QScriptValue;
|
||||
|
|
|
@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "workspace.h"
|
||||
#include "workspaceproxy.h"
|
||||
#include "meta.h"
|
||||
#include "../client.h"
|
||||
|
||||
|
@ -36,7 +35,6 @@ SWrapper::Workspace::Workspace(QObject* parent) : QObject(parent)
|
|||
if (centralObject == 0) {
|
||||
return;
|
||||
} else {
|
||||
SWrapper::WorkspaceProxy* proxy = SWrapper::WorkspaceProxy::instance();
|
||||
|
||||
QObject::connect(centralObject, SIGNAL(desktopPresenceChanged(KWin::Client*,int)),
|
||||
this, SIGNAL(desktopPresenceChanged(KWin::Client*,int))
|
||||
|
@ -49,6 +47,7 @@ SWrapper::Workspace::Workspace(QObject* parent) : QObject(parent)
|
|||
QObject::connect(centralObject, SIGNAL(clientAdded(KWin::Client*)),
|
||||
this, SIGNAL(clientAdded(KWin::Client*))
|
||||
);
|
||||
QObject::connect(centralObject, SIGNAL(clientAdded(KWin::Client*)), SLOT(setupClientConnections(KWin::Client*)));
|
||||
|
||||
QObject::connect(centralObject, SIGNAL(clientRemoved(KWin::Client*)),
|
||||
this, SIGNAL(clientRemoved(KWin::Client*))
|
||||
|
@ -57,36 +56,9 @@ SWrapper::Workspace::Workspace(QObject* parent) : QObject(parent)
|
|||
QObject::connect(centralObject, SIGNAL(clientActivated(KWin::Client*)),
|
||||
this, SIGNAL(clientActivated(KWin::Client*))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientMinimized(KWin::Client*)),
|
||||
this, SIGNAL(clientMinimized(KWin::Client*))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientUnminimized(KWin::Client*)),
|
||||
this, SIGNAL(clientUnminimized(KWin::Client*))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientMaximizeSet(KWin::Client*,bool,bool)),
|
||||
this, SIGNAL(clientMaximizeSet(KWin::Client*,bool,bool))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientManaging(KWin::Client*)),
|
||||
this, SIGNAL(clientManaging(KWin::Client*))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(killWindowCalled(KWin::Client*)),
|
||||
this, SIGNAL(killWindowCalled(KWin::Client*))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)),
|
||||
this, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool))
|
||||
);
|
||||
|
||||
QObject::connect(proxy, SIGNAL(clientSetKeepAbove(KWin::Client*,bool)),
|
||||
this, SIGNAL(clientSetKeepAbove(KWin::Client*,bool))
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
foreach (KWin::Client *client, centralObject->clientList()) {
|
||||
setupClientConnections(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,3 +171,12 @@ void SWrapper::Workspace::attach(QScriptEngine* engine)
|
|||
|
||||
(engine->globalObject()).setProperty("workspace", self, QScriptValue::Undeletable);
|
||||
}
|
||||
|
||||
void SWrapper::Workspace::setupClientConnections(KWin::Client *client)
|
||||
{
|
||||
connect(client, SIGNAL(clientMinimized(KWin::Client*,bool)), SIGNAL(clientMinimized(KWin::Client*)));
|
||||
connect(client, SIGNAL(clientUnminimized(KWin::Client*,bool)), SIGNAL(clientUnminimized(KWin::Client*)));
|
||||
connect(client, SIGNAL(clientManaging(KWin::Client*)), SIGNAL(clientManaging(KWin::Client*)));
|
||||
connect(client, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)));
|
||||
connect(client, SIGNAL(clientMaximizedStateChanged(KWin::Client*,bool,bool)), SIGNAL(clientMaximizeSet(KWin::Client*,bool,bool)));
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ public:
|
|||
static QScriptValue desktopGridSize(QScriptContext*, QScriptEngine*);
|
||||
static QScriptValue activeClient(QScriptContext*, QScriptEngine*);
|
||||
static QScriptValue clientGroups(QScriptContext*, QScriptEngine*);
|
||||
|
||||
private Q_SLOTS:
|
||||
void setupClientConnections(KWin::Client* client);
|
||||
};
|
||||
|
||||
QScriptValue valueForClient(KWin::Client *client, QScriptEngine *engine);
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2010 Rohan Prabhu <rohan@rohanprabhu.com>
|
||||
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#include "workspaceproxy.h"
|
||||
|
||||
SWrapper::WorkspaceProxy* SWrapper::WorkspaceProxy::_instance = 0;
|
||||
|
||||
SWrapper::WorkspaceProxy::WorkspaceProxy()
|
||||
{
|
||||
}
|
||||
|
||||
SWrapper::WorkspaceProxy* SWrapper::WorkspaceProxy::instance()
|
||||
{
|
||||
if (!_instance) {
|
||||
_instance = new WorkspaceProxy();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
PROXYPASS1(clientManaging, KWin::Client*)
|
||||
PROXYPASS1(clientMinimized, KWin::Client*)
|
||||
PROXYPASS1(clientUnminimized, KWin::Client*)
|
||||
PROXYPASS1(killWindowCalled, KWin::Client*)
|
||||
PROXYPASS2(clientSetKeepAbove, KWin::Client*, bool)
|
||||
|
||||
PROXYPASS3(clientFullScreenSet, KWin::Client*, bool, bool)
|
||||
PROXYPASS3(clientMaximizeSet, KWin::Client*, bool, bool)
|
|
@ -1,84 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2010 Rohan Prabhu <rohan@rohanprabhu.com>
|
||||
|
||||
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. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef KWIN_SCRIPTING_WORKSPACEPROXY_H
|
||||
#define KWIN_SCRIPTING_WORKSPACEPROXY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace KWin {
|
||||
class Client;
|
||||
class Workspace;
|
||||
}
|
||||
|
||||
#define PROXYPASS1(name, param) \
|
||||
void SWrapper::WorkspaceProxy::sl_ ## name(param _param) { \
|
||||
name(_param); \
|
||||
}
|
||||
|
||||
#define PROXYPASS2(name, param1, param2) \
|
||||
void SWrapper::WorkspaceProxy::sl_ ## name(param1 _param1, param2 _param2) { \
|
||||
name(_param1, _param2); \
|
||||
}
|
||||
|
||||
#define PROXYPASS3(name, param1, param2, param3) \
|
||||
void SWrapper::WorkspaceProxy::sl_ ## name(param1 _param1, param2 _param2, param3 _param3) { \
|
||||
name(_param1, _param2, _param3); \
|
||||
}
|
||||
|
||||
namespace SWrapper
|
||||
{
|
||||
/**
|
||||
* KWin::WorkspaceProxy simply allows connections from multiple clients to
|
||||
* multiple Workspace objects.
|
||||
*/
|
||||
class WorkspaceProxy : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static WorkspaceProxy* instance();
|
||||
|
||||
public slots:
|
||||
void sl_clientManaging(KWin::Client*);
|
||||
void sl_clientMinimized(KWin::Client*);
|
||||
void sl_clientUnminimized(KWin::Client*);
|
||||
void sl_clientMaximizeSet(KWin::Client*, bool, bool);
|
||||
void sl_killWindowCalled(KWin::Client*);
|
||||
void sl_clientFullScreenSet(KWin::Client*, bool, bool);
|
||||
void sl_clientSetKeepAbove(KWin::Client*, bool);
|
||||
|
||||
signals:
|
||||
void clientManaging(KWin::Client*);
|
||||
void clientMinimized(KWin::Client*);
|
||||
void clientUnminimized(KWin::Client*);
|
||||
void clientMaximizeSet(KWin::Client*, bool, bool);
|
||||
void killWindowCalled(KWin::Client*);
|
||||
void clientFullScreenSet(KWin::Client*, bool, bool);
|
||||
void clientSetKeepAbove(KWin::Client*, bool);
|
||||
|
||||
private:
|
||||
WorkspaceProxy();
|
||||
static WorkspaceProxy* _instance;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -149,7 +149,7 @@ void Tiling::createTile(Client* c)
|
|||
// if tiling is activated, connect to Client's signals and react with rearrangement when (un)minimizing
|
||||
connect(c, SIGNAL(clientMinimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*)));
|
||||
connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(notifyTilingWindowMinimizeToggled(KWin::Client*)));
|
||||
connect(c, SIGNAL(s_unminimized()), this, SLOT(updateAllTiles()));
|
||||
connect(c, SIGNAL(clientUnminimized(KWin::Client*,bool)), this, SLOT(updateAllTiles()));
|
||||
}
|
||||
|
||||
void Tiling::removeTile(Client *c)
|
||||
|
|
Loading…
Reference in New Issue