Codebase list evilwm / 8ec76f1
New upstream version 1.4.2 Mateusz Łukasik 1 year, 5 months ago
13 changed file(s) with 113 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
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
09 Version 1.4.0, Tue Sep 27 2022
110
211 * Send more accurate response to _NET_REQUEST_FRAME_EXTENTS.
111111 ############################################################################
112112 # You shouldn't need to change anything beyond this point
113113
114 version = 1.4.0
114 version = 1.4.2
115115 distdir = evilwm-$(version)
116116
117117 # Generally shouldn't be overridden:
218218
219219 next Cycle to the next window.
220220
221 raise
222
223 Raises the current window.
224
221225 resize When bound to a button, resizes a window with the mouse.
222226
223227 When bound to a key, if the relative flag is specified, modifies
250254 altmask shift
251255
252256 Button binds
253 bind button1=move,drag
254 bind button2=resize,drag
257 bind button1=move
258 bind button2=resize
255259 bind button3=lower
256260
257261 Keyboard binds
334338
335339
336340
337 evilwm-1.4 September 2022 evilwm(1)
341 evilwm-1.4 October 2022 evilwm(1)
9696 { "lower", func_lower, FL_CLIENT },
9797 { "move", func_move, FL_CLIENT },
9898 { "next", func_next, 0 },
99 { "raise", func_raise, FL_CLIENT },
99100 { "resize", func_resize, FL_CLIENT },
100101 { "spawn", func_spawn, 0 },
101102 { "vdesk", func_vdesk, FL_SCREEN },
452453
453454 for (struct list *l = controls; l; l = l->next) {
454455 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)) {
456457 void *sptr = NULL;
457458 if (bind->flags & FL_CLIENT) {
458459 sptr = current;
474475 void bind_handle_button(XButtonEvent *e) {
475476 for (struct list *l = controls; l; l = l->next) {
476477 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)) {
478479 void *sptr = NULL;
479480 if (bind->flags & FL_CLIENT) {
480481 sptr = find_client(e->window);
137137
138138 // Find out which modifier is NumLock - for every grab, we need to also
139139 // grab the combination where this is set.
140 numlockmask = 0;
140141 XModifierKeymap *modmap = XGetModifierMapping(display.dpy);
141142 for (unsigned i = 0; i < 8; i++) {
142143 for (unsigned j = 0; j < (unsigned)modmap->max_keypermod; j++) {
6969
7070 <body>
7171
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>
7373
7474
7575 <h2 id='name'>NAME</h2>
389389 <dt><code>next</code>
390390
391391 <dd>Cycle to the next window.
392
393 <dt><code>raise</code>
394
395 <p>Raises the current window.
392396
393397 <dt><code>resize</code>
394398
439443 <h3>Button binds</h3>
440444
441445 <pre>
442 bind button1=move,drag
443 bind button2=resize,drag
446 bind button1=move
447 bind button2=resize
444448 bind button3=lower
445449 </pre>
446450
8080 . pdfinfo /Author Ciaran Anscomb
8181 .\}
8282 .
83 .TH "evilwm" "1" "September 2022" "evilwm-1.4"
83 .TH "evilwm" "1" "October 2022" "evilwm-1.4"
8484 .hy 0
8585 .nh
8686 .H1 NAME
258258 \f(CBnext\fR
259259 Cycle to the next window.
260260 .TP
261 \f(CBraise\fR
262 .PP
263 Raises the current window.
264 .TP
261265 \f(CBresize\fR
262266 When bound to a button, resizes a window with the mouse.
263267 .IP
285289 .H2 Button binds
286290 .IP
287291 .EX
288 bind\ button1=move,drag
289 bind\ button2=resize,drag
292 bind\ button1=move
293 bind\ button2=resize
290294 bind\ button3=lower
291295 .EE
292296 .H2 Keyboard binds
7575 }
7676
7777 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;
8181 (void)e;
8282 client_lower(c);
8383 }
145145 XUngrabKeyboard(display.dpy, CurrentTime);
146146 }
147147 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);
148156 }
149157
150158 void func_resize(void *sptr, XEvent *e, unsigned flags) {
3535 void func_lower(void *, XEvent *, unsigned);
3636 void func_move(void *, XEvent *, unsigned);
3737 void func_next(void *, XEvent *, unsigned);
38 void func_raise(void *, XEvent *, unsigned);
3839 void func_resize(void *, XEvent *, unsigned);
3940 void func_spawn(void *, XEvent *, unsigned);
4041 void func_vdesk(void *, XEvent *, unsigned);
88
99 #include <stdio.h>
1010
11 #if defined(DEBUG) || defined(XDEBUG)
12 # include <X11/X.h>
13 #endif
14
1115 #ifdef XDEBUG
12 # include <X11/X.h>
1316 # include <X11/Xlib.h>
1417 # include <X11/Xutil.h>
1518 #endif
133133 );
134134 }
135135
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
136148 int main(int argc, char *argv[]) {
137149 struct sigaction act;
138150 int argn = 1, ret;
149161 wm_exit = 0;
150162 while (!wm_exit) {
151163
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
164164 // 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]);
171168
172169 // Read configuration file
173170 const char *home = getenv("HOME");
1313 #include <string.h>
1414
1515 #include "log.h"
16 #include "xalloc.h"
1617 #include "xconfig.h"
1718
1819 // Break a space-separated string into an array of strings.
117118 *(unsigned *)option->dest.u = strtoul(arg, NULL, 0);
118119 break;
119120 case XCONFIG_STRING:
120 *(char **)option->dest.s = strdup(arg);
121 *(char **)option->dest.s = xstrdup(arg);
121122 break;
122123 case XCONFIG_STR_LIST:
123124 *(char ***)option->dest.sl = split_string(arg);
131132 default:
132133 break;
133134 }
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;
134176 }
135177
136178 // Simple parser: one directive per line, "option argument"
138180 enum xconfig_result xconfig_parse_file(struct xconfig_option *options,
139181 const char *filename) {
140182 char buf[256];
141 char *line, *optstr, *arg;
183 char *line;
142184 FILE *cfg;
143185 cfg = fopen(filename, "r");
144186 if (cfg == NULL) return XCONFIG_FILE_ERROR;
145187
146188 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);
176190 }
177191 fclose(cfg);
178192 return XCONFIG_OK;
232246 return XCONFIG_OK;
233247 }
234248
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
242249 void xconfig_free(struct xconfig_option *options) {
243250 for (int i = 0; options[i].type != XCONFIG_END; i++) {
244251 unset_option(&options[i]);
4545 } dest;
4646 };
4747
48 void xconfig_parse_line(struct xconfig_option *options, const char *line);
49
4850 enum xconfig_result xconfig_parse_file(struct xconfig_option *options,
4951 const char *filename);
5052
5153 enum xconfig_result xconfig_parse_cli(struct xconfig_option *options,
5254 int argc, char **argv, int *argn);
5355
54 void xconfig_set_option(struct xconfig_option *options, const char *optstr, const char *arg);
55
5656 // Free all allocated strings pointed to by options
5757 void xconfig_free(struct xconfig_option *options);
5858