if (!key)
return 0;
+ layout = wrap_group_into_range(layout, key->num_groups,
+ key->out_of_range_group_action,
+ key->out_of_range_group_number);
+ if (layout == XKB_LAYOUT_INVALID)
+ return 0;
+
return XkbKeyGroupWidth(key, layout);
}
if (!key)
goto err;
- if (layout >= key->num_groups)
+
+ layout = wrap_group_into_range(layout, key->num_groups,
+ key->out_of_range_group_action,
+ key->out_of_range_group_number);
+ if (layout == XKB_LAYOUT_INVALID)
goto err;
+
if (level >= XkbKeyGroupWidth(key, layout))
goto err;
enum xkb_keymap_format format,
enum xkb_keymap_compile_flags);
+xkb_layout_index_t
+wrap_group_into_range(int32_t group,
+ xkb_layout_index_t num_groups,
+ enum xkb_range_exceed_type out_of_range_group_action,
+ xkb_layout_index_t out_of_range_group_number);
+
#endif
return entry->level;
}
-static xkb_layout_index_t
+xkb_layout_index_t
wrap_group_into_range(int32_t group,
xkb_layout_index_t num_groups,
enum xkb_range_exceed_type out_of_range_group_action,
/**
* Get the number of shift levels for a specific key and layout.
*
+ * If @c layout is out of range for this key (that is, larger or equal to
+ * the value returned by xkb_keymap_num_layouts_for_key()), it is brought
+ * back into range in a manner consistent with xkb_state_key_get_layout().
+ *
* @sa xkb_level_index_t
* @memberof xkb_keymap
*/
*
* @param[in] keymap The keymap.
* @param[in] key The keycode of the key.
- * @param[in] layout The layout for which to get the keysyms. This must
- * be smaller than:
- * @code xkb_keymap_num_layouts_for_key(keymap, key) @endcode
- * Usually it would be:
- * @code xkb_state_key_get_layout(state, key) @endcode
+ * @param[in] layout The layout for which to get the keysyms.
* @param[in] level The shift level in the layout for which to get the
* keysyms. This must be smaller than:
* @code xkb_keymap_num_layouts_for_key(keymap, key) @endcode
- * usually it would be:
- * @code xkb_state_key_get_level(state, key, layout) @endcode
- * @param[out] syms_out An immutible array of keysyms corresponding the
+ * @param[out] syms_out An immutible array of keysyms corresponding to the
* key in the given layout and shift level.
*
+ * If @c layout is out of range for this key (that is, larger or equal to
+ * the value returned by xkb_keymap_num_layouts_for_key()), it is brought
+ * back into range in a manner consistent with xkb_state_key_get_layout().
+ *
* @returns The number of keysyms in the syms_out array. If no keysyms
* are produced by the key in the given layout and shift level, returns 0
* and sets syms_out to NULL.