source: mainline/uspace/srv/hid/display/dsops.c@ 9e84d2c

serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9e84d2c was 9e84d2c, checked in by jxsvoboda <5887334+jxsvoboda@…>, 4 years ago

Popup windows event delivery is special

Popup windows don't get focus, yet they still receive events.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*
2 * Copyright (c) 2021 Jiri Svoboda
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 display
30 * @{
31 */
32/**
33 * @file Display ops implementation
34 */
35
36#include <disp_srv.h>
37#include <errno.h>
38#include <gfx/coord.h>
39#include <io/log.h>
40#include "client.h"
41#include "display.h"
42#include "dsops.h"
43#include "seat.h"
44#include "window.h"
45
46static errno_t disp_window_create(void *, display_wnd_params_t *, sysarg_t *);
47static errno_t disp_window_destroy(void *, sysarg_t);
48static errno_t disp_window_move_req(void *, sysarg_t, gfx_coord2_t *);
49static errno_t disp_window_move(void *, sysarg_t, gfx_coord2_t *);
50static errno_t disp_window_get_pos(void *, sysarg_t, gfx_coord2_t *);
51static errno_t disp_window_resize_req(void *, sysarg_t,
52 display_wnd_rsztype_t, gfx_coord2_t *);
53static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
54 gfx_rect_t *);
55static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
56static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *);
57static errno_t disp_get_info(void *, display_info_t *);
58
59display_ops_t display_srv_ops = {
60 .window_create = disp_window_create,
61 .window_destroy = disp_window_destroy,
62 .window_move_req = disp_window_move_req,
63 .window_move = disp_window_move,
64 .window_get_pos = disp_window_get_pos,
65 .window_resize_req = disp_window_resize_req,
66 .window_resize = disp_window_resize,
67 .window_set_cursor = disp_window_set_cursor,
68 .get_event = disp_get_event,
69 .get_info = disp_get_info
70};
71
72static errno_t disp_window_create(void *arg, display_wnd_params_t *params,
73 sysarg_t *rwnd_id)
74{
75 errno_t rc;
76 ds_client_t *client = (ds_client_t *) arg;
77 ds_window_t *wnd;
78
79 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()");
80
81 ds_display_lock(client->display);
82
83 rc = ds_window_create(client, params, &wnd);
84 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
85 if (rc != EOK) {
86 ds_display_unlock(client->display);
87 return rc;
88 }
89
90 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
91 wnd->id);
92
93 ds_display_unlock(client->display);
94
95 *rwnd_id = wnd->id;
96 return EOK;
97}
98
99static errno_t disp_window_destroy(void *arg, sysarg_t wnd_id)
100{
101 ds_client_t *client = (ds_client_t *) arg;
102 ds_window_t *wnd;
103
104 ds_display_lock(client->display);
105
106 wnd = ds_client_find_window(client, wnd_id);
107 if (wnd == NULL) {
108 ds_display_unlock(client->display);
109 return ENOENT;
110 }
111
112 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
113 ds_window_destroy(wnd);
114 ds_display_unlock(client->display);
115 return EOK;
116}
117
118static errno_t disp_window_move_req(void *arg, sysarg_t wnd_id,
119 gfx_coord2_t *pos)
120{
121 ds_client_t *client = (ds_client_t *) arg;
122 ds_window_t *wnd;
123
124 ds_display_lock(client->display);
125
126 wnd = ds_client_find_window(client, wnd_id);
127 if (wnd == NULL) {
128 ds_display_unlock(client->display);
129 return ENOENT;
130 }
131
132 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move_req()");
133 ds_window_move_req(wnd, pos);
134 ds_display_unlock(client->display);
135 return EOK;
136}
137
138static errno_t disp_window_move(void *arg, sysarg_t wnd_id, gfx_coord2_t *pos)
139{
140 ds_client_t *client = (ds_client_t *) arg;
141 ds_window_t *wnd;
142
143 ds_display_lock(client->display);
144
145 wnd = ds_client_find_window(client, wnd_id);
146 if (wnd == NULL) {
147 ds_display_unlock(client->display);
148 return ENOENT;
149 }
150
151 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move()");
152 ds_window_move(wnd, pos);
153 ds_display_unlock(client->display);
154 return EOK;
155}
156
157static errno_t disp_window_get_pos(void *arg, sysarg_t wnd_id,
158 gfx_coord2_t *pos)
159{
160 ds_client_t *client = (ds_client_t *) arg;
161 ds_window_t *wnd;
162
163 ds_display_lock(client->display);
164
165 wnd = ds_client_find_window(client, wnd_id);
166 if (wnd == NULL) {
167 ds_display_unlock(client->display);
168 return ENOENT;
169 }
170
171 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_pos()");
172 ds_window_get_pos(wnd, pos);
173 ds_display_unlock(client->display);
174 return EOK;
175}
176
177static errno_t disp_window_resize_req(void *arg, sysarg_t wnd_id,
178 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
179{
180 ds_client_t *client = (ds_client_t *) arg;
181 ds_window_t *wnd;
182
183 if (!display_wndrsz_valid(rsztype))
184 return EINVAL;
185
186 ds_display_lock(client->display);
187
188 wnd = ds_client_find_window(client, wnd_id);
189 if (wnd == NULL) {
190 ds_display_unlock(client->display);
191 return ENOENT;
192 }
193
194 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize_req()");
195 ds_window_resize_req(wnd, rsztype, pos);
196 ds_display_unlock(client->display);
197 return EOK;
198}
199
200static errno_t disp_window_resize(void *arg, sysarg_t wnd_id,
201 gfx_coord2_t *offs, gfx_rect_t *nbound)
202{
203 ds_client_t *client = (ds_client_t *) arg;
204 ds_window_t *wnd;
205 errno_t rc;
206
207 ds_display_lock(client->display);
208
209 wnd = ds_client_find_window(client, wnd_id);
210 if (wnd == NULL) {
211 ds_display_unlock(client->display);
212 return ENOENT;
213 }
214
215 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize()");
216 rc = ds_window_resize(wnd, offs, nbound);
217 ds_display_unlock(client->display);
218 return rc;
219}
220
221static errno_t disp_window_set_cursor(void *arg, sysarg_t wnd_id,
222 display_stock_cursor_t cursor)
223{
224 ds_client_t *client = (ds_client_t *) arg;
225 ds_window_t *wnd;
226 errno_t rc;
227
228 ds_display_lock(client->display);
229
230 wnd = ds_client_find_window(client, wnd_id);
231 if (wnd == NULL) {
232 ds_display_unlock(client->display);
233 return ENOENT;
234 }
235
236 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_cursor()");
237 rc = ds_window_set_cursor(wnd, cursor);
238 ds_display_unlock(client->display);
239 return rc;
240}
241
242static errno_t disp_get_event(void *arg, sysarg_t *wnd_id,
243 display_wnd_ev_t *event)
244{
245 ds_client_t *client = (ds_client_t *) arg;
246 ds_window_t *wnd;
247 errno_t rc;
248
249 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_event()");
250
251 ds_display_lock(client->display);
252
253 rc = ds_client_get_event(client, &wnd, event);
254 if (rc != EOK) {
255 ds_display_unlock(client->display);
256 return rc;
257 }
258
259 *wnd_id = wnd->id;
260 ds_display_unlock(client->display);
261 return EOK;
262}
263
264static errno_t disp_get_info(void *arg, display_info_t *info)
265{
266 ds_client_t *client = (ds_client_t *) arg;
267
268 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()");
269
270 ds_display_lock(client->display);
271 ds_display_get_info(client->display, info);
272 ds_display_unlock(client->display);
273 return EOK;
274}
275
276/** @}
277 */
Note: See TracBrowser for help on using the repository browser.