~lukas-kde/miral/shellchrome-windowinfo

« back to all changes in this revision

Viewing changes to miral-qt/src/modules/Unity/Application/dbusfocusinfo.h

  • Committer: Larry Price
  • Date: 2016-09-13 16:19:29 UTC
  • mto: (330.4.1 miral)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: larry.price@canonical.com-20160913161929-vs9ka1capmljq1es
Removing miral-qt from release branch, updating copyright file, and adding GPL3 license to root dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2016 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it under
5
 
 * the terms of the GNU Lesser General Public License version 3, as published by
6
 
 * the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
 
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 
 * Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
 
17
 
#include <QList>
18
 
#include <QSet>
19
 
 
20
 
#include "application.h"
21
 
 
22
 
namespace qtmir {
23
 
 
24
 
class CGManager;
25
 
class MirSurfaceInterface;
26
 
 
27
 
/*
28
 
   Enables other processes to check what is the currently focused application or surface,
29
 
   normally for security purposes.
30
 
 */
31
 
class DBusFocusInfo : public QObject
32
 
{
33
 
    Q_OBJECT
34
 
    Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.FocusInfo")
35
 
public:
36
 
    explicit DBusFocusInfo(const QList<Application*> &applications);
37
 
    virtual ~DBusFocusInfo() {}
38
 
 
39
 
public Q_SLOTS:
40
 
 
41
 
    /*
42
 
        Returns true if the application with the given PID has input focus
43
 
 
44
 
        FIXME: Identifying an app through its PID is deemed racy.
45
 
               isSurfaceFocused() is the preferred method.
46
 
     */
47
 
    Q_SCRIPTABLE bool isPidFocused(unsigned int pid);
48
 
 
49
 
    /*
50
 
        Returns true if the surface with the given id has input focus
51
 
     */
52
 
    Q_SCRIPTABLE bool isSurfaceFocused(const QString &surfaceId);
53
 
 
54
 
private:
55
 
    QSet<pid_t> fetchAssociatedPids(pid_t pid);
56
 
    SessionInterface* findSessionWithPid(const QSet<pid_t> &pidSet);
57
 
    MirSurfaceInterface *findQmlSurface(const QString &serializedId);
58
 
 
59
 
    const QList<Application*> &m_applications;
60
 
 
61
 
    CGManager *m_cgManager;
62
 
};
63
 
 
64
 
} // namespace qtmir