1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*****************************************************************
Copyright (c) 1996-2002 the kicker authors. See file AUTHORS.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
#include <config.h>
#include <klocale.h>
#include <tdecmdlineargs.h>
#include <kdebug.h>
#include <tdeaboutdata.h>
#include <kglobal.h>
#include <tdeconfig.h>
#include <dcopclient.h>
#include <dcopref.h>
#include <X11/Xlib.h>
#include <fixx11h.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include "kicker.h"
int kicker_screen_number = 0;
static const char description[] =
I18N_NOOP("The TDE panel");
static const char version[] = VERSION;
static void sighandler(int)
{
fprintf(stderr, "kicker: sighandler called\n");
TQApplication::exit();
}
extern "C" KDE_EXPORT int kdemain( int argc, char ** argv )
{
{
TQCString multiHead = getenv("TDE_MULTIHEAD");
if (multiHead.lower() == "true") {
Display *dpy = XOpenDisplay(NULL);
if (! dpy) {
fprintf(stderr, "%s: FATAL ERROR: couldn't open display %s\n",
argv[0], XDisplayName(NULL));
exit(1);
}
int number_of_screens = ScreenCount(dpy);
kicker_screen_number = DefaultScreen(dpy);
int pos;
TQCString display_name = XDisplayString(dpy);
XCloseDisplay(dpy);
dpy = 0;
if ((pos = display_name.findRev('.')) != -1)
display_name.remove(pos, 10);
TQCString env;
if (number_of_screens != 1) {
for (int i = 0; i < number_of_screens; i++) {
if (i != kicker_screen_number && fork() == 0) {
kicker_screen_number = i;
// break here because we are the child process, we don't
// want to fork() anymore
break;
}
}
env.sprintf("DISPLAY=%s.%d", display_name.data(), kicker_screen_number);
if (putenv(strdup(env.data()))) {
fprintf(stderr,
"%s: WARNING: unable to set DISPLAY environment variable\n",
argv[0]);
perror("putenv()");
}
}
}
}
TDEGlobal::locale()->setMainCatalogue("kicker");
TQCString appname;
if (kicker_screen_number == 0)
appname = "kicker";
else
appname.sprintf("kicker-screen-%d", kicker_screen_number);
TDEAboutData aboutData( appname.data(), I18N_NOOP("TDE Panel"),
version, description, TDEAboutData::License_GPL_V2,
I18N_NOOP("(c) 1999-2010, The KDE Team") );
aboutData.addAuthor("Timothy Pearson", I18N_NOOP("Current maintainer"), "kb9vqf@pearsoncomputing.net");
aboutData.addAuthor("Aaron J. Seigo",0, "aseigo@kde.org");
aboutData.addAuthor("Matthias Elter",0, "elter@kde.org");
aboutData.addAuthor("Matthias Ettrich",0, "ettrich@kde.org");
aboutData.addAuthor("Wilco Greven",0, "greven@kde.org");
aboutData.addAuthor("Rik Hemsley",0, "rik@kde.org");
aboutData.addAuthor("Daniel M. Duley",0, "mosfet@kde.org");
aboutData.addAuthor("Preston Brown",0, "pbrown@kde.org");
aboutData.addAuthor("John Firebaugh",0, "jfirebaugh@kde.org");
aboutData.addAuthor("Waldo Bastian", I18N_NOOP("Kiosk mode"), "bastian@kde.org");
aboutData.addCredit("Jessica Hall", /* I18N_NOOP("TDEConfigXT") */ 0, "jes.hall@kdemail.net");
aboutData.addCredit("Stefan Nikolaus", /* I18N_NOOP("Bug fixes") */ 0, "stefan.nikolaus@kdemail.net");
aboutData.addCredit("BenoƮt Minisini", /* I18N_NOOP("Bug fixes") */ 0, "gambas@users.sourceforge.net");
TDECmdLineArgs::init( argc, argv, &aboutData );
if (!Kicker::start()) {
kdError() << "kicker is already running!" << endl;
return 0;
}
if (signal(SIGTERM, sighandler) == SIG_IGN)
signal(SIGTERM, SIG_IGN);
if (signal(SIGINT, sighandler) == SIG_IGN)
signal(SIGINT, SIG_IGN);
if (signal(SIGHUP, sighandler) == SIG_IGN)
signal(SIGHUP, SIG_IGN);
// send it even before TDEApplication ctor, because ksmserver will launch another app as soon
// as TQApplication registers with it
DCOPClient* cl = new DCOPClient;
cl->attach();
DCOPRef r( "ksmserver", "ksmserver" );
r.setDCOPClient( cl );
r.send( "suspendStartup", TQCString( "kicker" ));
delete cl;
Kicker* kicker = new Kicker;
int rv = kicker->exec();
delete kicker;
return rv;
}
|