00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kuniqueapplication.h>
00022 #include <kcmdlineargs.h>
00023 #include <kaboutdata.h>
00024 #include <klocale.h>
00025 #include <kxerrorhandler.h>
00026
00027 #include <X11/Xlib.h>
00028 #include <X11/Xatom.h>
00029
00030 #include "knotesapp.h"
00031 #include "version.h"
00032 #include "main.h"
00033
00034
00035 void remove_sm_from_client_leader()
00036 {
00037 Atom type;
00038 int format, status;
00039 unsigned long nitems = 0;
00040 unsigned long extra = 0;
00041 unsigned char *data = 0;
00042
00043 Atom atoms[ 2 ];
00044 char *atom_names[ 2 ] = { "WM_CLIENT_LEADER", "SM_CLIENT_ID" };
00045
00046 XInternAtoms( qt_xdisplay(), atom_names, 2, False, atoms );
00047
00048 QWidget w;
00049 KXErrorHandler handler;
00050 status = XGetWindowProperty( qt_xdisplay(), w.winId(), atoms[ 0 ], 0, 10000,
00051 FALSE, XA_WINDOW, &type, &format,
00052 &nitems, &extra, &data );
00053
00054 if (status == Success && !handler.error( false ))
00055 {
00056 if (data && nitems > 0)
00057 {
00058 Window leader = *((Window*) data);
00059 XDeleteProperty( qt_xdisplay(), leader, atoms[ 1 ] );
00060 }
00061 XFree(data);
00062 }
00063 }
00064
00065
00066 Application::Application()
00067 : KUniqueApplication(), mMainWindow( 0 )
00068 {
00069 }
00070
00071 Application::~Application()
00072 {
00073 delete mMainWindow;
00074 }
00075
00076 int Application::newInstance()
00077 {
00078 if ( !mMainWindow )
00079 {
00080 mMainWindow = new KNotesApp();
00081 mMainWindow->show();
00082 }
00083 else
00084 mMainWindow->newNote();
00085
00086 return KUniqueApplication::newInstance();
00087 }
00088
00089 int main( int argc, char* argv[] )
00090 {
00091 QString version = QString::number( KNOTES_VERSION );
00092
00093 KAboutData aboutData(
00094 "knotes",
00095 I18N_NOOP("KNotes"),
00096 version.latin1(),
00097 I18N_NOOP( "KDE Notes" ),
00098 KAboutData::License_GPL,
00099 I18N_NOOP("(c) 1997-2004, The KNotes Developers")
00100 );
00101
00102 aboutData.addAuthor("Michael Brade", I18N_NOOP("Maintainer"), "brade@kde.org");
00103 aboutData.addAuthor("Bernd Johannes Wuebben", I18N_NOOP("Original KNotes Author"), "wuebben@kde.org");
00104 aboutData.addAuthor("Wynn Wilkes", I18N_NOOP("Ported KNotes to KDE 2"), "wynnw@calderasystems.com");
00105
00106 aboutData.addCredit("Matthias Ettrich", 0, "ettrich@kde.org");
00107 aboutData.addCredit("David Faure", 0, "faure@kde.org");
00108 aboutData.addCredit("Matthias Kiefer", 0, "kiefer@kde.org");
00109 aboutData.addCredit("Luboš Luňák", 0, "l.lunak@kde.org");
00110 aboutData.addCredit("Laurent Montel", 0, "montel@kde.org");
00111 aboutData.addCredit("Dirk A. Mueller", 0, "dmuell@gmx.net");
00112 aboutData.addCredit("Carsten Pfeiffer", 0, "pfeiffer@kde.org");
00113 aboutData.addCredit("Harri Porten", 0, "porten@kde.org");
00114 aboutData.addCredit("Espen Sand", 0, "espen@kde.org");
00115
00116 KCmdLineArgs::init( argc, argv, &aboutData );
00117
00118 KUniqueApplication::addCmdLineOptions();
00119
00120 Application app;
00121 app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
00122
00123 remove_sm_from_client_leader();
00124
00125 int rval = app.exec();
00126
00127 return rval;
00128 }