New upstream version 1.4.2
Mateusz Ĺukasik
1 year, 5 months ago
0 | Version 1.4.2, Tue Nov 8 2022 | |
1 | ||
2 | * Ignore NumLock correctly when processing events [Kacper Gutowski] | |
3 | ||
4 | Version 1.4.1, Wed Nov 2 2022 | |
5 | ||
6 | * Add "raise" function to complement "lower" [Juan Pedro Vallejo] | |
7 | * Allow '=' in option arguments, needed for -bind [Burkhard Kleemeier] | |
8 | ||
0 | 9 | Version 1.4.0, Tue Sep 27 2022 |
1 | 10 | |
2 | 11 | * Send more accurate response to _NET_REQUEST_FRAME_EXTENTS. |
111 | 111 | ############################################################################ |
112 | 112 | # You shouldn't need to change anything beyond this point |
113 | 113 | |
114 | version = 1.4.0 | |
114 | version = 1.4.2 | |
115 | 115 | distdir = evilwm-$(version) |
116 | 116 | |
117 | 117 | # Generally shouldn't be overridden: |
218 | 218 | |
219 | 219 | next Cycle to the next window. |
220 | 220 | |
221 | raise | |
222 | ||
223 | Raises the current window. | |
224 | ||
221 | 225 | resize When bound to a button, resizes a window with the mouse. |
222 | 226 | |
223 | 227 | When bound to a key, if the relative flag is specified, modifies |
250 | 254 | altmask shift |
251 | 255 | |
252 | 256 | Button binds |
253 | bind button1=move,drag | |
254 | bind button2=resize,drag | |
257 | bind button1=move | |
258 | bind button2=resize | |
255 | 259 | bind button3=lower |
256 | 260 | |
257 | 261 | Keyboard binds |
334 | 338 | |
335 | 339 | |
336 | 340 | |
337 | evilwm-1.4 September 2022 evilwm(1) | |
341 | evilwm-1.4 October 2022 evilwm(1) |
96 | 96 | { "lower", func_lower, FL_CLIENT }, |
97 | 97 | { "move", func_move, FL_CLIENT }, |
98 | 98 | { "next", func_next, 0 }, |
99 | { "raise", func_raise, FL_CLIENT }, | |
99 | 100 | { "resize", func_resize, FL_CLIENT }, |
100 | 101 | { "spawn", func_spawn, 0 }, |
101 | 102 | { "vdesk", func_vdesk, FL_SCREEN }, |
452 | 453 | |
453 | 454 | for (struct list *l = controls; l; l = l->next) { |
454 | 455 | struct bind *bind = l->data; |
455 | if (bind->type == KeyPress && key == bind->control.key && (e->state & KEY_STATE_MASK) == bind->state) { | |
456 | if (bind->type == KeyPress && key == bind->control.key && (e->state & KEY_STATE_MASK & ~numlockmask) == (bind->state & ~numlockmask)) { | |
456 | 457 | void *sptr = NULL; |
457 | 458 | if (bind->flags & FL_CLIENT) { |
458 | 459 | sptr = current; |
474 | 475 | void bind_handle_button(XButtonEvent *e) { |
475 | 476 | for (struct list *l = controls; l; l = l->next) { |
476 | 477 | struct bind *bind = l->data; |
477 | if (bind->type == ButtonPress && e->button == bind->control.button && (e->state & BUTTON_STATE_MASK) == bind->state) { | |
478 | if (bind->type == ButtonPress && e->button == bind->control.button && (e->state & BUTTON_STATE_MASK & ~numlockmask) == (bind->state & ~numlockmask)) { | |
478 | 479 | void *sptr = NULL; |
479 | 480 | if (bind->flags & FL_CLIENT) { |
480 | 481 | sptr = find_client(e->window); |
137 | 137 | |
138 | 138 | // Find out which modifier is NumLock - for every grab, we need to also |
139 | 139 | // grab the combination where this is set. |
140 | numlockmask = 0; | |
140 | 141 | XModifierKeymap *modmap = XGetModifierMapping(display.dpy); |
141 | 142 | for (unsigned i = 0; i < 8; i++) { |
142 | 143 | for (unsigned j = 0; j < (unsigned)modmap->max_keypermod; j++) { |
69 | 69 | |
70 | 70 | <body> |
71 | 71 | |
72 | <h1 man:date='September 2022' man:section='1' man:dist='evilwm-1.4' pdf:title="evilwm 1.4" pdf:author="Ciaran Anscomb">evilwm</h1> | |
72 | <h1 man:date='October 2022' man:section='1' man:dist='evilwm-1.4' pdf:title="evilwm 1.4" pdf:author="Ciaran Anscomb">evilwm</h1> | |
73 | 73 | |
74 | 74 | |
75 | 75 | <h2 id='name'>NAME</h2> |
389 | 389 | <dt><code>next</code> |
390 | 390 | |
391 | 391 | <dd>Cycle to the next window. |
392 | ||
393 | <dt><code>raise</code> | |
394 | ||
395 | <p>Raises the current window. | |
392 | 396 | |
393 | 397 | <dt><code>resize</code> |
394 | 398 | |
439 | 443 | <h3>Button binds</h3> |
440 | 444 | |
441 | 445 | <pre> |
442 | bind button1=move,drag | |
443 | bind button2=resize,drag | |
446 | bind button1=move | |
447 | bind button2=resize | |
444 | 448 | bind button3=lower |
445 | 449 | </pre> |
446 | 450 |
80 | 80 | . pdfinfo /Author Ciaran Anscomb |
81 | 81 | .\} |
82 | 82 | . |
83 | .TH "evilwm" "1" "September 2022" "evilwm-1.4" | |
83 | .TH "evilwm" "1" "October 2022" "evilwm-1.4" | |
84 | 84 | .hy 0 |
85 | 85 | .nh |
86 | 86 | .H1 NAME |
258 | 258 | \f(CBnext\fR |
259 | 259 | Cycle to the next window. |
260 | 260 | .TP |
261 | \f(CBraise\fR | |
262 | .PP | |
263 | Raises the current window. | |
264 | .TP | |
261 | 265 | \f(CBresize\fR |
262 | 266 | When bound to a button, resizes a window with the mouse. |
263 | 267 | .IP |
285 | 289 | .H2 Button binds |
286 | 290 | .IP |
287 | 291 | .EX |
288 | bind\ button1=move,drag | |
289 | bind\ button2=resize,drag | |
292 | bind\ button1=move | |
293 | bind\ button2=resize | |
290 | 294 | bind\ button3=lower |
291 | 295 | .EE |
292 | 296 | .H2 Keyboard binds |
75 | 75 | } |
76 | 76 | |
77 | 77 | void func_lower(void *sptr, XEvent *e, unsigned flags) { |
78 | if (!(flags & FL_CLIENT)) | |
79 | return; | |
80 | struct client *c = sptr; | |
78 | struct client *c = sptr; | |
79 | if (!(flags & FL_CLIENT) || !c) | |
80 | return; | |
81 | 81 | (void)e; |
82 | 82 | client_lower(c); |
83 | 83 | } |
145 | 145 | XUngrabKeyboard(display.dpy, CurrentTime); |
146 | 146 | } |
147 | 147 | clients_tab_order = list_to_head(clients_tab_order, current); |
148 | } | |
149 | ||
150 | void func_raise(void *sptr, XEvent *e, unsigned flags) { | |
151 | struct client *c = sptr; | |
152 | if (!(flags & FL_CLIENT) || !c) | |
153 | return; | |
154 | (void)e; | |
155 | client_raise(c); | |
148 | 156 | } |
149 | 157 | |
150 | 158 | void func_resize(void *sptr, XEvent *e, unsigned flags) { |
35 | 35 | void func_lower(void *, XEvent *, unsigned); |
36 | 36 | void func_move(void *, XEvent *, unsigned); |
37 | 37 | void func_next(void *, XEvent *, unsigned); |
38 | void func_raise(void *, XEvent *, unsigned); | |
38 | 39 | void func_resize(void *, XEvent *, unsigned); |
39 | 40 | void func_spawn(void *, XEvent *, unsigned); |
40 | 41 | void func_vdesk(void *, XEvent *, unsigned); |
8 | 8 | |
9 | 9 | #include <stdio.h> |
10 | 10 | |
11 | #if defined(DEBUG) || defined(XDEBUG) | |
12 | # include <X11/X.h> | |
13 | #endif | |
14 | ||
11 | 15 | #ifdef XDEBUG |
12 | # include <X11/X.h> | |
13 | 16 | # include <X11/Xlib.h> |
14 | 17 | # include <X11/Xutil.h> |
15 | 18 | #endif |
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | static const char *default_options[] = { | |
137 | "display", | |
138 | "term " DEF_TERM, | |
139 | "fn " DEF_FONT, | |
140 | "fg " DEF_FG, | |
141 | "bg " DEF_BG, | |
142 | "bw " xstr(DEF_BW), | |
143 | "fc " DEF_FC, | |
144 | "numvdesks 8", | |
145 | }; | |
146 | #define NUM_DEFAULT_OPTIONS (sizeof(default_options)/sizeof(default_options[0])) | |
147 | ||
136 | 148 | int main(int argc, char *argv[]) { |
137 | 149 | struct sigaction act; |
138 | 150 | int argn = 1, ret; |
149 | 161 | wm_exit = 0; |
150 | 162 | while (!wm_exit) { |
151 | 163 | |
152 | option = (struct options) { | |
153 | .bw = DEF_BW, | |
154 | ||
155 | .vdesks = 8, | |
156 | .snap = 0, | |
157 | .wholescreen = 0, | |
158 | ||
159 | #ifdef SOLIDDRAG | |
160 | .no_solid_drag = 0, | |
161 | #endif | |
162 | }; | |
163 | ||
164 | 164 | // Default options |
165 | xconfig_set_option(evilwm_options, "display", ""); | |
166 | xconfig_set_option(evilwm_options, "fn", DEF_FONT); | |
167 | xconfig_set_option(evilwm_options, "fg", DEF_FG); | |
168 | xconfig_set_option(evilwm_options, "bg", DEF_BG); | |
169 | xconfig_set_option(evilwm_options, "fc", DEF_FC); | |
170 | xconfig_set_option(evilwm_options, "term", DEF_TERM); | |
165 | option = (struct options){0}; | |
166 | for (unsigned i = 0; i < NUM_DEFAULT_OPTIONS; i++) | |
167 | xconfig_parse_line(evilwm_options, default_options[i]); | |
171 | 168 | |
172 | 169 | // Read configuration file |
173 | 170 | const char *home = getenv("HOME"); |
13 | 13 | #include <string.h> |
14 | 14 | |
15 | 15 | #include "log.h" |
16 | #include "xalloc.h" | |
16 | 17 | #include "xconfig.h" |
17 | 18 | |
18 | 19 | // Break a space-separated string into an array of strings. |
117 | 118 | *(unsigned *)option->dest.u = strtoul(arg, NULL, 0); |
118 | 119 | break; |
119 | 120 | case XCONFIG_STRING: |
120 | *(char **)option->dest.s = strdup(arg); | |
121 | *(char **)option->dest.s = xstrdup(arg); | |
121 | 122 | break; |
122 | 123 | case XCONFIG_STR_LIST: |
123 | 124 | *(char ***)option->dest.sl = split_string(arg); |
131 | 132 | default: |
132 | 133 | break; |
133 | 134 | } |
135 | } | |
136 | ||
137 | void xconfig_parse_line(struct xconfig_option *options, const char *line) { | |
138 | // skip leading spaces | |
139 | while (isspace((int)*line)) | |
140 | line++; | |
141 | ||
142 | // end of line or comment? | |
143 | if (*line == 0 || *line == '#') | |
144 | return; | |
145 | ||
146 | // from here on, work on a copy of the string | |
147 | char *linedup = xstrdup(line); | |
148 | ||
149 | // whitespace separates option from arguments | |
150 | char *optstr = strtok(linedup, "\t\n\v\f\r "); | |
151 | if (optstr == NULL) { | |
152 | goto done; | |
153 | } | |
154 | ||
155 | struct xconfig_option *opt = find_option(options, optstr); | |
156 | if (opt == NULL) { | |
157 | LOG_INFO("Ignoring unknown option `%s'\n", optstr); | |
158 | goto done; | |
159 | } | |
160 | ||
161 | char *arg; | |
162 | if (opt->type == XCONFIG_STR_LIST) { | |
163 | // special case: spaces here mean something | |
164 | arg = strtok(NULL, "\n\v\f\r"); | |
165 | while (isspace(*arg)) { | |
166 | arg++; | |
167 | } | |
168 | } else { | |
169 | arg = strtok(NULL, "\t\n\v\f\r "); | |
170 | } | |
171 | ||
172 | set_option(opt, arg ? arg : ""); | |
173 | done: | |
174 | free(linedup); | |
175 | return; | |
134 | 176 | } |
135 | 177 | |
136 | 178 | // Simple parser: one directive per line, "option argument" |
138 | 180 | enum xconfig_result xconfig_parse_file(struct xconfig_option *options, |
139 | 181 | const char *filename) { |
140 | 182 | char buf[256]; |
141 | char *line, *optstr, *arg; | |
183 | char *line; | |
142 | 184 | FILE *cfg; |
143 | 185 | cfg = fopen(filename, "r"); |
144 | 186 | if (cfg == NULL) return XCONFIG_FILE_ERROR; |
145 | 187 | |
146 | 188 | while ((line = fgets(buf, sizeof(buf), cfg))) { |
147 | // skip leading spaces | |
148 | while (isspace((int)*line)) | |
149 | line++; | |
150 | ||
151 | // end of line or comment? | |
152 | if (*line == 0 || *line == '#') | |
153 | continue; | |
154 | ||
155 | // whitespace and '=' separate option from arguments | |
156 | optstr = strtok(line, "\t\n\v\f\r ="); | |
157 | if (optstr == NULL) | |
158 | continue; | |
159 | ||
160 | struct xconfig_option *opt = find_option(options, optstr); | |
161 | if (opt == NULL) { | |
162 | LOG_INFO("Ignoring unknown option `%s'\n", optstr); | |
163 | continue; | |
164 | } | |
165 | ||
166 | if (opt->type == XCONFIG_STR_LIST) { | |
167 | // special case: spaces here mean something | |
168 | arg = strtok(NULL, "\n\v\f\r"); | |
169 | while (isspace(*arg) || *arg == '=') { | |
170 | arg++; | |
171 | } | |
172 | } else { | |
173 | arg = strtok(NULL, "\t\n\v\f\r ="); | |
174 | } | |
175 | set_option(opt, arg); | |
189 | xconfig_parse_line(options, line); | |
176 | 190 | } |
177 | 191 | fclose(cfg); |
178 | 192 | return XCONFIG_OK; |
232 | 246 | return XCONFIG_OK; |
233 | 247 | } |
234 | 248 | |
235 | void xconfig_set_option(struct xconfig_option *options, const char *optstr, const char *arg) { | |
236 | struct xconfig_option *opt = find_option(options, optstr); | |
237 | if (opt) { | |
238 | set_option(opt, arg); | |
239 | } | |
240 | } | |
241 | ||
242 | 249 | void xconfig_free(struct xconfig_option *options) { |
243 | 250 | for (int i = 0; options[i].type != XCONFIG_END; i++) { |
244 | 251 | unset_option(&options[i]); |
45 | 45 | } dest; |
46 | 46 | }; |
47 | 47 | |
48 | void xconfig_parse_line(struct xconfig_option *options, const char *line); | |
49 | ||
48 | 50 | enum xconfig_result xconfig_parse_file(struct xconfig_option *options, |
49 | 51 | const char *filename); |
50 | 52 | |
51 | 53 | enum xconfig_result xconfig_parse_cli(struct xconfig_option *options, |
52 | 54 | int argc, char **argv, int *argn); |
53 | 55 | |
54 | void xconfig_set_option(struct xconfig_option *options, const char *optstr, const char *arg); | |
55 | ||
56 | 56 | // Free all allocated strings pointed to by options |
57 | 57 | void xconfig_free(struct xconfig_option *options); |
58 | 58 |