From: Heebum Kwak Date: Tue, 7 May 2013 08:33:46 +0000 (+0900) Subject: Parse detail information of Atom and Region X-Git-Tag: 2.2.1_release~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9767841f417a2a9c8613796cf8efc6a53fac4b11;p=adaptation%2Fxorg%2Fdriver%2Fxserver-xorg-module-xdbg.git Parse detail information of Atom and Region Change-Id: I0f699b45c24f61934fc93046fcefe55a50d5941e --- diff --git a/bin/xevlog_analyze/xevlog_analyze.c b/bin/xevlog_analyze/xevlog_analyze.c index 7a5e5c6..a5074cd 100644 --- a/bin/xevlog_analyze/xevlog_analyze.c +++ b/bin/xevlog_analyze/xevlog_analyze.c @@ -89,7 +89,8 @@ _printUsage(char* name) printf("\n"); } -static void _xEvlogAnalyzePrint (EvlogOption *eo, char* reply, int* len) + +static void _xEvlogAnalyzePrint (Display* dpy, EvlogOption *eo, char* reply, int* len) { int fd = -1, cfd = -1; int total, read_len; @@ -192,7 +193,7 @@ static void _xEvlogAnalyzePrint (EvlogOption *eo, char* reply, int* len) if (xDbgEvlogRuleValidate (&evinfo)) { - xDbgEvlogFillLog(&evinfo, eo->detail, log, &size); + xDbgEvlogFillLog(dpy, &evinfo, eo->detail, log, &size); printf ("%s", log); } @@ -226,7 +227,7 @@ print_done: static void -_checkOption(int argc, char** argv) +_checkOption(Display* dpy, int argc, char** argv) { int c; int opt_str_len = 0; @@ -353,7 +354,7 @@ _checkOption(int argc, char** argv) } } - _xEvlogAnalyzePrint(&eo, rule_log, &rule_size); + _xEvlogAnalyzePrint(dpy, &eo, rule_log, &rule_size); } @@ -363,6 +364,14 @@ int main(int argc, char** argv) char **new_argv; int new_argc, i; char temp[128]; + Display *dpy; + + dpy = XOpenDisplay (NULL); + if (!dpy) + { + printf ("failed: open display\n"); + exit (-1); + } new_argc = argc + 1; new_argv = (char**)malloc (new_argc * sizeof (char*)); @@ -378,9 +387,10 @@ int main(int argc, char** argv) for (i = 0; i < argc; i++) new_argv[i+1] = argv[i]; - _checkOption(new_argc, new_argv); + _checkOption(dpy, new_argc, new_argv); free (new_argv); + XCloseDisplay (dpy); return 0; -} \ No newline at end of file +} diff --git a/common/xdbg_evlog.c b/common/xdbg_evlog.c index 948480e..1aec82a 100644 --- a/common/xdbg_evlog.c +++ b/common/xdbg_evlog.c @@ -44,6 +44,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog.h" #include "bool_exp_rule_checker.h" +#include + +#ifndef XDBG_CLIENT +#include "resource.h" +#include "region.h" +#include "dix.h" +#endif static char *evt_type[] = { "Event", "Request", "Reply", "Flush" }; static char *evt_dir[] = { "<====", "---->", "<----", "*****" }; @@ -282,11 +289,10 @@ _SortEvlogExtensions () static Bool -_EvlogGetExtentionEntry (int *return_extensions_size) +_EvlogGetExtentionEntry (void *dpy, int *return_extensions_size) { static int init = 0; static Bool success = FALSE; - Display *dpy = NULL; int i; if (init) @@ -294,15 +300,6 @@ _EvlogGetExtentionEntry (int *return_extensions_size) init = 1; -#ifdef XDBG_CLIENT - dpy = XOpenDisplay (NULL); - if (!dpy) - { - XDBG_LOG ("failed: open display\n"); - exit (-1); - } -#endif - for (i = 0 ; i < sizeof (Evlog_extensions) / sizeof (ExtensionInfo); i++) { Evlog_extensions[i].get_base_func (dpy, Evlog_extensions + i); @@ -311,10 +308,6 @@ _EvlogGetExtentionEntry (int *return_extensions_size) if(!_SortEvlogExtensions ()) return FALSE; -#ifdef XDBG_CLIENT - XCloseDisplay (dpy); -#endif - *return_extensions_size = sizeof(Evlog_extensions); success = TRUE; @@ -323,7 +316,7 @@ _EvlogGetExtentionEntry (int *return_extensions_size) void -xDbgEvlogFillLog (EvlogInfo *evinfo, Bool on, char *reply, int *len) +xDbgEvlogFillLog (void *dpy, EvlogInfo *evinfo, Bool on, char *reply, int *len) { static CARD32 prev; static int Extensions_size = 0; @@ -340,16 +333,16 @@ xDbgEvlogFillLog (EvlogInfo *evinfo, Bool on, char *reply, int *len) evt_dir[evinfo->type], evt_type[evinfo->type]); - if (evinfo->type == REQUEST && _EvlogGetExtentionEntry (&Extensions_size)) + if (evinfo->type == REQUEST && _EvlogGetExtentionEntry (dpy, &Extensions_size)) { REPLY ("("); - reply = xDbgEvlogReqeust (evinfo, on, Extensions_size, reply, len); + reply = xDbgEvlogReqeust (dpy, evinfo, on, Extensions_size, reply, len); REPLY (")"); } - else if (evinfo->type == EVENT && _EvlogGetExtentionEntry (&Extensions_size)) + else if (evinfo->type == EVENT && _EvlogGetExtentionEntry (dpy, &Extensions_size)) { REPLY ("("); - reply = xDbgEvlogEvent (evinfo, on, Extensions_size, reply, len); + reply = xDbgEvlogEvent (dpy, evinfo, on, Extensions_size, reply, len); REPLY (")"); } else @@ -369,3 +362,119 @@ xDbgEvlogFillLog (EvlogInfo *evinfo, Bool on, char *reply, int *len) +#ifdef XDBG_CLIENT +Bool get_error_caught; + +static int +_get_error_handle (Display *dpy, XErrorEvent *ev) +{ + if (!dpy) + return 0; + + get_error_caught = True; + return 0; +} +#endif + +char* xDbgGetAtom(void *dpy, Atom atom, char *reply, int *len) +{ +#ifdef XDBG_CLIENT + Display *d = NULL; + XErrorHandler old_handler = NULL; + + RETURN_VAL_IF_FAIL(dpy != NULL, reply); + + get_error_caught = False; + d = (Display*)dpy; + + XSync (d, 0); + old_handler = XSetErrorHandler (_get_error_handle); + + if(XGetAtomName(d, atom)) + REPLY("(%s)", XGetAtomName(d, atom)); + else + REPLY("(0x%lx)", atom); + + get_error_caught = False; + XSetErrorHandler (old_handler); +#else + if (NameForAtom(atom)) + REPLY("(%s)", (char*)NameForAtom(atom)); + else + REPLY("(0x%lx)", atom); +#endif + + return reply; +} + +char* xDbgGetRegion(void* dpy, EvlogInfo *evinfo, XserverRegion region, char *reply, int *len) +{ +#ifdef XDBG_CLIENT + int nrect, i; + XRectangle *rects; + Display *d = (Display*)dpy; + XErrorHandler old_handler = NULL; + + RETURN_VAL_IF_FAIL(dpy != NULL, reply); + + get_error_caught = False; + d = (Display*)dpy; + + XSync (d, 0); + old_handler = XSetErrorHandler (_get_error_handle); + + rects = XFixesFetchRegion(d, region, &nrect); + if (!get_error_caught) + { + REPLY ("("); + for (i = 0; i < nrect; i++) + { + REPLY ("[%d,%d %dx%d]", + rects[i].x, + rects[i].y, + rects[i].width, + rects[i].height); + if(i != nrect - 1) + REPLY (","); + } + REPLY (")"); + } + else + REPLY ("(0x%lx)", region); + + get_error_caught = False; + XSetErrorHandler (old_handler); +#else + extern _X_EXPORT RESTYPE RegionResType; + RegionPtr pRegion; + BoxPtr rects; + int nrect, i; + + int err = dixLookupResourceByType((pointer *) &pRegion, region, + RegionResType, (ClientPtr)evinfo->client.pClient, + DixReadAccess); + if (err != Success) + { + REPLY ("(0x%lx)", region); + return reply; + } + + nrect = RegionNumRects(pRegion); + rects = RegionRects(pRegion); + + REPLY ("("); + for (i = 0; i < nrect; i++) + { + REPLY ("[%d,%d %dx%d]", + rects[i].x1, + rects[i].y1, + rects[i].x2 - rects[i].x1, + rects[i].y2 - rects[i].y1); + if(i != nrect - 1) + REPLY (","); + } + REPLY (")"); +#endif + + return reply; +} diff --git a/common/xdbg_evlog.h b/common/xdbg_evlog.h index 2625455..74f7be7 100644 --- a/common/xdbg_evlog.h +++ b/common/xdbg_evlog.h @@ -47,9 +47,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_evlog_xv.h" -char* xDbgEvlogGetCmd (char *path); -Bool xDbgEvlogRuleSet (const int argc, const char **argv, char *reply, int *len); -Bool xDbgEvlogRuleValidate (EvlogInfo *evinfo); -void xDbgEvlogFillLog (EvlogInfo *evinfo, Bool on, char *reply, int *len); +char* xDbgEvlogGetCmd (char *path); +Bool xDbgEvlogRuleSet (const int argc, const char **argv, char *reply, int *len); +Bool xDbgEvlogRuleValidate (EvlogInfo *evinfo); +void xDbgEvlogFillLog (void* dpy, EvlogInfo *evinfo, Bool on, char *reply, int *len); + +char* xDbgGetAtom (void* dpy, Atom atom, char *reply, int *len); +char* xDbgGetRegion (void* dpy, EvlogInfo *evinfo, XserverRegion region, char *reply, int *len); #endif diff --git a/common/xdbg_evlog_composite.c b/common/xdbg_evlog_composite.c index 1cb364b..8ce5b2b 100644 --- a/common/xdbg_evlog_composite.c +++ b/common/xdbg_evlog_composite.c @@ -56,13 +56,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_composite.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestComposite(xReq *req, char *reply, int *len) +_EvlogRequestComposite(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_CompositeRedirectWindow: { @@ -122,11 +123,11 @@ _EvlogRequestComposite(xReq *req, char *reply, int *len) } static char * -_EvlogEventComposite (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventComposite (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { default: diff --git a/common/xdbg_evlog_core.c b/common/xdbg_evlog_core.c index 53dcd58..d3eaab7 100644 --- a/common/xdbg_evlog_core.c +++ b/common/xdbg_evlog_core.c @@ -55,12 +55,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_core.h" +#include "xdbg_evlog.h" -char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) +char * xDbgEvlogRequestCore (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->reqType) + switch (req->reqType) { case X_CreateWindow: { @@ -129,10 +130,13 @@ char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) case X_ChangeProperty: { xChangePropertyReq *stuff = (xChangePropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx) Type(0x%lx)", - stuff->window, - stuff->property, - stuff->type); + REPLY (": XID(0x%lx)", + stuff->window); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); + REPLY (" Type"); + reply = xDbgGetAtom(dpy, stuff->type, reply, len); return reply; } @@ -140,9 +144,11 @@ char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) case X_DeleteProperty: { xDeletePropertyReq *stuff = (xDeletePropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx)", - stuff->window, - stuff->property); + REPLY (": XID(0x%lx)", + stuff->window); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -150,9 +156,11 @@ char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) case X_SetSelectionOwner: { xSetSelectionOwnerReq *stuff = (xSetSelectionOwnerReq *)req; - REPLY (": XID(0x%lx) Selection(0x%lx)", - stuff->window, - stuff->selection); + REPLY (": XID(0x%lx)", + stuff->window); + + REPLY (" Selection"); + reply = xDbgGetAtom(dpy, stuff->selection, reply, len); return reply; } @@ -160,11 +168,15 @@ char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) case X_ConvertSelection: { xConvertSelectionReq *stuff = (xConvertSelectionReq *)req; - REPLY (": XID(0x%lx) Selection(0x%lx) Target(0x%lx) Property(0x%lx)", - stuff->requestor, - stuff->selection, - stuff->target, - stuff->property); + REPLY (": XID(0x%lx)", + stuff->requestor); + + REPLY (" Selection"); + reply = xDbgGetAtom(dpy, stuff->selection, reply, len); + REPLY (" Target"); + reply = xDbgGetAtom(dpy, stuff->target, reply, len); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -545,8 +557,10 @@ char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len) } -char * xDbgEvlogEventCore (xEvent *evt, char *reply, int *len) +char * xDbgEvlogEventCore (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { + xEvent *evt = evinfo->evt.ptr; + switch (evt->u.u.type & 0x7F) { case KeyPress: @@ -759,41 +773,52 @@ char * xDbgEvlogEventCore (xEvent *evt, char *reply, int *len) case PropertyNotify: { - REPLY (": Window(0x%lx) atom(0x%lx)", - evt->u.property.window, - evt->u.property.atom); + REPLY (": Window(0x%lx)", + evt->u.property.window); + REPLY (" Atom"); + reply = xDbgGetAtom(dpy, evt->u.property.atom, reply, len); return reply; } case SelectionClear: { - REPLY (": Window(0x%lx) atom(0x%lx)", - evt->u.selectionClear.window, - evt->u.selectionClear.atom); + REPLY (": Window(0x%lx)", + evt->u.selectionClear.window); + + REPLY (" Atom"); + reply = xDbgGetAtom(dpy, evt->u.selectionClear.atom, reply, len); return reply; } case SelectionRequest: { - REPLY (": Owner(0x%lx) Requestor(0x%lx) Selcection(0x%lx) Target(0x%lx) Property(0x%lx)", + REPLY (": Owner(0x%lx) Requestor(0x%lx)", evt->u.selectionRequest.owner, - evt->u.selectionRequest.requestor, - evt->u.selectionRequest.selection, - evt->u.selectionRequest.target, - evt->u.selectionRequest.property); + evt->u.selectionRequest.requestor); + + REPLY (" selection"); + reply = xDbgGetAtom(dpy, evt->u.selectionRequest.selection, reply, len); + REPLY (" Target"); + reply = xDbgGetAtom(dpy, evt->u.selectionRequest.target, reply, len); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, evt->u.selectionRequest.property, reply, len); return reply; } case SelectionNotify: { - REPLY (": Requestor(0x%lx) Selcection(0x%lx) Target(0x%lx) Property(0x%lx)", - evt->u.selectionNotify.requestor, - evt->u.selectionNotify.selection, - evt->u.selectionNotify.target, - evt->u.selectionNotify.property); + REPLY (": Requestor(0x%lx)", + evt->u.selectionNotify.requestor); + + REPLY (" selection"); + reply = xDbgGetAtom(dpy, evt->u.selectionNotify.selection, reply, len); + REPLY (" Target"); + reply = xDbgGetAtom(dpy, evt->u.selectionNotify.target, reply, len); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, evt->u.selectionNotify.property, reply, len); return reply; } @@ -809,9 +834,11 @@ char * xDbgEvlogEventCore (xEvent *evt, char *reply, int *len) case ClientMessage: { - REPLY (": XID(0x%lx) Atom(0x%lx)", - evt->u.clientMessage.window, - evt->u.clientMessage.u.b.type); + REPLY (": XID(0x%lx)", + evt->u.clientMessage.window); + + REPLY (" Type"); + reply = xDbgGetAtom(dpy, evt->u.clientMessage.u.b.type, reply, len); return reply; } diff --git a/common/xdbg_evlog_core.h b/common/xdbg_evlog_core.h index 68bf6bd..fd00d42 100644 --- a/common/xdbg_evlog_core.h +++ b/common/xdbg_evlog_core.h @@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" -char * xDbgEvlogRequestCore (xReq *req, char *reply, int *len); -char * xDbgEvlogEventCore (xEvent *evt, char *reply, int *len); +char * xDbgEvlogRequestCore (void *dpy, EvlogInfo *evinfo, char *reply, int *len); +char * xDbgEvlogEventCore (void *dpy, EvlogInfo *evinfo, char *reply, int *len); #endif diff --git a/common/xdbg_evlog_damage.c b/common/xdbg_evlog_damage.c index 3f4b53c..23de22a 100644 --- a/common/xdbg_evlog_damage.c +++ b/common/xdbg_evlog_damage.c @@ -57,13 +57,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_damage.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestDamage(xReq *req, char *reply, int *len) +_EvlogRequestDamage(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_DamageCreate: { @@ -93,11 +94,11 @@ _EvlogRequestDamage(xReq *req, char *reply, int *len) } static char* -_EvlogEventDamage (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventDamage (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case XDamageNotify: { diff --git a/common/xdbg_evlog_dri2.c b/common/xdbg_evlog_dri2.c index 1ced3b2..2f484eb 100644 --- a/common/xdbg_evlog_dri2.c +++ b/common/xdbg_evlog_dri2.c @@ -57,13 +57,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_dri2.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestDri2 (xReq *req, char *reply, int *len) +_EvlogRequestDri2 (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_DRI2CreateDrawable: { @@ -96,12 +97,14 @@ _EvlogRequestDri2 (xReq *req, char *reply, int *len) case X_DRI2CopyRegion: { xDRI2CopyRegionReq *stuff = (xDRI2CopyRegionReq *)req; - REPLY (": XID(0x%lx) Region(0x%lx) src(0x%lx) dst(0x%lx)", + REPLY (": XID(0x%lx) src(0x%lx) dst(0x%lx)", stuff->drawable, - stuff->region, stuff->src, stuff->dest); + REPLY (" Region"); + reply = xDbgGetRegion(dpy, evinfo, stuff->region, reply, len); + return reply; } @@ -144,9 +147,11 @@ _EvlogRequestDri2 (xReq *req, char *reply, int *len) case X_DRI2SwapBuffersWithRegion: { xDRI2SwapBuffersWithRegionReq *stuff = (xDRI2SwapBuffersWithRegionReq *)req; - REPLY (": XID(0x%lx) Region(0x%lx)", - stuff->drawable, - stuff->region); + REPLY (": XID(0x%lx)", + stuff->drawable); + + REPLY (" Region"); + reply = xDbgGetRegion(dpy, evinfo, stuff->region, reply, len); return reply; } @@ -160,11 +165,11 @@ _EvlogRequestDri2 (xReq *req, char *reply, int *len) static char * -_EvlogEventDri2 (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventDri2 (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case DRI2_BufferSwapComplete: { diff --git a/common/xdbg_evlog_event.c b/common/xdbg_evlog_event.c index 90f45b1..ae10532 100644 --- a/common/xdbg_evlog_event.c +++ b/common/xdbg_evlog_event.c @@ -62,7 +62,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. extern ExtensionInfo* Sorted_Evlog_extensions; char * -xDbgEvlogEvent (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len) +xDbgEvlogEvent (void *dpy, EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len) { EvlogEvent ev; xEvent *xEvt = NULL; @@ -89,7 +89,7 @@ xDbgEvlogEvent (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, in if (type < EXTENSION_EVENT_BASE) { - return xDbgEvlogEventCore (xEvt, reply, len); + return xDbgEvlogEventCore (dpy, evinfo, reply, len); } else { @@ -105,12 +105,12 @@ xDbgEvlogEvent (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, in if (type >= Sorted_Evlog_extensions[i].evt_base && type < Sorted_Evlog_extensions[i+1].evt_base) { - return Sorted_Evlog_extensions[i].evt_func (xEvt, Sorted_Evlog_extensions[i].evt_base, reply, len); + return Sorted_Evlog_extensions[i].evt_func (dpy, evinfo, Sorted_Evlog_extensions[i].evt_base, reply, len); } continue; } - return Sorted_Evlog_extensions[i].evt_func (xEvt, Sorted_Evlog_extensions[i].evt_base, reply, len); + return Sorted_Evlog_extensions[i].evt_func (dpy, evinfo, Sorted_Evlog_extensions[i].evt_base, reply, len); } } diff --git a/common/xdbg_evlog_event.h b/common/xdbg_evlog_event.h index 0fae711..8d61fee 100644 --- a/common/xdbg_evlog_event.h +++ b/common/xdbg_evlog_event.h @@ -34,6 +34,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" -char * xDbgEvlogEvent (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len); +char * xDbgEvlogEvent (void *dpy, EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len); #endif diff --git a/common/xdbg_evlog_gesture.c b/common/xdbg_evlog_gesture.c index 8e5710e..4ad23ee 100644 --- a/common/xdbg_evlog_gesture.c +++ b/common/xdbg_evlog_gesture.c @@ -57,13 +57,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_gesture.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestGesture(xReq *req, char *reply, int *len) +_EvlogRequestGesture(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_GestureSelectEvents: { @@ -113,11 +114,11 @@ _EvlogRequestGesture(xReq *req, char *reply, int *len) } static char * -_EvlogEventGesture (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventGesture (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case GestureNotifyFlick: { diff --git a/common/xdbg_evlog_randr.c b/common/xdbg_evlog_randr.c index 38ffe99..7e403c4 100644 --- a/common/xdbg_evlog_randr.c +++ b/common/xdbg_evlog_randr.c @@ -58,13 +58,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_randr.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestRandr (xReq *req, char *reply, int *len) +_EvlogRequestRandr (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_RRGetScreenSizeRange: { @@ -118,9 +119,11 @@ _EvlogRequestRandr (xReq *req, char *reply, int *len) case X_RRQueryOutputProperty: { xRRQueryOutputPropertyReq *stuff = (xRRQueryOutputPropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx)", - stuff->output, - stuff->property); + REPLY (": XID(0x%lx)", + stuff->output); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -128,9 +131,11 @@ _EvlogRequestRandr (xReq *req, char *reply, int *len) case X_RRConfigureOutputProperty: { xRRConfigureOutputPropertyReq *stuff = (xRRConfigureOutputPropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx)", - stuff->output, - stuff->property); + REPLY (": XID(0x%lx)", + stuff->output); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -138,22 +143,27 @@ _EvlogRequestRandr (xReq *req, char *reply, int *len) case X_RRChangeOutputProperty: { xRRChangeOutputPropertyReq *stuff = (xRRChangeOutputPropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx) Type(0x%lx) Format(%d) nUnits(%ld)", + REPLY (": XID(0x%lx) Format(%d) nUnits(%ld)", stuff->output, - stuff->property, - stuff->type, stuff->format, stuff->nUnits); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); + REPLY (" Type"); + reply = xDbgGetAtom(dpy, stuff->type, reply, len); + return reply; } case X_RRDeleteOutputProperty: { xRRDeleteOutputPropertyReq *stuff = (xRRDeleteOutputPropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx)", - stuff->output, - stuff->property); + REPLY (": XID(0x%lx)", + stuff->output); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -161,13 +171,16 @@ _EvlogRequestRandr (xReq *req, char *reply, int *len) case X_RRGetOutputProperty: { xRRGetOutputPropertyReq *stuff = (xRRGetOutputPropertyReq *)req; - REPLY (": XID(0x%lx) Property(0x%lx) Type(0x%lx) longOffset(%ld) longLength(%ld)", + REPLY (": XID(0x%lx) longOffset(%ld) longLength(%ld)", stuff->output, - stuff->property, - stuff->type, stuff->longOffset, stuff->longLength); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); + REPLY (" Type"); + reply = xDbgGetAtom(dpy, stuff->type, reply, len); + return reply; } @@ -210,11 +223,11 @@ _EvlogRequestRandr (xReq *req, char *reply, int *len) static char * -_EvlogEventRandr (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventRandr (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case RRScreenChangeNotify: { @@ -234,7 +247,7 @@ _EvlogEventRandr (xEvent *evt, int first_base, char *reply, int *len) case RRNotify: { - switch(stuff->u.u.detail) + switch(evt->u.u.detail) { case RRNotify_CrtcChange: { @@ -266,10 +279,12 @@ _EvlogEventRandr (xEvent *evt, int first_base, char *reply, int *len) case RRNotify_OutputProperty: { xRROutputPropertyNotifyEvent *stuff = (xRROutputPropertyNotifyEvent *) evt; - REPLY (": XID(0x%lx) Output(0x%lx) Atom(0x%lx)", + REPLY (": XID(0x%lx) Output(0x%lx)", stuff->window, - stuff->output, - stuff->atom); + stuff->output); + + REPLY (" Atom"); + reply = xDbgGetAtom(dpy, stuff->atom, reply, len); return reply; } @@ -287,10 +302,12 @@ _EvlogEventRandr (xEvent *evt, int first_base, char *reply, int *len) case RRNotify_ProviderProperty: { xRRProviderPropertyNotifyEvent *stuff = (xRRProviderPropertyNotifyEvent *) evt; - REPLY (": XID(0x%lx) Provider(0x%lx) Atom(0x%lx)", + REPLY (": XID(0x%lx) Provider(0x%lx)", stuff->window, - stuff->provider, - stuff->atom); + stuff->provider); + + REPLY (" Atom"); + reply = xDbgGetAtom(dpy, stuff->atom, reply, len); return reply; } diff --git a/common/xdbg_evlog_request.c b/common/xdbg_evlog_request.c index ad4d0be..102332d 100644 --- a/common/xdbg_evlog_request.c +++ b/common/xdbg_evlog_request.c @@ -62,7 +62,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. extern ExtensionInfo Evlog_extensions[]; char * -xDbgEvlogReqeust (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len) +xDbgEvlogReqeust (void *dpy, EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len) { EvlogRequest req; xReq *xReq = NULL; @@ -73,14 +73,14 @@ xDbgEvlogReqeust (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, req = evinfo->req; xReq = req.ptr; - REPLY ("%s", req.name); + REPLY ("%s", evinfo->req.name); if(!on) return reply; if (xReq->reqType < EXTENSION_BASE) { - return xDbgEvlogRequestCore (xReq, reply, len); + return xDbgEvlogRequestCore (dpy, evinfo, reply, len); } else { @@ -90,7 +90,7 @@ xDbgEvlogReqeust (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, { if (xReq->reqType == Evlog_extensions[i].opcode) { - return Evlog_extensions[i].req_func (xReq, reply, len); + return Evlog_extensions[i].req_func (dpy, evinfo, reply, len); } } } diff --git a/common/xdbg_evlog_request.h b/common/xdbg_evlog_request.h index 5dc5b47..908edef 100644 --- a/common/xdbg_evlog_request.h +++ b/common/xdbg_evlog_request.h @@ -34,6 +34,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" -char * xDbgEvlogReqeust (EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len); +char * xDbgEvlogReqeust (void *dpy, EvlogInfo *evinfo, Bool on, int Extensions_size, char *reply, int *len); #endif diff --git a/common/xdbg_evlog_xext.c b/common/xdbg_evlog_xext.c index e89530b..d4b1ab4 100644 --- a/common/xdbg_evlog_xext.c +++ b/common/xdbg_evlog_xext.c @@ -67,13 +67,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_xext.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestXextDpms(xReq *req, char *reply, int *len) +_EvlogRequestXextDpms(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_DPMSSetTimeouts: { @@ -104,11 +105,11 @@ _EvlogRequestXextDpms(xReq *req, char *reply, int *len) static char * -_EvlogRequestXextShm (xReq *req, char *reply, int *len) +_EvlogRequestXextShm (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_ShmPutImage: { @@ -160,11 +161,11 @@ _EvlogRequestXextShm (xReq *req, char *reply, int *len) } static char * -_EvlogRequestXextSync(xReq *req, char *reply, int *len) +_EvlogRequestXextSync(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_SyncCreateCounter: { @@ -225,11 +226,11 @@ _EvlogRequestXextSync(xReq *req, char *reply, int *len) } static char * -_EvlogRequestXextXtestExt1(xReq *req, char *reply, int *len) +_EvlogRequestXextXtestExt1(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_TestFakeInput: { @@ -258,11 +259,11 @@ _EvlogRequestXextXtestExt1(xReq *req, char *reply, int *len) static char * -_EvlogRequestXextXtest(xReq *req, char *reply, int *len) +_EvlogRequestXextXtest(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_XTestGetVersion: { @@ -313,11 +314,11 @@ _EvlogRequestXextXtest(xReq *req, char *reply, int *len) static char * -_EvlogEventXextDpms (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXextDpms (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { default: @@ -329,11 +330,11 @@ _EvlogEventXextDpms (xEvent *evt, int first_base, char *reply, int *len) static char * -_EvlogEventXextShm (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXextShm (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case ShmCompletion: { @@ -353,11 +354,11 @@ _EvlogEventXextShm (xEvent *evt, int first_base, char *reply, int *len) static char * -_EvlogEventXextSync (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXextSync (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case XSyncCounterNotify: { @@ -394,11 +395,11 @@ _EvlogEventXextSync (xEvent *evt, int first_base, char *reply, int *len) static char * -_EvlogEventXextXtestExt1 (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXextXtestExt1 (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { default: @@ -409,11 +410,11 @@ _EvlogEventXextXtestExt1 (xEvent *evt, int first_base, char *reply, int *len) } static char * -_EvlogEventXextXtest (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXextXtest (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { default: diff --git a/common/xdbg_evlog_xinput.c b/common/xdbg_evlog_xinput.c index e1db0cd..ebbc010 100644 --- a/common/xdbg_evlog_xinput.c +++ b/common/xdbg_evlog_xinput.c @@ -60,13 +60,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_xinput.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestXinput (xReq *req, char *reply, int *len) +_EvlogRequestXinput (void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case X_GrabDevice: { @@ -366,23 +367,28 @@ _EvlogRequestXinput (xReq *req, char *reply, int *len) case X_XIChangeProperty: { xXIChangePropertyReq *stuff = (xXIChangePropertyReq *)req; - REPLY (": devID(%d) mode(%d) format(%d) property(0x%x) type(0x%x) numItems(%d)", + REPLY (": devID(%d) mode(%d) format(%d) numItems(%d)", stuff->deviceid, stuff->mode, stuff->format, - stuff->property, - stuff->type, stuff->num_items); + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); + REPLY (" Type"); + reply = xDbgGetAtom(dpy, stuff->type, reply, len); + return reply; } case X_XIDeleteProperty: { xXIDeletePropertyReq *stuff = (xXIDeletePropertyReq *)req; - REPLY (": devID(%d) property(0x%x)", - stuff->deviceid, - stuff->property); + REPLY (": devID(%d)", + stuff->deviceid); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); return reply; } @@ -390,10 +396,13 @@ _EvlogRequestXinput (xReq *req, char *reply, int *len) case X_XIGetProperty: { xXIGetPropertyReq *stuff = (xXIGetPropertyReq *)req; - REPLY (": devID(%d) property(0x%x) type(0x%x)", - stuff->deviceid, - stuff->property, - stuff->type); + REPLY (": devID(%d)", + stuff->deviceid); + + REPLY (" Property"); + reply = xDbgGetAtom(dpy, stuff->property, reply, len); + REPLY (" Type"); + reply = xDbgGetAtom(dpy, stuff->type, reply, len); return reply; } @@ -415,11 +424,11 @@ _EvlogRequestXinput (xReq *req, char *reply, int *len) } static char * -_EvlogEventXinput (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXinput (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case XI_DeviceValuator: { @@ -623,8 +632,11 @@ _EvlogEventXinput (xEvent *evt, int first_base, char *reply, int *len) case XI_DevicePropertyNotify: { devicePropertyNotify *stuff = (devicePropertyNotify *) evt; - REPLY (": XID(0x%lx)", - stuff->atom); + REPLY (": deviceid(%d)", + stuff->deviceid); + + REPLY (" Atom"); + reply = xDbgGetAtom(dpy, stuff->atom, reply, len); return reply; } diff --git a/common/xdbg_evlog_xv.c b/common/xdbg_evlog_xv.c index 6d63ba9..47eaa7a 100644 --- a/common/xdbg_evlog_xv.c +++ b/common/xdbg_evlog_xv.c @@ -58,13 +58,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xdbg_types.h" #include "xdbg_evlog_xv.h" +#include "xdbg_evlog.h" static char * -_EvlogRequestXv(xReq *req, char *reply, int *len) +_EvlogRequestXv(void *dpy, EvlogInfo *evinfo, char *reply, int *len) { - xReq *stuff = req; + xReq *req = evinfo->req.ptr; - switch (stuff->data) + switch (req->data) { case xv_GrabPort: { @@ -145,11 +146,25 @@ _EvlogRequestXv(xReq *req, char *reply, int *len) case xv_SetPortAttribute: { xvSetPortAttributeReq *stuff = (xvSetPortAttributeReq *)req; - REPLY (": XID(0x%lx) Attribute(0x%lx) value(0x%lx)", + REPLY (": XID(0x%lx) value(0x%lx)", stuff->port, - stuff->attribute, stuff->value); + REPLY (" Attribute"); + reply = xDbgGetAtom(dpy, stuff->attribute, reply, len); + + return reply; + } + + case xv_GetPortAttribute: + { + xvGetPortAttributeReq *stuff = (xvGetPortAttributeReq *)req; + REPLY (": XID(0x%lx)", + stuff->port); + + REPLY (" Attribute"); + reply = xDbgGetAtom(dpy, stuff->attribute, reply, len); + return reply; } @@ -193,11 +208,11 @@ _EvlogRequestXv(xReq *req, char *reply, int *len) } static char * -_EvlogEventXv (xEvent *evt, int first_base, char *reply, int *len) +_EvlogEventXv (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len) { - xEvent *stuff = evt; + xEvent *evt = evinfo->evt.ptr; - switch ((stuff->u.u.type & 0x7F) - first_base) + switch ((evt->u.u.type & 0x7F) - first_base) { case XvVideoNotify: { @@ -213,11 +228,13 @@ _EvlogEventXv (xEvent *evt, int first_base, char *reply, int *len) case XvPortNotify: { XvPortNotifyEvent *stuff = (XvPortNotifyEvent *) evt; - REPLY (": XID(0x%lx) Attribute(%lx) Value(%ld)", + REPLY (": XID(0x%lx) Value(%ld)", stuff->port_id, - stuff->attribute, stuff->value); + REPLY (" Attribute"); + reply = xDbgGetAtom(dpy, stuff->attribute, reply, len); + return reply; } diff --git a/common/xdbg_types.h b/common/xdbg_types.h index d2298e5..791d3ae 100644 --- a/common/xdbg_types.h +++ b/common/xdbg_types.h @@ -34,6 +34,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include /* for Bool */ +#include +#include + #define XDBG_PATH_MAX 1024 @@ -87,6 +90,7 @@ typedef struct _EvlogClient int gid; int uid; char command[PATH_MAX+1]; + void* pClient; } EvlogClient; typedef struct _EvlogRequest @@ -124,8 +128,8 @@ struct _ExtensionInfo int opcode; int evt_base; int err_base; - char* (*req_func) (xReq *req, char *reply, int *len); - char* (*evt_func) (xEvent *evt, int first_base, char *reply, int *len); + char* (*req_func) (void *dpy, EvlogInfo *evinfo, char *reply, int *len); + char* (*evt_func) (void *dpy, EvlogInfo *evinfo, int first_base, char *reply, int *len); }; #endif diff --git a/module/xdbg_module_evlog.c b/module/xdbg_module_evlog.c index 8488efb..88b9579 100644 --- a/module/xdbg_module_evlog.c +++ b/module/xdbg_module_evlog.c @@ -157,7 +157,9 @@ static void evtPrintF (int fd, EvlogInfo *evinfo) char log[1024]; int size = sizeof (log); - xDbgEvlogFillLog (evinfo, TRUE, log, &size); + + + xDbgEvlogFillLog (NULL, evinfo, TRUE, log, &size); if (fd < 0) ErrorF ("%s", log); @@ -184,6 +186,7 @@ static void evtPrint (EvlogType type, ClientPtr client, xEvent *ev) evinfo.client.gid = info->gid; evinfo.client.uid = info->uid; strncpy (evinfo.client.command, info->command, strlen (info->command)); + evinfo.client.pClient = (void*)client; /* evinfo.req */ if (type == REQUEST)