[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 |
|
---|
[fa98b26a] | 42 | int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out,
|
---|
| 43 | sysarg_t x_offset, sysarg_t y_offset)
|
---|
[6d5e378] | 44 | {
|
---|
| 45 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
[fa98b26a] | 46 | int ret = async_req_2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);
|
---|
[6d5e378] | 47 | async_exchange_end(exch);
|
---|
| 48 |
|
---|
| 49 | return ret;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | int win_get_event(async_sess_t *sess, window_event_t *event)
|
---|
| 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 |
|
---|
| 59 | int rc = async_data_read_start(exch, event, sizeof(window_event_t));
|
---|
| 60 |
|
---|
| 61 | async_exchange_end(exch);
|
---|
| 62 |
|
---|
| 63 | sysarg_t ret;
|
---|
| 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 |
|
---|
| 75 | int win_damage(async_sess_t *sess,
|
---|
| 76 | sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
|
---|
| 77 | {
|
---|
| 78 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 79 | int ret = async_req_4_0(exch, WINDOW_DAMAGE, x, y, width, height);
|
---|
| 80 | async_exchange_end(exch);
|
---|
| 81 |
|
---|
| 82 | return ret;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | int win_grab(async_sess_t *sess, sysarg_t pos_id, sysarg_t grab_flags)
|
---|
| 86 | {
|
---|
| 87 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 88 | int ret = async_req_2_0(exch, WINDOW_GRAB, pos_id, grab_flags);
|
---|
| 89 | async_exchange_end(exch);
|
---|
| 90 |
|
---|
| 91 | return ret;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | int win_resize(async_sess_t *sess, sysarg_t width, sysarg_t height, void *cells)
|
---|
| 95 | {
|
---|
| 96 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 97 |
|
---|
| 98 | ipc_call_t answer;
|
---|
| 99 | aid_t req = async_send_2(exch, WINDOW_RESIZE, width, height, &answer);
|
---|
| 100 |
|
---|
| 101 | int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
|
---|
| 102 |
|
---|
| 103 | async_exchange_end(exch);
|
---|
| 104 |
|
---|
| 105 | sysarg_t ret;
|
---|
| 106 | async_wait_for(req, &ret);
|
---|
| 107 |
|
---|
| 108 | if (rc != EOK) {
|
---|
| 109 | return rc;
|
---|
| 110 | } else if (ret != EOK) {
|
---|
| 111 | return ret;
|
---|
| 112 | } else {
|
---|
| 113 | return EOK;
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | int win_close(async_sess_t *sess)
|
---|
| 118 | {
|
---|
| 119 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 120 | int ret = async_req_0_0(exch, WINDOW_CLOSE);
|
---|
| 121 | async_exchange_end(exch);
|
---|
| 122 |
|
---|
| 123 | return ret;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | int win_close_request(async_sess_t *sess)
|
---|
| 127 | {
|
---|
| 128 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 129 | int ret = async_req_0_0(exch, WINDOW_CLOSE_REQUEST);
|
---|
| 130 | async_exchange_end(exch);
|
---|
| 131 |
|
---|
| 132 | return ret;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | /** @}
|
---|
| 136 | */
|
---|