void Input::Poll() { // poll input window messages #if defined(_WIN32) MessageLoop(); #elif defined(__linux__) CheckMonitor(); #endif // input device handling for(int i = 0; i < numControllers; ++i) { Controller& pad = controllers[i]; switch(pad.type) { case KEYBOARD_AND_MOUSE: PollKeyboardAndMouse(); break; case GAMEPAD_XINPUT: PollXInputGamepad(i); break; case GAMEPAD_EVDEV: PollEvDevGamepad(i); break; } pad.Update(); } // mouse position handling #if defined(WIN32) POINT mouseScreenPosition; if(GetCursorPos(&mouseScreenPosition)) { mousePosition[0] = mouseScreenPosition.x; mousePosition[1] = mouseScreenPosition.y; } #elif defined(X11) { Window root, child; int rootCoords[2]; int windowCoords[2]; unsigned int mask; XQueryPointer(display, window, &root, &child, &rootCoords[0], &rootCoords[1], &windowCoords[0], &windowCoords[1], &mask); mousePosition[0] = windowCoords[0]; mousePosition[1] = windowCoords[1]; } #endif }
/*++++++++++++++++++++++++++++++++++++++*/ int main( int argc, char **argv ) { int n; Arg args[MAX_ARGS]; XEvent event; XPropertyEvent *pEvent=(XPropertyEvent *)&event; long mwmFunc; Boolean useMaskRtn, useIconFileCacheRtn; char *dirs = NULL; char *string; Visual *visual; #ifdef USERHELP malloc_check(1); malloc_trace(0); #endif XtSetLanguageProc(NULL, NULL, NULL); _DtEnvControl(DT_ENV_SET); /* Initialize the toolkit and open the display */ style.shell = XtInitialize(argv[0], XMCLASS, option_list, 1, (int *)&argc, argv); #ifdef __osf__ _XmColorObjCreate(style.shell, NULL, NULL); #endif /* Allow all WS manipulation functions except resize and maximize */ mwmFunc = MWM_FUNC_ALL ^ (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); n = 0; XtSetArg(args[n], XmNmwmFunctions, mwmFunc); n++; XtSetArg(args[n], XmNuseAsyncGeometry, True); n++; XtSetValues(style.shell, args, n); /* initialize global style data */ style.display = XtDisplay(style.shell); style.screen = DefaultScreenOfDisplay(style.display); style.screenNum = DefaultScreen(style.display); style.colormap = DefaultColormap(style.display, style.screenNum); style.root = DefaultRootWindow(style.display); style.execName = argv[0]; style.errDialog = NULL; style.tmpXmStr = NULL; style.home = (char *) XtMalloc(strlen((char *) getenv("HOME")) + 1); strcpy(style.home, (char *) getenv("HOME")); style.colorDialog = NULL; style.backdropDialog = NULL; style.fontDialog = NULL; style.kbdDialog = NULL; style.mouseDialog = NULL; style.audioDialog = NULL; style.screenDialog = NULL; style.startupDialog = NULL; style.dtwmDialog = NULL; style.i18nDialog = NULL; visual = XDefaultVisual(style.display,style.screenNum); style.visualClass = visual->class; if (progName = DtStrrchr(argv[0], '/')) progName++; else progName = argv[0]; /* Get the lock established to ensure only one dtstyle process * is running per screen .. first malloc enough space*/ if (_DtGetLock (style.display, STYLE_LOCK) == 0) { _DtSimpleError (progName, DtError, NULL, "%s", ((char *)GETMESSAGE(2, 5, "Style Manager is already running, second attempt aborted."))); exit(1); } InitDtstyleProtocol(); SetWindowProperties(); /* Register error handlers */ XSetErrorHandler(ErrorHandler); XSetIOErrorHandler(IOErrorHandler); XtAppSetErrorHandler(XtWidgetToApplicationContext(style.shell), ToolkitErrorHandler); XtAddEventHandler(style.shell, StructureNotifyMask, 0, (XtEventHandler)MwmReparentNotify, NULL); /* set up resolution dependent layout variables */ switch (_DtGetDisplayResolution(style.display, style.screenNum)) { case LOW_RES_DISPLAY: style.horizontalSpacing = style.verticalSpacing = 3; break; case MED_RES_DISPLAY: style.horizontalSpacing = style.verticalSpacing = 5; break; case HIGH_RES_DISPLAY: style.horizontalSpacing = style.verticalSpacing = 8; break; } GetApplicationResources(); XmeGetIconControlInfo(style.screen, &useMaskRtn, &style.useMultiColorIcons, &useIconFileCacheRtn); /* add the directory $HOME/.dt/backdrops */ string = (char *)XtMalloc(strlen(style.home) + strlen("/.dt/backdrops:") + 1); sprintf(string, "%s/.dt/backdrops:", style.home); dirs = (char *)XtCalloc(1, strlen("/etc/dt/backdrops:/usr/dt/backdrops") + (style.xrdb.backdropDir == NULL ? 2 : strlen(style.xrdb.backdropDir)) + strlen(string) + 2); strcpy(dirs, string); if (style.xrdb.backdropDir) { strcat(dirs, style.xrdb.backdropDir); strcat(dirs, ":"); } strcat(dirs, "/etc/dt/backdrops:/usr/dt/backdrops"); _DtWsmSetBackdropSearchPath(style.screen, dirs, style.useMultiColorIcons); if (string != NULL) XtFree((char *)string); if (dirs != NULL) XtFree((char *)dirs); style.count = 0; /* if this is started from save session we need to set up the BMS first, otherwise do it after making the window. (for user perception for how long it takes for the dtstyle to come up) */ if(style.xrdb.session != NULL) { DtInitialize (style.display, style.shell, progName, progName); /*Restore a session or build and display the main Window.*/ if(!restoreSession(style.shell,style.xrdb.session)) init_mainWindow(style.shell); } else { init_mainWindow(style.shell); DtInitialize (style.display, style.shell, progName, progName); InitializeAtoms(); CheckMonitor(style.shell); GetDefaultPal(style.shell); } signal(SIGINT,(void (*)())activateCB_exitBtn); signal(SIGTERM,(void (*)())activateCB_exitBtn); /* to avoid defunct screen saver processes */ signal(SIGCHLD, (void (*)())WaitChildDeath); /* backdrop dialog needs to know when the workspace changes to recolor the bitmap displayed in the dialog */ ListenForWorkspaceChange(); /* if using COLOR builtin, style.workProcs is True */ if ((XmeUseColorObj() != FALSE) && style.workProcs) XtAppAddWorkProc(XtWidgetToApplicationContext(style.shell), NewCreateD, style.shell); XtAppMainLoop(XtWidgetToApplicationContext(style.shell)); return 0; }