2
* Copyright (C) 2010 Canonical, Ltd.
5
* Florian Boucault <florian.boucault@canonical.com>
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; version 3.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/* Required otherwise using wnck_set_client_type breaks linking with error:
21
undefined reference to `wnck_set_client_type(WnckClientType)'
24
#include <libwnck/util.h>
27
#include "unity_place.h"
28
#include "unity_place_entry.h"
29
#include "qsortfilterproxymodelqml.h"
30
#include "blendedimageprovider.h"
32
#include <QtDeclarative/qdeclarative.h>
33
#include <QDeclarativeEngine>
34
#include <QDeclarativeContext>
35
#include <QDesktopWidget>
36
#include <QApplication>
38
#include "windowimageprovider.h"
39
#include "windowinfo.h"
40
#include "windowslist.h"
42
#include "cacheeffect.h"
46
void UnityPlacesPlugin::registerTypes(const char *uri)
48
qmlRegisterType<UnityPlace>(uri, 0, 1, "UnityPlace");
49
qmlRegisterType<UnityPlaceEntry>(uri, 0, 1, "UnityPlaceEntry");
50
qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "QSortFilterProxyModelQML");
52
qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
53
qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
54
qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect");
57
void UnityPlacesPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
61
engine->addImageProvider(QString("blended"), new BlendedImageProvider);
62
engine->addImageProvider(QString("window"), new WindowImageProvider);
64
// FIXME: these are probably not very proper here, since clearly not all users
65
// of this plugin wish to have this object in their context
66
engine->rootContext()->setContextProperty("availableGeometry",
67
QApplication::desktop()->availableGeometry());
68
engine->rootContext()->setContextProperty("screenGeometry",
69
QApplication::desktop()->geometry());
71
/* Critically important to set the client type to pager because wnck
72
will pass that type over to the window manager through XEvents.
73
Window managers tend to respect orders from pagers to the letter by
74
for example bypassing focus stealing prevention.
75
Compiz does exactly that in src/event.c:handleEvent(...) in the
76
ClientMessage case (line 1702).
77
Metacity has a similar policy in src/core/window.c:window_activate(...)
80
wnck_set_client_type(WNCK_CLIENT_TYPE_PAGER);
83
Q_EXPORT_PLUGIN2(UnityPlaces, UnityPlacesPlugin);