-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.cpp
More file actions
135 lines (94 loc) · 2.53 KB
/
Main.cpp
File metadata and controls
135 lines (94 loc) · 2.53 KB
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
//
// Telescope - graphical task switcher
//
// (c) Ilya Skriblovsky, 2010
// <Ilya.Skriblovsky@gmail.com>
//
// $Id: Main.cpp 184 2011-06-28 19:51:40Z mitrandir $
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include "TeleWindow.h"
#include "XTools.h"
#include "Settings.h"
#include "Resources.h"
#include "DBus.h"
#include "XEventLoop.h"
#ifdef LAUNCHER
#include "LauncherWindow.h"
#include "SectionList.h"
#include "MenuReader.h"
#endif
// We need to catch SIGCHLD in order to not leave zombie processes that was runned by execvp
#include <sys/types.h>
#include <sys/wait.h>
void sig_chld(int signo)
{
int status;
waitpid(-1, &status, WNOHANG);
}
int main(int argc, char *argv[])
{
// Add handling for SIGCHLD
struct sigaction act;
act.sa_handler = sig_chld;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_NOCLDSTOP;
sigaction(SIGCHLD, &act, 0);
// prepare i8n
setlocale(LC_ALL,"");
bindtextdomain("maemo-af-desktop","/usr/share/locale");
textdomain("maemo-af-desktop");
Display *dpy = XOpenDisplay(0);
if (! dpy)
{
fprintf(stderr, "Cannot open display\n");
return 1;
}
XTools::init(dpy);
if (! XTools::checkCompositeExtension())
{
fprintf(stderr, "XServer doesn't support Composite\n");
return 1;
}
if (! XTools::checkDamageExtension())
{
fprintf(stderr, "XServer doesn't support Damage\n");
return 1;
}
if (! XTools::checkXRenderExtension())
{
fprintf(stderr, "XServer doesn't support XRender\n");
return 1;
}
XTools::enableCompositeRedirect();
Settings *settings = new Settings;
// init resource
Resources * resources = new Resources(dpy);
XEventLoop *eventLoop = new XEventLoop(dpy);
TeleWindow *teleWindow = new TeleWindow(dpy);
#ifdef LAUNCHER
MenuReader *menuReader = new MenuReader(dpy);
LauncherWindow *launcherWindow = 0;
if (! settings->disableLauncher())
launcherWindow = new LauncherWindow(dpy/*, list*/);
#endif
#ifdef LAUNCHER
DBus *dbus = new DBus(eventLoop, teleWindow, launcherWindow);
#else
DBus *dbus = new DBus(eventLoop, teleWindow);
#endif
eventLoop->eventLoop();
delete eventLoop;
delete dbus;
delete teleWindow;
#ifdef LAUNCHER
delete launcherWindow;
delete menuReader;
#endif
delete resources;
delete settings;
XCloseDisplay(dpy);
}