mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Add function for getting list of modifier names.
Get an array of modifier names from modifier masks.
This commit is contained in:
parent
320c2915b0
commit
dffacea831
2 changed files with 21 additions and 0 deletions
|
@ -51,3 +51,17 @@ const char *get_modifier_name_by_mask(uint32_t modifier) {
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_modifier_names(const char **names, uint32_t modifier_masks) {
|
||||||
|
int length = 0;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++i) {
|
||||||
|
if ((modifier_masks & modifiers[i].mod) != 0) {
|
||||||
|
names[length] = modifiers[i].name;
|
||||||
|
++length;
|
||||||
|
modifier_masks ^= modifiers[i].mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
|
@ -29,4 +29,11 @@ uint32_t get_modifier_mask_by_name(const char *name);
|
||||||
*/
|
*/
|
||||||
const char *get_modifier_name_by_mask(uint32_t modifier);
|
const char *get_modifier_name_by_mask(uint32_t modifier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an array of modifier names from modifier_masks
|
||||||
|
*
|
||||||
|
* Populates the names array and return the number of names added.
|
||||||
|
*/
|
||||||
|
int get_modifier_names(const char **names, uint32_t modifier_masks);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue