Beispiel #1
0
void QXtEventLoop::appStartingUp()
{
    int argc = tqApp->argc();
    XtDisplayInitialize( d->appContext,
			 TQPaintDevice::x11AppDisplay(),
			 tqApp->name(),
			 d->applicationClass,
			 d->options,
			 d->numOptions,
			 &argc,
			 tqApp->argv() );
    d->hookMeUp();
}
Beispiel #2
0
XtEvents::XtEvents()
    {
    XtToolkitInitialize();
    context = XtCreateApplicationContext();
    int argc = qApp->argc();
    XtDisplayInitialize( context, QX11Info::display(), qAppName().toLatin1(), QX11Info::appClass(),
        NULL, 0, &argc, qApp->argv());
    connect( &timer, SIGNAL(timeout()), SLOT(idleProcess()));
    kapp->installX11EventFilter( this );
    // No way to find out when to process Xt events, so poll :(
    // ... but only after enable() has been called
    self = this;
    }
Beispiel #3
0
int main(int argc, char *argv[])
{
  KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KXSConfig"), description, version);

  KCmdLineArgs::addCmdLineOptions(options);

  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
  if(args->count()==0)
    exit(1);

  /* We must read exactly the same resources as xscreensaver.
     That means we must have both the same progclass *and* progname,
     at least as far as the resource database is concerned.  So,
     put "xscreensaver" in argv[0] while initializing Xt.
   */
  const char *dummyargs[] = { "xscreensaver" };
  int dummyargc = 1;
  progname = dummyargs[0];

  // Teach Xt to use the Display that TQt has already opened.
  XtToolkitInitialize ();
  XtAppContext xtApp = XtCreateApplicationContext ();
  Display *dpy = qt_xdisplay();
  XtAppSetFallbackResources (xtApp, const_cast<char**>(defaults));
  XtDisplayInitialize (xtApp, dpy, progname, progclass, 0, 0,
                       &dummyargc,
                       const_cast<char**>(dummyargs));
  Widget toplevel_shell = XtAppCreateShell (progname, progclass,
	  applicationShellWidgetClass,
	  dpy, 0, 0);
  dpy = XtDisplay (toplevel_shell);
  db = XtDatabase (dpy);
  XtGetApplicationNameAndClass (dpy, const_cast<char**>(&progname),
                                const_cast<char**>(&progclass));

  TQString name = TQString::fromLocal8Bit(args->arg(args->count() - 1));
  KXSConfigDialog *dialog=new KXSConfigDialog(args->arg(0), name);
  if ( dialog->create() ) {
      dialog->show();
      app.setMainWidget(dialog);
      app.exec();
  } else {
      KMessageBox::sorry(0,
	      i18n("No configuration available for %1").tqarg(name),
	      name );
  }

  delete dialog;
}
Beispiel #4
0
/*!
  Constructs a QApplication and initializes the Xt toolkit.
  The \a appclass, \a options, \a num_options, and \a resources
  arguments are passed on to XtAppSetFallbackResources and
  XtDisplayInitialize.

  Use this constructor when writing a new Qt application which
  needs to use some existing Xt/Motif widgets.
*/
KXtApplication::KXtApplication(int& argc, char** argv,
        const QCString& rAppName, bool allowStyles, bool GUIenabled,
        XrmOptionDescRec *options, int num_options,
        char** resources)
  : KApplication(argc, argv, rAppName, allowStyles, GUIenabled)
{
    my_xt = TRUE;

    XtToolkitInitialize();
    appcon = XtCreateApplicationContext();
    if (resources) XtAppSetFallbackResources(appcon, (char**)resources);
    XtDisplayInitialize(appcon, qt_xdisplay(), name(), rAppName, options,
        num_options, &argc, argv);
    init();
}
long int GetMultiClickTime() {
	long int value = 200;
	int clicktime;
	bool successful = false;

	// Try and acquire the multi-click time from the user defined X defaults.
	char *xprop = XGetDefault(disp, "*", "multiClickTime");
	if (xprop != NULL && sscanf(xprop, "%4i", &clicktime) != EOF) {
		successful = true;
	}

	xprop = XGetDefault(disp, "OpenWindows", "MultiClickTimeout");
	if (xprop != NULL && sscanf(xprop, "%4i", &clicktime) != EOF) {
		successful = true;
	}

	#ifdef XT
	int argc = 0;
	char ** argv = {NULL};

	// Fall back to the X Toolkit extension if available and other efforts failed.
    XtDisplayInitialize(app_context, disp, "JNativeHook", "JNativeHook", NULL, 0, &argc, argv);
	if (!successful) {
		clicktime = XtGetMultiClickTime(disp);
		if (clicktime >= 0) {
			successful = true;
		}
	}
	#endif

	if (successful) {
		value = clicktime;
	}

	return value;
}
Beispiel #6
0
void QNPXt::appStartingUp()
{
    /*
      QApplication could be using a Display from an outside source, so
      we should only initialize the display if the current application
      context does not contain the QApplication display
    */

    bool display_found = FALSE;
    Display **displays;
    Cardinal x, count;
    XtGetDisplays( d->appContext, &displays, &count );
    for ( x = 0; x < count && ! display_found; ++x ) {
	if ( displays[x] == QPaintDevice::x11AppDisplay() )
	    display_found = TRUE;
    }
    if ( displays )
	XtFree( (char *) displays );

    if ( ! display_found ) {
	int argc = qApp->argc();
	XtDisplayInitialize( d->appContext,
			     QPaintDevice::x11AppDisplay(),
			     qApp->name(),
			     d->applicationClass,
			     d->options,
			     d->numOptions,
			     &argc,
			     qApp->argv() );
    }

    d->hookMeUp();

    // start a zero-timer to get the timer keep-alive working
    d->timerid = XtAppAddTimeOut( d->appContext, 0, qnpxt_timeout_handler, 0 );
}