History

input: use bstr for section name

Resolves mixed use of bstr in internal processing and char* for storage. Also makes faster comparision when searching for section and resolves comparision when name contains null chars.

Kacper Michajłow committed 2 years ago

Commit 1a27f3c1 parent aa35f2e2 files · +56 −55Browse files

Unified · Split

2 files
  1. input/cmd.h +1 −1
  2. input/input.c +55 −54
input/cmd.h+1−1
@@ -105,7 +105,7 @@ typedef struct mp_cmd { · 104 unmodified lines
105 int flags; // mp_cmd_flags bitfield105 int flags; // mp_cmd_flags bitfield
106 char *original;106 char *original;
107 char *desc; // (usually NULL since stripped away later)107 char *desc; // (usually NULL since stripped away later)
108 char *input_section;108 bstr input_section;
109 bool is_up_down : 1;109 bool is_up_down : 1;
110 bool is_up : 1;110 bool is_up : 1;
111 bool emit_on_up : 1;111 bool emit_on_up : 1;
input/input.c+55−54
@@ -70,7 +70,7 @@ struct cmd_bind_section { · 69 unmodified lines
70 char *owner;70 char *owner;
71 struct cmd_bind *binds;71 struct cmd_bind *binds;
72 int num_binds;72 int num_binds;
73 char *section;73 bstr section;
74 struct mp_rect mouse_area; // set at runtime, if at all74 struct mp_rect mouse_area; // set at runtime, if at all
75 bool mouse_area_set; // mouse_area is valid and should be tested75 bool mouse_area_set; // mouse_area is valid and should be tested
76};76};
@@ -78,7 +78,7 @@ struct cmd_bind_section { · 1 unmodified line
78#define MP_MAX_SOURCES 1078#define MP_MAX_SOURCES 10
79 79
80struct active_section {80struct active_section {
81 char *name;81 bstr name;
82 int flags;82 int flags;
83};83};
84 84
@@ -129,7 +129,7 @@ struct input_ctx { · 44 unmodified lines
129 // Mouse position on the consumer side (as command.c sees it)129 // Mouse position on the consumer side (as command.c sees it)
130 int mouse_x, mouse_y;130 int mouse_x, mouse_y;
131 int mouse_hover; // updated on mouse-enter/leave131 int mouse_hover; // updated on mouse-enter/leave
132 char *mouse_section; // last section to receive mouse event132 bstr mouse_section; // last section to receive mouse event
133 133
134 // Mouse position on the producer side (as the VO sees it)134 // Mouse position on the producer side (as the VO sees it)
135 // Unlike mouse_x/y, this can be used to resolve mouse click bindings.135 // Unlike mouse_x/y, this can be used to resolve mouse click bindings.
@@ -168,7 +168,7 @@ struct input_ctx { · 32 unmodified lines
168};168};
169 169
170static int parse_config(struct input_ctx *ictx, bool builtin, bstr data,170static int parse_config(struct input_ctx *ictx, bool builtin, bstr data,
171 const char *location, const char *restrict_section);171 const char *location, bstr section);
172static void close_input_sources(struct input_ctx *ictx);172static void close_input_sources(struct input_ctx *ictx);
173static bool test_mouse(struct input_ctx *ictx, int x, int y, int rej_flags);173static bool test_mouse(struct input_ctx *ictx, int x, int y, int rej_flags);
174 174
@@ -316,9 +316,9 @@ static void append_bind_info(struct input_ctx *ictx, char **pmsg, · 141 unmodified lines
316 msg = talloc_asprintf_append(msg, " '%s'", stripped);316 msg = talloc_asprintf_append(msg, " '%s'", stripped);
317 if (!cmd)317 if (!cmd)
318 msg = talloc_asprintf_append(msg, " (invalid)");318 msg = talloc_asprintf_append(msg, " (invalid)");
319 if (strcmp(bind->owner->section, "default") != 0)319 if (bstr_equals0(bind->owner->section, "default"))
320 msg = talloc_asprintf_append(msg, " in section {%s}",320 msg = talloc_asprintf_append(msg, " in section {%.*s}",
321 bind->owner->section);321 BSTR_P(bind->owner->section));
322 msg = talloc_asprintf_append(msg, " in %s", bind->location);322 msg = talloc_asprintf_append(msg, " in %s", bind->location);
323 if (bind->is_builtin)323 if (bind->is_builtin)
324 msg = talloc_asprintf_append(msg, " (default)");324 msg = talloc_asprintf_append(msg, " (default)");
@@ -371,7 +371,7 @@ static struct cmd_bind_section *find_section(struct input_ctx *ictx, · 46 unmodified lines
371{371{
372 for (int n = 0; n < ictx->num_sections; n++) {372 for (int n = 0; n < ictx->num_sections; n++) {
373 struct cmd_bind_section *bs = ictx->sections[n];373 struct cmd_bind_section *bs = ictx->sections[n];
374 if (bstr_equals0(section, bs->section))374 if (bstr_equals(section, bs->section))
375 return bs;375 return bs;
376 }376 }
377 return NULL;377 return NULL;
@@ -387,7 +387,7 @@ static struct cmd_bind_section *get_bind_section(struct input_ctx *ictx, · 9 unmodified lines
387 return bind_section;387 return bind_section;
388 bind_section = talloc_ptrtype(ictx, bind_section);388 bind_section = talloc_ptrtype(ictx, bind_section);
389 *bind_section = (struct cmd_bind_section) {389 *bind_section = (struct cmd_bind_section) {
390 .section = bstrdup0(bind_section, section),390 .section = bstrdup(bind_section, section),
391 .mouse_area = {INT_MIN, INT_MIN, INT_MAX, INT_MAX},391 .mouse_area = {INT_MIN, INT_MIN, INT_MAX, INT_MAX},
392 .mouse_area_set = true,392 .mouse_area_set = true,
393 };393 };
@@ -403,9 +403,9 @@ static void key_buf_add(int *buf, int code) · 9 unmodified lines
403}403}
404 404
405static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,405static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,
406 char *section, int code)406 bstr section, int code)
407{407{
408 struct cmd_bind_section *bs = get_bind_section(ictx, bstr0(section));408 struct cmd_bind_section *bs = get_bind_section(ictx, section);
409 409
410 if (!bs->num_binds)410 if (!bs->num_binds)
411 return NULL;411 return NULL;
@@ -439,9 +439,9 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx, · 27 unmodified lines
439}439}
440 440
441static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx,441static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx,
442 char *force_section, int code)442 bstr force_section, int code)
443{443{
444 if (force_section)444 if (force_section.len)
445 return find_bind_for_key_section(ictx, force_section, code);445 return find_bind_for_key_section(ictx, force_section, code);
446 446
447 bool use_mouse = MP_KEY_DEPENDS_ON_MOUSE_POS(code);447 bool use_mouse = MP_KEY_DEPENDS_ON_MOUSE_POS(code);
@@ -484,7 +484,7 @@ static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx, · 36 unmodified lines
484 return best_bind;484 return best_bind;
485}485}
486 486
487static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section,487static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, bstr force_section,
488 int code)488 int code)
489{489{
490 if (ictx->opts->test)490 if (ictx->opts->test)
@@ -513,8 +513,8 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, · 22 unmodified lines
513 if (ret) {513 if (ret) {
514 ret->input_section = cmd->owner->section;514 ret->input_section = cmd->owner->section;
515 ret->key_name = talloc_steal(ret, mp_input_get_key_combo_name(&code, 1));515 ret->key_name = talloc_steal(ret, mp_input_get_key_combo_name(&code, 1));
516 MP_TRACE(ictx, "key '%s' -> '%s' in '%s'\n",516 MP_TRACE(ictx, "key '%s' -> '%s' in '%.*s'\n",
517 ret->key_name, cmd->cmd, ret->input_section);517 ret->key_name, cmd->cmd, BSTR_P(ret->input_section));
518 if (MP_KEY_IS_UNICODE(code)) {518 if (MP_KEY_IS_UNICODE(code)) {
519 bstr text = {0};519 bstr text = {0};
520 mp_append_utf8_bstr(ret, &text, code);520 mp_append_utf8_bstr(ret, &text, code);
@@ -533,16 +533,16 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, char *force_section, · 12 unmodified lines
533static void update_mouse_section(struct input_ctx *ictx)533static void update_mouse_section(struct input_ctx *ictx)
534{534{
535 struct cmd_bind *bind =535 struct cmd_bind *bind =
536 find_any_bind_for_key(ictx, NULL, MP_KEY_MOUSE_MOVE);536 find_any_bind_for_key(ictx, (bstr){0}, MP_KEY_MOUSE_MOVE);
537 537
538 char *new_section = bind ? bind->owner->section : "default";538 bstr new_section = bind ? bind->owner->section : bstr0("default");
539 539
540 char *old = ictx->mouse_section;540 bstr old = ictx->mouse_section;
541 ictx->mouse_section = new_section;541 ictx->mouse_section = new_section;
542 542
543 if (strcmp(old, ictx->mouse_section) != 0) {543 if (!bstr_equals(old, ictx->mouse_section)) {
544 MP_TRACE(ictx, "input: switch section %s -> %s\n",544 MP_TRACE(ictx, "input: switch section %.*s -> %.*s\n",
545 old, ictx->mouse_section);545 BSTR_P(old), BSTR_P(ictx->mouse_section));
546 queue_cmd(ictx, get_cmd_from_keys(ictx, old, MP_KEY_MOUSE_LEAVE));546 queue_cmd(ictx, get_cmd_from_keys(ictx, old, MP_KEY_MOUSE_LEAVE));
547 }547 }
548}548}
@@ -586,7 +586,7 @@ static bool should_drop_cmd(struct input_ctx *ictx, struct mp_cmd *cmd) · 37 unmodified lines
586static struct mp_cmd *resolve_key(struct input_ctx *ictx, int code)586static struct mp_cmd *resolve_key(struct input_ctx *ictx, int code)
587{587{
588 update_mouse_section(ictx);588 update_mouse_section(ictx);
589 struct mp_cmd *cmd = get_cmd_from_keys(ictx, NULL, code);589 struct mp_cmd *cmd = get_cmd_from_keys(ictx, (bstr){0}, code);
590 key_buf_add(ictx->key_history, code);590 key_buf_add(ictx->key_history, code);
591 if (cmd && !cmd->def->is_ignore && !should_drop_cmd(ictx, cmd))591 if (cmd && !cmd->def->is_ignore && !should_drop_cmd(ictx, cmd))
592 return cmd;592 return cmd;
@@ -765,7 +765,7 @@ static void feed_key(struct input_ctx *ictx, int code, double scale, · 172 unmodified lines
765 ictx->mouse_hover = unmod == MP_KEY_MOUSE_ENTER;765 ictx->mouse_hover = unmod == MP_KEY_MOUSE_ENTER;
766 update_mouse_section(ictx);766 update_mouse_section(ictx);
767 767
768 mp_cmd_t *cmd = get_cmd_from_keys(ictx, NULL, code);768 mp_cmd_t *cmd = get_cmd_from_keys(ictx, (bstr){0}, code);
769 if (!cmd) // queue dummy cmd so that mouse-pos can notify observers769 if (!cmd) // queue dummy cmd so that mouse-pos can notify observers
770 cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>");770 cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>");
771 queue_cmd(ictx, cmd);771 queue_cmd(ictx, cmd);
@@ -907,7 +907,7 @@ static void set_mouse_pos(struct input_ctx *ictx, int x, int y) · 135 unmodified lines
907 ictx->mouse_vo_y = y;907 ictx->mouse_vo_y = y;
908 908
909 update_mouse_section(ictx);909 update_mouse_section(ictx);
910 struct mp_cmd *cmd = get_cmd_from_keys(ictx, NULL, MP_KEY_MOUSE_MOVE);910 struct mp_cmd *cmd = get_cmd_from_keys(ictx, (bstr){0}, MP_KEY_MOUSE_MOVE);
911 if (!cmd)911 if (!cmd)
912 cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>");912 cmd = mp_input_parse_cmd(ictx, bstr0("ignore"), "<internal>");
913 913
@@ -1060,7 +1060,7 @@ static bool test_mouse(struct input_ctx *ictx, int x, int y, int rej_flags) · 146 unmodified lines
1060 struct active_section *as = &ictx->active_sections[i];1060 struct active_section *as = &ictx->active_sections[i];
1061 if (as->flags & rej_flags)1061 if (as->flags & rej_flags)
1062 continue;1062 continue;
1063 struct cmd_bind_section *s = get_bind_section(ictx, bstr0(as->name));1063 struct cmd_bind_section *s = get_bind_section(ictx, as->name);
1064 if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {1064 if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {
1065 res = true;1065 res = true;
1066 break;1066 break;
@@ -1197,19 +1197,19 @@ void mp_input_get_mouse_pos(struct input_ctx *ictx, int *x, int *y, int *hover) · 130 unmodified lines
1197// If name is NULL, return "default".1197// If name is NULL, return "default".
1198// Return a statically allocated name of the section (i.e. return value never1198// Return a statically allocated name of the section (i.e. return value never
1199// gets deallocated).1199// gets deallocated).
1200static char *normalize_section(struct input_ctx *ictx, char *name)1200static bstr normalize_section(struct input_ctx *ictx, bstr name)
1201{1201{
1202 return get_bind_section(ictx, bstr0(name))->section;1202 return get_bind_section(ictx, name)->section;
1203}1203}
1204 1204
1205static void disable_section(struct input_ctx *ictx, char *name)1205static void disable_section(struct input_ctx *ictx, bstr name)
1206{1206{
1207 name = normalize_section(ictx, name);1207 name = normalize_section(ictx, name);
1208 1208
1209 // Remove old section, or make sure it's on top if re-enabled1209 // Remove old section, or make sure it's on top if re-enabled
1210 for (int i = ictx->num_active_sections - 1; i >= 0; i--) {1210 for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
1211 struct active_section *as = &ictx->active_sections[i];1211 struct active_section *as = &ictx->active_sections[i];
1212 if (strcmp(as->name, name) == 0) {1212 if (bstr_equals(as->name, name)) {
1213 MP_TARRAY_REMOVE_AT(ictx->active_sections,1213 MP_TARRAY_REMOVE_AT(ictx->active_sections,
1214 ictx->num_active_sections, i);1214 ictx->num_active_sections, i);
1215 }1215 }
@@ -1219,18 +1219,19 @@ static void disable_section(struct input_ctx *ictx, char *name) · 3 unmodified lines
1219void mp_input_disable_section(struct input_ctx *ictx, char *name)1219void mp_input_disable_section(struct input_ctx *ictx, char *name)
1220{1220{
1221 input_lock(ictx);1221 input_lock(ictx);
1222 disable_section(ictx, name);1222 disable_section(ictx, bstr0(name));
1223 input_unlock(ictx);1223 input_unlock(ictx);
1224}1224}
1225 1225
1226void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags)1226void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags)
1227{1227{
1228 bstr bname = bstr0(name);
1228 input_lock(ictx);1229 input_lock(ictx);
1229 name = normalize_section(ictx, name);1230 bname = normalize_section(ictx, bname);
1230 1231
1231 disable_section(ictx, name);1232 disable_section(ictx, bname);
1232 1233
1233 MP_TRACE(ictx, "enable section '%s'\n", name);1234 MP_TRACE(ictx, "enable section '%.*s'\n", BSTR_P(bname));
1234 1235
1235 int top = ictx->num_active_sections;1236 int top = ictx->num_active_sections;
1236 if (!(flags & MP_INPUT_ON_TOP)) {1237 if (!(flags & MP_INPUT_ON_TOP)) {
@@ -1241,11 +1242,11 @@ void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags) · 4 unmodified lines
1241 }1242 }
1242 }1243 }
1243 MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,1244 MP_TARRAY_INSERT_AT(ictx, ictx->active_sections, ictx->num_active_sections,
1244 top, (struct active_section){name, flags});1245 top, (struct active_section){bname, flags});
1245 1246
1246 MP_TRACE(ictx, "active section stack:\n");1247 MP_TRACE(ictx, "active section stack:\n");
1247 for (int n = 0; n < ictx->num_active_sections; n++) {1248 for (int n = 0; n < ictx->num_active_sections; n++) {
1248 MP_TRACE(ictx, " %s %d\n", ictx->active_sections[n].name,1249 MP_TRACE(ictx, " %.*s %d\n", BSTR_P(ictx->active_sections[n].name),
1249 ictx->active_sections[n].flags);1250 ictx->active_sections[n].flags);
1250 }1251 }
1251 1252
@@ -1292,13 +1293,14 @@ static void remove_binds(struct cmd_bind_section *bs, bool builtin) · 40 unmodified lines
1292void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,1293void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
1293 char *contents, bool builtin, char *owner)1294 char *contents, bool builtin, char *owner)
1294{1295{
1295 if (!name || !name[0])1296 bstr bname = bstr0(name);
1297 if (!bname.len)
1296 return; // parse_config() changes semantics with restrict_section==empty1298 return; // parse_config() changes semantics with restrict_section==empty
1297 input_lock(ictx);1299 input_lock(ictx);
1298 // Delete:1300 // Delete:
1299 struct cmd_bind_section *bs = get_bind_section(ictx, bstr0(name));1301 struct cmd_bind_section *bs = get_bind_section(ictx, bname);
1300 if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&1302 if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
1301 strcmp(bs->section, "default") != 0)1303 !bstr_equals0(bs->section, "default"))
1302 {1304 {
1303 talloc_free(bs->owner);1305 talloc_free(bs->owner);
1304 bs->owner = talloc_strdup(bs, owner);1306 bs->owner = talloc_strdup(bs, owner);
@@ -1306,10 +1308,10 @@ void mp_input_define_section(struct input_ctx *ictx, char *name, char *location, · 1 unmodified line
1306 remove_binds(bs, builtin);1308 remove_binds(bs, builtin);
1307 if (contents && contents[0]) {1309 if (contents && contents[0]) {
1308 // Redefine:1310 // Redefine:
1309 parse_config(ictx, builtin, bstr0(contents), location, name);1311 parse_config(ictx, builtin, bstr0(contents), location, bname);
1310 } else {1312 } else {
1311 // Disable:1313 // Disable:
1312 disable_section(ictx, name);1314 disable_section(ictx, bname);
1313 }1315 }
1314 input_unlock(ictx);1316 input_unlock(ictx);
1315}1317}
@@ -1375,17 +1377,17 @@ static void bind_keys(struct input_ctx *ictx, bool builtin, bstr section, · 59 unmodified lines
1375 memcpy(bind->keys, keys, num_keys * sizeof(bind->keys[0]));1377 memcpy(bind->keys, keys, num_keys * sizeof(bind->keys[0]));
1376 if (mp_msg_test(ictx->log, MSGL_DEBUG)) {1378 if (mp_msg_test(ictx->log, MSGL_DEBUG)) {
1377 char *s = mp_input_get_key_combo_name(keys, num_keys);1379 char *s = mp_input_get_key_combo_name(keys, num_keys);
1378 MP_TRACE(ictx, "add: section='%s' key='%s'%s cmd='%s' location='%s'\n",1380 MP_TRACE(ictx, "add: section='%.*s' key='%s'%s cmd='%s' location='%s'\n",
1379 bind->owner->section, s, bind->is_builtin ? " builtin" : "",1381 BSTR_P(bind->owner->section), s, bind->is_builtin ? " builtin" : "",
1380 bind->cmd, bind->location);1382 bind->cmd, bind->location);
1381 talloc_free(s);1383 talloc_free(s);
1382 }1384 }
1383}1385}
1384 1386
1385// restrict_section: every entry is forced to this section name1387// section: every entry is forced to this section name
1386// if NULL, load normally and allow any sections1388// if NULL, load normally and allow any sections
1387static int parse_config(struct input_ctx *ictx, bool builtin, bstr data,1389static int parse_config(struct input_ctx *ictx, bool builtin, bstr data,
1388 const char *location, const char *restrict_section)1390 const char *location, bstr section)
1389{1391{
1390 int n_binds = 0;1392 int n_binds = 0;
1391 int line_no = 0;1393 int line_no = 0;
@@ -1432,7 +1434,6 @@ static int parse_config(struct input_ctx *ictx, bool builtin, bstr data, · 40 unmodified lines
1432 }1434 }
1433 talloc_free(name);1435 talloc_free(name);
1434 1436
1435 bstr section = bstr0(restrict_section);
1436 if (!section.len) {1437 if (!section.len) {
1437 if (bstr_startswith0(command, "{")) {1438 if (bstr_startswith0(command, "{")) {
1438 int p = bstrchr(command, '}');1439 int p = bstrchr(command, '}');
@@ -1479,7 +1480,7 @@ static bool parse_config_file(struct input_ctx *ictx, char *file) · 40 unmodified lines
1479 bstr data = stream_read_complete(s, tmp, 1000000);1480 bstr data = stream_read_complete(s, tmp, 1000000);
1480 if (data.start) {1481 if (data.start) {
1481 MP_VERBOSE(ictx, "Parsing input config file %s\n", file);1482 MP_VERBOSE(ictx, "Parsing input config file %s\n", file);
1482 int num = parse_config(ictx, false, data, file, NULL);1483 int num = parse_config(ictx, false, data, file, (bstr){0});
1483 MP_VERBOSE(ictx, "Input config file %s parsed: %d binds\n", file, num);1484 MP_VERBOSE(ictx, "Input config file %s parsed: %d binds\n", file, num);
1484 r = true;1485 r = true;
1485 } else {1486 } else {
@@ -1502,7 +1503,7 @@ struct input_ctx *mp_input_init(struct mpv_global *global, · 16 unmodified lines
1502 .global = global,1503 .global = global,
1503 .ar_state = -1,1504 .ar_state = -1,
1504 .log = mp_log_new(ictx, global->log, "input"),1505 .log = mp_log_new(ictx, global->log, "input"),
1505 .mouse_section = "default",1506 .mouse_section = bstr0("default"),
1506 .opts_cache = m_config_cache_alloc(ictx, global, &input_config),1507 .opts_cache = m_config_cache_alloc(ictx, global, &input_config),
1507 .wakeup_cb = wakeup_cb,1508 .wakeup_cb = wakeup_cb,
1508 .wakeup_ctx = wakeup_ctx,1509 .wakeup_ctx = wakeup_ctx,
@@ -1559,7 +1560,7 @@ void mp_input_load_config(struct input_ctx *ictx) · 50 unmodified lines
1559 bstr line = bstr_getline(builtin, &builtin);1560 bstr line = bstr_getline(builtin, &builtin);
1560 bstr_eatstart0(&line, "#");1561 bstr_eatstart0(&line, "#");
1561 if (!bstr_startswith0(line, " "))1562 if (!bstr_startswith0(line, " "))
1562 parse_config(ictx, true, line, "<builtin>", NULL);1563 parse_config(ictx, true, line, "<builtin>", (bstr){0});
1563 }1564 }
1564 1565
1565 bool config_ok = false;1566 bool config_ok = false;
@@ -1679,8 +1680,8 @@ void mp_input_bind_key(struct input_ctx *ictx, int key, bstr command) · 113 unmodified lines
1679 memcpy(bind->keys, &key, 1 * sizeof(bind->keys[0]));1680 memcpy(bind->keys, &key, 1 * sizeof(bind->keys[0]));
1680 if (mp_msg_test(ictx->log, MSGL_DEBUG)) {1681 if (mp_msg_test(ictx->log, MSGL_DEBUG)) {
1681 char *s = mp_input_get_key_combo_name(&key, 1);1682 char *s = mp_input_get_key_combo_name(&key, 1);
1682 MP_TRACE(ictx, "add:section='%s' key='%s'%s cmd='%s' location='%s'\n",1683 MP_TRACE(ictx, "add:section='%.*s' key='%s'%s cmd='%s' location='%s'\n",
1683 bind->owner->section, s, bind->is_builtin ? " builtin" : "",1684 BSTR_P(bind->owner->section), s, bind->is_builtin ? " builtin" : "",
1684 bind->cmd, bind->location);1685 bind->cmd, bind->location);
1685 talloc_free(s);1686 talloc_free(s);
1686 }1687 }
@@ -1699,7 +1700,7 @@ struct mpv_node mp_input_get_bindings(struct input_ctx *ictx) · 12 unmodified lines
1699 1700
1700 for (int i = 0; i < ictx->num_active_sections; i++) {1701 for (int i = 0; i < ictx->num_active_sections; i++) {
1701 struct active_section *as = &ictx->active_sections[i];1702 struct active_section *as = &ictx->active_sections[i];
1702 if (strcmp(as->name, s->section) == 0) {1703 if (bstr_equals(as->name, s->section)) {
1703 priority = i;1704 priority = i;
1704 break;1705 break;
1705 }1706 }
@@ -1718,7 +1719,7 @@ struct mpv_node mp_input_get_bindings(struct input_ctx *ictx) · 12 unmodified lines
1718 if (b_priority >= 0 && !b->is_builtin)1719 if (b_priority >= 0 && !b->is_builtin)
1719 b_priority += ictx->num_active_sections;1720 b_priority += ictx->num_active_sections;
1720 1721
1721 node_map_add_string(entry, "section", s->section);1722 node_map_add_string(entry, "section", s->section.start);
1722 if (s->owner)1723 if (s->owner)
1723 node_map_add_string(entry, "owner", s->owner);1724 node_map_add_string(entry, "owner", s->owner);
1724 node_map_add_string(entry, "cmd", b->cmd);1725 node_map_add_string(entry, "cmd", b->cmd);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t