~ubuntu-branches/ubuntu/natty/unity-2d/natty-updates

« back to all changes in this revision

Viewing changes to places/UnityPlaces/plugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2011-02-24 13:45:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224134527-d2lk3qu3sxe9a8z0
Tags: 3.6.0-0ubuntu1
New Upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2010 Canonical, Ltd.
3
 
 *
4
 
 * Authors:
5
 
 *  Florian Boucault <florian.boucault@canonical.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; version 3.
10
 
 *
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.
15
 
 *
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/>.
18
 
 */
19
 
 
20
 
/* Required otherwise using wnck_set_client_type breaks linking with error:
21
 
   undefined reference to `wnck_set_client_type(WnckClientType)'
22
 
*/
23
 
extern "C" {
24
 
#include <libwnck/util.h>
25
 
}
26
 
 
27
 
#include "unity_place.h"
28
 
#include "unity_place_entry.h"
29
 
#include "qsortfilterproxymodelqml.h"
30
 
#include "blendedimageprovider.h"
31
 
 
32
 
#include <QtDeclarative/qdeclarative.h>
33
 
#include <QDeclarativeEngine>
34
 
#include <QDeclarativeContext>
35
 
#include <QDesktopWidget>
36
 
#include <QApplication>
37
 
 
38
 
#include "windowimageprovider.h"
39
 
#include "windowinfo.h"
40
 
#include "windowslist.h"
41
 
#include "plugin.h"
42
 
#include "cacheeffect.h"
43
 
 
44
 
 
45
 
 
46
 
void UnityPlacesPlugin::registerTypes(const char *uri)
47
 
{
48
 
    qmlRegisterType<UnityPlace>(uri, 0, 1, "UnityPlace");
49
 
    qmlRegisterType<UnityPlaceEntry>(uri, 0, 1, "UnityPlaceEntry");
50
 
    qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "QSortFilterProxyModelQML");
51
 
 
52
 
    qmlRegisterType<WindowInfo>(uri, 0, 1, "WindowInfo");
53
 
    qmlRegisterType<WindowsList>(uri, 0, 1, "WindowsList");
54
 
    qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect");
55
 
}
56
 
 
57
 
void UnityPlacesPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
58
 
{
59
 
    Q_UNUSED(uri);
60
 
 
61
 
    engine->addImageProvider(QString("blended"), new BlendedImageProvider);
62
 
    engine->addImageProvider(QString("window"), new WindowImageProvider);
63
 
 
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());
70
 
 
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(...)
78
 
       (line 2951).
79
 
    */
80
 
    wnck_set_client_type(WNCK_CLIENT_TYPE_PAGER);
81
 
}
82
 
 
83
 
Q_EXPORT_PLUGIN2(UnityPlaces, UnityPlacesPlugin);