Changes in uspace/lib/display/src/display.c [5d380b6:c9927c66] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/src/display.c
r5d380b6 rc9927c66 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <mem.h> 39 39 #include <stdlib.h> 40 #include <str.h>41 40 #include "../private/display.h" 42 41 #include "../private/params.h" … … 69 68 dsname = SERVICE_NAME_DISPLAY; 70 69 71 rc = loc_service_get_id(dsname, &display_svc, 0);70 rc = loc_service_get_id(dsname, &display_svc, IPC_FLAG_BLOCKING); 72 71 if (rc != EOK) { 73 72 free(display); … … 76 75 77 76 display->sess = loc_service_connect(display_svc, INTERFACE_DISPLAY, 78 0);77 IPC_FLAG_BLOCKING); 79 78 if (display->sess == NULL) { 80 79 free(display); … … 148 147 { 149 148 memset(params, 0, sizeof(*params)); 150 params->caption = "";151 149 } 152 150 … … 164 162 { 165 163 display_window_t *window; 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; 164 async_exch_t *exch; 165 aid_t req; 166 ipc_call_t answer; 167 errno_t rc; 179 168 180 169 window = calloc(1, sizeof(display_window_t)); … … 184 173 exch = async_exchange_begin(display->sess); 185 174 req = async_send_0(exch, DISPLAY_WINDOW_CREATE, &answer); 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); 175 rc = async_data_write_start(exch, params, sizeof (display_wnd_params_t)); 200 176 async_exchange_end(exch); 201 177 if (rc != EOK) { … … 285 261 * @param window Window 286 262 * @param pos Position in the window where the button was pressed 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); 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); 301 274 rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t)); 302 275 async_exchange_end(exch); … … 377 350 } 378 351 379 /** Get display window maximized rectangle.380 *381 * Get the rectangle to which a window would be maximized.382 *383 * @param window Window384 * @param rect Place to store maximized rectangle385 * @return EOK on success or an error code386 */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 411 352 /** Request a window resize. 412 353 * … … 418 359 * @param rsztype Resize type (which part of window frame is being dragged) 419 360 * @param pos Position in the window where the button was pressed 420 * @param pos_id Positioning device ID421 361 * @return EOK on success or an error code 422 362 */ 423 363 errno_t display_window_resize_req(display_window_t *window, 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);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); 434 374 rc = async_data_write_start(exch, (void *)pos, sizeof (gfx_coord2_t)); 435 375 async_exchange_end(exch); … … 515 455 } 516 456 517 /** Minimize window.518 *519 * @param window Window520 * @return EOK on success or an error code521 */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 Window537 * @return EOK on success or an error code538 */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 Window554 * @return EOK on success or an error code555 */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 568 457 /** Set window cursor. 569 458 * … … 585 474 cursor); 586 475 async_exchange_end(exch); 587 return rc;588 }589 590 /** Set display window caption.591 *592 * @param window Window593 * @param caption New caption594 * @return EOK on success or an error code595 */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);620 476 return rc; 621 477 } … … 721 577 case wev_focus: 722 578 if (window->cb != NULL && window->cb->focus_event != NULL) { 723 window->cb->focus_event(window->cb_arg, 724 event.ev.focus.nfocus); 579 window->cb->focus_event(window->cb_arg); 725 580 } 726 581 break; … … 745 600 case wev_unfocus: 746 601 if (window->cb != NULL && window->cb->unfocus_event != NULL) { 747 window->cb->unfocus_event(window->cb_arg, 748 event.ev.unfocus.nfocus); 602 window->cb->unfocus_event(window->cb_arg); 749 603 } 750 604 break;
Note:
See TracChangeset
for help on using the changeset viewer.