annotate src/subtle/subtle.c @ 3285:6eb80e958ce6 tip

Fixed length of compare
author unexist
date Thu, 16 May 2019 14:20:38 +0200
parents 60b19aa1a187
children
rev   line source
131
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 107
diff changeset
1
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 107
diff changeset
2 /**
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
3 * @package subtle
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
4 *
1746
aacab4ac0a62 Removed older SUBLET macro
unexist
parents: 1731
diff changeset
5 * @file Main functions
3272
60b19aa1a187 Happy new year!
unexist
parents: 3257
diff changeset
6 * @copyright (c) 2005-2018 Christoph Kappel <unexist@subforge.org>
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
7 * @version $Id$
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
8 *
2736
72e9e761d6a1 Updated file header
unexist
parents: 2677
diff changeset
9 * This program can be distributed under the terms of the GNU GPLv2.
72e9e761d6a1 Updated file header
unexist
parents: 2677
diff changeset
10 * See the file COPYING for details.
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
11 **/
131
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 107
diff changeset
12
3084
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
13 #include <stdarg.h>
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
14 #include <getopt.h>
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
15 #include <sys/wait.h>
1800
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
16 #include <sys/time.h>
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
17 #include <signal.h>
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
18 #include <unistd.h>
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
19 #include "subtle.h"
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
20
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
21 #ifdef HAVE_EXECINFO_H
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
22 #include <execinfo.h>
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
23 #endif /* HAVE_EXECINFO_H */
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
24
613
bd4db51d20cd Replaced SubDisplay by SubSubtle and moved new/kill code to main.c
unexist
parents: 585
diff changeset
25 SubSubtle *subtle = NULL;
42
d7ddeefc94af [svn] Completely re-wrote Lua functions
unexist
parents: 9
diff changeset
26
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
27 /* SubtleSignal {{{ */
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
28 static void
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
29 SubtleSignal(int signum)
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
30 {
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
31 switch(signum)
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
32 {
2594
037e044a8d54 Updated #175: Moved actual reload from signal handler to event loop
unexist
parents: 2572
diff changeset
33 case SIGCHLD: wait(NULL); break;
037e044a8d54 Updated #175: Moved actual reload from signal handler to event loop
unexist
parents: 2572
diff changeset
34 case SIGHUP: if(subtle) subtle->flags |= SUB_SUBTLE_RELOAD; break;
037e044a8d54 Updated #175: Moved actual reload from signal handler to event loop
unexist
parents: 2572
diff changeset
35 case SIGINT: if(subtle) subtle->flags &= ~SUB_SUBTLE_RUN; break;
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
36 case SIGSEGV:
2262
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
37 {
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
38 #ifdef HAVE_EXECINFO_H
2262
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
39 int i, frames = 0;
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
40 void *callstack[10] = { 0 };
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
41 char **strings = NULL;
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
42
2262
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
43 frames = backtrace(callstack, 10);
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
44 strings = backtrace_symbols(callstack, frames);
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
45
2340
2a7b8baacce7 Added some newlines to stacktrace output
unexist
parents: 2321
diff changeset
46 printf("\n\nLast %d stack frames:\n", frames);
2262
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
47
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
48 for(i = 0; i < frames; i++)
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
49 printf("%s\n", strings[i]);
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
50
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
51 free(strings);
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
52 #endif /* HAVE_EXECINFO_H */
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
53
2379
f071d5ae2ed1 Fixed bugreport address in segfault handler
unexist
parents: 2375
diff changeset
54 printf("\nPlease report this bug at %s\n", PKG_BUGREPORT);
2262
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
55 abort();
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
56 }
7a4e16610fa5 Fixed backtrace output
unexist
parents: 2234
diff changeset
57 break;
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
58 }
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
59 } /* }}} */
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
60
795
afc8a6f12d5c Added tray stuff here too.
unexist
parents: 723
diff changeset
61 /* SubtleUsage {{{ */
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
62 static void
795
afc8a6f12d5c Added tray stuff here too.
unexist
parents: 723
diff changeset
63 SubtleUsage(void)
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
64 {
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
65 printf("Usage: %s [OPTIONS]\n\n" \
658
af6e4ed11b97 Renamed main.c to subtle.c
unexist
parents: 654
diff changeset
66 "Options:\n" \
3073
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
67 " -c, --config=FILE Load config\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
68 " -d, --display=DISPLAY Connect to DISPLAY\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
69 " -h, --help Show this help and exit\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
70 " -k, --check Check config syntax\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
71 " -n, --no-randr Disable RandR extension (required for Twinview)\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
72 " -r, --replace Replace current window manager\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
73 " -s, --sublets=DIR Load sublets from DIR\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
74 " -v, --version Show version info and exit\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
75 " -l, --level=LEVEL[,LEVEL] Set logging levels\n" \
f776d8883a73 Updated docs
unexist
parents: 3064
diff changeset
76 " -D, --debug Print debugging messages\n" \
2295
0874bf186cad Updated usage info
unexist
parents: 2292
diff changeset
77 "\nPlease report bugs at %s\n",
1338
49379b0086f3 Removed default values from usage message
unexist
parents: 1327
diff changeset
78 PKG_NAME, PKG_BUGREPORT);
496
47879cb198fd Converted to new subsys and updated signal handler
unexist
parents: 481
diff changeset
79 } /* }}} */
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
80
795
afc8a6f12d5c Added tray stuff here too.
unexist
parents: 723
diff changeset
81 /* SubtleVersion {{{ */
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
82 static void
795
afc8a6f12d5c Added tray stuff here too.
unexist
parents: 723
diff changeset
83 SubtleVersion(void)
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
84 {
3272
60b19aa1a187 Happy new year!
unexist
parents: 3257
diff changeset
85 printf("%s %s - Copyright (c) 2005-2018 Christoph Kappel\n" \
658
af6e4ed11b97 Renamed main.c to subtle.c
unexist
parents: 654
diff changeset
86 "Released under the GNU General Public License\n" \
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
87 "Compiled for X%dR%d and Ruby %s\n",
658
af6e4ed11b97 Renamed main.c to subtle.c
unexist
parents: 654
diff changeset
88 PKG_NAME, PKG_VERSION, X_PROTOCOL, X_PROTOCOL_REVISION, RUBY_VERSION);
496
47879cb198fd Converted to new subsys and updated signal handler
unexist
parents: 481
diff changeset
89 } /* }}} */
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
90
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
91 #ifdef DEBUG
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
92 /* SubtleLevel {{{ */
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
93 static int
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
94 SubtleLevel(const char *str)
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
95 {
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
96 int level = 0;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
97 char *tokens = NULL, *tok = NULL;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
98
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
99 tokens = strdup(str);
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
100 tok = strtok((char *)tokens, ",");
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
101
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
102 /* Parse levels */
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
103 while(tok)
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
104 {
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
105 if(0 == strncasecmp(tok, "warnings", 8))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
106 level |= SUB_LOG_WARN;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
107 else if(0 == strncasecmp(tok, "error", 5))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
108 level |= SUB_LOG_ERROR;
2737
cd1b7f3c4d1b Added loglevel for sublets
unexist
parents: 2736
diff changeset
109 else if(0 == strncasecmp(tok, "sublet", 6))
cd1b7f3c4d1b Added loglevel for sublets
unexist
parents: 2736
diff changeset
110 level |= SUB_LOG_SUBLET;
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
111 else if(0 == strncasecmp(tok, "depcrecated", 11))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
112 level |= SUB_LOG_DEPRECATED;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
113 else if(0 == strncasecmp(tok, "events", 6))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
114 level |= SUB_LOG_EVENTS;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
115 else if(0 == strncasecmp(tok, "ruby", 4))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
116 level |= SUB_LOG_RUBY;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
117 else if(0 == strncasecmp(tok, "xerror", 6))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
118 level |= SUB_LOG_XERROR;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
119 else if(0 == strncasecmp(tok, "subtle", 6))
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
120 level |= SUB_LOG_SUBTLE;
3285
6eb80e958ce6 Fixed length of compare
unexist
parents: 3272
diff changeset
121 else if(0 == strncasecmp(tok, "debug", 5))
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
122 level |= SUB_LOG_DEBUG;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
123
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
124 tok = strtok(NULL, ",");
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
125 }
2555
552c20359bef Removed debugging code
unexist
parents: 2553
diff changeset
126
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
127 free(tokens);
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
128
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
129 return level;
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
130 } /* }}} */
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
131 #endif /* DEBUG */
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
132
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
133 /* Public */
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
134
1800
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
135 /** subSubtleFind {{{
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
136 * @brief Find data with the context manager
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
137 * @param[in] win A #Window
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
138 * @param[in] id Context id
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
139 * @return Returns found data pointer or \p NULL
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
140 **/
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
141
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
142 XPointer *
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
143 subSubtleFind(Window win,
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
144 XContext id)
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
145 {
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
146 XPointer *data = NULL;
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
147
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
148 return XCNOENT != XFindContext(subtle->dpy, win, id, (XPointer *)&data) ? data : NULL;
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
149 } /* }}} */
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
150
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
151 /** subSubtleTime {{{
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
152 * @brief Get the current time in seconds
1800
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
153 * @return Returns time in seconds
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
154 **/
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
155
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
156 time_t
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
157 subSubtleTime(void)
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
158 {
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
159 struct timeval tv;
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
160
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
161 gettimeofday(&tv, 0);
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
162
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
163 return tv.tv_sec;
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
164 } /* }}} */
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
165
3084
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
166 /** subSubtleLog {{{
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
167 * @brief Print messages depending on type
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
168 * @param[in] level Message level
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
169 * @param[in] file File name
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
170 * @param[in] line Line number
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
171 * @param[in] format Message format
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
172 * @param[in] ... Variadic arguments
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
173 **/
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
174
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
175 void
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
176 subSubtleLog(int level,
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
177 const char *file,
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
178 int line,
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
179 const char *format,
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
180 ...)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
181 {
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
182 va_list ap;
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
183 char buf[255];
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
184
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
185 #ifdef DEBUG
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
186 if(!(subtle->loglevel & level)) return;
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
187 #endif /* DEBUG */
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
188
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
189 /* Get variadic arguments */
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
190 va_start(ap, format);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
191 vsnprintf(buf, sizeof(buf), format, ap);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
192 va_end(ap);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
193
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
194 /* Print according to loglevel */
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
195 if(level & SUB_LOG_WARN)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
196 fprintf(stdout, "<WARNING> %s", buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
197 else if(level & SUB_LOG_ERROR)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
198 fprintf(stderr, "<ERROR> %s", buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
199 else if(level & SUB_LOG_SUBLET)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
200 fprintf(stderr, "<WARNING SUBLET %s> %s", file, buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
201 else if(level & SUB_LOG_DEPRECATED)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
202 fprintf(stdout, "<DEPRECATED> %s", buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
203 #ifdef DEBUG
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
204 else if(level & SUB_LOG_EVENTS)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
205 fprintf(stderr, "<EVENTS> %s:%d: %s", file, line, buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
206 else if(level & SUB_LOG_RUBY)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
207 fprintf(stderr, "<RUBY> %s:%d: %s", file, line, buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
208 else if(level & SUB_LOG_XERROR)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
209 fprintf(stderr, "<XERROR> %s", buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
210 else if(level & SUB_LOG_SUBTLE)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
211 fprintf(stderr, "<SUBTLE> %s:%d: %s", file, line, buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
212 else if(level & SUB_LOG_DEBUG)
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
213 fprintf(stderr, "<DEBUG> %s:%d: %s", file, line, buf);
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
214 #endif /* DEBUG */
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
215 } /* }}} */
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
216
2283
a71604c0059e Fixed docs
unexist
parents: 2263
diff changeset
217 /** subSubtleFinish {{{
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
218 * @brief Finish subtle
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
219 **/
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
220
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
221 void
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
222 subSubtleFinish(void)
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
223 {
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
224 if(subtle)
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
225 {
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
226 if(subtle->dpy)
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
227 XSync(subtle->dpy, False); ///< Sync before going on
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
228
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
229 /* Handle hooks first */
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
230 if(subtle->hooks)
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
231 {
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
232 /* Hook: Exit */
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
233 subHookCall(SUB_HOOK_EXIT, NULL);
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
234
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
235 /* Clear hooks first to stop calling */
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
236 subArrayClear(subtle->hooks, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
237 }
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
238
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
239 /* Kill arrays */
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
240 if(subtle->clients) subArrayKill(subtle->clients, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
241 if(subtle->grabs) subArrayKill(subtle->grabs, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
242 if(subtle->gravities) subArrayKill(subtle->gravities, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
243 if(subtle->screens) subArrayKill(subtle->screens, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
244 if(subtle->sublets) subArrayKill(subtle->sublets, False);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
245 if(subtle->tags) subArrayKill(subtle->tags, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
246 if(subtle->trays) subArrayKill(subtle->trays, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
247 if(subtle->views) subArrayKill(subtle->views, True);
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
248 if(subtle->hooks) subArrayKill(subtle->hooks, False);
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
249
3064
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
250 /* Reset styles to free fonts and substyles */
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
251 subStyleReset(&subtle->styles.all, 0);
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
252 subStyleReset(&subtle->styles.views, 0);
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
253 subStyleReset(&subtle->styles.title, 0);
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
254 subStyleReset(&subtle->styles.sublets, 0);
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
255 subStyleReset(&subtle->styles.separator, 0);
21c86c9f0ee3 Updated #258: Added resetting of styles
unexist
parents: 2972
diff changeset
256 subStyleReset(&subtle->styles.clients, 0);
3249
b540d76235bf Merged changes from bitbucket
unexist
parents: 3239
diff changeset
257 subStyleReset(&subtle->styles.panel_top, 0);
b540d76235bf Merged changes from bitbucket
unexist
parents: 3239
diff changeset
258 subStyleReset(&subtle->styles.panel_bot, 0);
b540d76235bf Merged changes from bitbucket
unexist
parents: 3239
diff changeset
259 subStyleReset(&subtle->styles.tray, 0);
2954
1d3e61a6e0e4 Updated #240: Added style state removal to subSubtleFinish()
unexist
parents: 2946
diff changeset
260
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
261 subEventFinish();
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
262 subRubyFinish();
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
263 subEwmhFinish();
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
264 subDisplayFinish();
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
265
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
266 free(subtle);
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
267 }
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
268 } /* }}} */
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
269
481
fec96acfd7d7 Added folds and updated doc
unexist
parents: 468
diff changeset
270 /* main {{{ */
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
271 int
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
272 main(int argc,
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
273 char *argv[])
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
274 {
2835
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
275 int c;
1261
5101128f5e83 Moved config/sublet paths into global subtle structure
unexist
parents: 1248
diff changeset
276 char *display = NULL;
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
277 struct sigaction sa;
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
278 const struct option long_options[] =
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
279 {
2171
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
280 { "config", required_argument, 0, 'c' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
281 { "display", required_argument, 0, 'd' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
282 { "help", no_argument, 0, 'h' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
283 { "check", no_argument, 0, 'k' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
284 { "no-randr", no_argument, 0, 'n' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
285 { "replace", no_argument, 0, 'r' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
286 { "sublets", required_argument, 0, 's' },
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
287 { "version", no_argument, 0, 'v' },
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
288 { "level", required_argument, 0, 'l' },
2171
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
289 { "debug", no_argument, 0, 'D' },
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
290 { 0, 0, 0, 0}
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
291 };
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
292
1746
aacab4ac0a62 Removed older SUBLET macro
unexist
parents: 1731
diff changeset
293 /* Create subtle */
aacab4ac0a62 Removed older SUBLET macro
unexist
parents: 1731
diff changeset
294 subtle = (SubSubtle *)(subSharedMemoryAlloc(1, sizeof(SubSubtle)));
3096
be88cd9a972a Fixed default loglevel
unexist
parents: 3084
diff changeset
295 subtle->flags |= (SUB_SUBTLE_XRANDR|SUB_SUBTLE_XINERAMA);
be88cd9a972a Fixed default loglevel
unexist
parents: 3084
diff changeset
296 subtle->loglevel = DEFAULT_LOGLEVEL;
1261
5101128f5e83 Moved config/sublet paths into global subtle structure
unexist
parents: 1248
diff changeset
297
1746
aacab4ac0a62 Removed older SUBLET macro
unexist
parents: 1731
diff changeset
298 /* Parse arguments */
3096
be88cd9a972a Fixed default loglevel
unexist
parents: 3084
diff changeset
299 while(-1 != (c = getopt_long(argc, argv, "c:d:hknrs:vl:D",
be88cd9a972a Fixed default loglevel
unexist
parents: 3084
diff changeset
300 long_options, NULL)))
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
301 {
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
302 switch(c)
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
303 {
2171
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
304 case 'c': subtle->paths.config = optarg; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
305 case 'd': display = optarg; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
306 case 'h': SubtleUsage(); return 0;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
307 case 'k': subtle->flags |= SUB_SUBTLE_CHECK; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
308 case 'n': subtle->flags &= ~SUB_SUBTLE_XRANDR; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
309 case 'r': subtle->flags |= SUB_SUBTLE_REPLACE; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
310 case 's': subtle->paths.sublets = optarg; break;
86f6cbd6954c Added --no-randr commandline option
unexist
parents: 2164
diff changeset
311 case 'v': SubtleVersion(); return 0;
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
312 #ifdef DEBUG
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
313 case 'l':
3084
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
314 subtle->loglevel = SubtleLevel(optarg);
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
315 break;
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
316 case 'D':
3084
25396acb4876 Moved logging to subtle.c
unexist
parents: 3074
diff changeset
317 subtle->flags |= SUB_SUBTLE_DEBUG;
3096
be88cd9a972a Fixed default loglevel
unexist
parents: 3084
diff changeset
318 subtle->loglevel |= DEBUG_LOGLEVEL;
1800
0a53570e7e34 Removed SubIcon
unexist
parents: 1754
diff changeset
319 break;
1004
6edb2cf7a0bf Added stuff to assign ruby blocks to grabs
unexist
parents: 998
diff changeset
320 #else /* DEBUG */
2553
ab595fd5690a Added loglevel parser and command line argument
unexist
parents: 2525
diff changeset
321 case 'l':
1118
330b1e53d7a0 Fixed config syntax check
unexist
parents: 1117
diff changeset
322 case 'D':
330b1e53d7a0 Fixed config syntax check
unexist
parents: 1117
diff changeset
323 printf("Please recompile %s with `debug=yes'\n", PKG_NAME);
1004
6edb2cf7a0bf Added stuff to assign ruby blocks to grabs
unexist
parents: 998
diff changeset
324 return 0;
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
325 #endif /* DEBUG */
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
326 case '?':
998
f87be43ee46b Fixed usage messages
unexist
parents: 976
diff changeset
327 printf("Try `%s --help' for more information\n", PKG_NAME);
673
3dcb983f7d64 Removed brackets from return
unexist
parents: 658
diff changeset
328 return -1;
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
329 }
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
330 }
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1860
diff changeset
331
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
332 /* Signal handler */
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
333 sa.sa_handler = SubtleSignal;
2838
9b13c175edc0 Removed sigaction flags to get rid of zombies
unexist
parents: 2835
diff changeset
334 sa.sa_flags = 0;
1578
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
335 memset(&sa.sa_mask, 0, sizeof(sigset_t)); ///< Avoid uninitialized values
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
336 sigemptyset(&sa.sa_mask);
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
337
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
338 sigaction(SIGHUP, &sa, NULL);
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
339 sigaction(SIGINT, &sa, NULL);
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
340 sigaction(SIGSEGV, &sa, NULL);
00fa7fbe9de5 Moved signal handling back to subtle.c
unexist
parents: 1539
diff changeset
341 sigaction(SIGCHLD, &sa, NULL);
9
9ede4af841d2 [svn] Inserted EWMH start code
unexist
parents: 0
diff changeset
342
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
343 /* Load and check config only */
1982
8c08754bae83 Added SUB_SUBTLE_CHECK flag
unexist
parents: 1933
diff changeset
344 if(subtle->flags & SUB_SUBTLE_CHECK)
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
345 {
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
346 subRubyInit();
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
347 subRubyLoadConfig();
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
348 subRubyFinish();
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
349
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
350 free(subtle); ///< We just need to free this
1261
5101128f5e83 Moved config/sublet paths into global subtle structure
unexist
parents: 1248
diff changeset
351
3190
aa6e4508ed34 Updated #283: Moved syntax check handling to ruby.c
unexist
parents: 3168
diff changeset
352 return 0;
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
353 }
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
354
1611
2c6c77ea49c9 Updated code
unexist
parents: 1592
diff changeset
355 /* Alloc arrays */
1501
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
356 subtle->clients = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
357 subtle->grabs = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
358 subtle->gravities = subArrayNew();
1611
2c6c77ea49c9 Updated code
unexist
parents: 1592
diff changeset
359 subtle->hooks = subArrayNew();
1501
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
360 subtle->screens = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
361 subtle->sublets = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
362 subtle->tags = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
363 subtle->trays = subArrayNew();
30c6468c539c Added init/finish for gravities
unexist
parents: 1490
diff changeset
364 subtle->views = subArrayNew();
707
9e17a60b7236 Updated includes and config
unexist
parents: 691
diff changeset
365
642
3ea323f9c385 Updated version info and signal handler
unexist
parents: 616
diff changeset
366 /* Init */
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
367 SubtleVersion();
642
3ea323f9c385 Updated version info and signal handler
unexist
parents: 616
diff changeset
368 subDisplayInit(display);
2292
e73ed6962b74 Updated bugreport address
unexist
parents: 2283
diff changeset
369 subEwmhInit();
2057
d24ade68fe71 Added call to subScreenInit()
unexist
parents: 1990
diff changeset
370 subScreenInit();
642
3ea323f9c385 Updated version info and signal handler
unexist
parents: 616
diff changeset
371 subRubyInit();
691
b1b87a48efa2 Updated due renaming of key.c to grab.c
unexist
parents: 687
diff changeset
372 subGrabInit();
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
373
1004
6edb2cf7a0bf Added stuff to assign ruby blocks to grabs
unexist
parents: 998
diff changeset
374 /* Load */
1261
5101128f5e83 Moved config/sublet paths into global subtle structure
unexist
parents: 1248
diff changeset
375 subRubyLoadConfig();
5101128f5e83 Moved config/sublet paths into global subtle structure
unexist
parents: 1248
diff changeset
376 subRubyLoadSublets();
1616
ba582b406d58 Added subRubyLoadPanels()
unexist
parents: 1611
diff changeset
377 subRubyLoadPanels();
1004
6edb2cf7a0bf Added stuff to assign ruby blocks to grabs
unexist
parents: 998
diff changeset
378
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
379 /* Display */
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
380 subDisplayConfigure();
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
381 subDisplayScan();
1012
17620f229c3e Added subDisplayConfigure for applying config stuff
unexist
parents: 1004
diff changeset
382
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 613
diff changeset
383 subEventLoop();
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
384
2835
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
385 /* Restart if necessary */
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
386 if(subtle->flags & SUB_SUBTLE_RESTART)
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
387 {
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
388 subSubtleFinish();
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
389
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
390 printf("Restarting\n");
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
391
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
392 execvp(argv[0], argv);
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
393 }
2835
488ed05306aa Updated sigaction flags and refactored restart handler
unexist
parents: 2737
diff changeset
394 else subSubtleFinish();
1885
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
395
3484ba64142e Added subSubtleFinish(), SUB_GRAB_SUBTLE_RESTART and SUB_SUBTLE_RESTART
unexist
parents: 1876
diff changeset
396 printf("Exit\n");
1426
3cc1740c1894 Moved signal handling code into event
unexist
parents: 1423
diff changeset
397
3cc1740c1894 Moved signal handling code into event
unexist
parents: 1423
diff changeset
398 return 0;
496
47879cb198fd Converted to new subsys and updated signal handler
unexist
parents: 481
diff changeset
399 } /* }}} */
799
2803ba78c7c8 Added vim instructions
unexist
parents: 795
diff changeset
400
2803ba78c7c8 Added vim instructions
unexist
parents: 795
diff changeset
401 // vim:ts=2:bs=2:sw=2:et:fdm=marker