Changeset ec50d65e in mainline
- Timestamp:
- 2024-06-22T09:13:30Z (3 months ago)
- Branches:
- master
- Children:
- 49aaa0e
- Parents:
- 743f2cdd
- git-author:
- Jiri Svoboda <jiri@…> (2024-06-22 09:12:48)
- git-committer:
- Jiri Svoboda <jiri@…> (2024-06-22 09:13:30)
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2012 Martin Sucha 4 4 * All rights reserved. … … 238 238 239 239 static void edit_wnd_close(ui_window_t *, void *); 240 static void edit_wnd_focus(ui_window_t *, void *, unsigned); 240 241 static void edit_wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 242 static void edit_wnd_unfocus(ui_window_t *, void *, unsigned); 241 243 242 244 static ui_window_cb_t edit_window_cb = { 243 245 .close = edit_wnd_close, 244 .kbd = edit_wnd_kbd_event 246 .focus = edit_wnd_focus, 247 .kbd = edit_wnd_kbd_event, 248 .unfocus = edit_wnd_unfocus 249 }; 250 251 static void edit_menubar_activate(ui_menu_bar_t *, void *); 252 static void edit_menubar_deactivate(ui_menu_bar_t *, void *); 253 254 static ui_menu_bar_cb_t edit_menubar_cb = { 255 .activate = edit_menubar_activate, 256 .deactivate = edit_menubar_deactivate 245 257 }; 246 258 … … 431 443 } 432 444 445 ui_menu_bar_set_cb(edit->menubar, &edit_menubar_cb, (void *) edit); 446 433 447 rc = ui_menu_dd_create(edit->menubar, "~F~ile", NULL, &mfile); 434 448 if (rc != EOK) { … … 2221 2235 } 2222 2236 2237 /** Window focus event 2238 * 2239 * @param window Window 2240 * @param arg Argument (edit_t *) 2241 * @param focus Focus number 2242 */ 2243 static void edit_wnd_focus(ui_window_t *window, void *arg, unsigned focus) 2244 { 2245 edit_t *edit = (edit_t *)arg; 2246 2247 (void)edit; 2248 pane_caret_display(&pane); 2249 cursor_setvis(true); 2250 } 2251 2223 2252 /** Window keyboard event 2224 2253 * … … 2242 2271 } 2243 2272 2273 /** Window unfocus event 2274 * 2275 * @param window Window 2276 * @param arg Argument (edit_t *) 2277 * @param focus Focus number 2278 */ 2279 static void edit_wnd_unfocus(ui_window_t *window, void *arg, unsigned focus) 2280 { 2281 edit_t *edit = (edit_t *) arg; 2282 2283 (void)edit; 2284 cursor_setvis(false); 2285 } 2286 2287 /** Menu bar activate event 2288 * 2289 * @param mbar Menu bar 2290 * @param arg Argument (edit_t *) 2291 */ 2292 static void edit_menubar_activate(ui_menu_bar_t *mbar, void *arg) 2293 { 2294 edit_t *edit = (edit_t *)arg; 2295 2296 (void)edit; 2297 cursor_setvis(false); 2298 } 2299 2300 /** Menu bar deactivate event 2301 * 2302 * @param mbar Menu bar 2303 * @param arg Argument (edit_t *) 2304 */ 2305 static void edit_menubar_deactivate(ui_menu_bar_t *mbar, void *arg) 2306 { 2307 edit_t *edit = (edit_t *)arg; 2308 2309 (void)edit; 2310 pane_caret_display(&pane); 2311 cursor_setvis(true); 2312 } 2313 2244 2314 /** File / Save menu entry selected. 2245 2315 * … … 2407 2477 { 2408 2478 edit_t *edit = (edit_t *)arg; 2409 gfx_context_t *gc = ui_window_get_gc(edit->window);2410 2479 char *cname; 2411 2480 errno_t rc; 2412 2481 2482 (void)edit; 2413 2483 ui_file_dialog_destroy(dialog); 2414 // TODO Smarter cursor management2415 pane.rflags |= REDRAW_CARET;2416 (void) pane_update(&pane);2417 gfx_cursor_set_visible(gc, true);2418 2484 2419 2485 cname = str_dup(fname); … … 2441 2507 { 2442 2508 edit_t *edit = (edit_t *)arg; 2443 gfx_context_t *gc = ui_window_get_gc(edit->window); 2444 2509 2510 (void)edit; 2445 2511 ui_file_dialog_destroy(dialog); 2446 // TODO Smarter cursor management2447 pane.rflags |= REDRAW_CARET;2448 (void) pane_update(&pane);2449 gfx_cursor_set_visible(gc, true);2450 2512 } 2451 2513 … … 2458 2520 { 2459 2521 edit_t *edit = (edit_t *)arg; 2460 gfx_context_t *gc = ui_window_get_gc(edit->window); 2461 2522 2523 (void)edit; 2462 2524 ui_file_dialog_destroy(dialog); 2463 // TODO Smarter cursor management2464 pane.rflags |= REDRAW_CARET;2465 (void) pane_update(&pane);2466 gfx_cursor_set_visible(gc, true);2467 2525 } 2468 2526 … … 2477 2535 { 2478 2536 edit_t *edit = (edit_t *) arg; 2479 gfx_context_t *gc = ui_window_get_gc(edit->window);2480 2537 char *endptr; 2481 2538 int line; … … 2489 2546 2490 2547 caret_move_absolute(line, pane.ideal_column, dir_before, false); 2491 // TODO Smarter cursor management2548 (void)edit; 2492 2549 (void) pane_update(&pane); 2493 gfx_cursor_set_visible(gc, true);2494 (void) gfx_update(gc);2495 2550 } 2496 2551 … … 2503 2558 { 2504 2559 edit_t *edit = (edit_t *) arg; 2505 gfx_context_t *gc = ui_window_get_gc(edit->window); 2506 2560 2561 (void)edit; 2507 2562 ui_prompt_dialog_destroy(dialog); 2508 // TODO Smarter cursor management2509 pane.rflags |= REDRAW_CARET;2510 (void) pane_update(&pane);2511 gfx_cursor_set_visible(gc, true);2512 2563 } 2513 2564 … … 2520 2571 { 2521 2572 edit_t *edit = (edit_t *) arg; 2522 gfx_context_t *gc = ui_window_get_gc(edit->window); 2523 2573 2574 (void)edit; 2524 2575 ui_prompt_dialog_destroy(dialog); 2525 // TODO Smarter cursor management2526 pane.rflags |= REDRAW_CARET;2527 (void) pane_update(&pane);2528 gfx_cursor_set_visible(gc, true);2529 2576 } 2530 2577 … … 2539 2586 { 2540 2587 edit_t *edit = (edit_t *) arg; 2541 gfx_context_t *gc = ui_window_get_gc(edit->window);2542 2588 char *pattern; 2543 2589 bool reverse; 2544 2590 2591 (void)edit; 2545 2592 ui_prompt_dialog_destroy(dialog); 2546 2593 … … 2559 2606 search(pattern, reverse); 2560 2607 2561 // TODO Smarter cursor management2562 2608 (void) pane_update(&pane); 2563 gfx_cursor_set_visible(gc, true);2564 (void) gfx_update(gc);2565 2609 } 2566 2610 … … 2573 2617 { 2574 2618 edit_t *edit = (edit_t *) arg; 2575 gfx_context_t *gc = ui_window_get_gc(edit->window); 2576 2619 2620 (void)edit; 2577 2621 ui_prompt_dialog_destroy(dialog); 2578 // TODO Smarter cursor management2579 pane.rflags |= REDRAW_CARET;2580 (void) pane_update(&pane);2581 gfx_cursor_set_visible(gc, true);2582 2622 } 2583 2623 … … 2590 2630 { 2591 2631 edit_t *edit = (edit_t *) arg; 2592 gfx_context_t *gc = ui_window_get_gc(edit->window); 2593 2632 2633 (void)edit; 2594 2634 ui_prompt_dialog_destroy(dialog); 2595 // TODO Smarter cursor management2596 pane.rflags |= REDRAW_CARET;2597 (void) pane_update(&pane);2598 gfx_cursor_set_visible(gc, true);2599 2635 } 2600 2636 -
uspace/lib/ui/include/types/ui/menubar.h
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 typedef struct ui_menu_bar ui_menu_bar_t; 41 41 42 /** Menu bar callbacks */ 43 typedef struct ui_menu_bar_cb { 44 /** Activated */ 45 void (*activate)(ui_menu_bar_t *, void *); 46 /** Deactivated */ 47 void (*deactivate)(ui_menu_bar_t *, void *); 48 } ui_menu_bar_cb_t; 49 42 50 #endif 43 51 -
uspace/lib/ui/include/ui/menubar.h
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 52 52 ui_menu_bar_t **); 53 53 extern void ui_menu_bar_destroy(ui_menu_bar_t *); 54 extern void ui_menu_bar_set_cb(ui_menu_bar_t *, ui_menu_bar_cb_t *, void *); 54 55 extern ui_control_t *ui_menu_bar_ctl(ui_menu_bar_t *); 55 56 extern void ui_menu_bar_set_rect(ui_menu_bar_t *, gfx_rect_t *); -
uspace/lib/ui/private/menubar.h
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 64 64 /** List of menu drop-downs (ui_menu_dd_t) */ 65 65 list_t menudds; 66 /** Callbacks */ 67 struct ui_menu_bar_cb *cb; 68 /** Callback argument */ 69 void *arg; 66 70 }; 67 71 -
uspace/lib/ui/src/menubar.c
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 66 66 static ui_evclaim_t ui_menu_bar_ctl_kbd_event(void *, kbd_event_t *); 67 67 static ui_evclaim_t ui_menu_bar_ctl_pos_event(void *, pos_event_t *); 68 static void ui_menu_bar_activate_ev(ui_menu_bar_t *); 69 static void ui_menu_bar_deactivate_ev(ui_menu_bar_t *); 68 70 69 71 /** Menu bar control ops */ … … 131 133 ui_control_delete(mbar->control); 132 134 free(mbar); 135 } 136 137 /** Set menu bar callbacks. 138 * 139 * @param mbar Menu bar 140 * @param cb Callbacks 141 * @param arg Callback argument 142 */ 143 void ui_menu_bar_set_cb(ui_menu_bar_t *mbar, ui_menu_bar_cb_t *cb, void *arg) 144 { 145 mbar->cb = cb; 146 mbar->arg = arg; 133 147 } 134 148 … … 288 302 } 289 303 304 if (!mbar->active) 305 ui_menu_bar_activate_ev(mbar); 290 306 mbar->active = true; 291 307 } else { 308 if (mbar->active) 309 ui_menu_bar_deactivate_ev(mbar); 292 310 mbar->active = false; 293 311 } … … 640 658 641 659 (void) ui_menu_bar_paint(mbar); 660 ui_menu_bar_activate_ev(mbar); 642 661 } 643 662 … … 649 668 { 650 669 ui_menu_bar_select(mbar, NULL, false, 0); 670 ui_menu_bar_deactivate_ev(mbar); 651 671 } 652 672 … … 700 720 } 701 721 722 /** Send menu bar activate event. 723 * 724 * @param mbar Menu bar 725 */ 726 static void ui_menu_bar_activate_ev(ui_menu_bar_t *mbar) 727 { 728 if (mbar->cb != NULL && mbar->cb->activate != NULL) 729 mbar->cb->activate(mbar, mbar->arg); 730 } 731 732 /** Send menu bar deactivate event. 733 * 734 * @param mbar Menu bar 735 */ 736 static void ui_menu_bar_deactivate_ev(ui_menu_bar_t *mbar) 737 { 738 if (mbar->cb != NULL && mbar->cb->deactivate != NULL) 739 mbar->cb->deactivate(mbar, mbar->arg); 740 } 741 702 742 /** @} 703 743 */ -
uspace/lib/ui/src/window.c
r743f2cdd rec50d65e 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 318 318 { 319 319 ui_window_t *window; 320 ui_window_t *pwindow = NULL; 320 321 display_info_t info; 321 322 gfx_coord2_t scr_dims; … … 505 506 *rwindow = window; 506 507 508 if (ui_is_fullscreen(ui)) 509 pwindow = ui_window_get_active(ui); 510 507 511 list_append(&window->lwindows, &ui->windows); 512 513 if (ui_is_fullscreen(ui)) { 514 /* Send unfocus event to previously active window */ 515 if (pwindow != NULL) 516 ui_window_send_unfocus(pwindow, 0); 517 } 518 508 519 return EOK; 509 520 error: … … 531 542 { 532 543 ui_t *ui; 544 ui_window_t *nwindow; 533 545 534 546 if (window == NULL) … … 558 570 if (ui_is_fullscreen(ui)) { 559 571 ui_paint(ui); 572 /* Send focus event to newly active window */ 573 nwindow = ui_window_get_active(ui); 574 if (nwindow != NULL) 575 ui_window_send_focus(nwindow, 0); 560 576 } 561 577
Note:
See TracChangeset
for help on using the changeset viewer.