FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
xf_utils.c
1
21#include <string.h>
22#include <winpr/assert.h>
23#include <winpr/wtypes.h>
24#include <winpr/path.h>
25
26#include "xf_utils.h"
27#include "xfreerdp.h"
28
29#include <freerdp/log.h>
30
31#define TAG CLIENT_TAG("xfreerdp.utils")
32
33static const DWORD log_level = WLOG_TRACE;
34
35static const char* error_to_string(wLog* log, Display* display, int error, char* buffer,
36 size_t size)
37{
38 WINPR_ASSERT(size <= INT32_MAX);
39 const int rc = XGetErrorText(display, error, buffer, (int)size);
40 if (rc != Success)
41 WLog_Print(log, WLOG_WARN, "XGetErrorText returned %d", rc);
42 return buffer;
43}
44
45static void write_log(wLog* log, DWORD level, const char* fname, const char* fkt, size_t line, ...)
46{
47 va_list ap = { 0 };
48 va_start(ap, line);
49 WLog_PrintMessageVA(log, WLOG_MESSAGE_TEXT, level, line, fname, fkt, ap);
50 va_end(ap);
51}
52
53static BOOL ignore_code(int rc, size_t count, va_list ap)
54{
55 for (size_t x = 0; x < count; x++)
56 {
57 const int val = va_arg(ap, int);
58 if (rc == val)
59 return TRUE;
60 }
61 return FALSE;
62}
63
64/* libx11 return codes are not really well documented, so checked against
65 * https://gitlab.freedesktop.org/xorg/lib/libx11.git */
66static int write_result_log_va(wLog* log, DWORD level, const char* fname, const char* fkt,
67 size_t line, Display* display, char* name, int rc, size_t count,
68 va_list ap)
69{
70 const BOOL ignore = ignore_code(rc, count, ap);
71 if (!ignore)
72 {
73 char buffer[128] = { 0 };
74
75 if (WLog_IsLevelActive(log, level))
76 {
77 WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, fname, fkt, "%s returned %s",
78 name, error_to_string(log, display, rc, buffer, sizeof(buffer)));
79 }
80 }
81 return rc;
82}
83
84static int write_result_log_expect_success(wLog* log, DWORD level, const char* fname,
85 const char* fkt, size_t line, Display* display,
86 char* name, int rc)
87{
88 if (rc != Success)
89 {
90 va_list ap;
91 (void)write_result_log_va(log, level, fname, fkt, line, display, name, rc, 0, ap);
92 va_end(ap);
93 }
94 return rc;
95}
96
97static int write_result_log_expect_one(wLog* log, DWORD level, const char* fname, const char* fkt,
98 size_t line, Display* display, char* name, int rc)
99{
100 if (rc != 1)
101 {
102 va_list ap;
103 (void)write_result_log_va(log, level, fname, fkt, line, display, name, rc, 0, ap);
104 va_end(ap);
105 }
106 return rc;
107}
108
109static int write_result_log_ex(wLog* log, DWORD level, const char* fname, const char* fkt,
110 size_t line, Display* display, char* name, int rc, size_t count, ...)
111{
112 va_list ap;
113 va_start(ap, count);
114 (void)write_result_log_va(log, level, fname, fkt, line, display, name, rc, count, ap);
115 va_end(ap);
116 return rc;
117}
118
119char* Safe_XGetAtomNameEx(wLog* log, Display* display, Atom atom, const char* varname)
120{
121 WLog_Print(log, log_level, "XGetAtomName(%s, 0x%08" PRIx32 ")", varname, atom);
122 if (atom == None)
123 return strdup("Atom_None");
124 return XGetAtomName(display, atom);
125}
126
127Atom Logging_XInternAtom(wLog* log, Display* display, _Xconst char* atom_name, Bool only_if_exists)
128{
129 Atom atom = XInternAtom(display, atom_name, only_if_exists);
130 if (WLog_IsLevelActive(log, log_level))
131 {
132 WLog_Print(log, log_level, "XInternAtom(0x%08" PRIx32 ", %s, %s) -> 0x%08" PRIx32, display,
133 atom_name, only_if_exists ? "True" : "False", atom);
134 }
135 return atom;
136}
137
138const char* x11_error_to_string(xfContext* xfc, int error, char* buffer, size_t size)
139{
140 WINPR_ASSERT(xfc);
141 return error_to_string(xfc->log, xfc->display, error, buffer, size);
142}
143
144int LogDynAndXChangeProperty_ex(wLog* log, const char* file, const char* fkt, size_t line,
145 Display* display, Window w, Atom property, Atom type, int format,
146 int mode, const unsigned char* data, int nelements)
147{
148 if (WLog_IsLevelActive(log, log_level))
149 {
150 char* propstr = Safe_XGetAtomName(log, display, property);
151 char* typestr = Safe_XGetAtomName(log, display, type);
152 write_log(log, log_level, file, fkt, line,
153 "XChangeProperty(%p, %d, %s [%d], %s [%d], %d, %d, %p, %d)", display, w, propstr,
154 property, typestr, type, format, mode, data, nelements);
155 XFree(propstr);
156 XFree(typestr);
157 }
158 const int rc = XChangeProperty(display, w, property, type, format, mode, data, nelements);
159 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XChangeProperty",
160 rc);
161}
162
163int LogDynAndXDeleteProperty_ex(wLog* log, const char* file, const char* fkt, size_t line,
164 Display* display, Window w, Atom property)
165{
166 if (WLog_IsLevelActive(log, log_level))
167 {
168 char* propstr = Safe_XGetAtomName(log, display, property);
169 write_log(log, log_level, file, fkt, line, "XDeleteProperty(%p, %d, %s [%d])", display, w,
170 propstr, property);
171 XFree(propstr);
172 }
173 const int rc = XDeleteProperty(display, w, property);
174 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XDeleteProperty",
175 rc);
176}
177
178int LogDynAndXConvertSelection_ex(wLog* log, const char* file, const char* fkt, size_t line,
179 Display* display, Atom selection, Atom target, Atom property,
180 Window requestor, Time time)
181{
182 if (WLog_IsLevelActive(log, log_level))
183 {
184 char* selectstr = Safe_XGetAtomName(log, display, selection);
185 char* targetstr = Safe_XGetAtomName(log, display, target);
186 char* propstr = Safe_XGetAtomName(log, display, property);
187 write_log(log, log_level, file, fkt, line,
188 "XConvertSelection(%p, %s [%d], %s [%d], %s [%d], %d, %lu)", display, selectstr,
189 selection, targetstr, target, propstr, property, requestor, time);
190 XFree(propstr);
191 XFree(targetstr);
192 XFree(selectstr);
193 }
194 const int rc = XConvertSelection(display, selection, target, property, requestor, time);
195 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display,
196 "XConvertSelection", rc);
197}
198
199int LogDynAndXGetWindowProperty_ex(wLog* log, const char* file, const char* fkt, size_t line,
200 Display* display, Window w, Atom property, long long_offset,
201 long long_length, int delete, Atom req_type,
202 Atom* actual_type_return, int* actual_format_return,
203 unsigned long* nitems_return, unsigned long* bytes_after_return,
204 unsigned char** prop_return)
205{
206 if (WLog_IsLevelActive(log, log_level))
207 {
208 char* propstr = Safe_XGetAtomName(log, display, property);
209 char* req_type_str = Safe_XGetAtomName(log, display, req_type);
210 write_log(log, log_level, file, fkt, line,
211 "XGetWindowProperty(%p, %d, %s [%d], %ld, %ld, %d, %s [%d], %p, %p, %p, %p, %p)",
212 display, w, propstr, property, long_offset, long_length, delete, req_type_str,
213 req_type, actual_type_return, actual_format_return, nitems_return,
214 bytes_after_return, prop_return);
215 XFree(propstr);
216 XFree(req_type_str);
217 }
218 const int rc = XGetWindowProperty(display, w, property, long_offset, long_length, delete,
219 req_type, actual_type_return, actual_format_return,
220 nitems_return, bytes_after_return, prop_return);
221 return write_result_log_expect_success(log, WLOG_WARN, file, fkt, line, display,
222 "XGetWindowProperty", rc);
223}
224
225BOOL IsGnome(void)
226{
227 // NOLINTNEXTLINE(concurrency-mt-unsafe)
228 char* env = getenv("DESKTOP_SESSION");
229 return (env != NULL && strcmp(env, "gnome") == 0);
230}
231
232BOOL run_action_script(xfContext* xfc, const char* what, const char* arg, fn_action_script_run fkt,
233 void* user)
234{
235 BOOL rc = FALSE;
236 FILE* keyScript = NULL;
237 WINPR_ASSERT(xfc);
238
239 rdpSettings* settings = xfc->common.context.settings;
240 WINPR_ASSERT(settings);
241
242 const char* ActionScript = freerdp_settings_get_string(settings, FreeRDP_ActionScript);
243
244 xfc->actionScriptExists = winpr_PathFileExists(ActionScript);
245
246 if (!xfc->actionScriptExists)
247 {
248 WLog_DBG(TAG, "[ActionScript] no such script '%s'", ActionScript);
249 goto fail;
250 }
251
252 char command[2048] = { 0 };
253 (void)sprintf_s(command, sizeof(command), "%s %s", ActionScript, what);
254 keyScript = popen(command, "r");
255
256 if (!keyScript)
257 {
258 WLog_ERR(TAG, "[ActionScript] Failed to execute '%s'", command);
259 goto fail;
260 }
261
262 BOOL read_data = FALSE;
263 char buffer[2048] = { 0 };
264 while (fgets(buffer, sizeof(buffer), keyScript) != NULL)
265 {
266 char* context = NULL;
267 (void)strtok_s(buffer, "\n", &context);
268
269 if (fkt)
270 {
271 if (!fkt(xfc, buffer, strnlen(buffer, sizeof(buffer)), user, what, arg))
272 goto fail;
273 }
274 read_data = TRUE;
275 }
276
277 rc = read_data;
278 if (!rc)
279 WLog_ERR(TAG, "[ActionScript] No data returned from command '%s'", command);
280fail:
281 if (keyScript)
282 pclose(keyScript);
283 const BOOL res = rc || !xfc->actionScriptExists;
284 if (!rc)
285 xfc->actionScriptExists = FALSE;
286 return res;
287}
288
289int LogDynAndXCopyArea_ex(wLog* log, const char* file, const char* fkt, size_t line,
290 Display* display, Pixmap src, Window dest, GC gc, int src_x, int src_y,
291 unsigned int width, unsigned int height, int dest_x, int dest_y)
292{
293 if (WLog_IsLevelActive(log, log_level))
294 {
295 XWindowAttributes attr = { 0 };
296 const Status rc = XGetWindowAttributes(display, dest, &attr);
297
298 write_log(log, log_level, file, fkt, line,
299 "XCopyArea(%p, src: {%lu}, dest: [%d]{%lu, %lu, %d}, gc: {%p}, src_x: {%d}, "
300 "src_y: {%d}, "
301 "width: {%d}, "
302 "height: {%d}, dest_x: {%d}, dest_y: {%d})",
303 display, src, rc, dest, attr.root, attr.depth, gc, src_x, src_y, width, height,
304 dest_x, dest_y);
305 }
306
307 if ((width == 0) || (height == 0))
308 {
309 const DWORD lvl = WLOG_WARN;
310 if (WLog_IsLevelActive(log, lvl))
311 write_log(log, lvl, file, fkt, line, "XCopyArea(width=%d, height=%d) !", width, height);
312 return Success;
313 }
314
315 const int rc = XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y);
316 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XCopyArea", rc);
317}
318
319int LogDynAndXPutImage_ex(wLog* log, const char* file, const char* fkt, size_t line,
320 Display* display, Drawable d, GC gc, XImage* image, int src_x, int src_y,
321 int dest_x, int dest_y, unsigned int width, unsigned int height)
322{
323 if (WLog_IsLevelActive(log, log_level))
324 {
325 write_log(log, log_level, file, fkt, line,
326 "XPutImage(%p, d: {%lu}, gc: {%p}, image: [%p]{%d}, src_x: {%d}, src_y: {%d}, "
327 "dest_x: {%d}, "
328 "dest_y: {%d}, width: {%d}, "
329 "height: {%d})",
330 display, d, gc, image, image ? image->depth : -1, src_x, src_y, dest_x, dest_y,
331 width, height);
332 }
333
334 if ((width == 0) || (height == 0))
335 {
336 const DWORD lvl = WLOG_WARN;
337 if (WLog_IsLevelActive(log, lvl))
338 write_log(log, lvl, file, fkt, line, "XPutImage(width=%d, height=%d) !", width, height);
339 return Success;
340 }
341
342 const int rc = XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
343 return write_result_log_expect_success(log, WLOG_WARN, file, fkt, line, display, "XPutImage",
344 rc);
345}
346
347/* be careful here.
348 * XSendEvent returns Status, but implementation always returns 1
349 */
350Status LogDynAndXSendEvent_ex(wLog* log, const char* file, const char* fkt, size_t line,
351 Display* display, Window w, int propagate, long event_mask,
352 XEvent* event_send)
353{
354 if (WLog_IsLevelActive(log, log_level))
355 {
356 write_log(log, log_level, file, fkt, line,
357 "XSendEvent(%p, d: {%lu}, w: {%lu}, propagate: {%d}, event_mask: {%d}, "
358 "event_send: [%p]{TODO})",
359 display, w, propagate, event_mask, event_send);
360 }
361
362 const int rc = XSendEvent(display, w, propagate, event_mask, event_send);
363 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSendEvent", rc);
364}
365
366int LogDynAndXFlush_ex(wLog* log, const char* file, const char* fkt, size_t line, Display* display)
367{
368 if (WLog_IsLevelActive(log, log_level))
369 {
370 write_log(log, log_level, file, fkt, line, "XFlush(%p)", display);
371 }
372
373 const int rc = XFlush(display);
374 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XFlush", rc);
375}
376
377Window LogDynAndXGetSelectionOwner_ex(wLog* log, const char* file, const char* fkt, size_t line,
378 Display* display, Atom selection)
379{
380 if (WLog_IsLevelActive(log, log_level))
381 {
382 char* selectionstr = Safe_XGetAtomName(log, display, selection);
383 write_log(log, log_level, file, fkt, line, "XGetSelectionOwner(%p, %s)", display,
384 selectionstr);
385 XFree(selectionstr);
386 }
387 return XGetSelectionOwner(display, selection);
388}
389
390int LogDynAndXDestroyWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
391 Display* display, Window window)
392{
393 if (WLog_IsLevelActive(log, log_level))
394 {
395 write_log(log, log_level, file, fkt, line, "XDestroyWindow(%p, %lu)", display, window);
396 }
397 const int rc = XDestroyWindow(display, window);
398 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XDestroyWindow",
399 rc);
400}
401
402int LogDynAndXSync_ex(wLog* log, const char* file, const char* fkt, size_t line, Display* display,
403 Bool discard)
404{
405 if (WLog_IsLevelActive(log, log_level))
406 {
407 write_log(log, log_level, file, fkt, line, "XSync(%p, %d)", display, discard);
408 }
409 const int rc = XSync(display, discard);
410 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSync", rc);
411}
412
413int LogDynAndXChangeWindowAttributes_ex(wLog* log, const char* file, const char* fkt, size_t line,
414 Display* display, Window window, unsigned long valuemask,
415 XSetWindowAttributes* attributes)
416{
417 if (WLog_IsLevelActive(log, log_level))
418 {
419 write_log(log, log_level, file, fkt, line, "XChangeWindowAttributes(%p, %lu, 0x%08lu, %p)",
420 display, window, valuemask, attributes);
421 }
422 const int rc = XChangeWindowAttributes(display, window, valuemask, attributes);
423 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display,
424 "XChangeWindowAttributes", rc);
425}
426
427int LogDynAndXSetTransientForHint_ex(wLog* log, const char* file, const char* fkt, size_t line,
428 Display* display, Window window, Window prop_window)
429{
430 if (WLog_IsLevelActive(log, log_level))
431 {
432 write_log(log, log_level, file, fkt, line, "XSetTransientForHint(%p, %lu, %lu)", display,
433 window, prop_window);
434 }
435 const int rc = XSetTransientForHint(display, window, prop_window);
436 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display,
437 "XSetTransientForHint", rc);
438}
439
440int LogDynAndXCloseDisplay_ex(wLog* log, const char* file, const char* fkt, size_t line,
441 Display* display)
442{
443 if (WLog_IsLevelActive(log, log_level))
444 {
445 write_log(log, log_level, file, fkt, line, "XCloseDisplay(%p)", display);
446 }
447 const int rc = XCloseDisplay(display);
448 return write_result_log_expect_success(log, WLOG_WARN, file, fkt, line, display,
449 "XCloseDisplay", rc);
450}
451
452XImage* LogDynAndXCreateImage_ex(wLog* log, const char* file, const char* fkt, size_t line,
453 Display* display, Visual* visual, unsigned int depth, int format,
454 int offset, char* data, unsigned int width, unsigned int height,
455 int bitmap_pad, int bytes_per_line)
456{
457 if (WLog_IsLevelActive(log, log_level))
458 {
459 write_log(log, log_level, file, fkt, line, "XCreateImage(%p)", display);
460 }
461 return XCreateImage(display, visual, depth, format, offset, data, width, height, bitmap_pad,
462 bytes_per_line);
463}
464
465Window LogDynAndXCreateWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
466 Display* display, Window parent, int x, int y, unsigned int width,
467 unsigned int height, unsigned int border_width, int depth,
468 unsigned int class, Visual* visual, unsigned long valuemask,
469 XSetWindowAttributes* attributes)
470{
471 if (WLog_IsLevelActive(log, log_level))
472 {
473 write_log(log, log_level, file, fkt, line, "XCreateWindow(%p)", display);
474 }
475 return XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual,
476 valuemask, attributes);
477}
478
479GC LogDynAndXCreateGC_ex(wLog* log, const char* file, const char* fkt, size_t line,
480 Display* display, Drawable d, unsigned long valuemask, XGCValues* values)
481{
482 if (WLog_IsLevelActive(log, log_level))
483 {
484 write_log(log, log_level, file, fkt, line, "XCreateGC(%p)", display);
485 }
486 return XCreateGC(display, d, valuemask, values);
487}
488
489int LogDynAndXFreeGC_ex(wLog* log, const char* file, const char* fkt, size_t line, Display* display,
490 GC gc)
491{
492 if (WLog_IsLevelActive(log, log_level))
493 {
494 write_log(log, log_level, file, fkt, line, "XFreeGC(%p)", display);
495 }
496 const int rc = XFreeGC(display, gc);
497 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XFreeGC", rc);
498}
499
500Pixmap LogDynAndXCreatePixmap_ex(wLog* log, const char* file, const char* fkt, size_t line,
501 Display* display, Drawable d, unsigned int width,
502 unsigned int height, unsigned int depth)
503{
504 if (WLog_IsLevelActive(log, log_level))
505 {
506 write_log(log, log_level, file, fkt, line, "XCreatePixmap(%p, 0x%08lu, %u, %u, %u)",
507 display, d, width, height, depth);
508 }
509 return XCreatePixmap(display, d, width, height, depth);
510}
511
512int LogDynAndXFreePixmap_ex(wLog* log, const char* file, const char* fkt, size_t line,
513 Display* display, Pixmap pixmap)
514{
515 if (WLog_IsLevelActive(log, log_level))
516 {
517 write_log(log, log_level, file, fkt, line, "XFreePixmap(%p)", display);
518 }
519 const int rc = XFreePixmap(display, pixmap);
520 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XFreePixmap", rc);
521}
522
523int LogDynAndXSetSelectionOwner_ex(wLog* log, const char* file, const char* fkt, size_t line,
524 Display* display, Atom selection, Window owner, Time time)
525{
526 if (WLog_IsLevelActive(log, log_level))
527 {
528 char* selectionstr = Safe_XGetAtomName(log, display, selection);
529 write_log(log, log_level, file, fkt, line, "XSetSelectionOwner(%p, %s, 0x%08lu, %lu)",
530 display, selectionstr, owner, time);
531 XFree(selectionstr);
532 }
533 const int rc = XSetSelectionOwner(display, selection, owner, time);
534 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display,
535 "XSetSelectionOwner", rc);
536}
537
538int LogDynAndXSetForeground_ex(wLog* log, const char* file, const char* fkt, size_t line,
539 Display* display, GC gc, unsigned long foreground)
540{
541 if (WLog_IsLevelActive(log, log_level))
542 {
543 write_log(log, log_level, file, fkt, line, "XSetForeground(%p, %p, 0x%08lu)", display, gc,
544 foreground);
545 }
546 const int rc = XSetForeground(display, gc, foreground);
547 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetForeground",
548 rc);
549}
550
551int LogDynAndXMoveWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
552 Display* display, Window w, int x, int y)
553{
554 if (WLog_IsLevelActive(log, log_level))
555 {
556 write_log(log, log_level, file, fkt, line, "XMoveWindow(%p, 0x%08lu, %d, %d)", display, w,
557 x, y);
558 }
559 const int rc = XMoveWindow(display, w, x, y);
560 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XMoveWindow", rc);
561}
562
563int LogDynAndXSetFillStyle_ex(wLog* log, const char* file, const char* fkt, size_t line,
564 Display* display, GC gc, int fill_style)
565{
566 if (WLog_IsLevelActive(log, log_level))
567 {
568 write_log(log, log_level, file, fkt, line, "XSetFillStyle(%p, %p, %d)", display, gc,
569 fill_style);
570 }
571 const int rc = XSetFillStyle(display, gc, fill_style);
572 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetFillStyle",
573 rc);
574}
575
576int LogDynAndXSetFunction_ex(wLog* log, const char* file, const char* fkt, size_t line,
577 Display* display, GC gc, int function)
578{
579 if (WLog_IsLevelActive(log, log_level))
580 {
581 write_log(log, log_level, file, fkt, line, "XSetFunction(%p, %p, %d)", display, gc,
582 function);
583 }
584 const int rc = XSetFunction(display, gc, function);
585 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetFunction",
586 rc);
587}
588
589int LogDynAndXRaiseWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
590 Display* display, Window w)
591{
592 if (WLog_IsLevelActive(log, log_level))
593 {
594 write_log(log, log_level, file, fkt, line, "XRaiseWindow(%p, %lu)", display, w);
595 }
596 const int rc = XRaiseWindow(display, w);
597 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XRaiseWindow",
598 rc);
599}
600
601int LogDynAndXMapWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
602 Display* display, Window w)
603{
604 if (WLog_IsLevelActive(log, log_level))
605 {
606 write_log(log, log_level, file, fkt, line, "XMapWindow(%p, %lu)", display, w);
607 }
608 const int rc = XMapWindow(display, w);
609 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XMapWindow", rc);
610}
611
612int LogDynAndXUnmapWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
613 Display* display, Window w)
614{
615 if (WLog_IsLevelActive(log, log_level))
616 {
617 write_log(log, log_level, file, fkt, line, "XUnmapWindow(%p, %lu)", display, w);
618 }
619 const int rc = XUnmapWindow(display, w);
620 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XUnmapWindow",
621 rc);
622}
623
624int LogDynAndXMoveResizeWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
625 Display* display, Window w, int x, int y, unsigned int width,
626 unsigned int height)
627{
628 if (WLog_IsLevelActive(log, log_level))
629 {
630 write_log(log, log_level, file, fkt, line, "XMoveResizeWindow(%p, %lu, %d, %d, %u, %u)",
631 display, w, x, y, width, height);
632 }
633 const int rc = XMoveResizeWindow(display, w, x, y, width, height);
634 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display,
635 "XMoveResizeWindow", rc);
636}
637
638Status LogDynAndXWithdrawWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
639 Display* display, Window w, int screen_number)
640{
641 if (WLog_IsLevelActive(log, log_level))
642 {
643 write_log(log, log_level, file, fkt, line, "XWithdrawWindow(%p, %lu, %d)", display, w,
644 screen_number);
645 }
646 const Status rc = XWithdrawWindow(display, w, screen_number);
647 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XWithdrawWindow",
648 rc);
649}
650
651int LogDynAndXResizeWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
652 Display* display, Window w, unsigned int width, unsigned int height)
653{
654 if (WLog_IsLevelActive(log, log_level))
655 {
656 write_log(log, log_level, file, fkt, line, "XResizeWindow(%p, %lu, %u, %u)", display, w,
657 width, height);
658 }
659 const int rc = XResizeWindow(display, w, width, height);
660 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XResizeWindow",
661 rc);
662}
663
664int LogDynAndXClearWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
665 Display* display, Window w)
666{
667 if (WLog_IsLevelActive(log, log_level))
668 {
669 write_log(log, log_level, file, fkt, line, "XClearWindow(%p, %lu)", display, w);
670 }
671 const int rc = XClearWindow(display, w);
672 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XClearWindow",
673 rc);
674}
675
676int LogDynAndXSetBackground_ex(wLog* log, const char* file, const char* fkt, size_t line,
677 Display* display, GC gc, unsigned long background)
678{
679 if (WLog_IsLevelActive(log, log_level))
680 {
681 write_log(log, log_level, file, fkt, line, "XSetBackground(%p, %p, %lu)", display, gc,
682 background);
683 }
684 const int rc = XSetBackground(display, gc, background);
685 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetBackground",
686 rc);
687}
688
689int LogDynAndXSetClipMask_ex(wLog* log, const char* file, const char* fkt, size_t line,
690 Display* display, GC gc, Pixmap pixmap)
691{
692 if (WLog_IsLevelActive(log, log_level))
693 {
694 write_log(log, log_level, file, fkt, line, "XSetClipMask(%p, %p, %lu)", display, gc,
695 pixmap);
696 }
697 const int rc = XSetClipMask(display, gc, pixmap);
698 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetClipMask",
699 rc);
700}
701
702int LogDynAndXFillRectangle_ex(wLog* log, const char* file, const char* fkt, size_t line,
703 Display* display, Window w, GC gc, int x, int y, unsigned int width,
704 unsigned int height)
705{
706 if (WLog_IsLevelActive(log, log_level))
707 {
708 write_log(log, log_level, file, fkt, line, "XFillRectangle(%p, %lu, %p, %d, %d, %u, %u)",
709 display, w, gc, x, y, width, height);
710 }
711 const int rc = XFillRectangle(display, w, gc, x, y, width, height);
712 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XFillRectangle",
713 rc);
714}
715
716int LogDynAndXSetRegion_ex(wLog* log, const char* file, const char* fkt, size_t line,
717 Display* display, GC gc, Region r)
718{
719 if (WLog_IsLevelActive(log, log_level))
720 {
721 write_log(log, log_level, file, fkt, line, "XSetRegion(%p, %p, %lu)", display, gc, r);
722 }
723 const int rc = XSetRegion(display, gc, r);
724 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XSetRegion", rc);
725}
726
727int LogDynAndXReparentWindow_ex(wLog* log, const char* file, const char* fkt, size_t line,
728 Display* display, Window w, Window parent, int x, int y)
729{
730 if (WLog_IsLevelActive(log, log_level))
731 {
732 write_log(log, log_level, file, fkt, line, "XReparentWindow(%p, %lu, %lu, %d, %d)", display,
733 w, parent, x, y);
734 }
735 const int rc = XReparentWindow(display, w, parent, x, y);
736 return write_result_log_expect_one(log, WLOG_WARN, file, fkt, line, display, "XReparentWindow",
737 rc);
738}
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.