54 |
int window_placement, snap_to_border, snap_to_windows, snap_width; |
int window_placement, snap_to_border, snap_to_windows, snap_width; |
55 |
int workspace_count = -1, wrap_workspaces; |
int workspace_count = -1, wrap_workspaces; |
56 |
|
|
57 |
int handleXError(Display * dpy, XErrorEvent * err) |
int |
58 |
|
handleXError (Display * dpy, XErrorEvent * err) |
59 |
{ |
{ |
60 |
switch (err->error_code) |
switch (err->error_code) |
61 |
{ |
{ |
62 |
case BadAccess: |
case BadAccess: |
63 |
if(err->resourceid == root) |
if (err->resourceid == root) |
64 |
{ |
{ |
65 |
fprintf(stderr, "%s: Another window manager is running\n", |
fprintf (stderr, "%s: Another window manager is running\n", |
66 |
progname); |
progname); |
67 |
exit(1); |
exit (1); |
68 |
} |
} |
69 |
} |
} |
70 |
return 0; |
return 0; |
71 |
} |
} |
72 |
|
|
73 |
void cleanUp() |
void |
74 |
|
cleanUp () |
75 |
{ |
{ |
76 |
int i; |
int i; |
77 |
|
|
78 |
#ifdef DEBUG |
#ifdef DEBUG |
79 |
printf("entering cleanUp\n"); |
printf ("entering cleanUp\n"); |
80 |
#endif |
#endif |
81 |
|
|
82 |
clientUnframeAll(); |
clientUnframeAll (); |
83 |
unloadSettings(); |
unloadSettings (); |
84 |
XFreeCursor(dpy, root_cursor); |
XFreeCursor (dpy, root_cursor); |
85 |
XFreeCursor(dpy, move_cursor); |
XFreeCursor (dpy, move_cursor); |
86 |
for(i = 0; i < 4; i++) |
for (i = 0; i < 4; i++) |
87 |
XFreeCursor(dpy, resize_cursor[i]); |
XFreeCursor (dpy, resize_cursor[i]); |
88 |
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
XSetInputFocus (dpy, root, RevertToPointerRoot, CurrentTime); |
89 |
XCloseDisplay(dpy); |
XCloseDisplay (dpy); |
90 |
} |
} |
91 |
|
|
92 |
void handleSignal(int sig) |
void |
93 |
|
handleSignal (int sig) |
94 |
{ |
{ |
95 |
int *status; |
int *status; |
96 |
#ifdef DEBUG |
#ifdef DEBUG |
97 |
printf("entering handleSignal\n"); |
printf ("entering handleSignal\n"); |
98 |
#endif |
#endif |
99 |
|
|
100 |
switch (sig) |
switch (sig) |
101 |
{ |
{ |
102 |
case SIGINT: |
case SIGINT: |
103 |
case SIGTERM: |
case SIGTERM: |
104 |
quit = True; |
quit = True; |
105 |
break; |
break; |
106 |
case SIGSEGV: |
case SIGSEGV: |
107 |
fprintf(stderr, "%s: Segmentation fault\n", progname); |
fprintf (stderr, "%s: Segmentation fault\n", progname); |
108 |
cleanUp(); |
cleanUp (); |
109 |
exit(1); |
exit (1); |
110 |
break; |
break; |
111 |
case SIGHUP: |
case SIGHUP: |
112 |
reload = True; |
reload = True; |
113 |
break; |
break; |
114 |
case SIGCHLD: |
case SIGCHLD: |
115 |
printf("waiting for a child\n"); |
printf ("waiting for a child\n"); |
116 |
waitpid(-1, status, WNOHANG); |
waitpid (-1, status, WNOHANG); |
117 |
break; |
break; |
118 |
} |
} |
119 |
} |
} |
120 |
|
|
121 |
void initialize(int argc, char **argv) |
void |
122 |
|
initialize (int argc, char **argv) |
123 |
{ |
{ |
124 |
struct sigaction act; |
struct sigaction act; |
125 |
char *locale; |
char *locale; |
126 |
int dummy; |
int dummy; |
127 |
|
|
128 |
#ifdef DEBUG |
#ifdef DEBUG |
129 |
printf("entering initialize\n"); |
printf ("entering initialize\n"); |
130 |
#endif |
#endif |
131 |
|
|
132 |
progname = argv[0]; |
progname = argv[0]; |
133 |
|
|
134 |
printf |
printf |
135 |
("\n\nOroborus\n(c) 2001 Ken Lynch\n(c) 2002 Stefan Pfetzing\nDistributed under the terms and conditions of the GPL\n\n"); |
("\n\nOroborus\n(c) 2001 Ken Lynch\n(c) 2002 Stefan Pfetzing\nDistributed under the terms and conditions of the GPL\n\n"); |
136 |
|
|
137 |
locale = setlocale(LC_ALL, ""); |
locale = setlocale (LC_ALL, ""); |
138 |
|
|
139 |
stat_argv = argv; |
stat_argv = argv; |
|
|
|
|
if(!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX") || |
|
|
!XSupportsLocale()) |
|
|
use_fontset = False; |
|
|
else |
|
|
use_fontset = True; |
|
140 |
|
|
141 |
dpy = XOpenDisplay(NULL); |
if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX") || |
142 |
if(!dpy) |
!XSupportsLocale ()) |
143 |
|
use_fontset = False; |
144 |
|
else |
145 |
|
use_fontset = True; |
146 |
|
|
147 |
|
dpy = XOpenDisplay (NULL); |
148 |
|
if (!dpy) |
149 |
{ |
{ |
150 |
fprintf(stderr, "%s: failed to open display\n", progname); |
fprintf (stderr, "%s: failed to open display\n", progname); |
151 |
exit(1); |
exit (1); |
152 |
} |
} |
153 |
|
|
154 |
act.sa_handler = handleSignal; |
act.sa_handler = handleSignal; |
155 |
act.sa_flags = 0; |
act.sa_flags = 0; |
156 |
if(sigaction(SIGINT, &act, NULL)) |
if (sigaction (SIGINT, &act, NULL)) |
157 |
fprintf(stderr, "Warning, could not install SIGINT Handler!\n"); |
fprintf (stderr, "Warning, could not install SIGINT Handler!\n"); |
158 |
if(sigaction(SIGTERM, &act, NULL)) |
if (sigaction (SIGTERM, &act, NULL)) |
159 |
fprintf(stderr, "Warning, could not install SIGTERM Handler!\n"); |
fprintf (stderr, "Warning, could not install SIGTERM Handler!\n"); |
160 |
if(sigaction(SIGHUP, &act, NULL)) |
if (sigaction (SIGHUP, &act, NULL)) |
161 |
fprintf(stderr, "Warning, could not install SIGHUP Handler!\n"); |
fprintf (stderr, "Warning, could not install SIGHUP Handler!\n"); |
162 |
if(sigaction(SIGSEGV, &act, NULL)) |
if (sigaction (SIGSEGV, &act, NULL)) |
163 |
fprintf(stderr, "Warning, could not install SIGSEGV Handler!\n"); |
fprintf (stderr, "Warning, could not install SIGSEGV Handler!\n"); |
164 |
if(sigaction(SIGCHLD, &act, NULL)) |
if (sigaction (SIGCHLD, &act, NULL)) |
165 |
fprintf(stderr, "Warning, could not install SIGCHLD Handler!\n"); |
fprintf (stderr, "Warning, could not install SIGCHLD Handler!\n"); |
166 |
|
|
167 |
root = XDefaultRootWindow(dpy); |
root = XDefaultRootWindow (dpy); |
168 |
screen = XDefaultScreen(dpy); |
screen = XDefaultScreen (dpy); |
169 |
depth = DefaultDepth(dpy, screen); |
depth = DefaultDepth (dpy, screen); |
170 |
cmap = DefaultColormap(dpy, screen); |
cmap = DefaultColormap (dpy, screen); |
171 |
|
|
172 |
XSetErrorHandler(handleXError); |
XSetErrorHandler (handleXError); |
173 |
XSelectInput(dpy, root, |
XSelectInput (dpy, root, |
174 |
SubstructureNotifyMask | SubstructureRedirectMask | |
SubstructureNotifyMask | SubstructureRedirectMask | |
175 |
ButtonPressMask | ButtonReleaseMask | FocusChangeMask | |
ButtonPressMask | ButtonReleaseMask | FocusChangeMask | |
176 |
PropertyChangeMask); |
PropertyChangeMask); |
177 |
|
|
178 |
shape = XShapeQueryExtension(dpy, &shape_event, &dummy); |
shape = XShapeQueryExtension (dpy, &shape_event, &dummy); |
179 |
|
|
180 |
initICCCMHints(dpy); |
initICCCMHints (dpy); |
181 |
initMotifHints(dpy); |
initMotifHints (dpy); |
182 |
initGnomeHints(dpy); |
initGnomeHints (dpy); |
183 |
gnome_win = XCreateSimpleWindow(dpy, root, -1000, -1000, 5, 5, 0, 0, 0); |
gnome_win = XCreateSimpleWindow (dpy, root, -1000, -1000, 5, 5, 0, 0, 0); |
184 |
setGnomeHint(dpy, root, win_supporting_wm_check, gnome_win); |
setGnomeHint (dpy, root, win_supporting_wm_check, gnome_win); |
185 |
setGnomeHint(dpy, gnome_win, win_supporting_wm_check, gnome_win); |
setGnomeHint (dpy, gnome_win, win_supporting_wm_check, gnome_win); |
186 |
setGnomeHint(dpy, root, win_desktop_button_proxy, gnome_win); |
setGnomeHint (dpy, root, win_desktop_button_proxy, gnome_win); |
187 |
setGnomeHint(dpy, gnome_win, win_desktop_button_proxy, gnome_win); |
setGnomeHint (dpy, gnome_win, win_desktop_button_proxy, gnome_win); |
188 |
getGnomeHint(dpy, root, win_workspace, &workspace); |
getGnomeHint (dpy, root, win_workspace, &workspace); |
189 |
getGnomeDesktopMargins(dpy, margins); |
getGnomeDesktopMargins (dpy, margins); |
190 |
|
|
191 |
root_cursor = XCreateFontCursor(dpy, XC_left_ptr); |
root_cursor = XCreateFontCursor (dpy, XC_left_ptr); |
192 |
move_cursor = XCreateFontCursor(dpy, XC_fleur); |
move_cursor = XCreateFontCursor (dpy, XC_fleur); |
193 |
resize_cursor[CORNER_TOP_LEFT] = XCreateFontCursor(dpy, XC_top_left_corner); |
resize_cursor[CORNER_TOP_LEFT] = |
194 |
resize_cursor[CORNER_TOP_RIGHT] = |
XCreateFontCursor (dpy, XC_top_left_corner); |
195 |
XCreateFontCursor(dpy, XC_top_right_corner); |
resize_cursor[CORNER_TOP_RIGHT] = |
196 |
resize_cursor[CORNER_BOTTOM_LEFT] = |
XCreateFontCursor (dpy, XC_top_right_corner); |
197 |
XCreateFontCursor(dpy, XC_bottom_left_corner); |
resize_cursor[CORNER_BOTTOM_LEFT] = |
198 |
resize_cursor[CORNER_BOTTOM_RIGHT] = |
XCreateFontCursor (dpy, XC_bottom_left_corner); |
199 |
XCreateFontCursor(dpy, XC_bottom_right_corner); |
resize_cursor[CORNER_BOTTOM_RIGHT] = |
200 |
XDefineCursor(dpy, root, root_cursor); |
XCreateFontCursor (dpy, XC_bottom_right_corner); |
201 |
|
XDefineCursor (dpy, root, root_cursor); |
202 |
|
|
203 |
loadSettings(); |
loadSettings (); |
204 |
clientFrameAll(); |
clientFrameAll (); |
205 |
|
|
206 |
XMapWindow(dpy, gnome_win); |
XMapWindow (dpy, gnome_win); |
207 |
XSetInputFocus(dpy, gnome_win, RevertToNone, CurrentTime); |
XSetInputFocus (dpy, gnome_win, RevertToNone, CurrentTime); |
208 |
} |
} |
209 |
|
|
210 |
int main(int argc, char **argv) |
int |
211 |
|
main (int argc, char **argv) |
212 |
{ |
{ |
213 |
initialize(argc, argv); |
initialize (argc, argv); |
214 |
eventLoop(); |
eventLoop (); |
215 |
cleanUp(); |
cleanUp (); |
216 |
return 0; |
return 0; |
217 |
} |
} |