Changes in uspace/lib/display/src/display.c [c9927c66:5d380b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/src/display.c
rc9927c66 r5d380b6 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <mem.h> 39 39 #include <stdlib.h> 40 #include <str.h> 40 41 #include "../private/display.h" 41 42 #include "../private/params.h" … … 68 69 dsname = SERVICE_NAME_DISPLAY; 69 70 70 rc = loc_service_get_id(dsname, &display_svc, IPC_FLAG_BLOCKING);71 rc = loc_service_get_id(dsname, &display_svc, 0); 71 72 if (rc != EOK) { 72 73 free(display); … … 75 76 76 77 display->sess = loc_service_connect(display_svc, INTERFACE_DISPLAY, 77 IPC_FLAG_BLOCKING);78 0); 78 79 if (display->sess == NULL) { 79 80 free(display); … … 147 148 { 148 149 memset(params, 0, sizeof(*params)); 150 params->caption = ""; 149 151 } 150 152 … … 162 164 { 163 165 display_window_t *window; 164 async_exch_t *exch; 165 aid_t req; 166 ipc_call_t answer; 167 errno_t rc; 166 display_wnd_params_enc_t eparams; 167 async_exch_t *exch; 168 aid_t req; 169 ipc_call_t answer; 170 errno_t rc; 171 172 /* Encode the parameters for transport */ 173 eparams.rect = params->rect; 174 eparams.caption_size = str_size(params->caption); 175 eparams.min_size = params->min_size; 176 eparams.pos = params->pos; 177 eparams.flags = params->flags; 178 eparams.idev_id = params->idev_id; 168 179 169 180 window = calloc(1, sizeof(display_window_t)); … … 173 184 exch = async_exchange_begin(display->sess); 174 185 req = async_send_0(exch, DISPLAY_WINDOW_CREATE, &answer); 175 rc = async_data_write_start(exch, params, sizeof (display_wnd_params_t)); 186 187 /* Write fixed fields */ 188 rc = async_data_write_start(exch, &eparams, 189 sizeof (display_wnd_params_enc_t)); 190 if (rc != EOK) { 191 async_exchange_end(exch); 192 async_forget(req); 193 free(window); 194 return rc; 195 } 196 197 /* Write caption */ 198 rc = async_data_write_start(exch, params->caption, 199 eparams.caption_size); 176 200 async_exchange_end(exch); 177 201 if (rc != EOK) { … … 261 285 * @param window Window 262 286 * @param pos Position in the window where the button was pressed 263 * @return EOK on success or an error code 264 */ 265 errno_t display_window_move_req(display_window_t *window, gfx_coord2_t *pos) 266 { 267 async_exch_t *exch; 268 aid_t req; 269 ipc_call_t answer; 270 errno_t rc; 271 272 exch = async_exchange_begin(window->display->sess); 273 req = async_send_1(exch, DISPLAY_WINDOW_MOVE_REQ, window->id, &answer); 287 * @param pos_id Positioning device ID 288 * @return EOK on success or an error code 289 */ 290 errno_t display_window_move_req(display_window_t *window, gfx_coord2_t *pos, 291 sysarg_t pos_id) 292 { 293 async_exch_t *exch; 294 aid_t req; 295 ipc_call_t answer; 296 errno_t rc; 297 298 exch = async_exchange_begin(window->display->sess); 299 req = async_send_2(exch, DISPLAY_WINDOW_MOVE_REQ, window->id, 300 pos_id, &answer); 274 301 rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t)); 275 302 async_exchange_end(exch); … … 350 377 } 351 378 379 /** Get display window maximized rectangle. 380 * 381 * Get the rectangle to which a window would be maximized. 382 * 383 * @param window Window 384 * @param rect Place to store maximized rectangle 385 * @return EOK on success or an error code 386 */ 387 errno_t display_window_get_max_rect(display_window_t *window, gfx_rect_t *rect) 388 { 389 async_exch_t *exch; 390 aid_t req; 391 ipc_call_t answer; 392 errno_t rc; 393 394 exch = async_exchange_begin(window->display->sess); 395 req = async_send_1(exch, DISPLAY_WINDOW_GET_MAX_RECT, window->id, 396 &answer); 397 rc = async_data_read_start(exch, rect, sizeof (gfx_rect_t)); 398 async_exchange_end(exch); 399 if (rc != EOK) { 400 async_forget(req); 401 return rc; 402 } 403 404 async_wait_for(req, &rc); 405 if (rc != EOK) 406 return rc; 407 408 return EOK; 409 } 410 352 411 /** Request a window resize. 353 412 * … … 359 418 * @param rsztype Resize type (which part of window frame is being dragged) 360 419 * @param pos Position in the window where the button was pressed 420 * @param pos_id Positioning device ID 361 421 * @return EOK on success or an error code 362 422 */ 363 423 errno_t display_window_resize_req(display_window_t *window, 364 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos )365 { 366 async_exch_t *exch; 367 aid_t req; 368 ipc_call_t answer; 369 errno_t rc; 370 371 exch = async_exchange_begin(window->display->sess); 372 req = async_send_ 2(exch, DISPLAY_WINDOW_RESIZE_REQ, window->id,373 (sysarg_t) rsztype, &answer);424 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id) 425 { 426 async_exch_t *exch; 427 aid_t req; 428 ipc_call_t answer; 429 errno_t rc; 430 431 exch = async_exchange_begin(window->display->sess); 432 req = async_send_3(exch, DISPLAY_WINDOW_RESIZE_REQ, window->id, 433 (sysarg_t) rsztype, pos_id, &answer); 374 434 rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t)); 375 435 async_exchange_end(exch); … … 455 515 } 456 516 517 /** Minimize window. 518 * 519 * @param window Window 520 * @return EOK on success or an error code 521 */ 522 errno_t display_window_minimize(display_window_t *window) 523 { 524 async_exch_t *exch; 525 errno_t rc; 526 527 exch = async_exchange_begin(window->display->sess); 528 rc = async_req_1_0(exch, DISPLAY_WINDOW_MINIMIZE, window->id); 529 async_exchange_end(exch); 530 531 return rc; 532 } 533 534 /** Maximize window. 535 * 536 * @param window Window 537 * @return EOK on success or an error code 538 */ 539 errno_t display_window_maximize(display_window_t *window) 540 { 541 async_exch_t *exch; 542 errno_t rc; 543 544 exch = async_exchange_begin(window->display->sess); 545 rc = async_req_1_0(exch, DISPLAY_WINDOW_MAXIMIZE, window->id); 546 async_exchange_end(exch); 547 548 return rc; 549 } 550 551 /** Unmaximize window. 552 * 553 * @param window Window 554 * @return EOK on success or an error code 555 */ 556 errno_t display_window_unmaximize(display_window_t *window) 557 { 558 async_exch_t *exch; 559 errno_t rc; 560 561 exch = async_exchange_begin(window->display->sess); 562 rc = async_req_1_0(exch, DISPLAY_WINDOW_UNMAXIMIZE, window->id); 563 async_exchange_end(exch); 564 565 return rc; 566 } 567 457 568 /** Set window cursor. 458 569 * … … 474 585 cursor); 475 586 async_exchange_end(exch); 587 return rc; 588 } 589 590 /** Set display window caption. 591 * 592 * @param window Window 593 * @param caption New caption 594 * @return EOK on success or an error code 595 */ 596 errno_t display_window_set_caption(display_window_t *window, 597 const char *caption) 598 { 599 async_exch_t *exch; 600 aid_t req; 601 ipc_call_t answer; 602 size_t cap_size; 603 errno_t rc; 604 605 cap_size = str_size(caption); 606 607 exch = async_exchange_begin(window->display->sess); 608 req = async_send_1(exch, DISPLAY_WINDOW_SET_CAPTION, window->id, 609 &answer); 610 611 /* Write caption */ 612 rc = async_data_write_start(exch, caption, cap_size); 613 async_exchange_end(exch); 614 if (rc != EOK) { 615 async_forget(req); 616 return rc; 617 } 618 619 async_wait_for(req, &rc); 476 620 return rc; 477 621 } … … 577 721 case wev_focus: 578 722 if (window->cb != NULL && window->cb->focus_event != NULL) { 579 window->cb->focus_event(window->cb_arg); 723 window->cb->focus_event(window->cb_arg, 724 event.ev.focus.nfocus); 580 725 } 581 726 break; … … 600 745 case wev_unfocus: 601 746 if (window->cb != NULL && window->cb->unfocus_event != NULL) { 602 window->cb->unfocus_event(window->cb_arg); 747 window->cb->unfocus_event(window->cb_arg, 748 event.ev.unfocus.nfocus); 603 749 } 604 750 break;
Note:
See TracChangeset
for help on using the changeset viewer.