/* * Hook to be called from toolkit event loop. */ int awt_mgrsel_processEvent(XEvent *ev) { Display *dpy = awt_display; struct AwtMgrsel *mgrsel; int scr; if (ev->type == ClientMessage) { /* new manager announces ownership? */ if (awt_mgrsel_managed(&ev->xclient)) return (1); } if (ev->type == DestroyNotify) { /* manager gives up selection? */ if (awt_mgrsel_unmanaged(&ev->xdestroywindow)) return (1); } /* is this an event selected on one of selection owners? */ for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) { for (scr = 0; scr < ScreenCount(dpy); ++scr) { if (ev->xany.window == mgrsel->per_scr_owners[scr]) { /* can one window own selections for more than one screen? */ goto out; /* XXX??? */ } } } out: DTRACE_PRINT2("MG: screen %d, event %d ... ", scr, ev->xany.type); if (mgrsel == NULL) { DTRACE_PRINTLN("ignored"); return (0); /* not interested */ } DTRACE_PRINT1("%s ... ", mgrsel->selname); if (mgrsel->callback_event != NULL) { DTRACE_PRINTLN("dispatching"); (*mgrsel->callback_event)(scr, ev, mgrsel->cookie); } #ifdef DEBUG else { DTRACE_PRINTLN("no callback"); } #endif return (1); }
static Boolean init_atoms(Display* display) { struct atominit { Atom *atomptr; const char *name; }; /* Add new atoms to this list */ static struct atominit atom_list[] = { /* Shared atoms */ { &XA_WM_STATE, "WM_STATE" }, { &XA_DELETE, "DELETE" }, /* XDnD atoms */ { &XA_XdndAware, "XdndAware" }, { &XA_XdndProxy, "XdndProxy" }, { &XA_XdndEnter, "XdndEnter" }, { &XA_XdndPosition, "XdndPosition" }, { &XA_XdndLeave, "XdndLeave" }, { &XA_XdndDrop, "XdndDrop" }, { &XA_XdndStatus, "XdndStatus" }, { &XA_XdndFinished, "XdndFinished" }, { &XA_XdndTypeList, "XdndTypeList" }, { &XA_XdndSelection, "XdndSelection" }, { &XA_XdndActionCopy, "XdndActionCopy" }, { &XA_XdndActionMove, "XdndActionMove" }, { &XA_XdndActionLink, "XdndActionLink" }, { &XA_XdndActionAsk, "XdndActionAsk" }, { &XA_XdndActionPrivate, "XdndActionPrivate" }, { &XA_XdndActionList, "XdndActionList" }, /* Motif DnD atoms */ { &_XA_MOTIF_DRAG_WINDOW, "_MOTIF_DRAG_WINDOW" }, { &_XA_MOTIF_DRAG_TARGETS, "_MOTIF_DRAG_TARGETS" }, { &_XA_MOTIF_DRAG_INITIATOR_INFO, "_MOTIF_DRAG_INITIATOR_INFO" }, { &_XA_MOTIF_DRAG_RECEIVER_INFO, "_MOTIF_DRAG_RECEIVER_INFO" }, { &_XA_MOTIF_DRAG_AND_DROP_MESSAGE, "_MOTIF_DRAG_AND_DROP_MESSAGE" }, { &_XA_MOTIF_ATOM_0, "_MOTIF_ATOM_0" }, { &XA_XmTRANSFER_SUCCESS, "XmTRANSFER_SUCCESS" }, { &XA_XmTRANSFER_FAILURE, "XmTRANSFER_FAILURE" } }; #define ATOM_LIST_LENGTH (sizeof(atom_list)/sizeof(atom_list[0])) const char *names[ATOM_LIST_LENGTH]; Atom atoms[ATOM_LIST_LENGTH]; Status status; size_t i; /* Fill the array of atom names */ for (i = 0; i < ATOM_LIST_LENGTH; ++i) { names[i] = atom_list[i].name; } DTRACE_PRINT2("%s:%d initializing atoms ... ", __FILE__, __LINE__); status = XInternAtoms(awt_display, (char**)names, ATOM_LIST_LENGTH, False, atoms); if (status == 0) { DTRACE_PRINTLN("failed"); return False; } /* Store returned atoms into corresponding global variables */ DTRACE_PRINTLN("ok"); for (i = 0; i < ATOM_LIST_LENGTH; ++i) { *atom_list[i].atomptr = atoms[i]; } return True; #undef ATOM_LIST_LENGTH }