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

« back to all changes in this revision

Viewing changes to kwin/scripting/windowinfo.h

  • 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
#ifndef KWIN_SCRIPTING_WINDOWINFO_H
 
22
#define KWIN_SCRIPTING_WINDOWINFO_H
 
23
 
 
24
#include "./../client.h"
 
25
 
 
26
#include "meta.h"
 
27
 
 
28
#include <kwindowsystem.h>
 
29
#include <kwindowinfo.h>
 
30
 
 
31
#include <QScriptEngine>
 
32
 
 
33
// The following two extremely helpful functions are taken
 
34
// from the KWin Scripting proof-of-concept submitted by
 
35
// Lubos Lunak <l.lunak@kde.org>. Copyrights belong with
 
36
// original author (Lubos Lunak).
 
37
 
 
38
#undef MAP_GET
 
39
#undef MAP_SET
 
40
 
 
41
#define MAP_GET2(name, type2) \
 
42
    type2 SWrapper::WindowInfo::name() const { \
 
43
        return type2(infoClass.name()); \
 
44
    }
 
45
 
 
46
#define MAP_GET(name, type) \
 
47
    type SWrapper::WindowInfo::name() const { \
 
48
        return infoClass.name(); \
 
49
    }
 
50
 
 
51
#define MAP_SET(name, type) \
 
52
    void SWrapper::Toplevel::name(type value) { \
 
53
        subObject->name(value); \
 
54
    }
 
55
 
 
56
 
 
57
namespace SWrapper
 
58
{
 
59
 
 
60
// No signals/slots here, but the usage of properties
 
61
// would make things a breeze, so a QObject it is.
 
62
class WindowInfo : public QObject
 
63
{
 
64
    Q_OBJECT
 
65
private:
 
66
    KWindowInfo infoClass;
 
67
    QScriptEngine* centralEngine;
 
68
 
 
69
    /**
 
70
      * The info about a lot of window properties enumerated from the
 
71
      * client this windowinfo was generated from.
 
72
      */
 
73
    Q_PROPERTY(bool valid READ valid)
 
74
    Q_PROPERTY(int state READ state)
 
75
    Q_PROPERTY(bool isMinimized READ isMinimized)
 
76
    Q_PROPERTY(QString visibleName READ visibleName)
 
77
    Q_PROPERTY(QString windowClassClass READ windowClassClass)
 
78
    Q_PROPERTY(QString windowClassName READ windowClassName)
 
79
    Q_PROPERTY(QString windowRole READ windowRole)
 
80
 
 
81
    bool valid() const;
 
82
    int state() const;
 
83
    bool isMinimized() const;
 
84
    QString visibleName() const;
 
85
 
 
86
    QString windowClassClass() const;
 
87
    QString windowClassName() const;
 
88
    QString windowRole() const;
 
89
 
 
90
public:
 
91
    WindowInfo(const KWindowInfo, QScriptEngine*, QObject* parent = 0);
 
92
    static QScriptValue generate(const KWindowInfo, QScriptEngine*, KWin::Client* client = 0);
 
93
};
 
94
 
 
95
}
 
96
 
 
97
#endif