jcs
/wallops
/amendments
/98
focusable: Assign an id to each window
jcs made amendment 98 2 months ago
--- focusable.c Thu Sep 12 09:53:24 2024
+++ focusable.c Thu Sep 12 21:32:42 2024
@@ -47,7 +47,8 @@ focusable_focused(void)
void
focusable_add(struct focusable *focusable)
{
- short n;
+ short n, id;
+ bool found;
nfocusables++;
focusables = xreallocarray(focusables, sizeof(struct focusable *),
@@ -59,6 +60,23 @@ focusable_add(struct focusable *focusable)
focusables[0] = focusable;
+ focusable->id = -1;
+ for (id = 0; id < nfocusables; id++) {
+ found = false;
+ for (n = 0; n < nfocusables; n++) {
+ if (focusables[n]->id == id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ focusable->id = id;
+ break;
+ }
+ }
+ if (focusable->id == -1)
+ panic("no focusable id");
+
focusable_show(focusable);
}
--- focusable.h Fri Aug 30 21:53:59 2024
+++ focusable.h Thu Sep 12 21:22:12 2024
@@ -21,6 +21,7 @@
struct focusable {
WindowPtr win;
+ short id;
bool visible;
void *cookie;
bool modal;