Changeset 2f11647f in mainline


Ignore:
Timestamp:
2024-03-18T14:43:51Z (8 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
a29af37
Parents:
7b7a7d2
Message:

Barber should respond to Ctrl-Q/Escape. Call ui_window_def_kbd().

Location:
uspace/app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/barber/barber.c

    r7b7a7d2 r2f11647f  
    102102
    103103static void wnd_close(ui_window_t *, void *);
     104static void wnd_kbd_event(ui_window_t *, void *, kbd_event_t *);
    104105
    105106static ui_window_cb_t window_cb = {
    106         .close = wnd_close
     107        .close = wnd_close,
     108        .kbd = wnd_kbd_event
    107109};
     110
    108111
    109112/** Window close button was clicked.
     
    117120
    118121        ui_quit(barber->ui);
     122}
     123
     124/** Barber unmodified key press.
     125 *
     126 * @param barber Barber
     127 * @param event Keyboard event
     128 */
     129static void barber_kbd_event_unmod(barber_t *barber, kbd_event_t *event)
     130{
     131        if (event->key == KC_ESCAPE)
     132                ui_quit(barber->ui);
     133}
     134
     135/** Barber ctrl-key key press.
     136 *
     137 * @param barber Barber
     138 * @param event Keyboard event
     139 */
     140static void barber_kbd_event_ctrl(barber_t *barber, kbd_event_t *event)
     141{
     142        if (event->key == KC_Q)
     143                ui_quit(barber->ui);
     144}
     145
     146/** Barber window keyboard event.
     147 *
     148 * @param window UI window
     149 * @param arg Argument (barber_t *)
     150 * @param event Keyboard event
     151 */
     152static void wnd_kbd_event(ui_window_t *window, void *arg, kbd_event_t *event)
     153{
     154        barber_t *barber = (barber_t *)arg;
     155
     156        if (event->type != KEY_PRESS)
     157                return;
     158
     159        if ((event->mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
     160                barber_kbd_event_unmod(barber, event);
     161
     162        if ((event->mods & KM_CTRL) != 0 &&
     163            (event->mods & (KM_ALT | KM_SHIFT)) == 0)
     164                barber_kbd_event_ctrl(barber, event);
     165
     166        ui_window_def_kbd(window, event);
    119167}
    120168
  • uspace/app/viewer/viewer.c

    r7b7a7d2 r2f11647f  
    181181            (event->mods & (KM_ALT | KM_SHIFT)) == 0)
    182182                viewer_kbd_event_ctrl(viewer, event);
     183
     184        ui_window_def_kbd(window, event);
    183185}
    184186
Note: See TracChangeset for help on using the changeset viewer.