[6d5e378] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 Petr Koupy
|
---|
| 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 |
|
---|
| 29 | /** @addtogroup libc
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | #include <errno.h>
|
---|
| 36 | #include <as.h>
|
---|
| 37 | #include <ipc/window.h>
|
---|
| 38 | #include <io/window.h>
|
---|
| 39 |
|
---|
| 40 | #include <stdio.h>
|
---|
| 41 |
|
---|
[b7fd2a0] | 42 | errno_t win_register(async_sess_t *sess, window_flags_t flags, service_id_t *in,
|
---|
[2c7fdaa] | 43 | service_id_t *out)
|
---|
[6d5e378] | 44 | {
|
---|
| 45 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 46 | errno_t ret = async_req_1_2(exch, WINDOW_REGISTER, flags, in, out);
|
---|
[6d5e378] | 47 | async_exchange_end(exch);
|
---|
[a35b458] | 48 |
|
---|
[6d5e378] | 49 | return ret;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[b7fd2a0] | 52 | errno_t win_get_event(async_sess_t *sess, window_event_t *event)
|
---|
[6d5e378] | 53 | {
|
---|
| 54 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 55 |
|
---|
| 56 | ipc_call_t answer;
|
---|
| 57 | aid_t req = async_send_0(exch, WINDOW_GET_EVENT, &answer);
|
---|
| 58 |
|
---|
[b7fd2a0] | 59 | errno_t rc = async_data_read_start(exch, event, sizeof(window_event_t));
|
---|
[6d5e378] | 60 |
|
---|
| 61 | async_exchange_end(exch);
|
---|
| 62 |
|
---|
[b7fd2a0] | 63 | errno_t ret;
|
---|
[6d5e378] | 64 | async_wait_for(req, &ret);
|
---|
| 65 |
|
---|
| 66 | if (rc != EOK) {
|
---|
| 67 | return rc;
|
---|
| 68 | } else if (ret != EOK) {
|
---|
| 69 | return ret;
|
---|
| 70 | } else {
|
---|
| 71 | return EOK;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[b7fd2a0] | 75 | errno_t win_damage(async_sess_t *sess,
|
---|
[6d5e378] | 76 | sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
|
---|
| 77 | {
|
---|
| 78 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 79 | errno_t ret = async_req_4_0(exch, WINDOW_DAMAGE, x, y, width, height);
|
---|
[6d5e378] | 80 | async_exchange_end(exch);
|
---|
| 81 |
|
---|
| 82 | return ret;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[b7fd2a0] | 85 | errno_t win_grab(async_sess_t *sess, sysarg_t pos_id, sysarg_t grab_flags)
|
---|
[6d5e378] | 86 | {
|
---|
| 87 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 88 | errno_t ret = async_req_2_0(exch, WINDOW_GRAB, pos_id, grab_flags);
|
---|
[6d5e378] | 89 | async_exchange_end(exch);
|
---|
| 90 |
|
---|
| 91 | return ret;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[b7fd2a0] | 94 | errno_t win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width,
|
---|
[62fbb7e] | 95 | sysarg_t height, window_placement_flags_t placement_flags, void *cells)
|
---|
[6d5e378] | 96 | {
|
---|
| 97 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[a35b458] | 98 |
|
---|
[6d5e378] | 99 | ipc_call_t answer;
|
---|
[62fbb7e] | 100 | aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height,
|
---|
| 101 | (sysarg_t) placement_flags, &answer);
|
---|
[a35b458] | 102 |
|
---|
[b7fd2a0] | 103 | errno_t rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
|
---|
[a35b458] | 104 |
|
---|
[6d5e378] | 105 | async_exchange_end(exch);
|
---|
[a35b458] | 106 |
|
---|
[b7fd2a0] | 107 | errno_t ret;
|
---|
[6d5e378] | 108 | async_wait_for(req, &ret);
|
---|
[a35b458] | 109 |
|
---|
[62fbb7e] | 110 | if (rc != EOK)
|
---|
[6d5e378] | 111 | return rc;
|
---|
[62fbb7e] | 112 | else if (ret != EOK)
|
---|
[6d5e378] | 113 | return ret;
|
---|
[a35b458] | 114 |
|
---|
[62fbb7e] | 115 | return EOK;
|
---|
[6d5e378] | 116 | }
|
---|
| 117 |
|
---|
[b7fd2a0] | 118 | errno_t win_close(async_sess_t *sess)
|
---|
[6d5e378] | 119 | {
|
---|
| 120 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 121 | errno_t ret = async_req_0_0(exch, WINDOW_CLOSE);
|
---|
[6d5e378] | 122 | async_exchange_end(exch);
|
---|
| 123 |
|
---|
| 124 | return ret;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
[b7fd2a0] | 127 | errno_t win_close_request(async_sess_t *sess)
|
---|
[6d5e378] | 128 | {
|
---|
| 129 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[b7fd2a0] | 130 | errno_t ret = async_req_0_0(exch, WINDOW_CLOSE_REQUEST);
|
---|
[6d5e378] | 131 | async_exchange_end(exch);
|
---|
| 132 |
|
---|
| 133 | return ret;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | /** @}
|
---|
| 137 | */
|
---|