static void xt_add_focus_listener_tree ( Widget treeroot, XtPointer user_data) { Window win = XtWindow(treeroot); Window *children; Window root, parent; Display *dpy = XtDisplay(treeroot); unsigned int i, nchildren; /* ensure we don't add more than once */ xt_remove_focus_listener( treeroot, user_data); xt_add_focus_listener( treeroot, user_data); trap_errors(); if(!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) { untrap_error(); return; } if(untrap_error()) return; for(i=0; i<nchildren; ++i) { Widget child = XtWindowToWidget(dpy, children[i]); if (child) xt_add_focus_listener_tree( child, user_data); } XFree((void*)children); return; }
static void send_xembed_message (XtClient *xtclient, long message, long detail, long data1, long data2, long time) { XEvent xevent; Window w=XtWindow(xtclient->top_widget); Display* dpy=xtclient->xtdisplay; int errorcode; memset(&xevent,0,sizeof(xevent)); xevent.xclient.window = w; xevent.xclient.type = ClientMessage; xevent.xclient.message_type = XInternAtom(dpy,"_XEMBED",False); xevent.xclient.format = 32; xevent.xclient.data.l[0] = time; xevent.xclient.data.l[1] = message; xevent.xclient.data.l[2] = detail; xevent.xclient.data.l[3] = data1; xevent.xclient.data.l[4] = data2; trap_errors (); XSendEvent (dpy, w, False, NoEventMask, &xevent); XSync (dpy,False); if((errorcode = untrap_error())) { #ifdef DEBUG_XTBIN printf("send_xembed_message error(%d)!!!\n",errorcode); #endif } }
static void xt_remove_focus_listener(Widget w, XtPointer user_data) { trap_errors (); XtRemoveEventHandler(w, SubstructureNotifyMask | ButtonReleaseMask, TRUE, (XtEventHandler)xt_client_focus_listener, user_data); untrap_error(); }
static void xt_add_focus_listener( Widget w, XtPointer user_data) { XtClient *xtclient = user_data; trap_errors (); XtAddEventHandler(w, SubstructureNotifyMask | ButtonReleaseMask, FALSE, (XtEventHandler)xt_client_focus_listener, xtclient); untrap_error(); }
static void xt_add_focus_listener( Widget w, XtPointer user_data) { XWindowAttributes attr; long eventmask; XtClient *xtclient = user_data; trap_errors (); XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attr); eventmask = attr.your_event_mask | SubstructureNotifyMask | ButtonReleaseMask; XSelectInput(XtDisplay(w), XtWindow(w), eventmask); XtAddEventHandler(w, SubstructureNotifyMask | ButtonReleaseMask, TRUE, (XtEventHandler)xt_client_focus_listener, xtclient); untrap_error(); }