-
Notifications
You must be signed in to change notification settings - Fork 1
/
python-xlib_13.html
149 lines (136 loc) · 6.93 KB
/
python-xlib_13.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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created on September 16, 2020 by texi2html 5.0
texi2html was written by:
Lionel Cons <[email protected]> (original author)
Karl Berry <[email protected]>
Olaf Bachmann <[email protected]>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <[email protected]>
-->
<head>
<title>The Python X Library: 5.4 Sending Events</title>
<meta name="description" content="The Python X Library: 5.4 Sending Events">
<meta name="keywords" content="The Python X Library: 5.4 Sending Events">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 5.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:pre}
span.nolinebreak {white-space:pre}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Sending-Events"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="python-xlib_9.html#Event-Handling" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_12.html#Event-Types" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_9.html#Event-Handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_14.html#X-Objects" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_14.html#X-Objects" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="python-xlib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="python-xlib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr>
<a name="Sending-Events-1"></a>
<h2 class="section">5.4 Sending Events</h2>
<p>Clients can send events to each other. Most often these are
general-purpose <code>ClientMessage</code> events, but any event type can be
sent.
</p>
<p>To send an event, an event object must be created. This is done by
instantiating an event class, providing values to all its fields as
keyword parameters. The event is then sent with the <code>send_event()</code>
method:
</p>
<dl>
<dt><a name="index-send_005fevent-on-Window"></a>Method on Window: <strong>send_event</strong><em> ( event, event_mask = 0, propagate = 0, onerror = None )</em></dt>
<dd>
<p>Send <var>event</var> to this window.
</p>
<p>If <var>event_mask</var> is 0, the event is sent to the client that created
the window. Otherwise the event is sent to every client selecting any
of the event types in <var>event_mask</var>.
</p>
<p>If no clients have selected any of the event types and <var>propagate</var>
is true, the X server will search for an ancestor of this window on
which some client has selected any of the event types. For details, see
XSendEvent(3X11).
</p>
</dd></dl>
<dl>
<dt><a name="index-send_005fevent-on-Display"></a>Method on Display: <strong>send_event</strong><em> ( destination, event, <span class="nolinebreak">event_mask</span> = 0, propagate = 0, onerror = None )</em></dt>
<dd>
<p>Send <var>event</var> to <var>destination</var>, which can either be a
<code>Window</code> object or a constant: If <code>X.PointerWindow</code> is
specified, send the event to the window the pointer is in. If
<code>X.InputFocus</code> is specified and the focus window contains the
pointer, send the event to the window that the pointer is in.
Otherwise, send the event to the focus window.
</p>
</dd></dl>
<p>As an example, this creates and sends a <code>ClientMessage</code> event of
the client specific type <code>HELLO_WORLD</code> (an atom), to the window
<code>dest</code> and with the 8-bitformat value <code>"G'day, mate"</code> (which
must be exactly twenty bytes):
</p>
<div class="example">
<pre class="example">cm_event = Xlib.protocol.event.ClientMessage(
window = dest,
client_type = HELLO_WORLD,
data = (8, "G'day mate\0\0\0\0\0\0\0\0\0\0"))
dest.send_event(cm_event)
</pre></div>
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="python-xlib_9.html#Event-Handling" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_12.html#Event-Types" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_9.html#Event-Handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_14.html#X-Objects" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_14.html#X-Objects" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="python-xlib.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="python-xlib_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[Index]</td>
<td valign="middle" align="left">[<a href="python-xlib_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated on <i>September 16, 2020</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 5.0</i></a>.
</font>
<br>
</p>
</body>
</html>