Changes in uspace/app/taskbar/taskbar.c [82d3c28:d92b8e8f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/taskbar.c
r82d3c28 rd92b8e8f 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 #include "wndlist.h" 49 49 50 #define TASKBAR_CONFIG_FILE "/cfg/taskbar.sif" 51 50 52 static void taskbar_wnd_close(ui_window_t *, void *); 51 53 static void taskbar_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 52 54 static void taskbar_wnd_pos(ui_window_t *, void *, pos_event_t *); 55 static void taskbar_notif_cb(void *); 53 56 54 57 static ui_window_cb_t window_cb = { … … 128 131 gfx_rect_t scr_rect; 129 132 gfx_rect_t rect; 133 char *dspec = NULL; 134 char *qmark; 130 135 errno_t rc; 131 136 132 137 taskbar = calloc(1, sizeof(taskbar_t)); 133 138 if (taskbar == NULL) { 139 printf("Out of memory.\n"); 134 140 rc = ENOMEM; 135 141 goto error; 136 142 } 143 144 dspec = str_dup(display_spec); 145 if (dspec == NULL) { 146 printf("Out of memory.\n"); 147 rc = ENOMEM; 148 goto error; 149 } 150 151 /* Remove additional arguments */ 152 qmark = str_chr(dspec, '?'); 153 if (qmark != NULL) 154 *qmark = '\0'; 137 155 138 156 rc = ui_create(display_spec, &taskbar->ui); … … 195 213 } 196 214 197 rc = tbsmenu_create(taskbar->window, taskbar->fixed, &taskbar->tbsmenu); 215 rc = tbsmenu_create(taskbar->window, taskbar->fixed, dspec, 216 &taskbar->tbsmenu); 198 217 if (rc != EOK) { 199 218 printf("Error creating start menu.\n"); … … 201 220 } 202 221 203 rc = tbsmenu_load(taskbar->tbsmenu, "/cfg/taskbar.sif");222 rc = tbsmenu_load(taskbar->tbsmenu, TASKBAR_CONFIG_FILE); 204 223 if (rc != EOK) { 205 224 printf("Error loading start menu from '%s'.\n", 206 "/cfg/taskbar.sif"); 225 TASKBAR_CONFIG_FILE); 226 } 227 228 rc = tbarcfg_listener_create(TBARCFG_NOTIFY_DEFAULT, 229 taskbar_notif_cb, (void *)taskbar, &taskbar->lst); 230 if (rc != EOK) { 231 printf("Error listening for configuration changes.\n"); 207 232 } 208 233 … … 284 309 } 285 310 311 free(dspec); 286 312 *rtaskbar = taskbar; 287 313 return EOK; 288 314 error: 315 if (dspec != NULL) 316 free(dspec); 317 if (taskbar->lst != NULL) 318 tbarcfg_listener_destroy(taskbar->lst); 289 319 if (taskbar->clock != NULL) 290 320 taskbar_clock_destroy(taskbar->clock); … … 297 327 if (taskbar->ui != NULL) 298 328 ui_destroy(taskbar->ui); 329 free(taskbar); 299 330 return rc; 300 331 … … 304 335 void taskbar_destroy(taskbar_t *taskbar) 305 336 { 337 if (taskbar->lst != NULL) 338 tbarcfg_listener_destroy(taskbar->lst); 306 339 ui_fixed_remove(taskbar->fixed, taskbar_clock_ctl(taskbar->clock)); 307 340 taskbar_clock_destroy(taskbar->clock); … … 312 345 } 313 346 347 /** Configuration change notification callback. 348 * 349 * Called when configuration changed. 350 * 351 * @param arg Argument (taskbar_t *) 352 */ 353 static void taskbar_notif_cb(void *arg) 354 { 355 taskbar_t *taskbar = (taskbar_t *)arg; 356 357 ui_lock(taskbar->ui); 358 tbsmenu_reload(taskbar->tbsmenu); 359 ui_unlock(taskbar->ui); 360 } 361 314 362 /** @} 315 363 */
Note:
See TracChangeset
for help on using the changeset viewer.