static void removeXtEventFilters() { if (!filters_installed) return; // We aren't needed any more... slink back into the shadows. for (int et=2; et < LASTEvent; et++) { XtSetEventDispatcher( qt_xdisplay(), et, qt_np_cascade_event_handler[et] ); } filters_installed = FALSE; }
static void installXtEventFilters() { if (filters_installed) return; // Get Xt out of our face - install filter on every event type for (int et=2; et < LASTEvent; et++) { qt_np_cascade_event_handler[et] = XtSetEventDispatcher( qt_xdisplay(), et, qt_event_handler_wrapper ); } filters_installed = TRUE; }
static void installXtEventFilters(FilterType t) { if (qt_np_filters_installed[t]) return; // Get Xt out of our face - install filter on every event type for (int et=2; et < LASTEvent; et++) { if ( filterTypeFor(et) == t ) qt_np_cascade_event_handler[et] = XtSetEventDispatcher( qt_xdisplay(), et, qt_event_handler ); } qt_np_filters_installed[t] = TRUE; }
void QXtEventLoopPrivate::hookMeUp() { // worker to plug Qt into Xt (event dispatchers) // and Xt into Qt (QXtEventLoopEventLoop) // ### TODO extensions? dispatchers.resize( LASTEvent ); dispatchers.fill( 0 ); int et; for ( et = 2; et < LASTEvent; et++ ) dispatchers[ et ] = XtSetEventDispatcher( TQPaintDevice::x11AppDisplay(), et, ::qmotif_event_dispatcher ); }
void QXtEventLoopPrivate::unhook() { // unhook Qt from Xt (event dispatchers) // unhook Xt from Qt? (QXtEventLoopEventLoop) // ### TODO extensions? int et; for ( et = 2; et < LASTEvent; et++ ) (void) XtSetEventDispatcher( TQPaintDevice::x11AppDisplay(), et, dispatchers[ et ] ); dispatchers.resize( 0 ); /* We cannot destroy the app context here because it closes the X display, something TQApplication does as well a bit later. if ( ownContext ) XtDestroyApplicationContext( ownContext ); */ appContext = ownContext = 0; }
/************************************************************************ * * Initialize * ************************************************************************/ static void Initialize( Widget req_widget, Widget new_widget, ArgList args, Cardinal *num_args ) { int event_base_return, error_base_return ; XmPrintShellWidget print_shell = (XmPrintShellWidget) new_widget ; XPContext pcontext ; Screen * pscreen ; _XmProcessLock(); /* mark the screen of this print shell in this context */ XSaveContext(XtDisplay(new_widget), (XID)XtScreen(new_widget), _XmPrintScreenToShellContext, (XPointer) new_widget); /* also maintain a counter of all shell */ _XmPrintShellCounter ++ ; _XmProcessUnlock(); print_shell->print.xp_connected = False ; print_shell->print.print_resolution = 100 ; /*** first check if the Print extension is present at all */ if (!XpQueryExtension (XtDisplay(new_widget), &event_base_return, &error_base_return)) { return ; } /* need to check that the print context is set for the screen of this print shell (i.e. it's a print screen, not just a screen on a display that support printing and for which a context was establish on a different screen - which can be common in preview case */ pcontext = XpGetContext(XtDisplay(new_widget)); if (!pcontext || XpGetScreenOfContext(XtDisplay(new_widget),pcontext) != XtScreen(new_widget)) { return ; } print_shell->print.xp_connected = True ; /*** add an element to a widget/XPContext table, used in the event dispatch mechanism */ AddToTable(pcontext, new_widget); /*** add extension event Handler for Start/End Job/Page Notify */ XtInsertEventTypeHandler(new_widget, event_base_return + XPPrintNotify, (XtPointer)XPPrintMask, PrintNotifyHandler, NULL, XtListTail); /*** also add extension event Handler for tracking attributes change */ XtInsertEventTypeHandler(new_widget, event_base_return + XPAttributeNotify, (XtPointer)XPAttributeMask, AttributesNotifyHandler, NULL, XtListTail); /* always register the extension selector, and the event dispatcher, it will override itself accordingly and works ok for different display connection */ XtRegisterExtensionSelector(XtDisplay(new_widget), event_base_return + XPPrintNotify, event_base_return + XPAttributeNotify, SelectXpEvents, NULL); (void) XtSetEventDispatcher(XtDisplay(new_widget), event_base_return + XPPrintNotify, PrintDispatchEvent); (void) XtSetEventDispatcher(XtDisplay(new_widget), event_base_return + XPAttributeNotify, PrintDispatchEvent); /* go and get resolution and initial sizes */ ResourcesUpdate(new_widget, pcontext, &(new_widget->core.width), &(new_widget->core.height)); }
Boolean InitXkb(Display *theDisplay) { int i,opcode,errorBase,major,minor; XkbDescPtr xkb; unsigned int bit; unsigned int real,virtual,named,explicit,automatic; char *name; if (!XkbQueryExtension(theDisplay, &opcode, &xkbEventBase, &errorBase, &major, &minor)) return False; if (!XkbUseExtension(theDisplay,&major,&minor)) return False; XkbSelectEvents(theDisplay, XkbUseCoreKbd, XkbIndicatorStateNotifyMask|XkbIndicatorMapNotifyMask, XkbIndicatorStateNotifyMask|XkbIndicatorMapNotifyMask); XtSetEventDispatcher(theDisplay, xkbEventBase+XkbEventCode, XkbEventHandler); xkb=XkbGetMap(theDisplay,0,XkbUseCoreKbd); real=virtual=named=explicit=automatic=0; if (!xkb) { fprintf(stderr,"Couldn't get keymap\n"); return False; } if (XkbGetIndicatorMap(theDisplay,XkbAllIndicatorsMask,xkb)!=Success) { fprintf(stderr,"Couldn't read indicator map\n"); XkbFreeKeyboard(xkb,XkbAllComponentsMask,True); return False; } real=virtual=named=explicit=automatic=0; if (XkbGetNames(theDisplay,XkbIndicatorNamesMask,xkb)!=Success) { fprintf(stderr,"Couldn't read indicator names\n"); XkbFreeKeyboard(xkb,XkbAllComponentsMask,True); return False; } real=virtual=named=explicit=automatic=0; for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { XkbIndicatorMapPtr map= &xkb->indicators->maps[i]; name = NULL; if (xkb->names->indicators[i]!=None) { named|= bit; name = XGetAtomName(theDisplay,xkb->names->indicators[i]); } if (name != NULL) { ledAtoms[i] = xkb->names->indicators[i]; ledNames[i] = XmStringCreate(name,XmSTRING_DEFAULT_CHARSET); } else { char temp[12]; sprintf(temp,"led%d\0",i+1); ledAtoms[i] = None; ledNames[i] = XmStringCreate(temp,XmSTRING_DEFAULT_CHARSET); } if (xkb->indicators->phys_indicators&bit) real|= bit; if ((((map->which_groups!=0)&&(map->groups!=0))|| ((map->which_mods!=0)&& ((map->mods.real_mods!=0)||(map->mods.vmods!=0)))|| (map->ctrls!=0))&& ((map->flags&XkbIM_NoAutomatic)==0)) { automatic|= bit; } else explicit|= bit; } virtual = ~real; if (options.useUnion) { if ((options.wantReal==NO) || (options.wantReal==DONT_CARE)) real = 0; if ((options.wantVirtual==NO) || (options.wantVirtual==DONT_CARE)) virtual = 0; if ((options.wantNamed==NO) || (options.wantNamed==DONT_CARE)) named = 0; if ((options.wantAutomatic==NO) || (options.wantAutomatic==DONT_CARE)) automatic = 0; if ((options.wantExplicit==NO) || (options.wantExplicit==DONT_CARE)) explicit = 0; options.wanted |= real|virtual|named|automatic|explicit; } else { if (options.wanted == DONT_CARE)