This repository has been archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dtk-gui-dforeignwindow.html
210 lines (202 loc) · 14.2 KB
/
dtk-gui-dforeignwindow.html
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- dforeignwindow.cpp -->
<title>DForeignWindow Class | Dtk Reference Documentation 1.0.0</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li><a href="index.html">Dtk Doc</a></li>
<li><a href="index.html">Dtk Reference Documentation</a></li>
<li>DForeignWindow</li>
<li id="buildversion"><a href="index.html">Qt 5.15.2 Reference Documentation</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">DForeignWindow Class</h1>
<span class="small-subtitle">class <a href="dtk.html">Dtk</a>::<a href="dtk-gui.html">Gui</a>::DForeignWindow</span>
<!-- $$$DForeignWindow-brief -->
<p>一个用于获取本地窗口信息的类. <a href="#details">More...</a></p>
<!-- @@@DForeignWindow -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <DForeignWindow></span>
</td></tr></table></div><ul>
<li><a href="dtk-gui-dforeignwindow-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><a href="dtk-gui-dforeignwindow.html#pid-prop">pid</a></b> : const quint32</li>
<li class="fn"><b><a href="dtk-gui-dforeignwindow.html#wmClass-prop">wmClass</a></b> : const QString</li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#DForeignWindow">DForeignWindow</a></b>(QWindow *<i>parent</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> quint32 </td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#pid-prop">pid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#wmClass-prop">wmClass</a></b>() const</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#pidChanged">pidChanged</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#wmClassChanged">wmClassChanged</a></b>()</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Dtk::Gui::DForeignWindow *</td><td class="memItemRight bottomAlign"><b><a href="dtk-gui-dforeignwindow.html#fromWinId">fromWinId</a></b>(int <i>id</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$DForeignWindow-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>继承于 <a href="http://doc.qt.io/qt-5/qwindow.html">QWindow</a>,支持 <a href="http://doc.qt.io/qt-5/qwindow.html#geometry">QWindow::geometry</a> <a href="http://doc.qt.io/qt-5/qwindow.html#x-prop">QWindow::x</a> <a href="http://doc.qt.io/qt-5/qwindow.html#y-prop">QWindow::y</a> <a href="http://doc.qt.io/qt-5/qwindow.html#width-prop">QWindow::width</a> <a href="http://doc.qt.io/qt-5/qwindow.html#height-prop">QWindow::height</a> <a href="http://doc.qt.io/qt-5/qwindow.html#title-prop">QWindow::title</a> <a href="http://doc.qt.io/qt-5/qwindow.html#flags-prop">QWindow::flags</a> <a href="http://doc.qt.io/qt-5/qwindow.html#visibility-prop">QWindow::visibility</a> <a href="http://doc.qt.io/qt-5/qwindow.html#type">QWindow::type</a> <a href="http://doc.qt.io/qt-5/qwindow.html#windowStates">QWindow::windowStates</a> <a href="http://doc.qt.io/qt-5/qwindow.html#windowState">QWindow::windowState</a> 等接口的使用,另外扩展 增加了一部分接口,方面更加详细的获取窗口信息。依赖于 dxcb 插件,在未加载 dxcb 插件的应用中使用时结果未知</p>
</div>
<p><b>See also </b><a href="dtk-gui-dwindowmanagerhelper.html#currentWorkspaceWindows">DWindowManagerHelper::currentWorkspaceWindows</a>, Dtk::Widget::DApplication::loadDXcbPlugin, and Dtk::Widget::DApplication::isDXcbPlatform.</p>
<!-- @@@DForeignWindow -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$pid-prop$$$pid$$$pidChanged -->
<h3 class="fn" id="pid-prop"><a name="pid-prop"></a><span class="name">pid</span> : const <span class="type"><a href="http://doc.qt.io/qt-5/qtglobal.html#quint32-typedef">quint32</a></span></h3>
<p>窗口所属进程的 pid</p>
<p><b>Note: </b>只读 <a href="https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html">_NET_WM_PID</a></p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> quint32 </td><td class="memItemRight bottomAlign"><span class="name"><b>pid</b></span>() const</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-gui-dforeignwindow.html#pidChanged">pidChanged</a></b></span>()</td></tr>
</table></div>
<!-- @@@pid -->
<!-- $$$wmClass-prop$$$wmClass$$$wmClassChanged -->
<h3 class="fn" id="wmClass-prop"><a name="wmClass-prop"></a><span class="name">wmClass</span> : const <span class="type"><a href="http://doc.qt.io/qt-5/qstring.html">QString</a></span></h3>
<p>窗口 WM_CLASS 的值</p>
<p><b>Note: </b>只读 <a href="https://tronche.com/gui/x/icccm/sec-4.html#WM_CLASS">WM_CLASS</a></p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>wmClass</b></span>() const</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="dtk-gui-dforeignwindow.html#wmClassChanged">wmClassChanged</a></b></span>()</td></tr>
</table></div>
<!-- @@@wmClass -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$DForeignWindow[overload1]$$$DForeignWindowQWindow* -->
<h3 class="fn" id="DForeignWindow"><a name="DForeignWindow"></a>DForeignWindow::<span class="name">DForeignWindow</span>(<span class="type"><a href="http://doc.qt.io/qt-5/qwindow.html">QWindow</a></span> *<i>parent</i> = 0)</h3>
<p>直接构造一个 DForeignWindow 对象和使用 <a href="http://doc.qt.io/qt-5/qwindow.html">QWindow</a> 对象没有区别.</p>
<p><i>parent</i></p>
<p><b>See also </b><a href="dtk-gui-dforeignwindow.html#fromWinId">DForeignWindow::fromWinId</a>.</p>
<!-- @@@DForeignWindow -->
<!-- $$$pidChanged -->
<h3 class="fn" id="pidChanged"><a name="pidChanged"></a><code>[signal] </code><span class="type">void</span> DForeignWindow::<span class="name">pidChanged</span>()</h3>
<p>信号会在 pid 属性的值改变时被发送.</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-gui-dforeignwindow.html#pid-prop">pid</a>. </p>
<p><b>See also </b><a href="dtk-gui-dforeignwindow.html#pid-prop">DForeignWindow::pid</a>.</p>
<!-- @@@pidChanged -->
<!-- $$$wmClassChanged -->
<h3 class="fn" id="wmClassChanged"><a name="wmClassChanged"></a><code>[signal] </code><span class="type">void</span> DForeignWindow::<span class="name">wmClassChanged</span>()</h3>
<p>信号会在 <a href="dtk-gui-dforeignwindow.html#wmClass-prop">wmClass</a> 属性改变时被发送.</p>
<p><b>Note: </b>Notifier signal for property <a href="dtk-gui-dforeignwindow.html#wmClass-prop">wmClass</a>. </p>
<p><b>See also </b><a href="dtk-gui-dforeignwindow.html#wmClass-prop">DForeignWindow::wmClass</a>.</p>
<!-- @@@wmClassChanged -->
<!-- $$$fromWinId[overload1]$$$fromWinIdint -->
<h3 class="fn" id="fromWinId"><a name="fromWinId"></a><code>[static] </code><span class="type"><a href="dtk-gui-dforeignwindow.html">Dtk::Gui::DForeignWindow</a></span> *DForeignWindow::<span class="name">fromWinId</span>(<span class="type">int</span> <i>id</i>)</h3>
<p>DForeignWindow::fromWinId. 使用这个窗口id创建一个 <a href="dtk-gui-dforeignwindow.html">DForeignWindow</a> 对象,此对象不会被加到 <a href="http://doc.qt.io/qt-5/qguiapplication.html#allWindows">QGuiApplication::allWindows</a> 中。一般应用在需要获取一个本地窗口信息的场景。示例:</p>
<pre class="cpp">
<span class="comment">// a.cpp</span>
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
DApplication a(argc<span class="operator">,</span> argv);
<span class="type"><a href="http://doc.qt.io/qt-5/qwidget.html">QWidget</a></span> w;
w<span class="operator">.</span>setWindowTitle(<span class="string">"deepin"</span>);
w<span class="operator">.</span>show();
<span class="type"><a href="http://doc.qt.io/qt-5/qfile.html">QFile</a></span> app_win_id(<span class="string">"/tmp/window_id.txt"</span>);
<span class="keyword">if</span> (app_win_id<span class="operator">.</span>open(<span class="type"><a href="http://doc.qt.io/qt-5/qfile.html">QFile</a></span><span class="operator">::</span>WriteOnly)) {
app_win_id<span class="operator">.</span>write(<span class="type"><a href="http://doc.qt.io/qt-5/qbytearray.html">QByteArray</a></span><span class="operator">::</span>number(w<span class="operator">.</span>winId()));
app_win_id<span class="operator">.</span>close();
}
<span class="keyword">return</span> a<span class="operator">.</span>exec();
}
</pre>
<pre class="cpp">
<span class="comment">// b.cpp</span>
<span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
{
DApplication<span class="operator">::</span>loadDXcbPlugin();
DApplication a(argc<span class="operator">,</span> argv);
DForeignWindow <span class="operator">*</span>fw <span class="operator">=</span> nullptr;
<span class="type"><a href="http://doc.qt.io/qt-5/qfile.html">QFile</a></span> app_win_id(<span class="string">"/tmp/window_id.txt"</span>);
<span class="keyword">if</span> (app_win_id<span class="operator">.</span>open(<span class="type"><a href="http://doc.qt.io/qt-5/qfile.html">QFile</a></span><span class="operator">::</span>ReadOnly)) {
fw <span class="operator">=</span> DForeignWindow<span class="operator">::</span>fromWinId(app_win_id<span class="operator">.</span>readAll()<span class="operator">.</span>toInt());
}
<span class="keyword">if</span> (fw) {
<a href="http://doc.qt.io/qt-5/qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> fw<span class="operator">-</span><span class="operator">></span>title();
fw<span class="operator">-</span><span class="operator">></span>connect(fw<span class="operator">,</span> <span class="operator">&</span>DForeignWindow<span class="operator">::</span>widthChanged<span class="operator">,</span> <span class="operator">[</span><span class="operator">&</span><span class="operator">]</span> {
<a href="http://doc.qt.io/qt-5/qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> fw<span class="operator">-</span><span class="operator">></span>width();
});
}
<span class="keyword">return</span> a<span class="operator">.</span>exec();
}
</pre>
<p>先启动应用 a 再启动应用 b</p>
<p>在应用 b 启动后将看到如下输出:</p>
<pre class="cpp">
<span class="string">"deepin"</span>
</pre>
<p>当改变应用 a 中的窗口宽度时,在应用 b 中会看到宽度的输出 <i>id</i> Returns</p>
<p><b>Warning:</b> 不要尝试对由本应用创建的窗口调用此接口,可能会导致窗口行为发生不可逆转的变化</p>
<!-- @@@fromWinId -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2020 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>