From 7077776bb1686eac0d79e4dfc161f0b4f869b517 Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Wed, 12 Jan 2000 15:08:42 +0000 Subject: [PATCH] WABA: Use KCmdLineArgs svn path=/trunk/kdebase/kwin/; revision=38160 --- main.cpp | 34 +++++++++++++++++++++++++++------- main.h | 2 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 2dc44828cc..726959dbdd 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,19 @@ #undef INT8 #undef INT32 -#define i18n(x) (x) +#include +#include +#include + +static const char *version = "0.9"; + +static const char *description = I18N_NOOP( "KDE Window Manager." ); + +static KCmdLineOptions cmdOptions[] = +{ + { "+[workspace]", I18N_NOOP("A cryptic command line option"), 0 }, + { 0, 0, 0 } +}; Options* options; Atoms* atoms; @@ -54,8 +66,8 @@ int x11ErrorHandler(Display *d, XErrorEvent *e){ return 0; } -Application::Application( int &argc, char *argv[] ) -: KApplication( argc, argv, "kwin" ) +Application::Application( ) +: KApplication( ) { initting = TRUE; options = new Options; @@ -67,11 +79,14 @@ Application::Application( int &argc, char *argv[] ) // create a workspace. workspaces += new Workspace(); initting = FALSE; - if ( argc > 1 ) { - QString s = argv[1]; + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if ( args->count() ) { + QString s = args->arg(0); int i = s.toInt(); workspaces += new Workspace( (WId ) i ); } + args->clear(); syncX(); initting = FALSE; @@ -119,7 +134,12 @@ static void sighandler(int) { QApplication::exit(); } -int main( int argc, char * argv[] ) { +int main( int argc, char * argv[] ) +{ + KAboutData aboutData( "kwin", I18N_NOOP("KWin"), version, description); + + KCmdLineArgs::init(argc, argv, &aboutData); + KCmdLineArgs::addCmdLineOptions( cmdOptions ); if (signal(SIGTERM, sighandler) == SIG_IGN) signal(SIGTERM, SIG_IGN); @@ -128,7 +148,7 @@ int main( int argc, char * argv[] ) { if (signal(SIGHUP, sighandler) == SIG_IGN) signal(SIGHUP, SIG_IGN); - Application a( argc, argv ); + Application a; fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); return a.exec(); diff --git a/main.h b/main.h index a7ec2e2fc8..a814100f99 100644 --- a/main.h +++ b/main.h @@ -8,7 +8,7 @@ typedef QValueList WorkspaceList; class Application : public KApplication { public: - Application( int &argc, char **argv ); + Application(); ~Application(); protected: