Changeset aeb3037 in mainline for uspace/lib/display/src


Ignore:
Timestamp:
2020-03-18T17:27:18Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0680854
Parents:
1a1271d
git-author:
Jiri Svoboda <jiri@…> (2020-03-18 16:57:15)
git-committer:
Jiri Svoboda <jiri@…> (2020-03-18 17:27:18)
Message:

Allow getting display dimensions

Can be used to position special windows such as panels, or to help
emulate libgui's window placement policy. To support multi-monitor
setups we would rather need to be able to query individual monitors.
But let's keep things simple for now.

Location:
uspace/lib/display/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/src/disp_srv.c

    r1a1271d raeb3037  
    3737#include <disp_srv.h>
    3838#include <display/event.h>
     39#include <display/info.h>
    3940#include <display/wndresize.h>
    4041#include <errno.h>
     
    268269}
    269270
     271static void display_get_info_srv(display_srv_t *srv, ipc_call_t *icall)
     272{
     273        display_info_t info;
     274        ipc_call_t call;
     275        size_t size;
     276        errno_t rc;
     277
     278        if (srv->ops->get_info == NULL) {
     279                async_answer_0(icall, ENOTSUP);
     280                return;
     281        }
     282
     283        /* Transfer information */
     284        if (!async_data_read_receive(&call, &size)) {
     285                async_answer_0(icall, EREFUSED);
     286                return;
     287        }
     288
     289        if (size != sizeof(info)) {
     290                async_answer_0(icall, EREFUSED);
     291                async_answer_0(&call, EREFUSED);
     292                return;
     293        }
     294
     295        rc = srv->ops->get_info(srv->arg, &info);
     296        if (rc != EOK) {
     297                async_answer_0(icall, rc);
     298                async_answer_0(&call, rc);
     299                return;
     300        }
     301
     302        rc = async_data_read_finalize(&call, &info, sizeof(info));
     303        if (rc != EOK) {
     304                async_answer_0(icall, rc);
     305                async_answer_0(&call, rc);
     306                return;
     307        }
     308
     309        async_answer_0(icall, EOK);
     310}
     311
    270312void display_conn(ipc_call_t *icall, display_srv_t *srv)
    271313{
     
    306348                case DISPLAY_GET_EVENT:
    307349                        display_get_event_srv(srv, &call);
     350                        break;
     351                case DISPLAY_GET_INFO:
     352                        display_get_info_srv(srv, &call);
    308353                        break;
    309354                default:
  • uspace/lib/display/src/display.c

    r1a1271d raeb3037  
    385385 *
    386386 * @param display Display
    387  * @param rwindow Place to store pointe to window that received event
     387 * @param rwindow Place to store pointer to window that received event
    388388 * @param event Place to store event
    389389 * @return EOK on success or an error code
     
    418418
    419419        *rwindow = window;
     420        return EOK;
     421}
     422
     423/** Get display information.
     424 *
     425 * @param display Display
     426 * @param info Place to store display information
     427 * @return EOK on success or an error code
     428 */
     429errno_t display_get_info(display_t *display, display_info_t *info)
     430{
     431        async_exch_t *exch;
     432        ipc_call_t answer;
     433        aid_t req;
     434        errno_t rc;
     435
     436        exch = async_exchange_begin(display->sess);
     437        req = async_send_0(exch, DISPLAY_GET_INFO, &answer);
     438        rc = async_data_read_start(exch, info, sizeof(*info));
     439        async_exchange_end(exch);
     440        if (rc != EOK) {
     441                async_forget(req);
     442                return rc;
     443        }
     444
     445        async_wait_for(req, &rc);
     446        if (rc != EOK)
     447                return rc;
     448
    420449        return EOK;
    421450}
Note: See TracChangeset for help on using the changeset viewer.