-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_machine.h
117 lines (94 loc) · 2.57 KB
/
client_machine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Martin Gräßlin <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_CLIENT_MACHINE_H
#define KWIN_CLIENT_MACHINE_H
#include <QObject>
#include <xcb/xcb.h>
// forward declaration
struct addrinfo;
template <typename T>
class QFutureWatcher;
namespace KWin {
class GetAddrInfo : public QObject
{
Q_OBJECT
public:
explicit GetAddrInfo(const QByteArray &hostName, QObject *parent = NULL);
virtual ~GetAddrInfo();
void resolve();
Q_SIGNALS:
void local();
private Q_SLOTS:
void slotResolved();
void slotOwnAddressResolved();
private:
void compare();
bool resolved(QFutureWatcher<int> *watcher);
bool m_resolving;
bool m_resolved;
bool m_ownResolved;
QByteArray m_hostName;
addrinfo *m_addressHints;
addrinfo *m_address;
addrinfo *m_ownAddress;
QFutureWatcher<int> *m_watcher;
QFutureWatcher<int> *m_ownAddressWatcher;
};
class ClientMachine : public QObject
{
Q_OBJECT
public:
explicit ClientMachine(QObject *parent = NULL);
virtual ~ClientMachine();
void resolve(xcb_window_t window, xcb_window_t clientLeader);
const QByteArray &hostName() const;
bool isLocal() const;
static QByteArray localhost();
bool isResolving() const;
Q_SIGNALS:
void localhostChanged();
private Q_SLOTS:
void setLocal();
void resolveFinished();
private:
void checkForLocalhost();
QByteArray m_hostName;
bool m_localhost;
bool m_resolved;
bool m_resolving;
};
inline
bool ClientMachine::isLocal() const
{
return m_localhost;
}
inline
const QByteArray &ClientMachine::hostName() const
{
return m_hostName;
}
inline
QByteArray ClientMachine::localhost()
{
return "localhost";
}
inline
bool ClientMachine::isResolving() const
{
return m_resolving;
}
} // namespace
#endif