From a63e81581de575774626d28a5029b4d54bb562ca Mon Sep 17 00:00:00 2001 From: Anthony Tong Date: Wed, 21 Dec 2011 12:50:22 -0500 Subject: [PATCH] xfreerdp: add --dbg-x11 which may help debugging --- client/X11/xfreerdp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index a6ea95c7d..c765a70c1 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -415,6 +415,34 @@ boolean xf_get_pixmap_info(xfInfo* xfi) return true; } +static int (*_def_error_handler)(Display*, XErrorEvent*); +int xf_error_handler(Display* d, XErrorEvent* ev) +{ + char buf[256]; + int do_abort = true; + + XGetErrorText(d, ev->error_code, buf, sizeof(buf)); + printf(buf); + + if (do_abort) + abort(); + + _def_error_handler(d, ev); + + return false; +} + +int _xf_error_handler(Display* d, XErrorEvent* ev) +{ + /* + * ungrab the keyboard, in case a debugger is running in + * another window. This make xf_error_handler() a potential + * debugger breakpoint. + */ + XUngrabKeyboard(d, CurrentTime); + return xf_error_handler(d, ev); +} + boolean xf_pre_connect(freerdp* instance) { xfInfo* xfi; @@ -475,6 +503,13 @@ boolean xf_pre_connect(freerdp* instance) return false; } + if (xfi->debug) + { + printf("Enabling X11 debug mode.\n"); + XSynchronize(xfi->display, true); + _def_error_handler = XSetErrorHandler(_xf_error_handler); + } + xfi->_NET_WM_ICON = XInternAtom(xfi->display, "_NET_WM_ICON", True); xfi->_MOTIF_WM_HINTS = XInternAtom(xfi->display, "_MOTIF_WM_HINTS", True); xfi->_NET_CURRENT_DESKTOP = XInternAtom(xfi->display, "_NET_CURRENT_DESKTOP", True); @@ -738,6 +773,7 @@ boolean xf_verify_certificate(freerdp* instance, char* subject, char* issuer, ch int xf_process_client_args(rdpSettings* settings, const char* opt, const char* val, void* user_data) { int argc = 0; + xfInfo* xfi = (xfInfo*) user_data; if (strcmp("--kbd-list", opt) == 0) { @@ -769,6 +805,11 @@ int xf_process_client_args(rdpSettings* settings, const char* opt, const char* v xv_port = atoi(val); argc = 2; } + else if (strcmp("--dbg-x11", opt) == 0) + { + xfi->debug = true; + argc = 1; + } return argc; }