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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549 | /*-*- Mode: C; c-basic-offset: 8 -*-*/
/***
This file is part of libkanberra.
Copyright 2008 Lennart Poettering
libkanberra is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 2.1 of the
License, or (at your option) any later version.
libkanberra 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with libkanberra. If not, see
<http://www.gnu.org/licenses/>.
***/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ctk/ctk.h>
#include <cdk/cdk.h>
#include <cdk/cdkx.h>
#include <X11/Xatom.h>
#include "kanberra.h"
#include "kanberra-ctk.h"
#include "common.h"
#include "malloc.h"
#include "proplist.h"
#include "fork-detect.h"
/**
* SECTION:kanberra-ctk
* @short_description: Ctk+ libkanberra Bindings
*
* libkanberra-ctk provides a few functions that simplify libkanberra
* usage from Ctk+ programs. It maintains a single ka_context object
* per #CdkScreen that is made accessible via
* ka_ctk_context_get_for_screen(), with a shortcut ka_ctk_context_get()
* to get the context for the default screen. More importantly, it provides
* a few functions
* to compile event sound property lists based on CtkWidget objects or
* CdkEvent events.
*/
static void read_sound_theme_name(ka_context *c, CtkSettings *s) {
gchar *theme_name = NULL;
g_object_get(G_OBJECT(s), "ctk-sound-theme-name", &theme_name, NULL);
if (theme_name) {
ka_context_change_props(c, KA_PROP_KANBERRA_XDG_THEME_NAME, theme_name, NULL);<--- Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. [+]Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
The C99 standard, in section 7.15.1.1, states that if the type used by va_arg() is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined.
The value of the NULL macro is an implementation-defined null pointer constant (7.17), which can be any integer constant expression with the value 0, or such an expression casted to (void*) (6.3.2.3). This includes values like 0, 0L, or even 0LL.
In practice on common architectures, this will cause real crashes if sizeof(int) != sizeof(void*), and NULL is defined to 0 or any other null pointer constant that promotes to int.
To reproduce you might be able to use this little code example on 64bit platforms. If the output includes "ERROR", the sentinel had only 4 out of 8 bytes initialized to zero and was not detected as the final argument to stop argument processing via va_arg(). Changing the 0 to (void*)0 or 0L will make the "ERROR" output go away.
#include <stdarg.h>
#include <stdio.h>
void f(char *s, ...) {
va_list ap;
va_start(ap,s);
for (;;) {
char *p = va_arg(ap,char*);
printf("%018p, %s\n", p, (long)p & 255 ? p : "");
if(!p) break;
}
va_end(ap);
}
void g() {
char *s2 = "x";
char *s3 = "ERROR";
// changing 0 to 0L for the 7th argument (which is intended to act as sentinel) makes the error go away on x86_64
f("first", s2, s2, s2, s2, s2, 0, s3, (char*)0);
}
void h() {
int i;
volatile unsigned char a[1000];
for (i = 0; i<sizeof(a); i++)
a[i] = -1;
}
int main() {
h();
g();
return 0;
}
g_free(theme_name);
}
}
static void read_enable_event_sounds(ka_context *c, CtkSettings *s) {
gboolean enable_event_sounds = TRUE;
if (!g_getenv("KANBERRA_FORCE_EVENT_SOUNDS"))
g_object_get(G_OBJECT(s), "ctk-enable-event-sounds", &enable_event_sounds, NULL);
ka_context_change_props(c, KA_PROP_KANBERRA_ENABLE, enable_event_sounds ? "1" : "0", NULL);<--- Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. [+]Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.
The C99 standard, in section 7.15.1.1, states that if the type used by va_arg() is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), the behavior is undefined.
The value of the NULL macro is an implementation-defined null pointer constant (7.17), which can be any integer constant expression with the value 0, or such an expression casted to (void*) (6.3.2.3). This includes values like 0, 0L, or even 0LL.
In practice on common architectures, this will cause real crashes if sizeof(int) != sizeof(void*), and NULL is defined to 0 or any other null pointer constant that promotes to int.
To reproduce you might be able to use this little code example on 64bit platforms. If the output includes "ERROR", the sentinel had only 4 out of 8 bytes initialized to zero and was not detected as the final argument to stop argument processing via va_arg(). Changing the 0 to (void*)0 or 0L will make the "ERROR" output go away.
#include <stdarg.h>
#include <stdio.h>
void f(char *s, ...) {
va_list ap;
va_start(ap,s);
for (;;) {
char *p = va_arg(ap,char*);
printf("%018p, %s\n", p, (long)p & 255 ? p : "");
if(!p) break;
}
va_end(ap);
}
void g() {
char *s2 = "x";
char *s3 = "ERROR";
// changing 0 to 0L for the 7th argument (which is intended to act as sentinel) makes the error go away on x86_64
f("first", s2, s2, s2, s2, s2, 0, s3, (char*)0);
}
void h() {
int i;
volatile unsigned char a[1000];
for (i = 0; i<sizeof(a); i++)
a[i] = -1;
}
int main() {
h();
g();
return 0;
}
}
static void sound_theme_name_changed(CtkSettings *s, GParamSpec *arg1, ka_context *c) {
read_sound_theme_name(c, s);
}
static void enable_event_sounds_changed(CtkSettings *s, GParamSpec *arg1, ka_context *c) {
read_enable_event_sounds(c, s);
}
/**
* ka_ctk_context_get:
*
* Gets the single ka_context object for the default screen. See
* ka_ctk_context_get_for_screen().
*
* Returns: a ka_context object. The object is owned by libkanberra-ctk
* and must not be destroyed
*/
ka_context *ka_ctk_context_get(void) {
return ka_ctk_context_get_for_screen(NULL);
}
/**
* ka_ctk_context_get_for_screen:
* @screen: the #CdkScreen to get the context for, or %NULL to use
* the default screen
*
* libkanberra-ctk maintains a single ka_context object for each
* #CdkScreen. Use this function to access it. The
* %KA_PROP_KANBERRA_XDG_THEME_NAME of this context property is
* dynamically bound to the XSETTINGS setting for the XDG theme
* name. KA_PROP_APPLICATION_NAME is bound to
* g_get_application_name().
*
* Returns: a ka_context object. The object is owned by libkanberra-ctk
* and must not be destroyed
*
* Since: 0.13
*/
ka_context *ka_ctk_context_get_for_screen(CdkScreen *screen) {
ka_context *c = NULL;
ka_proplist *p = NULL;
const char *name;
CtkSettings *s;
if (!screen)
screen = cdk_screen_get_default();
if ((c = g_object_get_data(G_OBJECT(screen), "kanberra::ctk::context")))
return c;
if (ka_context_create(&c) != KA_SUCCESS)
return NULL;
if (ka_proplist_create(&p) != KA_SUCCESS) {
ka_context_destroy(c);
return NULL;
}
if ((name = g_get_application_name()))
ka_proplist_sets(p, KA_PROP_APPLICATION_NAME, name);
else {
ka_proplist_sets(p, KA_PROP_APPLICATION_NAME, "libkanberra-ctk");
ka_proplist_sets(p, KA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
ka_proplist_sets(p, KA_PROP_APPLICATION_ID, "org.freedesktop.libkanberra.ctk");
}
if ((name = ctk_window_get_default_icon_name()))
ka_proplist_sets(p, KA_PROP_APPLICATION_ICON_NAME, name);
if ((name = cdk_display_get_name(cdk_screen_get_display(screen))))
ka_proplist_sets(p, KA_PROP_WINDOW_X11_DISPLAY, name);
ka_proplist_setf(p, KA_PROP_WINDOW_X11_SCREEN, "%i", cdk_x11_screen_get_screen_number(screen));
ka_context_change_props_full(c, p);
ka_proplist_destroy(p);
if ((s = ctk_settings_get_for_screen(screen))) {
if (g_object_class_find_property(G_OBJECT_GET_CLASS(s), "ctk-sound-theme-name")) {
g_signal_connect(G_OBJECT(s), "notify::ctk-sound-theme-name", G_CALLBACK(sound_theme_name_changed), c);
read_sound_theme_name(c, s);
} else
g_debug("This Ctk+ version doesn't have the CtkSettings::ctk-sound-theme-name property.");
if (g_object_class_find_property(G_OBJECT_GET_CLASS(s), "ctk-enable-event-sounds")) {
g_signal_connect(G_OBJECT(s), "notify::ctk-enable-event-sounds", G_CALLBACK(enable_event_sounds_changed), c);
read_enable_event_sounds(c, s);
} else
g_debug("This Ctk+ version doesn't have the CtkSettings::ctk-enable-event-sounds property.");
}
g_object_set_data_full(G_OBJECT(screen), "kanberra::ctk::context", c, (GDestroyNotify) ka_context_destroy);
return c;
}
static CtkWindow* get_toplevel(CtkWidget *w) {
if (!(w = ctk_widget_get_toplevel(w)))
return NULL;
if (!CTK_IS_WINDOW(w))
return NULL;
return CTK_WINDOW(w);
}
static gint window_get_desktop(CdkDisplay *d, CdkWindow *w) {
Atom type_return;
gint format_return;
gulong nitems_return;
gulong bytes_after_return;
guchar *data = NULL;
gint ret = -1;
#ifdef CDK_IS_X11_DISPLAY
if (!CDK_IS_X11_DISPLAY(d))<--- Skipping configuration 'CDK_IS_X11_DISPLAY;PACKAGE' since the value of 'CDK_IS_X11_DISPLAY' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
return 0;
#endif
if (XGetWindowProperty(CDK_DISPLAY_XDISPLAY(d), CDK_WINDOW_XID(w),
cdk_x11_get_xatom_by_name_for_display(d, "_NET_WM_DESKTOP"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
&format_return, &nitems_return, &bytes_after_return,
&data) != Success)
return -1;
if (type_return == XA_CARDINAL && format_return == 32 && data) {
guint32 desktop = *(guint32*) data;
if (desktop != 0xFFFFFFFF)
ret = (gint) desktop;
}
if (type_return != None && data != NULL)
XFree(data);
return ret;
}
/**
* ka_ctk_proplist_set_for_widget:
* @p: The proplist to store these sound event properties in
* @w: The Ctk widget to base these sound event properties on
*
* Fill in a ka_proplist object for a sound event that shall originate
* from the specified Ctk Widget. This will fill in properties like
* %KA_PROP_WINDOW_NAME or %KA_PROP_WINDOW_X11_DISPLAY for you.
*
* Returns: 0 on success, negative error code on error.
*/
int ka_ctk_proplist_set_for_widget(ka_proplist *p, CtkWidget *widget) {
CtkWindow *w;
int ret;
const char *t, *role;
ka_return_val_if_fail(p, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(widget, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(!ka_detect_fork(), KA_ERROR_FORKED);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
if (!(w = get_toplevel(widget)))
return KA_ERROR_INVALID;
if ((t = ctk_window_get_title(w)))
if ((ret = ka_proplist_sets(p, KA_PROP_WINDOW_NAME, t)) < 0)
return ret;
if ((role = ctk_window_get_role(w))) {
if (role && t) {<--- Condition 'role' is always true
char *id = ka_sprintf_malloc("%s#%s", t, role);
if ((ret = ka_proplist_sets(p, KA_PROP_WINDOW_ID, id)) < 0) {
ka_free(id);
return ret;
}
ka_free(id);
}
} else if (t)
if ((ret = ka_proplist_sets(p, KA_PROP_WINDOW_ID, t)) < 0)
return ret;
if ((t = ctk_window_get_icon_name(w)))
if ((ret = ka_proplist_sets(p, KA_PROP_WINDOW_ICON_NAME, t)) < 0)
return ret;
if (ctk_widget_get_realized(CTK_WIDGET(w))) {
CdkWindow *dw = NULL;
CdkScreen *screen = NULL;
CdkDisplay *display = NULL;
gint x = -1, y = -1, width = -1, height = -1, screen_width = -1, screen_height = -1;<--- Variable 'screen_width' is assigned a value that is never used.<--- Variable 'screen_height' is assigned a value that is never used.
if ((dw = ctk_widget_get_window(CTK_WIDGET(w))))
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_X11_XID, "%lu", (unsigned long) CDK_WINDOW_XID(dw))) < 0)
return ret;
if ((display = ctk_widget_get_display(CTK_WIDGET(w)))) {
if ((t = cdk_display_get_name(display)))
if ((ret = ka_proplist_sets(p, KA_PROP_WINDOW_X11_DISPLAY, t)) < 0)
return ret;
if (dw) {
gint desktop = window_get_desktop(display, dw);
if (desktop >= 0)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_DESKTOP, "%i", desktop)) < 0)
return ret;
}
}
if ((screen = ctk_widget_get_screen(CTK_WIDGET(w)))) {
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_X11_SCREEN, "%i", cdk_x11_screen_get_screen_number(screen))) < 0)
return ret;
if (dw)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_X11_MONITOR, "%i", cdk_screen_get_monitor_at_window(screen, dw))) < 0)
return ret;
}
/* FIXME, this might cause a round trip */
if (dw) {
cdk_window_get_origin(dw, &x, &y);
if (x >= 0)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_X, "%i", x)) < 0)
return ret;
if (y >= 0)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_Y, "%i", y)) < 0)
return ret;
}
ctk_window_get_size(w, &width, &height);
if (width > 0)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_WIDTH, "%i", width)) < 0)
return ret;
if (height > 0)
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_HEIGHT, "%i", height)) < 0)
return ret;
if (x >= 0 && width > 0) {
screen_width = WidthOfScreen(cdk_x11_screen_get_xscreen(ctk_widget_get_screen(CTK_WIDGET(w))));
x += width/2;
x = KA_CLAMP(x, 0, screen_width-1);
/* We use these strange format strings here to avoid that libc
* applies locale information on the formatting of floating
* numbers. */
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_HPOS, "%i.%03i",
(int) (x/(screen_width-1)), (int) (1000.0*x/(screen_width-1)) % 1000)) < 0)
return ret;
}
if (y >= 0 && height > 0) {
screen_height = HeightOfScreen(cdk_x11_screen_get_xscreen(ctk_widget_get_screen(CTK_WIDGET(w))));
y += height/2;
y = KA_CLAMP(y, 0, screen_height-1);
if ((ret = ka_proplist_setf(p, KA_PROP_WINDOW_VPOS, "%i.%03i",
(int) (y/(screen_height-1)), (int) (1000.0*y/(screen_height-1)) % 1000)) < 0)
return ret;
}
}
return KA_SUCCESS;
}
/**
* ka_ctk_proplist_set_for_event:
* @p: The proplist to store these sound event properties in
* @e: The Cdk event to base these sound event properties on
*
* Fill in a ka_proplist object for a sound event that is being
* triggered by the specified Cdk Event. This will fill in properties
* like %KA_PROP_EVENT_MOUSE_X or %KA_PROP_EVENT_MOUSE_BUTTON for
* you. This will internally also cal ka_ctk_proplist_set_for_widget()
* on the widget this event belongs to.
*
* Returns: 0 on success, negative error code on error.
*/
int ka_ctk_proplist_set_for_event(ka_proplist *p, CdkEvent *e) {
gdouble x, y;
CdkWindow *gw;
CtkWidget *w = NULL;
int ret;
ka_return_val_if_fail(p, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(e, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(!ka_detect_fork(), KA_ERROR_FORKED);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
if ((gw = e->any.window)) {
cdk_window_get_user_data(gw, (gpointer*) &w);
if (w)
if ((ret = ka_ctk_proplist_set_for_widget(p, w)) < 0)
return ret;
}
if (cdk_event_get_root_coords(e, &x, &y)) {
if ((ret = ka_proplist_setf(p, KA_PROP_EVENT_MOUSE_X, "%0.0f", x)) < 0)
return ret;
if ((ret = ka_proplist_setf(p, KA_PROP_EVENT_MOUSE_Y, "%0.0f", y)) < 0)
return ret;
if (w) {
int width, height;
width = WidthOfScreen(cdk_x11_screen_get_xscreen(ctk_widget_get_screen(w)));
height = HeightOfScreen(cdk_x11_screen_get_xscreen(ctk_widget_get_screen(w)));
/* We use these strange format strings here to avoid that
* libc applies locale information on the formatting of
* floating numbers. */
if ((ret = ka_proplist_setf(p, KA_PROP_EVENT_MOUSE_HPOS, "%i.%03i",
(int) (x/(width-1)), (int) (1000.0*x/(width-1)) % 1000)) < 0)
return ret;
if ((ret = ka_proplist_setf(p, KA_PROP_EVENT_MOUSE_VPOS, "%i.%03i",
(int) (y/(height-1)), (int) (1000.0*y/(height-1)) % 1000)) < 0)
return ret;
}
}
if (e->type == CDK_BUTTON_PRESS ||
e->type == CDK_2BUTTON_PRESS ||
e->type == CDK_3BUTTON_PRESS ||
e->type == CDK_BUTTON_RELEASE) {
if ((ret = ka_proplist_setf(p, KA_PROP_EVENT_MOUSE_BUTTON, "%u", e->button.button)) < 0)
return ret;
}
return KA_SUCCESS;
}
/**
* ka_ctk_play_for_widget:
* @w: The Ctk widget to base these sound event properties on
* @id: The event id that can later be used to cancel this event sound
* using ka_context_cancel(). This can be any integer and shall be
* chosen be the client program. It is a good idea to pass 0 here if
* cancelling the sound later is not needed. If the same id is passed
* to multiple sounds they can be canceled with a single
* ka_context_cancel() call.
* @...: additional event properties as pairs of strings, terminated by NULL.
*
* Play a sound event for the specified widget. This will internally
* call ka_ctk_proplist_set_for_widget() and then merge them with the
* properties passed in via the NULL terminated argument
* list. Finally, it will call ka_context_play_full() to actually play
* the event sound.
*
* Returns: 0 on success, negative error code on error.
*/
int ka_ctk_play_for_widget(CtkWidget *w, uint32_t id, ...) {
va_list ap;
int ret;
ka_proplist *p;
CdkScreen *s;
ka_return_val_if_fail(w, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(!ka_detect_fork(), KA_ERROR_FORKED);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
if ((ret = ka_proplist_create(&p)) < 0)
return ret;
if ((ret = ka_ctk_proplist_set_for_widget(p, w)) < 0)
goto fail;
va_start(ap, id);
ret = ka_proplist_merge_ap(p, ap);
va_end(ap);
if (ret < 0)
goto fail;
s = ctk_widget_get_screen(w);
ret = ka_context_play_full(ka_ctk_context_get_for_screen(s), id, p, NULL, NULL);
fail:
ka_assert_se(ka_proplist_destroy(p) == 0);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
return ret;
}
/**
* ka_ctk_play_for_event:
* @e: The Cdk event to base these sound event properties on
* @id: The event id that can later be used to cancel this event sound
* using ka_context_cancel(). This can be any integer and shall be
* chosen be the client program. It is a good idea to pass 0 here if
* cancelling the sound later is not needed. If the same id is passed
* to multiple sounds they can be canceled with a single
* ka_context_cancel() call.
* @...: additional event properties as pairs of strings, terminated by NULL.
*
* Play a sound event for the specified event. This will internally
* call ka_ctk_proplist_set_for_event() and then merge them with the
* properties passed in via the NULL terminated argument
* list. Finally, it will call ka_context_play_full() to actually play
* the event sound.
*
* Returns: 0 on success, negative error code on error.
*/
int ka_ctk_play_for_event(CdkEvent *e, uint32_t id, ...) {
va_list ap;
int ret;
ka_proplist *p;
CdkScreen *s;
ka_return_val_if_fail(e, KA_ERROR_INVALID);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
ka_return_val_if_fail(!ka_detect_fork(), KA_ERROR_FORKED);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
if ((ret = ka_proplist_create(&p)) < 0)
return ret;
if ((ret = ka_ctk_proplist_set_for_event(p, e)) < 0)
goto fail;
va_start(ap, id);
ret = ka_proplist_merge_ap(p, ap);
va_end(ap);
if (ret < 0)
goto fail;
if (e->any.window)
#if CTK_CHECK_VERSION (2, 90, 7)
s = cdk_window_get_screen(e->any.window);
#else
s = cdk_drawable_get_screen(CDK_DRAWABLE(e->any.window));
#endif
else
s = cdk_screen_get_default();
ret = ka_context_play_full(ka_ctk_context_get_for_screen(s), id, p, NULL, NULL);
fail:
ka_assert_se(ka_proplist_destroy(p) == 0);<--- %u in format string (no. 3) requires 'unsigned int' but the argument type is 'signed int'.
return ret;
}
/**
* ka_ctk_widget_disable_sounds:
* @w: The Ctk widget to disable automatic event sounds for.
* @enable: Boolean specifying whether sound events shall be enabled or disabled for this widget.
*
* By default sound events are automatically generated for all kinds
* of input events. Use this function to disable this. This is
* intended to be used for widgets which directly generate sound
* events.
*/
void ka_ctk_widget_disable_sounds(CtkWidget *w, gboolean enable) {
static GQuark disable_sound_quark = 0;
/* This is the same quark used by libgnomeui! */
if (!disable_sound_quark)
disable_sound_quark = g_quark_from_static_string("gnome_disable_sound_events");
g_object_set_qdata(G_OBJECT(w), disable_sound_quark, GINT_TO_POINTER(!!enable));
}
|