aboutsummaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authoradnano <me@adnano.co>2025-03-01 07:04:00 -0500
committeradnano <me@adnano.co>2025-03-01 07:04:00 -0500
commitfc69aa6e2bccca461a0bd0c10b448b64ccda1d42 (patch)
tree98b05a54f9d150690702f224b79a651fa3660752 /menu.c
parenteec775fad7f7b090e6de2dbfe0c242129fddba41 (diff)
downloadwmenu-fc69aa6e2bccca461a0bd0c10b448b64ccda1d42.tar.gz
Render menu after surface enter event
This fixes an issue where the first visible frame is blurry on fractional scale displays.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/menu.c b/menu.c
index 9bda76c..207d71c 100644
--- a/menu.c
+++ b/menu.c
@@ -376,6 +376,11 @@ static void match_items(struct menu *menu) {
}
}
+// Marks the menu as needing to be rendered again.
+void menu_invalidate(struct menu *menu) {
+ menu->rendered = false;
+}
+
// Render menu items.
void menu_render_items(struct menu *menu) {
calc_widths(menu);
@@ -498,13 +503,13 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
// Delete right
menu->input[menu->cursor] = '\0';
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_u:
// Delete left
insert(menu, NULL, 0 - menu->cursor);
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_w:
// Delete word
@@ -515,7 +520,7 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
insert(menu, NULL, nextrune(menu, -1) - menu->cursor);
}
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_Y:
// Paste clipboard
@@ -523,17 +528,17 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
return;
}
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_Left:
case XKB_KEY_KP_Left:
movewordedge(menu, -1);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_Right:
case XKB_KEY_KP_Right:
movewordedge(menu, +1);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_Return:
@@ -547,11 +552,11 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
switch (sym) {
case XKB_KEY_b:
movewordedge(menu, -1);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_f:
movewordedge(menu, +1);
- render_menu(menu);
+ menu_invalidate(menu);
return;
case XKB_KEY_g:
sym = XKB_KEY_Home;
@@ -593,10 +598,10 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
case XKB_KEY_KP_Up:
if (menu->sel && menu->sel->prev_match) {
menu->sel = menu->sel->prev_match;
- render_menu(menu);
+ menu_invalidate(menu);
} else if (menu->cursor > 0) {
menu->cursor = nextrune(menu, -1);
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_Right:
@@ -605,51 +610,51 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
case XKB_KEY_KP_Down:
if (menu->cursor < len) {
menu->cursor = nextrune(menu, +1);
- render_menu(menu);
+ menu_invalidate(menu);
} else if (menu->sel && menu->sel->next_match) {
menu->sel = menu->sel->next_match;
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_Prior:
case XKB_KEY_KP_Prior:
if (menu->sel && menu->sel->page->prev) {
menu->sel = menu->sel->page->prev->first;
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_Next:
case XKB_KEY_KP_Next:
if (menu->sel && menu->sel->page->next) {
menu->sel = menu->sel->page->next->first;
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_Home:
case XKB_KEY_KP_Home:
if (menu->sel == menu->matches) {
menu->cursor = 0;
- render_menu(menu);
+ menu_invalidate(menu);
} else {
menu->sel = menu->matches;
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_End:
case XKB_KEY_KP_End:
if (menu->cursor < len) {
menu->cursor = len;
- render_menu(menu);
+ menu_invalidate(menu);
} else {
menu->sel = menu->matches_end;
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_BackSpace:
if (menu->cursor > 0) {
insert(menu, NULL, nextrune(menu, -1) - menu->cursor);
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
}
break;
case XKB_KEY_Delete:
@@ -660,7 +665,7 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
menu->cursor = nextrune(menu, +1);
insert(menu, NULL, nextrune(menu, -1) - menu->cursor);
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
break;
case XKB_KEY_Tab:
if (!menu->sel) {
@@ -670,7 +675,7 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
memcpy(menu->input, menu->sel->text, menu->cursor);
menu->input[menu->cursor] = '\0';
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
break;
case XKB_KEY_Escape:
menu->exit = true;
@@ -680,7 +685,7 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
if (xkb_keysym_to_utf8(sym, buf, 8)) {
insert(menu, buf, strnlen(buf, 8));
match_items(menu);
- render_menu(menu);
+ menu_invalidate(menu);
}
}
}