2
* Copyright 1994-2011 Olivier Girondel
4
* This file is part of lebiniou.
6
* lebiniou is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 2 of the License, or
9
* (at your option) any later version.
11
* lebiniou 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.
16
* You should have received a copy of the GNU General Public License
17
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
27
* [C][To, Cmd, Arg] // keyboard command
28
* [U][C|P|S][uint32_t id] // update event
31
extern int write_exact(const u_char *, const int);
34
extern uint32_t last_colormap;
35
extern uint32_t last_picture;
36
extern uint32_t last_sequence;
38
extern char send_colormap_update;
39
extern char send_picture_update;
40
extern char send_sequence_update;
44
v7_send_event(const Event_t *e)
46
uint32_t proto = 7, proto2;
47
uint32_t total, total2;
52
/* send packet size */
53
total = sizeof(uint32_t)+4*sizeof(u_char);
54
total2 = htonl(total);
55
ret = write_exact((const u_char *)&total2, sizeof(uint32_t));
57
/* protocol version */
58
proto2 = htonl(proto);
59
ret = write_exact((const u_char *)&proto2, sizeof(uint32_t));
62
ret = write_exact(&val, sizeof(u_char));
64
ret = write_exact(&val, sizeof(u_char));
66
ret = write_exact(&val, sizeof(u_char));
68
ret = write_exact(&val, sizeof(u_char));
73
v7_send_events(Context_t *ctx)
77
for (t = ctx->events; t != NULL; t = g_list_next(t)) {
78
Event_t *e = (Event_t *)t->data;
85
v7_send_id(const u_char what, const uint32_t id)
87
uint32_t proto = 7, proto2;
88
uint32_t total, total2;
94
/* send packet size */
95
total = sizeof(uint32_t)+2*sizeof(u_char)+sizeof(uint32_t);
96
total2 = htonl(total);
97
ret = write_exact((const u_char *)&total2, sizeof(uint32_t));
99
/* protocol version */
100
proto2 = htonl(proto);
101
ret = write_exact((const u_char *)&proto2, sizeof(uint32_t));
104
ret = write_exact(&val, sizeof(u_char));
106
ret = write_exact(&val, sizeof(u_char));
109
ret = write_exact((const u_char *)&id2, sizeof(uint32_t));
114
v7_send_sequence(const uint32_t id)
116
uint32_t proto = 7, proto2;
117
uint32_t total, total2;
126
seq = Sequences_find(id);
128
seq_size = Sequence_size(seq);
130
/* send packet size */
131
total = sizeof(uint32_t) /* proto */
132
+ 2*sizeof(u_char) /* 'US' */
133
+ sizeof(uint32_t) /* sequence id */
134
+ sizeof(uint8_t) /* sequence size */
135
+ (seq_size * sizeof(uint32_t)); /* N plugins */ /* TODO plugin_id -> uint32_t */
136
total2 = htonl(total);
137
ret = write_exact((const u_char *)&total2, sizeof(uint32_t));
139
/* protocol version */
140
proto2 = htonl(proto);
141
ret = write_exact((const u_char *)&proto2, sizeof(uint32_t));
144
ret = write_exact(&val, sizeof(u_char));
145
val = UPDATE_SEQUENCE_CHAR;
146
ret = write_exact(&val, sizeof(u_char));
150
ret = write_exact((const u_char *)&id2, sizeof(uint32_t));
153
ret = write_exact((const u_char *)&seq_size, sizeof(uint8_t));
155
for (i = 0; i < seq_size; i++) {
156
Layer_t *l = (Layer_t *)tmp->data;
158
id2 = htonl(l->plugin->id);
159
ret = write_exact((const u_char *)&id2, sizeof(uint32_t));
160
tmp = g_list_next(tmp);
170
if (send_colormap_update)
171
if (ctx->sm->cur->cmap_id != last_colormap) {
172
v7_send_id(UPDATE_COLORMAP_CHAR, ctx->sm->cur->cmap_id);
173
last_colormap = ctx->sm->cur->cmap_id;
176
if (send_picture_update)
177
if (ctx->sm->cur->picture_id != last_picture) {
178
v7_send_id(UPDATE_PICTURE_CHAR, ctx->sm->cur->picture_id);
179
last_picture = ctx->sm->cur->picture_id;
182
if (send_sequence_update)
183
if (ctx->sm->cur->id != last_sequence) {
184
v7_send_sequence(ctx->sm->cur->id);
185
last_sequence = ctx->sm->cur->id;