Changeset 5d9403d5 in mainline
- Timestamp:
- 2023-10-13T20:27:14Z (15 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7aa9fa1b
- Parents:
- 788c76e3
- Location:
- uspace/app/taskbar
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/taskbar.c
r788c76e3 r5d9403d5 49 49 50 50 static void taskbar_wnd_close(ui_window_t *, void *); 51 static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 51 52 static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *); 52 53 53 54 static ui_window_cb_t window_cb = { 54 55 .close = taskbar_wnd_close, 56 .kbd = taskbar_wnd_kbd, 55 57 .pos = taskbar_wnd_pos 56 58 }; … … 66 68 67 69 ui_quit(taskbar->ui); 70 } 71 72 /** Window received keyboard event. 73 * 74 * @param window Window 75 * @param arg Argument (taskbar) 76 * @param event Keyboard event 77 */ 78 static void taskbar_wnd_kbd(ui_window_t *window, void *arg, kbd_event_t *event) 79 { 80 taskbar_t *taskbar = (taskbar_t *) arg; 81 ui_evclaim_t claim; 82 83 /* Remember ID of device that sent the last event */ 84 taskbar->wndlist->ev_idev_id = event->kbd_id; 85 taskbar->tbsmenu->ev_idev_id = event->kbd_id; 86 87 claim = ui_window_def_kbd(window, event); 88 if (claim == ui_claimed) 89 return; 90 91 if (event->type == KEY_PRESS && (event->mods & KM_CTRL) == 0 && 92 (event->mods & KM_ALT) == 0 && (event->mods & KM_SHIFT) == 0 && 93 event->key == KC_ENTER) { 94 if (!tbsmenu_is_open(taskbar->tbsmenu)) 95 tbsmenu_open(taskbar->tbsmenu); 96 } 68 97 } 69 98 … … 79 108 80 109 /* Remember ID of device that sent the last event */ 81 taskbar->wndlist->ev_pos_id = event->pos_id; 110 taskbar->wndlist->ev_idev_id = event->pos_id; 111 taskbar->tbsmenu->ev_idev_id = event->pos_id; 82 112 83 113 ui_window_def_pos(window, event); -
uspace/app/taskbar/tbsmenu.c
r788c76e3 r5d9403d5 92 92 (void *)tbsmenu); 93 93 94 ui_pbutton_set_default(tbsmenu->sbutton, true); 95 94 96 rc = ui_fixed_add(fixed, ui_pbutton_ctl(tbsmenu->sbutton)); 95 97 if (rc != EOK) … … 166 168 tbsmenu->rect = *rect; 167 169 ui_pbutton_set_rect(tbsmenu->sbutton, rect); 170 } 171 172 /** Open taskbar start menu. 173 * 174 * @param tbsmenu Start menu 175 */ 176 void tbsmenu_open(tbsmenu_t *tbsmenu) 177 { 178 (void) ui_menu_open(tbsmenu->smenu, &tbsmenu->rect, 179 tbsmenu->ev_idev_id); 180 } 181 182 /** Close taskbar start menu. 183 * 184 * @param tbsmenu Start menu 185 */ 186 void tbsmenu_close(tbsmenu_t *tbsmenu) 187 { 188 ui_menu_close(tbsmenu->smenu); 189 } 190 191 /** Determine if taskbar start menu is open. 192 * 193 * @param tbsmenu Start menu 194 * @return @c true iff start menu is open 195 */ 196 bool tbsmenu_is_open(tbsmenu_t *tbsmenu) 197 { 198 return ui_menu_is_open(tbsmenu->smenu); 168 199 } 169 200 … … 352 383 tbsmenu_t *tbsmenu = (tbsmenu_t *)arg; 353 384 354 if (!ui_menu_is_open(tbsmenu->smenu)) { 355 // XXX ev_pos_id is not set!!! 356 (void) ui_menu_open(tbsmenu->smenu, &tbsmenu->rect, 357 tbsmenu->ev_pos_id); 385 if (!tbsmenu_is_open(tbsmenu)) { 386 tbsmenu_open(tbsmenu); 358 387 } else { 359 388 /* menu is open */ 360 ui_menu_close(tbsmenu->smenu);389 tbsmenu_close(tbsmenu); 361 390 } 362 391 } -
uspace/app/taskbar/tbsmenu.h
r788c76e3 r5d9403d5 49 49 extern errno_t tbsmenu_load(tbsmenu_t *, const char *); 50 50 extern void tbsmenu_set_rect(tbsmenu_t *, gfx_rect_t *); 51 extern void tbsmenu_open(tbsmenu_t *); 52 extern void tbsmenu_close(tbsmenu_t *); 53 extern bool tbsmenu_is_open(tbsmenu_t *); 51 54 extern void tbsmenu_destroy(tbsmenu_t *); 52 55 extern errno_t tbsmenu_add(tbsmenu_t *, const char *, const char *, -
uspace/app/taskbar/test/tbsmenu.c
r788c76e3 r5d9403d5 69 69 } 70 70 71 /** Test tbsmenu_open/close/is_open() */ 72 PCUT_TEST(open_close_is_open) 73 { 74 errno_t rc; 75 ui_t *ui = NULL; 76 ui_wnd_params_t params; 77 ui_window_t *window = NULL; 78 ui_fixed_t *fixed = NULL; 79 tbsmenu_t *tbsmenu = NULL; 80 81 rc = ui_create_disp(NULL, &ui); 82 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 83 84 ui_wnd_params_init(¶ms); 85 params.caption = "Hello"; 86 87 rc = ui_window_create(ui, ¶ms, &window); 88 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 89 PCUT_ASSERT_NOT_NULL(window); 90 91 rc = ui_fixed_create(&fixed); 92 ui_window_add(window, ui_fixed_ctl(fixed)); 93 94 rc = tbsmenu_create(window, fixed, &tbsmenu); 95 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 96 97 PCUT_ASSERT_FALSE(tbsmenu_is_open(tbsmenu)); 98 tbsmenu_open(tbsmenu); 99 PCUT_ASSERT_TRUE(tbsmenu_is_open(tbsmenu)); 100 tbsmenu_close(tbsmenu); 101 PCUT_ASSERT_FALSE(tbsmenu_is_open(tbsmenu)); 102 103 tbsmenu_destroy(tbsmenu); 104 ui_window_destroy(window); 105 ui_destroy(ui); 106 } 107 71 108 PCUT_EXPORT(tbsmenu); -
uspace/app/taskbar/types/tbsmenu.h
r788c76e3 r5d9403d5 80 80 list_t entries; 81 81 82 // TODO libstartmenu instance 83 84 /** Position ID of last position event */ 85 sysarg_t ev_pos_id; 82 /** Device ID of last input event */ 83 sysarg_t ev_idev_id; 86 84 } tbsmenu_t; 87 85 -
uspace/app/taskbar/types/wndlist.h
r788c76e3 r5d9403d5 84 84 wndmgt_t *wndmgt; 85 85 86 /** Position ID of last positionevent */87 sysarg_t ev_ pos_id;86 /** Device ID of last input event */ 87 sysarg_t ev_idev_id; 88 88 } wndlist_t; 89 89 -
uspace/app/taskbar/wndlist.c
r788c76e3 r5d9403d5 720 720 721 721 /* ID of device that clicked the button */ 722 dev_id = entry->wndlist->ev_ pos_id;722 dev_id = entry->wndlist->ev_idev_id; 723 723 724 724 (void) wndmgt_activate_window(entry->wndlist->wndmgt,
Note:
See TracChangeset
for help on using the changeset viewer.