Changes in uspace/app/taskbar/taskbar.c [82d3c28:29a5a99] in mainline
- File:
-
- 1 edited
-
uspace/app/taskbar/taskbar.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/taskbar.c
r82d3c28 r29a5a99 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 * @{ 31 31 */ 32 /** @file Task bar32 /** @file Task Bar 33 33 */ 34 34 … … 39 39 #include <str.h> 40 40 #include <ui/fixed.h> 41 #include <ui/label.h> 41 42 #include <ui/resource.h> 42 43 #include <ui/ui.h> … … 45 46 #include "clock.h" 46 47 #include "taskbar.h" 47 #include "tbsmenu.h"48 48 #include "wndlist.h" 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 *);52 51 static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *); 53 52 54 53 static ui_window_cb_t window_cb = { 55 54 .close = taskbar_wnd_close, 56 .kbd = taskbar_wnd_kbd,57 55 .pos = taskbar_wnd_pos 58 56 }; … … 68 66 69 67 ui_quit(taskbar->ui); 70 }71 72 /** Window received keyboard event.73 *74 * @param window Window75 * @param arg Argument (taskbar)76 * @param event Keyboard event77 */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 }97 68 } 98 69 … … 108 79 109 80 /* Remember ID of device that sent the last event */ 110 taskbar->wndlist->ev_idev_id = event->pos_id; 111 taskbar->tbsmenu->ev_idev_id = event->pos_id; 81 taskbar->wndlist->ev_pos_id = event->pos_id; 112 82 113 83 ui_window_def_pos(window, event); 114 84 } 115 85 116 /** Create task bar.86 /** Create task bar. 117 87 * 118 88 * @param display_spec Display specification 119 89 * @param wndmgt_svc Window management service (or WNDMGT_DEFAULT) 120 * @param rtaskbar Place to store pointer to new task bar90 * @param rtaskbar Place to store pointer to new task bar 121 91 * @return @c EOK on success or an error coe 122 92 */ … … 128 98 gfx_rect_t scr_rect; 129 99 gfx_rect_t rect; 100 ui_resource_t *ui_res; 130 101 errno_t rc; 131 102 … … 157 128 158 129 ui_wnd_params_init(¶ms); 159 params.caption = "Task bar";130 params.caption = "Task Bar"; 160 131 params.placement = ui_wnd_place_bottom_left; 161 132 … … 189 160 } 190 161 162 ui_window_set_cb(taskbar->window, &window_cb, (void *)taskbar); 163 ui_res = ui_window_get_res(taskbar->window); 164 191 165 rc = ui_fixed_create(&taskbar->fixed); 192 166 if (rc != EOK) { … … 195 169 } 196 170 197 rc = tbsmenu_create(taskbar->window, taskbar->fixed, &taskbar->tbsmenu); 198 if (rc != EOK) { 199 printf("Error creating start menu.\n"); 200 goto error; 201 } 202 203 rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif"); 204 if (rc != EOK) { 205 printf("Error loading start menu from '%s'.\n", 206 "/cfg/taskbar.sif"); 207 } 208 209 if (ui_is_textmode(taskbar->ui)) { 210 rect.p0.x = params.rect.p0.x + 1; 211 rect.p0.y = 0; 212 rect.p1.x = params.rect.p0.x + 9; 213 rect.p1.y = 1; 214 } else { 215 rect.p0.x = params.rect.p0.x + 5; 216 rect.p0.y = 4; 217 rect.p1.x = params.rect.p0.x + 84; 218 rect.p1.y = 32 - 4; 219 } 220 221 tbsmenu_set_rect(taskbar->tbsmenu, &rect); 171 rc = ui_label_create(ui_res, "HelenOS", &taskbar->label); 172 if (rc != EOK) { 173 printf("Error creating label.\n"); 174 goto error; 175 } 176 177 ui_window_get_app_rect(taskbar->window, &rect); 178 if (ui_is_textmode(taskbar->ui)) { 179 rect.p0.x += 1; 180 } else { 181 rect.p0.x += 10; 182 } 183 ui_label_set_rect(taskbar->label, &rect); 184 ui_label_set_halign(taskbar->label, gfx_halign_left); 185 ui_label_set_valign(taskbar->label, gfx_valign_center); 186 187 rc = ui_fixed_add(taskbar->fixed, ui_label_ctl(taskbar->label)); 188 if (rc != EOK) { 189 printf("Error adding control to layout.\n"); 190 ui_label_destroy(taskbar->label); 191 goto error; 192 } 222 193 223 194 rc = wndlist_create(taskbar->window, taskbar->fixed, &taskbar->wndlist); … … 228 199 229 200 if (ui_is_textmode(taskbar->ui)) { 230 rect.p0.x = params.rect.p0.x + 10;201 rect.p0.x = params.rect.p0.x + 9; 231 202 rect.p0.y = 0; 232 203 rect.p1.x = params.rect.p1.x - 10; … … 240 211 wndlist_set_rect(taskbar->wndlist, &rect); 241 212 242 /*243 * We may not be able to open WM service if display server is not244 * running. That's okay, there simply are no windows to manage.245 */246 213 rc = wndlist_open_wm(taskbar->wndlist, wndmgt_svc); 247 if (rc != EOK && rc != ENOENT) {214 if (rc != EOK) { 248 215 printf("Error attaching window management service.\n"); 249 216 goto error; … … 276 243 277 244 ui_window_add(taskbar->window, ui_fixed_ctl(taskbar->fixed)); 278 ui_window_set_cb(taskbar->window, &window_cb, (void *)taskbar);279 245 280 246 rc = ui_window_paint(taskbar->window); … … 291 257 if (taskbar->wndlist != NULL) 292 258 wndlist_destroy(taskbar->wndlist); 293 if (taskbar->tbsmenu != NULL)294 tbsmenu_destroy(taskbar->tbsmenu);295 259 if (taskbar->window != NULL) 296 260 ui_window_destroy(taskbar->window); … … 301 265 } 302 266 303 /** Destroy task bar. */267 /** Destroy task bar. */ 304 268 void taskbar_destroy(taskbar_t *taskbar) 305 269 { 306 270 ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock)); 307 271 taskbar_clock_destroy(taskbar->clock); 308 wndlist_destroy(taskbar->wndlist);309 tbsmenu_destroy(taskbar->tbsmenu);310 272 ui_window_destroy(taskbar->window); 311 273 ui_destroy(taskbar->ui);
Note:
See TracChangeset
for help on using the changeset viewer.
