Changeset 46a47c0 in mainline for uspace/lib/ui
- Timestamp:
- 2023-01-16T20:34:01Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b0ae23f
- Parents:
- b3eeae5
- Location:
- uspace/lib/ui
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/types/ui/control.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 56 56 ui_evclaim_t (*pos_event)(void *, pos_event_t *); 57 57 /** Unfocus */ 58 void (*unfocus)(void * );58 void (*unfocus)(void *, unsigned); 59 59 } ui_control_ops_t; 60 60 -
uspace/lib/ui/include/types/ui/window.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 97 97 void (*unmaximize)(ui_window_t *, void *); 98 98 void (*close)(ui_window_t *, void *); 99 void (*focus)(ui_window_t *, void * );99 void (*focus)(ui_window_t *, void *, unsigned); 100 100 void (*kbd)(ui_window_t *, void *, kbd_event_t *); 101 101 errno_t (*paint)(ui_window_t *, void *); 102 102 void (*pos)(ui_window_t *, void *, pos_event_t *); 103 void (*unfocus)(ui_window_t *, void * );103 void (*unfocus)(ui_window_t *, void *, unsigned); 104 104 } ui_window_cb_t; 105 105 -
uspace/lib/ui/include/ui/control.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 extern ui_evclaim_t ui_control_kbd_event(ui_control_t *, kbd_event_t *); 50 50 extern ui_evclaim_t ui_control_pos_event(ui_control_t *, pos_event_t *); 51 extern void ui_control_unfocus(ui_control_t * );51 extern void ui_control_unfocus(ui_control_t *, unsigned); 52 52 53 53 #endif -
uspace/lib/ui/include/ui/fixed.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 51 51 extern ui_evclaim_t ui_fixed_kbd_event(ui_fixed_t *, kbd_event_t *); 52 52 extern ui_evclaim_t ui_fixed_pos_event(ui_fixed_t *, pos_event_t *); 53 extern void ui_fixed_unfocus(ui_fixed_t * );53 extern void ui_fixed_unfocus(ui_fixed_t *, unsigned); 54 54 55 55 #endif -
uspace/lib/ui/include/ui/window.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 71 71 extern errno_t ui_window_def_paint(ui_window_t *); 72 72 extern void ui_window_def_pos(ui_window_t *, pos_event_t *); 73 extern void ui_window_def_unfocus(ui_window_t * );73 extern void ui_window_def_unfocus(ui_window_t *, unsigned); 74 74 75 75 #endif -
uspace/lib/ui/private/window.h
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 116 116 extern void ui_window_send_unmaximize(ui_window_t *); 117 117 extern void ui_window_send_close(ui_window_t *); 118 extern void ui_window_send_focus(ui_window_t * );118 extern void ui_window_send_focus(ui_window_t *, unsigned); 119 119 extern void ui_window_send_kbd(ui_window_t *, kbd_event_t *); 120 120 extern errno_t ui_window_send_paint(ui_window_t *); 121 121 extern void ui_window_send_pos(ui_window_t *, pos_event_t *); 122 extern void ui_window_send_unfocus(ui_window_t * );122 extern void ui_window_send_unfocus(ui_window_t *, unsigned); 123 123 extern errno_t ui_window_size_change(ui_window_t *, gfx_rect_t *, 124 124 ui_wnd_sc_op_t); -
uspace/lib/ui/src/control.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 130 130 * 131 131 * @param control Control 132 * @param nfocus Number of remaining foci 132 133 */ 133 void ui_control_unfocus(ui_control_t *control )134 void ui_control_unfocus(ui_control_t *control, unsigned nfocus) 134 135 { 135 136 if (control->ops->unfocus != NULL) 136 control->ops->unfocus(control->ext );137 control->ops->unfocus(control->ext, nfocus); 137 138 } 138 139 -
uspace/lib/ui/src/fixed.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 static ui_evclaim_t ui_fixed_ctl_kbd_event(void *, kbd_event_t *); 49 49 static ui_evclaim_t ui_fixed_ctl_pos_event(void *, pos_event_t *); 50 static void ui_fixed_ctl_unfocus(void * );50 static void ui_fixed_ctl_unfocus(void *, unsigned); 51 51 52 52 /** Push button control ops */ … … 262 262 * 263 263 * @param fixed Fixed layout 264 */ 265 void ui_fixed_unfocus(ui_fixed_t *fixed) 266 { 267 ui_fixed_elem_t *elem; 268 269 elem = ui_fixed_first(fixed); 270 while (elem != NULL) { 271 ui_control_unfocus(elem->control); 264 * @param nfocus Number of remaining foci 265 */ 266 void ui_fixed_unfocus(ui_fixed_t *fixed, unsigned nfocus) 267 { 268 ui_fixed_elem_t *elem; 269 270 elem = ui_fixed_first(fixed); 271 while (elem != NULL) { 272 ui_control_unfocus(elem->control, nfocus); 272 273 273 274 elem = ui_fixed_next(elem); … … 327 328 * 328 329 * @param arg Argument (ui_fixed_t *) 329 */ 330 void ui_fixed_ctl_unfocus(void *arg) 331 { 332 ui_fixed_t *fixed = (ui_fixed_t *) arg; 333 334 ui_fixed_unfocus(fixed); 330 * @param nfocus Number of remaining foci 331 */ 332 void ui_fixed_ctl_unfocus(void *arg, unsigned nfocus) 333 { 334 ui_fixed_t *fixed = (ui_fixed_t *) arg; 335 336 ui_fixed_unfocus(fixed, nfocus); 335 337 } 336 338 -
uspace/lib/ui/src/window.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 59 59 60 60 static void dwnd_close_event(void *); 61 static void dwnd_focus_event(void * );61 static void dwnd_focus_event(void *, unsigned); 62 62 static void dwnd_kbd_event(void *, kbd_event_t *); 63 63 static void dwnd_pos_event(void *, pos_event_t *); 64 64 static void dwnd_resize_event(void *, gfx_rect_t *); 65 static void dwnd_unfocus_event(void * );65 static void dwnd_unfocus_event(void *, unsigned); 66 66 67 67 static display_wnd_cb_t dwnd_cb = { … … 833 833 834 834 /** Handle window focus event. */ 835 static void dwnd_focus_event(void *arg )835 static void dwnd_focus_event(void *arg, unsigned nfocus) 836 836 { 837 837 ui_window_t *window = (ui_window_t *) arg; … … 839 839 840 840 ui_lock(ui); 841 (void)nfocus; 841 842 842 843 if (window->wdecor != NULL) { … … 845 846 } 846 847 847 ui_window_send_focus(window );848 ui_window_send_focus(window, nfocus); 848 849 ui_unlock(ui); 849 850 } … … 903 904 904 905 /** Handle window unfocus event. */ 905 static void dwnd_unfocus_event(void *arg )906 static void dwnd_unfocus_event(void *arg, unsigned nfocus) 906 907 { 907 908 ui_window_t *window = (ui_window_t *) arg; … … 910 911 ui_lock(ui); 911 912 912 if (window->wdecor != NULL ) {913 if (window->wdecor != NULL && nfocus == 0) { 913 914 ui_wdecor_set_active(window->wdecor, false); 914 915 ui_wdecor_paint(window->wdecor); 915 916 } 916 917 917 ui_window_send_unfocus(window );918 ui_window_send_unfocus(window, nfocus); 918 919 ui_unlock(ui); 919 920 } … … 1104 1105 * 1105 1106 * @param window Window 1106 */ 1107 void ui_window_send_focus(ui_window_t *window) 1107 * @param nfocus New number of foci 1108 */ 1109 void ui_window_send_focus(ui_window_t *window, unsigned nfocus) 1108 1110 { 1109 1111 if (window->cb != NULL && window->cb->focus != NULL) 1110 window->cb->focus(window, window->arg );1112 window->cb->focus(window, window->arg, nfocus); 1111 1113 } 1112 1114 … … 1150 1152 * 1151 1153 * @param window Window 1152 */ 1153 void ui_window_send_unfocus(ui_window_t *window) 1154 * @param nfocus Number of remaining foci 1155 */ 1156 void ui_window_send_unfocus(ui_window_t *window, unsigned nfocus) 1154 1157 { 1155 1158 if (window->cb != NULL && window->cb->unfocus != NULL) 1156 window->cb->unfocus(window, window->arg );1159 window->cb->unfocus(window, window->arg, nfocus); 1157 1160 else 1158 return ui_window_def_unfocus(window );1161 return ui_window_def_unfocus(window, nfocus); 1159 1162 } 1160 1163 … … 1292 1295 * 1293 1296 * @param window Window 1297 * @param nfocus Number of remaining foci 1294 1298 * @return EOK on success or an error code 1295 1299 */ 1296 void ui_window_def_unfocus(ui_window_t *window )1300 void ui_window_def_unfocus(ui_window_t *window, unsigned nfocus) 1297 1301 { 1298 1302 if (window->control != NULL) 1299 ui_control_unfocus(window->control );1303 ui_control_unfocus(window->control, nfocus); 1300 1304 } 1301 1305 -
uspace/lib/ui/test/control.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 static ui_evclaim_t test_ctl_kbd_event(void *, kbd_event_t *); 45 45 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 46 static void test_ctl_unfocus(void * );46 static void test_ctl_unfocus(void *, unsigned); 47 47 48 48 static ui_control_ops_t test_ctl_ops = { … … 79 79 /** @c true iff unfocus was called */ 80 80 bool unfocus; 81 /** Number of remaining foci that was sent */ 82 unsigned unfocus_nfocus; 81 83 } test_resp_t; 82 84 … … 223 225 resp.unfocus = false; 224 226 225 ui_control_unfocus(control );227 ui_control_unfocus(control, 42); 226 228 PCUT_ASSERT_TRUE(resp.unfocus); 229 PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus); 227 230 228 231 ui_control_delete(control); … … 264 267 } 265 268 266 static void test_ctl_unfocus(void *arg )269 static void test_ctl_unfocus(void *arg, unsigned nfocus) 267 270 { 268 271 test_resp_t *resp = (test_resp_t *) arg; 269 272 270 273 resp->unfocus = true; 274 resp->unfocus_nfocus = nfocus; 271 275 } 272 276 -
uspace/lib/ui/test/fixed.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 static errno_t test_ctl_paint(void *); 42 42 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 43 static void test_ctl_unfocus(void * );43 static void test_ctl_unfocus(void *, unsigned); 44 44 45 45 static ui_control_ops_t test_ctl_ops = { … … 66 66 /** @c true iff unfocus was called */ 67 67 bool unfocus; 68 /** Number of remaining foci */ 69 unsigned unfocus_nfocus; 68 70 } test_resp_t; 69 71 … … 253 255 resp.unfocus = false; 254 256 255 ui_fixed_unfocus(fixed );257 ui_fixed_unfocus(fixed, 42); 256 258 PCUT_ASSERT_TRUE(resp.unfocus); 259 PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus); 257 260 258 261 ui_fixed_destroy(fixed); … … 284 287 } 285 288 286 static void test_ctl_unfocus(void *arg )289 static void test_ctl_unfocus(void *arg, unsigned nfocus) 287 290 { 288 291 test_resp_t *resp = (test_resp_t *) arg; 289 292 290 293 resp->unfocus = true; 294 resp->unfocus_nfocus = nfocus; 291 295 } 292 296 -
uspace/lib/ui/test/popup.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 64 64 static errno_t test_ctl_paint(void *); 65 65 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 66 static void test_ctl_unfocus(void * );66 static void test_ctl_unfocus(void *, unsigned); 67 67 68 68 static ui_control_ops_t test_ctl_ops = { … … 91 91 pos_event_t pos_event; 92 92 bool unfocus; 93 unsigned unfocus_nfocus; 93 94 } test_ctl_resp_t; 94 95 … … 341 342 } 342 343 343 static void test_ctl_unfocus(void *arg )344 static void test_ctl_unfocus(void *arg, unsigned nfocus) 344 345 { 345 346 test_ctl_resp_t *resp = (test_ctl_resp_t *) arg; 346 347 347 348 resp->unfocus = true; 349 resp->unfocus_nfocus = nfocus; 348 350 } 349 351 -
uspace/lib/ui/test/window.c
rb3eeae5 r46a47c0 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 static void test_window_unmaximize(ui_window_t *, void *); 50 50 static void test_window_close(ui_window_t *, void *); 51 static void test_window_focus(ui_window_t *, void * );51 static void test_window_focus(ui_window_t *, void *, unsigned); 52 52 static void test_window_kbd(ui_window_t *, void *, kbd_event_t *); 53 53 static errno_t test_window_paint(ui_window_t *, void *); 54 54 static void test_window_pos(ui_window_t *, void *, pos_event_t *); 55 static void test_window_unfocus(ui_window_t *, void * );55 static void test_window_unfocus(ui_window_t *, void *, unsigned); 56 56 57 57 static ui_window_cb_t test_window_cb = { … … 72 72 static errno_t test_ctl_paint(void *); 73 73 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 74 static void test_ctl_unfocus(void * );74 static void test_ctl_unfocus(void *, unsigned); 75 75 76 76 static ui_control_ops_t test_ctl_ops = { … … 87 87 bool close; 88 88 bool focus; 89 unsigned focus_nfocus; 89 90 bool kbd; 90 91 kbd_event_t kbd_event; … … 93 94 pos_event_t pos_event; 94 95 bool unfocus; 96 unsigned unfocus_nfocus; 95 97 } test_cb_resp_t; 96 98 … … 102 104 pos_event_t pos_event; 103 105 bool unfocus; 106 unsigned unfocus_nfocus; 104 107 } test_ctl_resp_t; 105 108 … … 530 533 resp.unfocus = false; 531 534 532 ui_window_def_unfocus(window );535 ui_window_def_unfocus(window, 42); 533 536 PCUT_ASSERT_TRUE(resp.unfocus); 537 PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus); 534 538 535 539 /* Need to remove first because we didn't implement the destructor */ … … 704 708 705 709 /* Focus callback with no callbacks set */ 706 ui_window_send_focus(window );710 ui_window_send_focus(window, 42); 707 711 708 712 /* Focus callback with focus callback not implemented */ 709 713 ui_window_set_cb(window, &dummy_window_cb, NULL); 710 ui_window_send_focus(window );714 ui_window_send_focus(window, 42); 711 715 712 716 /* Focus callback with real callback set */ 713 717 resp.focus = false; 714 718 ui_window_set_cb(window, &test_window_cb, &resp); 715 ui_window_send_focus(window );719 ui_window_send_focus(window, 42); 716 720 PCUT_ASSERT_TRUE(resp.focus); 721 PCUT_ASSERT_INT_EQUALS(42, resp.focus_nfocus); 717 722 718 723 ui_window_destroy(window); … … 872 877 873 878 /* Unfocus callback with no callbacks set */ 874 ui_window_send_unfocus(window );879 ui_window_send_unfocus(window, 42); 875 880 876 881 /* Unfocus callback with unfocus callback not implemented */ 877 882 ui_window_set_cb(window, &dummy_window_cb, NULL); 878 ui_window_send_unfocus(window );883 ui_window_send_unfocus(window, 42); 879 884 880 885 /* Unfocus callback with real callback set */ 881 886 resp.close = false; 882 887 ui_window_set_cb(window, &test_window_cb, &resp); 883 ui_window_send_unfocus(window );888 ui_window_send_unfocus(window, 42); 884 889 PCUT_ASSERT_TRUE(resp.unfocus); 890 PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus); 885 891 886 892 ui_window_destroy(window); … … 916 922 } 917 923 918 static void test_window_focus(ui_window_t *window, void *arg )924 static void test_window_focus(ui_window_t *window, void *arg, unsigned nfocus) 919 925 { 920 926 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 921 927 922 928 resp->focus = true; 929 resp->focus_nfocus = nfocus; 923 930 } 924 931 … … 949 956 } 950 957 951 static void test_window_unfocus(ui_window_t *window, void *arg )958 static void test_window_unfocus(ui_window_t *window, void *arg, unsigned nfocus) 952 959 { 953 960 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 954 961 955 962 resp->unfocus = true; 963 resp->unfocus_nfocus = nfocus; 956 964 } 957 965 … … 974 982 } 975 983 976 static void test_ctl_unfocus(void *arg )984 static void test_ctl_unfocus(void *arg, unsigned nfocus) 977 985 { 978 986 test_ctl_resp_t *resp = (test_ctl_resp_t *) arg; 979 987 980 988 resp->unfocus = true; 989 resp->unfocus_nfocus = nfocus; 981 990 } 982 991
Note:
See TracChangeset
for help on using the changeset viewer.