[c8cf261] | 1 | /*
|
---|
[35cffea] | 2 | * Copyright (c) 2022 Jiri Svoboda
|
---|
[c8cf261] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[973efd36] | 29 | /** @addtogroup libdisplay
|
---|
[c8cf261] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /**
|
---|
| 33 | * @file
|
---|
| 34 | * @brief Display protocol server stub
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | #include <disp_srv.h>
|
---|
[b3c185b6] | 38 | #include <display/event.h>
|
---|
[aeb3037] | 39 | #include <display/info.h>
|
---|
[1e4a937] | 40 | #include <display/wndresize.h>
|
---|
[c8cf261] | 41 | #include <errno.h>
|
---|
[b3c185b6] | 42 | #include <io/log.h>
|
---|
[c8cf261] | 43 | #include <ipc/display.h>
|
---|
[959b7ec] | 44 | #include <mem.h>
|
---|
[c8cf261] | 45 | #include <stdlib.h>
|
---|
| 46 | #include <stddef.h>
|
---|
[0e6e77f] | 47 | #include "../private/params.h"
|
---|
[c8cf261] | 48 |
|
---|
[b3c185b6] | 49 | static void display_callback_create_srv(display_srv_t *srv, ipc_call_t *call)
|
---|
| 50 | {
|
---|
| 51 | async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
|
---|
| 52 | if (sess == NULL) {
|
---|
| 53 | async_answer_0(call, ENOMEM);
|
---|
| 54 | return;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | srv->client_sess = sess;
|
---|
| 58 | async_answer_0(call, EOK);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[c8cf261] | 61 | static void display_window_create_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 62 | {
|
---|
| 63 | sysarg_t wnd_id;
|
---|
[4d9c807] | 64 | ipc_call_t call;
|
---|
| 65 | display_wnd_params_t params;
|
---|
| 66 | size_t size;
|
---|
[c8cf261] | 67 | errno_t rc;
|
---|
| 68 |
|
---|
[4d9c807] | 69 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 70 | async_answer_0(&call, EREFUSED);
|
---|
| 71 | async_answer_0(icall, EREFUSED);
|
---|
| 72 | return;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | if (size != sizeof(display_wnd_params_t)) {
|
---|
| 76 | async_answer_0(&call, EINVAL);
|
---|
| 77 | async_answer_0(icall, EINVAL);
|
---|
| 78 | return;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | rc = async_data_write_finalize(&call, ¶ms, size);
|
---|
| 82 | if (rc != EOK) {
|
---|
| 83 | async_answer_0(&call, rc);
|
---|
| 84 | async_answer_0(icall, rc);
|
---|
| 85 | return;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[c8cf261] | 88 | if (srv->ops->window_create == NULL) {
|
---|
| 89 | async_answer_0(icall, ENOTSUP);
|
---|
| 90 | return;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[4d9c807] | 93 | rc = srv->ops->window_create(srv->arg, ¶ms, &wnd_id);
|
---|
[c8cf261] | 94 | async_answer_1(icall, rc, wnd_id);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | static void display_window_destroy_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 98 | {
|
---|
| 99 | sysarg_t wnd_id;
|
---|
| 100 | errno_t rc;
|
---|
| 101 |
|
---|
| 102 | wnd_id = ipc_get_arg1(icall);
|
---|
| 103 |
|
---|
[a2e104e] | 104 | if (srv->ops->window_destroy == NULL) {
|
---|
[c8cf261] | 105 | async_answer_0(icall, ENOTSUP);
|
---|
| 106 | return;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | rc = srv->ops->window_destroy(srv->arg, wnd_id);
|
---|
| 110 | async_answer_0(icall, rc);
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[a2e104e] | 113 | static void display_window_move_req_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 114 | {
|
---|
| 115 | sysarg_t wnd_id;
|
---|
| 116 | ipc_call_t call;
|
---|
| 117 | gfx_coord2_t pos;
|
---|
| 118 | size_t size;
|
---|
| 119 | errno_t rc;
|
---|
| 120 |
|
---|
| 121 | wnd_id = ipc_get_arg1(icall);
|
---|
| 122 |
|
---|
| 123 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 124 | async_answer_0(&call, EREFUSED);
|
---|
| 125 | async_answer_0(icall, EREFUSED);
|
---|
| 126 | return;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | if (size != sizeof(gfx_coord2_t)) {
|
---|
| 130 | async_answer_0(&call, EINVAL);
|
---|
| 131 | async_answer_0(icall, EINVAL);
|
---|
| 132 | return;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | rc = async_data_write_finalize(&call, &pos, size);
|
---|
| 136 | if (rc != EOK) {
|
---|
| 137 | async_answer_0(&call, rc);
|
---|
| 138 | async_answer_0(icall, rc);
|
---|
| 139 | return;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | if (srv->ops->window_move_req == NULL) {
|
---|
| 143 | async_answer_0(icall, ENOTSUP);
|
---|
| 144 | return;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | rc = srv->ops->window_move_req(srv->arg, wnd_id, &pos);
|
---|
| 148 | async_answer_0(icall, rc);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
[0680854] | 151 | static void display_window_move_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 152 | {
|
---|
| 153 | sysarg_t wnd_id;
|
---|
| 154 | ipc_call_t call;
|
---|
| 155 | gfx_coord2_t dpos;
|
---|
| 156 | size_t size;
|
---|
| 157 | errno_t rc;
|
---|
| 158 |
|
---|
| 159 | wnd_id = ipc_get_arg1(icall);
|
---|
| 160 |
|
---|
| 161 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 162 | async_answer_0(&call, EREFUSED);
|
---|
| 163 | async_answer_0(icall, EREFUSED);
|
---|
| 164 | return;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | if (size != sizeof(gfx_coord2_t)) {
|
---|
| 168 | async_answer_0(&call, EINVAL);
|
---|
| 169 | async_answer_0(icall, EINVAL);
|
---|
| 170 | return;
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | rc = async_data_write_finalize(&call, &dpos, size);
|
---|
| 174 | if (rc != EOK) {
|
---|
| 175 | async_answer_0(&call, rc);
|
---|
| 176 | async_answer_0(icall, rc);
|
---|
| 177 | return;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | if (srv->ops->window_move == NULL) {
|
---|
| 181 | async_answer_0(icall, ENOTSUP);
|
---|
| 182 | return;
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | rc = srv->ops->window_move(srv->arg, wnd_id, &dpos);
|
---|
| 186 | async_answer_0(icall, rc);
|
---|
| 187 | }
|
---|
| 188 |
|
---|
[c9927c66] | 189 | static void display_window_get_pos_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 190 | {
|
---|
| 191 | sysarg_t wnd_id;
|
---|
| 192 | ipc_call_t call;
|
---|
| 193 | gfx_coord2_t dpos;
|
---|
| 194 | size_t size;
|
---|
| 195 | errno_t rc;
|
---|
| 196 |
|
---|
| 197 | wnd_id = ipc_get_arg1(icall);
|
---|
| 198 |
|
---|
| 199 | if (srv->ops->window_get_pos == NULL) {
|
---|
| 200 | async_answer_0(icall, ENOTSUP);
|
---|
| 201 | return;
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 205 | async_answer_0(icall, EREFUSED);
|
---|
| 206 | return;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | rc = srv->ops->window_get_pos(srv->arg, wnd_id, &dpos);
|
---|
| 210 | if (rc != EOK) {
|
---|
| 211 | async_answer_0(&call, rc);
|
---|
| 212 | async_answer_0(icall, rc);
|
---|
| 213 | return;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | if (size != sizeof(gfx_coord2_t)) {
|
---|
| 217 | async_answer_0(&call, EINVAL);
|
---|
| 218 | async_answer_0(icall, EINVAL);
|
---|
| 219 | return;
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | rc = async_data_read_finalize(&call, &dpos, size);
|
---|
| 223 | if (rc != EOK) {
|
---|
| 224 | async_answer_0(&call, rc);
|
---|
| 225 | async_answer_0(icall, rc);
|
---|
| 226 | return;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | async_answer_0(icall, EOK);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[35cffea] | 232 | static void display_window_get_max_rect_srv(display_srv_t *srv,
|
---|
| 233 | ipc_call_t *icall)
|
---|
| 234 | {
|
---|
| 235 | sysarg_t wnd_id;
|
---|
| 236 | ipc_call_t call;
|
---|
| 237 | gfx_rect_t rect;
|
---|
| 238 | size_t size;
|
---|
| 239 | errno_t rc;
|
---|
| 240 |
|
---|
| 241 | wnd_id = ipc_get_arg1(icall);
|
---|
| 242 |
|
---|
| 243 | if (srv->ops->window_get_max_rect == NULL) {
|
---|
| 244 | async_answer_0(icall, ENOTSUP);
|
---|
| 245 | return;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 249 | async_answer_0(icall, EREFUSED);
|
---|
| 250 | return;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | rc = srv->ops->window_get_max_rect(srv->arg, wnd_id, &rect);
|
---|
| 254 | if (rc != EOK) {
|
---|
| 255 | async_answer_0(&call, rc);
|
---|
| 256 | async_answer_0(icall, rc);
|
---|
| 257 | return;
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | if (size != sizeof(gfx_rect_t)) {
|
---|
| 261 | async_answer_0(&call, EINVAL);
|
---|
| 262 | async_answer_0(icall, EINVAL);
|
---|
| 263 | return;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | rc = async_data_read_finalize(&call, &rect, size);
|
---|
| 267 | if (rc != EOK) {
|
---|
| 268 | async_answer_0(&call, rc);
|
---|
| 269 | async_answer_0(icall, rc);
|
---|
| 270 | return;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | async_answer_0(icall, EOK);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[1e4a937] | 276 | static void display_window_resize_req_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 277 | {
|
---|
| 278 | sysarg_t wnd_id;
|
---|
| 279 | ipc_call_t call;
|
---|
| 280 | display_wnd_rsztype_t rsztype;
|
---|
| 281 | gfx_coord2_t pos;
|
---|
| 282 | size_t size;
|
---|
| 283 | errno_t rc;
|
---|
| 284 |
|
---|
| 285 | wnd_id = ipc_get_arg1(icall);
|
---|
| 286 | rsztype = (display_wnd_rsztype_t) ipc_get_arg2(icall);
|
---|
| 287 |
|
---|
| 288 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 289 | async_answer_0(&call, EREFUSED);
|
---|
| 290 | async_answer_0(icall, EREFUSED);
|
---|
| 291 | return;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | if (size != sizeof(gfx_coord2_t)) {
|
---|
| 295 | async_answer_0(&call, EINVAL);
|
---|
| 296 | async_answer_0(icall, EINVAL);
|
---|
| 297 | return;
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | rc = async_data_write_finalize(&call, &pos, size);
|
---|
| 301 | if (rc != EOK) {
|
---|
| 302 | async_answer_0(&call, rc);
|
---|
| 303 | async_answer_0(icall, rc);
|
---|
| 304 | return;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | if (srv->ops->window_resize_req == NULL) {
|
---|
| 308 | async_answer_0(icall, ENOTSUP);
|
---|
| 309 | return;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | rc = srv->ops->window_resize_req(srv->arg, wnd_id, rsztype, &pos);
|
---|
| 313 | async_answer_0(icall, rc);
|
---|
| 314 | }
|
---|
| 315 |
|
---|
[0e6e77f] | 316 | static void display_window_resize_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 317 | {
|
---|
| 318 | sysarg_t wnd_id;
|
---|
| 319 | ipc_call_t call;
|
---|
[7bb45e3] | 320 | display_wnd_resize_t wresize;
|
---|
[0e6e77f] | 321 | size_t size;
|
---|
| 322 | errno_t rc;
|
---|
| 323 |
|
---|
| 324 | wnd_id = ipc_get_arg1(icall);
|
---|
| 325 |
|
---|
| 326 | if (!async_data_write_receive(&call, &size)) {
|
---|
| 327 | async_answer_0(&call, EREFUSED);
|
---|
| 328 | async_answer_0(icall, EREFUSED);
|
---|
| 329 | return;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[7bb45e3] | 332 | if (size != sizeof(display_wnd_resize_t)) {
|
---|
[0e6e77f] | 333 | async_answer_0(&call, EINVAL);
|
---|
| 334 | async_answer_0(icall, EINVAL);
|
---|
| 335 | return;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
[7bb45e3] | 338 | rc = async_data_write_finalize(&call, &wresize, size);
|
---|
[0e6e77f] | 339 | if (rc != EOK) {
|
---|
| 340 | async_answer_0(&call, rc);
|
---|
| 341 | async_answer_0(icall, rc);
|
---|
| 342 | return;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | if (srv->ops->window_resize == NULL) {
|
---|
| 346 | async_answer_0(icall, ENOTSUP);
|
---|
| 347 | return;
|
---|
| 348 | }
|
---|
| 349 |
|
---|
[7bb45e3] | 350 | rc = srv->ops->window_resize(srv->arg, wnd_id, &wresize.offs,
|
---|
| 351 | &wresize.nrect);
|
---|
[0e6e77f] | 352 | async_answer_0(icall, rc);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
[35cffea] | 355 | static void display_window_maximize_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 356 | {
|
---|
| 357 | sysarg_t wnd_id;
|
---|
| 358 | errno_t rc;
|
---|
| 359 |
|
---|
| 360 | wnd_id = ipc_get_arg1(icall);
|
---|
| 361 |
|
---|
| 362 | if (srv->ops->window_maximize == NULL) {
|
---|
| 363 | async_answer_0(icall, ENOTSUP);
|
---|
| 364 | return;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | rc = srv->ops->window_maximize(srv->arg, wnd_id);
|
---|
| 368 | async_answer_0(icall, rc);
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | static void display_window_unmaximize_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 372 | {
|
---|
| 373 | sysarg_t wnd_id;
|
---|
| 374 | errno_t rc;
|
---|
| 375 |
|
---|
| 376 | wnd_id = ipc_get_arg1(icall);
|
---|
| 377 |
|
---|
| 378 | if (srv->ops->window_unmaximize == NULL) {
|
---|
| 379 | async_answer_0(icall, ENOTSUP);
|
---|
| 380 | return;
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 | rc = srv->ops->window_unmaximize(srv->arg, wnd_id);
|
---|
| 384 | async_answer_0(icall, rc);
|
---|
| 385 | }
|
---|
| 386 |
|
---|
[5480d5e] | 387 | static void display_window_set_cursor_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 388 | {
|
---|
| 389 | sysarg_t wnd_id;
|
---|
| 390 | display_stock_cursor_t cursor;
|
---|
| 391 | errno_t rc;
|
---|
| 392 |
|
---|
| 393 | wnd_id = ipc_get_arg1(icall);
|
---|
| 394 | cursor = ipc_get_arg2(icall);
|
---|
| 395 |
|
---|
| 396 | if (srv->ops->window_set_cursor == NULL) {
|
---|
| 397 | async_answer_0(icall, ENOTSUP);
|
---|
| 398 | return;
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | rc = srv->ops->window_set_cursor(srv->arg, wnd_id, cursor);
|
---|
| 402 | async_answer_0(icall, rc);
|
---|
| 403 | }
|
---|
| 404 |
|
---|
[b3c185b6] | 405 | static void display_get_event_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 406 | {
|
---|
| 407 | sysarg_t wnd_id;
|
---|
| 408 | display_wnd_ev_t event;
|
---|
| 409 | ipc_call_t call;
|
---|
| 410 | size_t size;
|
---|
| 411 | errno_t rc;
|
---|
| 412 |
|
---|
| 413 | if (srv->ops->get_event == NULL) {
|
---|
| 414 | async_answer_0(icall, ENOTSUP);
|
---|
| 415 | return;
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | rc = srv->ops->get_event(srv->arg, &wnd_id, &event);
|
---|
[dcac756] | 419 | if (rc != EOK) {
|
---|
[b3c185b6] | 420 | async_answer_0(icall, rc);
|
---|
[dcac756] | 421 | return;
|
---|
| 422 | }
|
---|
[b3c185b6] | 423 |
|
---|
| 424 | /* Transfer event data */
|
---|
| 425 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 426 | async_answer_0(icall, EREFUSED);
|
---|
| 427 | return;
|
---|
| 428 | }
|
---|
| 429 |
|
---|
| 430 | if (size != sizeof(event)) {
|
---|
| 431 | async_answer_0(icall, EREFUSED);
|
---|
| 432 | async_answer_0(&call, EREFUSED);
|
---|
| 433 | return;
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | rc = async_data_read_finalize(&call, &event, sizeof(event));
|
---|
| 437 | if (rc != EOK) {
|
---|
| 438 | async_answer_0(icall, rc);
|
---|
| 439 | async_answer_0(&call, rc);
|
---|
| 440 | return;
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | async_answer_1(icall, EOK, wnd_id);
|
---|
| 444 | }
|
---|
| 445 |
|
---|
[aeb3037] | 446 | static void display_get_info_srv(display_srv_t *srv, ipc_call_t *icall)
|
---|
| 447 | {
|
---|
| 448 | display_info_t info;
|
---|
| 449 | ipc_call_t call;
|
---|
| 450 | size_t size;
|
---|
| 451 | errno_t rc;
|
---|
| 452 |
|
---|
| 453 | if (srv->ops->get_info == NULL) {
|
---|
| 454 | async_answer_0(icall, ENOTSUP);
|
---|
| 455 | return;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | /* Transfer information */
|
---|
| 459 | if (!async_data_read_receive(&call, &size)) {
|
---|
| 460 | async_answer_0(icall, EREFUSED);
|
---|
| 461 | return;
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | if (size != sizeof(info)) {
|
---|
| 465 | async_answer_0(icall, EREFUSED);
|
---|
| 466 | async_answer_0(&call, EREFUSED);
|
---|
| 467 | return;
|
---|
| 468 | }
|
---|
| 469 |
|
---|
| 470 | rc = srv->ops->get_info(srv->arg, &info);
|
---|
| 471 | if (rc != EOK) {
|
---|
| 472 | async_answer_0(icall, rc);
|
---|
| 473 | async_answer_0(&call, rc);
|
---|
| 474 | return;
|
---|
| 475 | }
|
---|
| 476 |
|
---|
| 477 | rc = async_data_read_finalize(&call, &info, sizeof(info));
|
---|
| 478 | if (rc != EOK) {
|
---|
| 479 | async_answer_0(icall, rc);
|
---|
| 480 | async_answer_0(&call, rc);
|
---|
| 481 | return;
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | async_answer_0(icall, EOK);
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[c8cf261] | 487 | void display_conn(ipc_call_t *icall, display_srv_t *srv)
|
---|
| 488 | {
|
---|
| 489 | /* Accept the connection */
|
---|
| 490 | async_accept_0(icall);
|
---|
| 491 |
|
---|
| 492 | while (true) {
|
---|
| 493 | ipc_call_t call;
|
---|
| 494 |
|
---|
| 495 | async_get_call(&call);
|
---|
| 496 | sysarg_t method = ipc_get_imethod(&call);
|
---|
| 497 |
|
---|
| 498 | if (!method) {
|
---|
| 499 | /* The other side has hung up */
|
---|
| 500 | async_answer_0(&call, EOK);
|
---|
| 501 | break;
|
---|
| 502 | }
|
---|
| 503 |
|
---|
| 504 | switch (method) {
|
---|
[b3c185b6] | 505 | case DISPLAY_CALLBACK_CREATE:
|
---|
| 506 | display_callback_create_srv(srv, &call);
|
---|
| 507 | break;
|
---|
[c8cf261] | 508 | case DISPLAY_WINDOW_CREATE:
|
---|
| 509 | display_window_create_srv(srv, &call);
|
---|
| 510 | break;
|
---|
| 511 | case DISPLAY_WINDOW_DESTROY:
|
---|
| 512 | display_window_destroy_srv(srv, &call);
|
---|
| 513 | break;
|
---|
[a2e104e] | 514 | case DISPLAY_WINDOW_MOVE_REQ:
|
---|
| 515 | display_window_move_req_srv(srv, &call);
|
---|
| 516 | break;
|
---|
[0680854] | 517 | case DISPLAY_WINDOW_MOVE:
|
---|
| 518 | display_window_move_srv(srv, &call);
|
---|
| 519 | break;
|
---|
[c9927c66] | 520 | case DISPLAY_WINDOW_GET_POS:
|
---|
| 521 | display_window_get_pos_srv(srv, &call);
|
---|
| 522 | break;
|
---|
[35cffea] | 523 | case DISPLAY_WINDOW_GET_MAX_RECT:
|
---|
| 524 | display_window_get_max_rect_srv(srv, &call);
|
---|
| 525 | break;
|
---|
[1e4a937] | 526 | case DISPLAY_WINDOW_RESIZE_REQ:
|
---|
| 527 | display_window_resize_req_srv(srv, &call);
|
---|
| 528 | break;
|
---|
[0e6e77f] | 529 | case DISPLAY_WINDOW_RESIZE:
|
---|
| 530 | display_window_resize_srv(srv, &call);
|
---|
| 531 | break;
|
---|
[35cffea] | 532 | case DISPLAY_WINDOW_MAXIMIZE:
|
---|
| 533 | display_window_maximize_srv(srv, &call);
|
---|
| 534 | break;
|
---|
| 535 | case DISPLAY_WINDOW_UNMAXIMIZE:
|
---|
| 536 | display_window_unmaximize_srv(srv, &call);
|
---|
| 537 | break;
|
---|
[5480d5e] | 538 | case DISPLAY_WINDOW_SET_CURSOR:
|
---|
| 539 | display_window_set_cursor_srv(srv, &call);
|
---|
| 540 | break;
|
---|
[b3c185b6] | 541 | case DISPLAY_GET_EVENT:
|
---|
| 542 | display_get_event_srv(srv, &call);
|
---|
| 543 | break;
|
---|
[aeb3037] | 544 | case DISPLAY_GET_INFO:
|
---|
| 545 | display_get_info_srv(srv, &call);
|
---|
| 546 | break;
|
---|
[c8cf261] | 547 | default:
|
---|
| 548 | async_answer_0(&call, ENOTSUP);
|
---|
| 549 | }
|
---|
| 550 | }
|
---|
[959b7ec] | 551 |
|
---|
| 552 | /* Hang up callback session */
|
---|
| 553 | if (srv->client_sess != NULL) {
|
---|
| 554 | async_hangup(srv->client_sess);
|
---|
| 555 | srv->client_sess = NULL;
|
---|
| 556 | }
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | /** Initialize display server structure
|
---|
| 560 | *
|
---|
| 561 | * @param srv Display server structure to initialize
|
---|
| 562 | */
|
---|
| 563 | void display_srv_initialize(display_srv_t *srv)
|
---|
| 564 | {
|
---|
| 565 | memset(srv, 0, sizeof(*srv));
|
---|
[c8cf261] | 566 | }
|
---|
| 567 |
|
---|
[b3c185b6] | 568 | /** Send 'pending' event to client.
|
---|
| 569 | *
|
---|
| 570 | * @param srv Display server structure
|
---|
| 571 | */
|
---|
| 572 | void display_srv_ev_pending(display_srv_t *srv)
|
---|
| 573 | {
|
---|
| 574 | async_exch_t *exch;
|
---|
| 575 |
|
---|
| 576 | exch = async_exchange_begin(srv->client_sess);
|
---|
| 577 | async_msg_0(exch, DISPLAY_EV_PENDING);
|
---|
| 578 | async_exchange_end(exch);
|
---|
| 579 | }
|
---|
| 580 |
|
---|
[c8cf261] | 581 | /** @}
|
---|
| 582 | */
|
---|