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