~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/scripting/client.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2010 Rohan Prabhu <rohan@rohanprabhu.com>
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
#include "client.h"
 
22
 
 
23
SWrapper::Client::Client(KWin::Client* client) :
 
24
    Toplevel(client)
 
25
{
 
26
    if (client != 0) {
 
27
        QObject::connect(client, SIGNAL(s_clientMoved()), this, SLOT(sl_clientMoved()));
 
28
        QObject::connect(client, SIGNAL(maximizeSet(QPair<bool, bool>)), this, SLOT(sl_maximizeSet(QPair<bool, bool>)));
 
29
        QObject::connect(client, SIGNAL(s_minimized()), this, SIGNAL(minimized()));
 
30
        QObject::connect(client, SIGNAL(s_activated()), this, SIGNAL(gotFocus()));
 
31
        QObject::connect(client, SIGNAL(s_fullScreenSet(bool, bool)), this, SIGNAL(fullScreenSet(bool, bool)));
 
32
        QObject::connect(client, SIGNAL(s_setKeepAbove(bool)), this, SIGNAL(onSetKeepAbove(bool)));
 
33
        QObject::connect(client, SIGNAL(s_unminimized()), this, SIGNAL(unminimized()));
 
34
        QObject::connect(this, SIGNAL(unminimized()), this, SIGNAL(restored()));
 
35
    }
 
36
 
 
37
    centralObject = client;
 
38
}
 
39
 
 
40
KWin::Client* SWrapper::Client::getCentralObject()
 
41
{
 
42
    return centralObject;
 
43
}
 
44
 
 
45
/*
 
46
SWrapper::ClientResolution SWrapper::Client::clientResolve(const QScriptEngine*, const KWin::Client* client) {
 
47
    if (client == 0) {
 
48
        return ClientResolution(0, QScriptValue());
 
49
    } else {
 
50
        return
 
51
    }
 
52
}
 
53
*/
 
54
 
 
55
void SWrapper::Client::setEngine(QScriptEngine* eng)
 
56
{
 
57
    engine = eng;
 
58
}
 
59
 
 
60
void SWrapper::Client::sl_clientMoved()
 
61
{
 
62
    emit clientMoved();
 
63
}
 
64
 
 
65
void SWrapper::Client::sl_maximizeSet(QPair<bool, bool> param)
 
66
{
 
67
    QScriptValue temp = engine->newObject();
 
68
    temp.setProperty("v", engine->toScriptValue(param.first));
 
69
    temp.setProperty("h", engine->toScriptValue(param.second));
 
70
 
 
71
    emit maximizeSet(temp);
 
72
}
 
73
 
 
74
/*
 
75
bool SWrapper::Client::clientRelease(const KWin::Client* client) {
 
76
    if (client == 0) {
 
77
    return false;
 
78
    } else {
 
79
    if (client->swrapper != 0) {
 
80
        delete client->swrapper;
 
81
        return true;
 
82
    }
 
83
    }
 
84
 
 
85
    return false;
 
86
}
 
87
*/
 
88
 
 
89
//newWrapper does not search clientMap for existing entries
 
90
//a search must be performed prior to this call.
 
91
//However, since now clientMap is actually a QHash, it wouldn't
 
92
//hurt to perform a check here as well.
 
93
SWrapper::ClientResolution SWrapper::Client::newWrapper(KWin::Client* client, QScriptEngine* eng)
 
94
{
 
95
    SWrapper::Client* wrapper = new SWrapper::Client(client);
 
96
    wrapper->setEngine(eng);
 
97
    QScriptValue value;
 
98
 
 
99
    // Use this value to avoid repeated function generations
 
100
    // for function aliases.
 
101
    QScriptValue func;
 
102
 
 
103
    /*
 
104
     * Step1: Prepping
 
105
     * Connect all signals and slots from client to
 
106
     * the wrapper object.
 
107
     */
 
108
 
 
109
 
 
110
    //End of prepping
 
111
 
 
112
    /*
 
113
     * Step2: Conversion
 
114
     * Wrap the object, set the data parameter
 
115
     * and obtain a QScriptValue
 
116
     */
 
117
 
 
118
    value = eng->newQObject(wrapper,
 
119
                            QScriptEngine::AutoOwnership,
 
120
                            QScriptEngine::ExcludeSuperClassContents | QScriptEngine::ExcludeDeleteLater
 
121
                           );
 
122
 
 
123
    wrapper->tl_centralObject = client;
 
124
    tl_append(value, eng);
 
125
 
 
126
    //End of Conversion
 
127
 
 
128
    /*
 
129
     * Step3: Spice
 
130
     * Add the static functions and other things
 
131
     * that rely on the value of data() and not the
 
132
     * wrapper address.
 
133
     */
 
134
 
 
135
    value.setProperty("caption", eng->newFunction(caption, 0), QScriptValue::Undeletable);
 
136
    value.setProperty("close", eng->newFunction(close, 0), QScriptValue::Undeletable);
 
137
    value.setProperty("resize", eng->newFunction(resize, 1), QScriptValue::Undeletable);
 
138
    value.setProperty("move", eng->newFunction(move, 1), QScriptValue::Undeletable);
 
139
    value.setProperty("setGeometry", eng->newFunction(setGeometry, 1), QScriptValue::Undeletable);
 
140
    value.setProperty("getWindowInfo", eng->newFunction(getWindowInfo, 0), QScriptValue::Undeletable);
 
141
    value.setProperty("isTransient", eng->newFunction(isTransient, 0), QScriptValue::Undeletable);
 
142
    value.setProperty("transientFor", eng->newFunction(transientFor, 0), QScriptValue::Undeletable);
 
143
    value.setProperty("activate", eng->newFunction(activate, 1), QScriptValue::Undeletable);
 
144
    value.setProperty("setCaption", eng->newFunction(setCaption, 1), QScriptValue::Undeletable);
 
145
    value.setProperty("setFullScreen", eng->newFunction(setFullScreen, 2), QScriptValue::Undeletable);
 
146
    value.setProperty("isFullScreen", eng->newFunction(isFullScreen, 0), QScriptValue::Undeletable);
 
147
    value.setProperty("isFullScreenable", eng->newFunction(isFullScreenable, 0), QScriptValue::Undeletable);
 
148
    value.setProperty("minimize", eng->newFunction(minimize, 0), QScriptValue::Undeletable);
 
149
    value.setProperty("clientGroup", eng->newFunction(clientGroup, 0), QScriptValue::Undeletable);
 
150
    value.setProperty("maximize", eng->newFunction(maximize, 0), QScriptValue::Undeletable);
 
151
    value.setProperty("setMaximize", eng->newFunction(setMaximize, 2), QScriptValue::Undeletable);
 
152
    value.setProperty("desktop", eng->newFunction(desktop, 0), QScriptValue::Undeletable);
 
153
    value.setProperty("setKeepAbove", eng->newFunction(setKeepAbove, 0), QScriptValue::Undeletable);
 
154
    value.setProperty("setKeepBelow", eng->newFunction(setKeepBelow, 0), QScriptValue::Undeletable);
 
155
 
 
156
    BOOLATTACHCLIENT(isShade)
 
157
    BOOLATTACHCLIENT(isShadeable)
 
158
    BOOLATTACHCLIENT(isMinimized)
 
159
    BOOLATTACHCLIENT(isMinimizable)
 
160
    BOOLATTACHCLIENT(isMaximizable)
 
161
    BOOLATTACHCLIENT(isResizable)
 
162
    BOOLATTACHCLIENT(isMovable)
 
163
    BOOLATTACHCLIENT(isMovableAcrossScreens)
 
164
    BOOLATTACHCLIENT(isCloseable)
 
165
    BOOLATTACHCLIENT(keepAbove)
 
166
    BOOLATTACHCLIENT(keepBelow)
 
167
 
 
168
    func = eng->newFunction(unminimize, 0);
 
169
    value.setProperty("unminimize", func, QScriptValue::Undeletable);
 
170
    value.setProperty("restore", func, QScriptValue::Undeletable);
 
171
 
 
172
    ClientResolution final(wrapper, value);
 
173
 
 
174
    //Finally, append the entire thing to the clientMap
 
175
    //clientMap.insert(const_cast<KWin::Client*>(client), ClientResolution(wrapper, value));
 
176
 
 
177
    //And.. we're done
 
178
    (client->scriptCache)->insert(eng, final);
 
179
    return final;
 
180
}
 
181
 
 
182
QScriptValue SWrapper::Client::generate(KWin::Client* client, QScriptEngine* eng)
 
183
{
 
184
    if (client == 0) {
 
185
        return QScriptValue();
 
186
    } else {
 
187
        ClientResolution res = (client->scriptCache)->value(eng, ClientResolution(0, QScriptValue()));
 
188
 
 
189
        if (res.first != 0) {
 
190
            //The required object has been already created
 
191
            //Return that instead of creating a new one
 
192
            return res.second;
 
193
        } else {
 
194
            res = newWrapper(client, eng);
 
195
            return res.second;
 
196
        }
 
197
    }
 
198
}
 
199
 
 
200
QScriptValue SWrapper::Client::setMaximize(QScriptContext* ctx, QScriptEngine* eng)
 
201
{
 
202
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
203
 
 
204
    if (central == 0) {
 
205
        return eng->toScriptValue<bool>(0);
 
206
    } else {
 
207
        central->setMaximize((ctx->argument(0)).toBool(), (ctx->argument(1)).toBool());
 
208
        return eng->toScriptValue<bool>(1);
 
209
    }
 
210
}
 
211
 
 
212
BOOLEXPORTCLIENT(isShade)
 
213
BOOLEXPORTCLIENT(isShadeable)
 
214
BOOLEXPORTCLIENT(isMinimized)
 
215
BOOLEXPORTCLIENT(isMinimizable)
 
216
BOOLEXPORTCLIENT(isMaximizable)
 
217
BOOLEXPORTCLIENT(isResizable)
 
218
BOOLEXPORTCLIENT(isMovable)
 
219
BOOLEXPORTCLIENT(isMovableAcrossScreens)
 
220
BOOLEXPORTCLIENT(isCloseable)
 
221
BOOLEXPORTCLIENT(keepAbove)
 
222
BOOLEXPORTCLIENT(keepBelow)
 
223
 
 
224
QScriptValue SWrapper::Client::setKeepAbove(QScriptContext* ctx, QScriptEngine* eng)
 
225
{
 
226
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
227
    QScriptValue setValue = ctx->argument(0);
 
228
 
 
229
    if ((central == 0) || (setValue.isUndefined())) {
 
230
        return eng->toScriptValue<bool>(0);
 
231
    } else {
 
232
        central->setKeepAbove(eng->fromScriptValue<bool>(setValue));
 
233
        return eng->toScriptValue<bool>(1);
 
234
    }
 
235
}
 
236
 
 
237
QScriptValue SWrapper::Client::setKeepBelow(QScriptContext* ctx, QScriptEngine* eng)
 
238
{
 
239
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
240
    QScriptValue setValue = ctx->argument(0);
 
241
 
 
242
    if ((central == 0) || (setValue.isUndefined())) {
 
243
        return eng->toScriptValue<bool>(0);
 
244
    } else {
 
245
        central->setKeepBelow(eng->fromScriptValue<bool>(setValue));
 
246
        return eng->toScriptValue<bool>(1);
 
247
    }
 
248
}
 
249
 
 
250
QScriptValue SWrapper::Client::isNormal(QScriptContext* ctx, QScriptEngine* eng)
 
251
{
 
252
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
253
 
 
254
    if (central == 0) {
 
255
        return eng->undefinedValue();
 
256
    } else {
 
257
        return eng->toScriptValue<bool>(!central->isSpecialWindow());
 
258
    }
 
259
}
 
260
 
 
261
QScriptValue SWrapper::Client::maximize(QScriptContext* ctx, QScriptEngine* eng)
 
262
{
 
263
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
264
 
 
265
    if (central == 0) {
 
266
        return eng->toScriptValue<bool>(0);
 
267
    } else {
 
268
        central->setMaximize(1, 1);
 
269
        return eng->toScriptValue<bool>(1);
 
270
    }
 
271
}
 
272
 
 
273
QScriptValue SWrapper::Client::desktop(QScriptContext* ctx, QScriptEngine* eng)
 
274
{
 
275
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
276
 
 
277
    if (central == 0) {
 
278
        return eng->undefinedValue();
 
279
    } else {
 
280
        return eng->toScriptValue(central->desktop());
 
281
    }
 
282
}
 
283
 
 
284
QScriptValue SWrapper::Client::clientGroup(QScriptContext* ctx, QScriptEngine* eng)
 
285
{
 
286
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
287
 
 
288
    if (central == 0) {
 
289
        return QScriptValue();
 
290
    } else {
 
291
        return eng->toScriptValue<KWin::ClientGroup*>(central->clientGroup());
 
292
    }
 
293
}
 
294
 
 
295
QScriptValue SWrapper::Client::caption(QScriptContext* ctx, QScriptEngine* eng)
 
296
{
 
297
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
298
 
 
299
    if (central == 0) {
 
300
        return QScriptValue();
 
301
    } else {
 
302
        return eng->toScriptValue(central->caption());
 
303
    }
 
304
}
 
305
 
 
306
QScriptValue SWrapper::Client::setCaption(QScriptContext* ctx, QScriptEngine* eng)
 
307
{
 
308
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
309
 
 
310
    if (ctx->argument(0).isUndefined()) {
 
311
        return eng->toScriptValue<bool>(0);
 
312
    } else {
 
313
        QString cap = (ctx->argument(0)).toString();
 
314
        central->setCaption(cap);
 
315
        return eng->toScriptValue<bool>(1);
 
316
    }
 
317
}
 
318
 
 
319
QScriptValue SWrapper::Client::resize(QScriptContext* ctx, QScriptEngine* eng)
 
320
{
 
321
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
322
    QScriptValue arg = ctx->argument(0);
 
323
    QSize size;
 
324
    bool emitJs;
 
325
    QScriptValue emitJsQs;
 
326
 
 
327
    if (central == 0 || arg.isUndefined()) {
 
328
        return eng->toScriptValue<bool>(0);
 
329
    } else {
 
330
        if (arg.isNumber()) {
 
331
            size = QSize(arg.toInt32(), (ctx->argument(1)).toInt32());
 
332
            emitJsQs = ctx->argument(2);
 
333
        } else if (arg.isObject()) {
 
334
            size = eng->fromScriptValue<QSize>(arg);
 
335
            emitJsQs = ctx->argument(1);
 
336
        }
 
337
 
 
338
        if (emitJsQs.isUndefined() || !emitJsQs.isValid()) {
 
339
            emitJs = true;
 
340
        } else {
 
341
            emitJs = emitJsQs.toBool();
 
342
        }
 
343
 
 
344
        if (size.isValid()) {
 
345
            central->plainResize(size, KWin::NormalGeometrySet, emitJs);
 
346
            return eng->toScriptValue<bool>(0);
 
347
        } else {
 
348
            return eng->toScriptValue<bool>(1);
 
349
        }
 
350
    }
 
351
}
 
352
 
 
353
QScriptValue SWrapper::Client::move(QScriptContext* ctx, QScriptEngine* eng)
 
354
{
 
355
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
356
    QScriptValue arg = ctx->argument(0);
 
357
 
 
358
    if (central == 0 || arg.isUndefined()) {
 
359
        return eng->toScriptValue<bool>(0);
 
360
    } else {
 
361
        QPoint point;
 
362
        bool emitJs;
 
363
        QScriptValue emitJsQs;
 
364
 
 
365
        if (arg.isNumber()) {
 
366
            point = QPoint(arg.toInt32(), (ctx->argument(1)).toInt32());
 
367
            emitJsQs = ctx->argument(2);
 
368
        } else if (arg.isObject()) {
 
369
            point = eng->fromScriptValue<QPoint>(arg);
 
370
            emitJsQs = ctx->argument(1);
 
371
        }
 
372
 
 
373
        if (emitJsQs.isUndefined() || !emitJsQs.isValid()) {
 
374
            emitJs = true;
 
375
        } else {
 
376
            emitJs = emitJsQs.toBool();
 
377
        }
 
378
 
 
379
 
 
380
        central->setGeometry(QRect(point, central->size()), KWin::NormalGeometrySet, emitJs);
 
381
        return eng->toScriptValue<bool>(1);
 
382
    }
 
383
}
 
384
 
 
385
QScriptValue SWrapper::Client::setGeometry(QScriptContext* ctx, QScriptEngine* eng)
 
386
{
 
387
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
388
    QScriptValue arg = ctx->argument(0);
 
389
    QRect rect;
 
390
    bool emitJs;
 
391
    QScriptValue emitJsQs;
 
392
 
 
393
    if (central == 0 || arg.isUndefined()) {
 
394
        return eng->toScriptValue<bool>(0);
 
395
    } else {
 
396
        if (arg.isNumber()) {
 
397
            rect = QRect(arg.toInt32(), (ctx->argument(1)).toInt32(),
 
398
                         (ctx->argument(2)).toInt32(), (ctx->argument(3)).toInt32());
 
399
            emitJsQs = ctx->argument(4);
 
400
        } else if (arg.isObject()) {
 
401
            rect = eng->fromScriptValue<QRect>(arg);
 
402
            emitJsQs = ctx->argument(1);
 
403
        }
 
404
 
 
405
        if (emitJsQs.isUndefined() || !emitJsQs.isValid()) {
 
406
            emitJs = true;
 
407
        } else {
 
408
            emitJs = emitJsQs.toBool();
 
409
        }
 
410
 
 
411
        central->setGeometry(rect, KWin::NormalGeometrySet, emitJs);
 
412
        return eng->toScriptValue<bool>(1);
 
413
    }
 
414
}
 
415
 
 
416
QScriptValue SWrapper::Client::getWindowInfo(QScriptContext* ctx, QScriptEngine* eng)
 
417
{
 
418
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
419
 
 
420
    if (central == 0) {
 
421
        return QScriptValue();
 
422
    } else {
 
423
        // For now at least, just get all properties. Tweaking will be taken care
 
424
        // of later. TODO
 
425
        KWindowInfo info = KWindowSystem::windowInfo(central->window(), -1U, -1U);
 
426
        return SWrapper::WindowInfo::generate(info, eng, central);
 
427
    }
 
428
}
 
429
 
 
430
/*
 
431
QString SWrapper::Client::caption() {
 
432
    return centralObject->caption();
 
433
}*/
 
434
 
 
435
QScriptValue SWrapper::Client::unminimize(QScriptContext* ctx, QScriptEngine* eng)
 
436
{
 
437
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
438
 
 
439
    if (central == 0) {
 
440
        return eng->toScriptValue<bool>(0);
 
441
    } else {
 
442
        central->unminimize(false);
 
443
        return eng->toScriptValue<bool>(1);
 
444
    }
 
445
}
 
446
 
 
447
QScriptValue SWrapper::Client::minimize(QScriptContext* ctx, QScriptEngine* eng)
 
448
{
 
449
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
450
 
 
451
    if (central == 0) {
 
452
        return eng->toScriptValue<bool>(0);
 
453
    } else {
 
454
        central->minimize(false);
 
455
        return eng->toScriptValue<bool>(1);
 
456
    }
 
457
}
 
458
 
 
459
QScriptValue SWrapper::Client::close(QScriptContext* ctx, QScriptEngine* eng)
 
460
{
 
461
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
462
 
 
463
    if (central == 0) {
 
464
        return QScriptValue();
 
465
    } else {
 
466
        central->closeWindow();
 
467
        return eng->toScriptValue(true);
 
468
    }
 
469
}
 
470
 
 
471
QScriptValue SWrapper::Client::isTransient(QScriptContext* ctx, QScriptEngine* eng)
 
472
{
 
473
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
474
 
 
475
    if (central == 0) {
 
476
        return QScriptValue();
 
477
    } else {
 
478
        bool x = central->isTransient();
 
479
        return eng->toScriptValue(x);
 
480
    }
 
481
}
 
482
 
 
483
QScriptValue SWrapper::Client::transientFor(QScriptContext* ctx, QScriptEngine* eng)
 
484
{
 
485
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
486
 
 
487
    if (central == 0) {
 
488
        return QScriptValue();
 
489
    } else {
 
490
        return eng->toScriptValue(central->transientFor());
 
491
    }
 
492
}
 
493
 
 
494
QScriptValue SWrapper::Client::setFullScreen(QScriptContext* ctx, QScriptEngine* eng)
 
495
{
 
496
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
497
    QScriptValue set = ctx->argument(0);
 
498
    QScriptValue user = ctx->argument(0);
 
499
 
 
500
    if (set.isUndefined() || user.isUndefined()) {
 
501
        return QScriptValue();
 
502
    }
 
503
 
 
504
    if (central == 0) {
 
505
        return eng->toScriptValue<bool>(0);
 
506
    } else {
 
507
        central->setFullScreen(set.toBool(), user.toBool());
 
508
        return eng->toScriptValue<bool>(1);
 
509
    }
 
510
}
 
511
 
 
512
QScriptValue SWrapper::Client::isFullScreen(QScriptContext* ctx, QScriptEngine* eng)
 
513
{
 
514
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
515
 
 
516
    if (central == 0) {
 
517
        return QScriptValue();
 
518
    } else {
 
519
        return eng->toScriptValue<bool>(central->isFullScreen());
 
520
    }
 
521
}
 
522
 
 
523
QScriptValue SWrapper::Client::isFullScreenable(QScriptContext* ctx, QScriptEngine* eng)
 
524
{
 
525
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
526
 
 
527
    if (central == 0) {
 
528
        return QScriptValue();
 
529
    } else {
 
530
        return eng->toScriptValue<bool>(central->isFullScreenable());
 
531
    }
 
532
}
 
533
 
 
534
QScriptValue SWrapper::Client::activate(QScriptContext* ctx, QScriptEngine* eng)
 
535
{
 
536
    KWin::Client* central = eng->fromScriptValue<KWin::Client*>(ctx->thisObject());
 
537
    QScriptValue force = ctx->argument(0);
 
538
    bool _force = 0;
 
539
 
 
540
    if (central == 0) {
 
541
        return eng->toScriptValue<bool>(0);
 
542
    } else {
 
543
        if (!force.isBool()) {
 
544
            _force = force.toBool();
 
545
        }
 
546
 
 
547
        (KWin::Workspace::self())->activateClient(central, _force);
 
548
        return eng->toScriptValue<bool>(1);
 
549
    }
 
550
}