source: mainline/uspace/lib/c/generic/io/window.c@ 62fbb7e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 62fbb7e was 62fbb7e, checked in by Martin Decky <martin@…>, 11 years ago

refactor window placement logic and introduce logical window placement flags

  • The original setup of window position during creation (window_open()) was quite useless, because the window had no surface yet.
  • Now the window position can be optinally set using window_resize() and various logical placement flags are available.
  • A separate window_move() routine could be introduced eventually if needed, but for the initial setup of the window the combination of window position and size works fine.
  • Property mode set to 100644
File size: 3.6 KB
Line 
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
42int 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
51int 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
74int 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
84int 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
93int win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width,
94 sysarg_t height, window_placement_flags_t placement_flags, void *cells)
95{
96 async_exch_t *exch = async_exchange_begin(sess);
97
98 ipc_call_t answer;
99 aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height,
100 (sysarg_t) placement_flags, &answer);
101
102 int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
103
104 async_exchange_end(exch);
105
106 sysarg_t ret;
107 async_wait_for(req, &ret);
108
109 if (rc != EOK)
110 return rc;
111 else if (ret != EOK)
112 return ret;
113
114 return EOK;
115}
116
117int 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
126int 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 */
Note: See TracBrowser for help on using the repository browser.