Changeset 8a6ebbb in mainline
- Timestamp:
- 2023-09-14T11:39:09Z (12 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a0b2cc
- Parents:
- 112f70a
- git-author:
- Jiri Svoboda <jiri@…> (2023-09-13 19:39:06)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-09-14 11:39:09)
- Location:
- uspace/lib/ui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/private/window.h
r112f70a r8a6ebbb 96 96 /** System menu */ 97 97 struct ui_menu *sysmenu; 98 /** System menu restore entry */ 99 struct ui_menu_entry *sysmenu_restore; 100 /** System menu minimize entry */ 101 struct ui_menu_entry *sysmenu_minimize; 102 /** System menu maximize entry */ 103 struct ui_menu_entry *sysmenu_maximize; 98 104 /** Top-level control in the application area */ 99 105 struct ui_control *control; -
uspace/lib/ui/src/window.c
r112f70a r8a6ebbb 109 109 }; 110 110 111 static void wnd_sysmenu_erestore(ui_menu_entry_t *, void *); 112 static void wnd_sysmenu_eminimize(ui_menu_entry_t *, void *); 113 static void wnd_sysmenu_emaximize(ui_menu_entry_t *, void *); 111 114 static void wnd_sysmenu_eclose(ui_menu_entry_t *, void *); 112 115 … … 208 211 } 209 212 213 /** Create window's system menu. 214 * 215 * @param window Window 216 * @return EOK on success or an error code 217 */ 218 static errno_t ui_window_sysmenu_create(ui_window_t *window) 219 { 220 errno_t rc; 221 ui_menu_entry_t *mrestore; 222 ui_menu_entry_t *mmin; 223 ui_menu_entry_t *mmax; 224 ui_menu_entry_t *msep; 225 ui_menu_entry_t *mclose; 226 227 rc = ui_menu_create(window, &window->sysmenu); 228 if (rc != EOK) 229 goto error; 230 231 ui_menu_set_cb(window->sysmenu, &wnd_sysmenu_cb, (void *)window); 232 233 rc = ui_menu_entry_create(window->sysmenu, "~R~estore", 234 "", &mrestore); 235 if (rc != EOK) 236 goto error; 237 238 if (!window->wdecor->maximized) 239 ui_menu_entry_set_disabled(mrestore, true); 240 241 ui_menu_entry_set_cb(mrestore, wnd_sysmenu_erestore, (void *)window); 242 243 rc = ui_menu_entry_create(window->sysmenu, "Mi~n~imize", 244 "", &mmin); 245 if (rc != EOK) 246 goto error; 247 248 if ((window->wdecor->style & ui_wds_minimize_btn) == 0) 249 ui_menu_entry_set_disabled(mmin, true); 250 251 ui_menu_entry_set_cb(mmin, wnd_sysmenu_eminimize, (void *)window); 252 253 rc = ui_menu_entry_create(window->sysmenu, "Ma~x~imize", 254 "", &mmax); 255 if (rc != EOK) 256 goto error; 257 258 if ((window->wdecor->style & ui_wds_maximize_btn) == 0 || 259 window->wdecor->maximized) 260 ui_menu_entry_set_disabled(mmax, true); 261 262 ui_menu_entry_set_cb(mmax, wnd_sysmenu_emaximize, (void *)window); 263 264 rc = ui_menu_entry_sep_create(window->sysmenu, &msep); 265 if (rc != EOK) 266 goto error; 267 268 rc = ui_menu_entry_create(window->sysmenu, "~C~lose", "Alt-F4", 269 &mclose); 270 if (rc != EOK) 271 goto error; 272 273 if ((window->wdecor->style & ui_wds_close_btn) == 0) 274 ui_menu_entry_set_disabled(mclose, true); 275 276 ui_menu_entry_set_cb(mclose, wnd_sysmenu_eclose, (void *)window); 277 278 window->sysmenu_restore = mrestore; 279 window->sysmenu_minimize = mmin; 280 window->sysmenu_maximize = mmax; 281 282 return EOK; 283 error: 284 return rc; 285 } 286 210 287 /** Create new window. 211 288 * … … 399 476 window->cursor = ui_curs_arrow; 400 477 window->placement = params->placement; 478 479 rc = ui_window_sysmenu_create(window); 480 if (rc != EOK) 481 goto error; 482 401 483 *rwindow = window; 402 484 … … 1230 1312 { 1231 1313 errno_t rc; 1232 ui_menu_entry_t *mclose;1233 1314 ui_wdecor_geom_t geom; 1234 1235 if (window->sysmenu == NULL) {1236 rc = ui_menu_create(window, &window->sysmenu);1237 if (rc != EOK)1238 goto error;1239 1240 ui_menu_set_cb(window->sysmenu, &wnd_sysmenu_cb,1241 (void *)window);1242 1243 rc = ui_menu_entry_create(window->sysmenu, "~C~lose", "Alt-F4",1244 &mclose);1245 if (rc != EOK)1246 goto error;1247 1248 ui_menu_entry_set_cb(mclose, wnd_sysmenu_eclose,1249 (void *)window);1250 }1251 1315 1252 1316 if (ui_menu_is_open(window->sysmenu)) { … … 1308 1372 1309 1373 ui_wdecor_set_maximized(window->wdecor, true); 1374 ui_menu_entry_set_disabled(window->sysmenu_restore, false); 1375 ui_menu_entry_set_disabled(window->sysmenu_maximize, true); 1310 1376 1311 1377 rc = ui_window_size_change(window, &rect, ui_wsc_maximize); … … 1330 1396 1331 1397 ui_wdecor_set_maximized(window->wdecor, false); 1398 ui_menu_entry_set_disabled(window->sysmenu_restore, true); 1399 ui_menu_entry_set_disabled(window->sysmenu_maximize, false); 1332 1400 1333 1401 rc = ui_window_size_change(window, &window->normal_rect, … … 1452 1520 1453 1521 ui_menu_close(sysmenu); 1522 } 1523 1524 /** Handle system menu Restore entry activation. 1525 * 1526 * @param mentry Menu entry 1527 * @param arg Argument (ui_window_t *) 1528 */ 1529 static void wnd_sysmenu_erestore(ui_menu_entry_t *mentry, void *arg) 1530 { 1531 ui_window_t *window = (ui_window_t *)arg; 1532 1533 ui_window_send_unmaximize(window); 1534 } 1535 1536 /** Handle system menu Minimize entry activation. 1537 * 1538 * @param mentry Menu entry 1539 * @param arg Argument (ui_window_t *) 1540 */ 1541 static void wnd_sysmenu_eminimize(ui_menu_entry_t *mentry, void *arg) 1542 { 1543 ui_window_t *window = (ui_window_t *)arg; 1544 1545 ui_window_send_minimize(window); 1546 } 1547 1548 /** Handle system menu Maximize entry activation. 1549 * 1550 * @param mentry Menu entry 1551 * @param arg Argument (ui_window_t *) 1552 */ 1553 static void wnd_sysmenu_emaximize(ui_menu_entry_t *mentry, void *arg) 1554 { 1555 ui_window_t *window = (ui_window_t *)arg; 1556 1557 ui_window_send_maximize(window); 1454 1558 } 1455 1559
Note:
See TracChangeset
for help on using the changeset viewer.