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

ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d19d15b was d19d15b, checked in by Jiri Svoboda <jiri@…>, 3 years ago

Adjust message verbosity levels in display server

  • Property mode set to 100644
File size: 9.7 KB
RevLine 
[38e5f36c]1/*
[35cffea]2 * Copyright (c) 2022 Jiri Svoboda
[38e5f36c]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>
[0e6e77f]38#include <gfx/coord.h>
[38e5f36c]39#include <io/log.h>
40#include "client.h"
[cf32dbd]41#include "display.h"
[38e5f36c]42#include "dsops.h"
[cf32dbd]43#include "seat.h"
44#include "window.h"
[38e5f36c]45
[4d9c807]46static errno_t disp_window_create(void *, display_wnd_params_t *, sysarg_t *);
[38e5f36c]47static errno_t disp_window_destroy(void *, sysarg_t);
[a2e104e]48static errno_t disp_window_move_req(void *, sysarg_t, gfx_coord2_t *);
[0680854]49static errno_t disp_window_move(void *, sysarg_t, gfx_coord2_t *);
[c9927c66]50static errno_t disp_window_get_pos(void *, sysarg_t, gfx_coord2_t *);
[35cffea]51static errno_t disp_window_get_max_rect(void *, sysarg_t, gfx_rect_t *);
[e022819]52static errno_t disp_window_resize_req(void *, sysarg_t,
53 display_wnd_rsztype_t, gfx_coord2_t *);
[0e6e77f]54static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
55 gfx_rect_t *);
[35cffea]56static errno_t disp_window_maximize(void *, sysarg_t);
57static errno_t disp_window_unmaximize(void *, sysarg_t);
[9242ad9]58static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
[7cc30e9]59static errno_t disp_window_set_caption(void *, sysarg_t, const char *);
[38e5f36c]60static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *);
[aeb3037]61static errno_t disp_get_info(void *, display_info_t *);
[38e5f36c]62
63display_ops_t display_srv_ops = {
64 .window_create = disp_window_create,
65 .window_destroy = disp_window_destroy,
[a2e104e]66 .window_move_req = disp_window_move_req,
[0680854]67 .window_move = disp_window_move,
[c9927c66]68 .window_get_pos = disp_window_get_pos,
[35cffea]69 .window_get_max_rect = disp_window_get_max_rect,
[e022819]70 .window_resize_req = disp_window_resize_req,
[0e6e77f]71 .window_resize = disp_window_resize,
[35cffea]72 .window_maximize = disp_window_maximize,
73 .window_unmaximize = disp_window_unmaximize,
[9242ad9]74 .window_set_cursor = disp_window_set_cursor,
[7cc30e9]75 .window_set_caption = disp_window_set_caption,
[aeb3037]76 .get_event = disp_get_event,
77 .get_info = disp_get_info
[38e5f36c]78};
79
[4d9c807]80static errno_t disp_window_create(void *arg, display_wnd_params_t *params,
81 sysarg_t *rwnd_id)
[38e5f36c]82{
83 errno_t rc;
84 ds_client_t *client = (ds_client_t *) arg;
85 ds_window_t *wnd;
86
87 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()");
88
[c11ee605]89 ds_display_lock(client->display);
90
[3434233]91 rc = ds_window_create(client, params, &wnd);
[38e5f36c]92 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
[c11ee605]93 if (rc != EOK) {
94 ds_display_unlock(client->display);
[38e5f36c]95 return rc;
[c11ee605]96 }
[38e5f36c]97
98 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
99 wnd->id);
100
[c11ee605]101 ds_display_unlock(client->display);
102
[38e5f36c]103 *rwnd_id = wnd->id;
104 return EOK;
105}
106
107static errno_t disp_window_destroy(void *arg, sysarg_t wnd_id)
108{
109 ds_client_t *client = (ds_client_t *) arg;
110 ds_window_t *wnd;
111
[c11ee605]112 ds_display_lock(client->display);
113
[38e5f36c]114 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]115 if (wnd == NULL) {
116 ds_display_unlock(client->display);
[38e5f36c]117 return ENOENT;
[c11ee605]118 }
[38e5f36c]119
120 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
121 ds_window_destroy(wnd);
[c11ee605]122 ds_display_unlock(client->display);
[38e5f36c]123 return EOK;
124}
125
[a2e104e]126static errno_t disp_window_move_req(void *arg, sysarg_t wnd_id,
127 gfx_coord2_t *pos)
128{
129 ds_client_t *client = (ds_client_t *) arg;
130 ds_window_t *wnd;
131
[c11ee605]132 ds_display_lock(client->display);
133
[a2e104e]134 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]135 if (wnd == NULL) {
136 ds_display_unlock(client->display);
[a2e104e]137 return ENOENT;
[c11ee605]138 }
[a2e104e]139
[195b7b3]140 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move_req()");
[a2e104e]141 ds_window_move_req(wnd, pos);
[c11ee605]142 ds_display_unlock(client->display);
[a2e104e]143 return EOK;
144}
145
[0680854]146static errno_t disp_window_move(void *arg, sysarg_t wnd_id, gfx_coord2_t *pos)
147{
148 ds_client_t *client = (ds_client_t *) arg;
149 ds_window_t *wnd;
150
[c11ee605]151 ds_display_lock(client->display);
152
[0680854]153 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]154 if (wnd == NULL) {
155 ds_display_unlock(client->display);
[0680854]156 return ENOENT;
[c11ee605]157 }
[0680854]158
[195b7b3]159 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move()");
[0680854]160 ds_window_move(wnd, pos);
[c11ee605]161 ds_display_unlock(client->display);
[0680854]162 return EOK;
163}
164
[c9927c66]165static errno_t disp_window_get_pos(void *arg, sysarg_t wnd_id,
166 gfx_coord2_t *pos)
167{
168 ds_client_t *client = (ds_client_t *) arg;
169 ds_window_t *wnd;
170
171 ds_display_lock(client->display);
172
173 wnd = ds_client_find_window(client, wnd_id);
174 if (wnd == NULL) {
175 ds_display_unlock(client->display);
176 return ENOENT;
177 }
178
179 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_pos()");
180 ds_window_get_pos(wnd, pos);
181 ds_display_unlock(client->display);
182 return EOK;
183}
184
[35cffea]185static errno_t disp_window_get_max_rect(void *arg, sysarg_t wnd_id,
186 gfx_rect_t *rect)
187{
188 ds_client_t *client = (ds_client_t *) arg;
189 ds_window_t *wnd;
190
191 ds_display_lock(client->display);
192
193 wnd = ds_client_find_window(client, wnd_id);
194 if (wnd == NULL) {
195 ds_display_unlock(client->display);
196 return ENOENT;
197 }
198
199 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_max_rect()");
200 ds_window_get_max_rect(wnd, rect);
201 ds_display_unlock(client->display);
202 return EOK;
203}
204
[e022819]205static errno_t disp_window_resize_req(void *arg, sysarg_t wnd_id,
206 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
207{
208 ds_client_t *client = (ds_client_t *) arg;
209 ds_window_t *wnd;
210
[9901f267]211 if (!display_wndrsz_valid(rsztype))
212 return EINVAL;
213
[c11ee605]214 ds_display_lock(client->display);
215
[e022819]216 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]217 if (wnd == NULL) {
218 ds_display_unlock(client->display);
[e022819]219 return ENOENT;
[c11ee605]220 }
[e022819]221
[195b7b3]222 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize_req()");
[e022819]223 ds_window_resize_req(wnd, rsztype, pos);
[c11ee605]224 ds_display_unlock(client->display);
[e022819]225 return EOK;
226}
227
[0e6e77f]228static errno_t disp_window_resize(void *arg, sysarg_t wnd_id,
229 gfx_coord2_t *offs, gfx_rect_t *nbound)
230{
231 ds_client_t *client = (ds_client_t *) arg;
232 ds_window_t *wnd;
[c11ee605]233 errno_t rc;
234
235 ds_display_lock(client->display);
[0e6e77f]236
237 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]238 if (wnd == NULL) {
239 ds_display_unlock(client->display);
[0e6e77f]240 return ENOENT;
[c11ee605]241 }
[0e6e77f]242
[195b7b3]243 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize()");
[c11ee605]244 rc = ds_window_resize(wnd, offs, nbound);
245 ds_display_unlock(client->display);
246 return rc;
[0e6e77f]247}
248
[35cffea]249static errno_t disp_window_maximize(void *arg, sysarg_t wnd_id)
250{
251 ds_client_t *client = (ds_client_t *) arg;
252 ds_window_t *wnd;
253 errno_t rc;
254
255 ds_display_lock(client->display);
256
257 wnd = ds_client_find_window(client, wnd_id);
258 if (wnd == NULL) {
259 ds_display_unlock(client->display);
260 return ENOENT;
261 }
262
263 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_maximize()");
264 rc = ds_window_maximize(wnd);
265 ds_display_unlock(client->display);
266 return rc;
267}
268
269static errno_t disp_window_unmaximize(void *arg, sysarg_t wnd_id)
270{
271 ds_client_t *client = (ds_client_t *) arg;
272 ds_window_t *wnd;
273 errno_t rc;
274
275 ds_display_lock(client->display);
276
277 wnd = ds_client_find_window(client, wnd_id);
278 if (wnd == NULL) {
279 ds_display_unlock(client->display);
280 return ENOENT;
281 }
282
283 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_unmaximize()");
284 rc = ds_window_unmaximize(wnd);
285 ds_display_unlock(client->display);
286 return rc;
287}
288
[9242ad9]289static errno_t disp_window_set_cursor(void *arg, sysarg_t wnd_id,
290 display_stock_cursor_t cursor)
291{
292 ds_client_t *client = (ds_client_t *) arg;
293 ds_window_t *wnd;
294 errno_t rc;
295
296 ds_display_lock(client->display);
297
298 wnd = ds_client_find_window(client, wnd_id);
299 if (wnd == NULL) {
300 ds_display_unlock(client->display);
301 return ENOENT;
302 }
303
[195b7b3]304 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_cursor()");
[9242ad9]305 rc = ds_window_set_cursor(wnd, cursor);
306 ds_display_unlock(client->display);
307 return rc;
308}
309
[7cc30e9]310static errno_t disp_window_set_caption(void *arg, sysarg_t wnd_id,
311 const char *caption)
312{
313 ds_client_t *client = (ds_client_t *) arg;
314 ds_window_t *wnd;
315 errno_t rc;
316
317 ds_display_lock(client->display);
318
319 wnd = ds_client_find_window(client, wnd_id);
320 if (wnd == NULL) {
321 ds_display_unlock(client->display);
322 return ENOENT;
323 }
324
325 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_caption()");
326 rc = ds_window_set_caption(wnd, caption);
327 ds_display_unlock(client->display);
328 return rc;
329}
330
[38e5f36c]331static errno_t disp_get_event(void *arg, sysarg_t *wnd_id,
332 display_wnd_ev_t *event)
333{
334 ds_client_t *client = (ds_client_t *) arg;
335 ds_window_t *wnd;
336 errno_t rc;
337
[d19d15b]338 log_msg(LOG_DEFAULT, LVL_DEBUG2, "disp_window_get_event()");
[38e5f36c]339
[c11ee605]340 ds_display_lock(client->display);
341
[38e5f36c]342 rc = ds_client_get_event(client, &wnd, event);
[c11ee605]343 if (rc != EOK) {
344 ds_display_unlock(client->display);
[38e5f36c]345 return rc;
[c11ee605]346 }
[38e5f36c]347
348 *wnd_id = wnd->id;
[c11ee605]349 ds_display_unlock(client->display);
[38e5f36c]350 return EOK;
351}
352
[aeb3037]353static errno_t disp_get_info(void *arg, display_info_t *info)
354{
355 ds_client_t *client = (ds_client_t *) arg;
356
357 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()");
358
[c11ee605]359 ds_display_lock(client->display);
[aeb3037]360 ds_display_get_info(client->display, info);
[c11ee605]361 ds_display_unlock(client->display);
[aeb3037]362 return EOK;
363}
364
[38e5f36c]365/** @}
366 */
Note: See TracBrowser for help on using the repository browser.