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

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

Clean up debug messages and logging

  • Property mode set to 100644
File size: 7.2 KB
RevLine 
[38e5f36c]1/*
2 * Copyright (c) 2019 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>
[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 *);
[e022819]50static errno_t disp_window_resize_req(void *, sysarg_t,
51 display_wnd_rsztype_t, gfx_coord2_t *);
[0e6e77f]52static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
53 gfx_rect_t *);
[9242ad9]54static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
[38e5f36c]55static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *);
[aeb3037]56static errno_t disp_get_info(void *, display_info_t *);
[38e5f36c]57
58display_ops_t display_srv_ops = {
59 .window_create = disp_window_create,
60 .window_destroy = disp_window_destroy,
[a2e104e]61 .window_move_req = disp_window_move_req,
[0680854]62 .window_move = disp_window_move,
[e022819]63 .window_resize_req = disp_window_resize_req,
[0e6e77f]64 .window_resize = disp_window_resize,
[9242ad9]65 .window_set_cursor = disp_window_set_cursor,
[aeb3037]66 .get_event = disp_get_event,
67 .get_info = disp_get_info
[38e5f36c]68};
69
[4d9c807]70static errno_t disp_window_create(void *arg, display_wnd_params_t *params,
71 sysarg_t *rwnd_id)
[38e5f36c]72{
73 errno_t rc;
74 ds_client_t *client = (ds_client_t *) arg;
[cf32dbd]75 ds_seat_t *seat;
[38e5f36c]76 ds_window_t *wnd;
77
78 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()");
79
[c11ee605]80 ds_display_lock(client->display);
81
[3434233]82 rc = ds_window_create(client, params, &wnd);
[38e5f36c]83 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
[c11ee605]84 if (rc != EOK) {
85 ds_display_unlock(client->display);
[38e5f36c]86 return rc;
[c11ee605]87 }
[38e5f36c]88
89 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
90 wnd->id);
91
[cc90846]92 /* XXX All the below should probably be part of ds_window_create() */
[38e5f36c]93 wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
94 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
95
[cf32dbd]96 seat = ds_display_first_seat(client->display);
97 ds_seat_set_focus(seat, wnd);
[cc90846]98 (void) ds_display_paint(wnd->display, NULL);
[cf32dbd]99
[c11ee605]100 ds_display_unlock(client->display);
101
[38e5f36c]102 *rwnd_id = wnd->id;
103 return EOK;
104}
105
106static errno_t disp_window_destroy(void *arg, sysarg_t wnd_id)
107{
108 ds_client_t *client = (ds_client_t *) arg;
109 ds_window_t *wnd;
110
[c11ee605]111 ds_display_lock(client->display);
112
[38e5f36c]113 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]114 if (wnd == NULL) {
115 ds_display_unlock(client->display);
[38e5f36c]116 return ENOENT;
[c11ee605]117 }
[38e5f36c]118
119 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
120 ds_client_remove_window(wnd);
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
[e022819]165static errno_t disp_window_resize_req(void *arg, sysarg_t wnd_id,
166 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
167{
168 ds_client_t *client = (ds_client_t *) arg;
169 ds_window_t *wnd;
170
[9901f267]171 if (!display_wndrsz_valid(rsztype))
172 return EINVAL;
173
[c11ee605]174 ds_display_lock(client->display);
175
[e022819]176 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]177 if (wnd == NULL) {
178 ds_display_unlock(client->display);
[e022819]179 return ENOENT;
[c11ee605]180 }
[e022819]181
[195b7b3]182 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize_req()");
[e022819]183 ds_window_resize_req(wnd, rsztype, pos);
[c11ee605]184 ds_display_unlock(client->display);
[e022819]185 return EOK;
186}
187
[0e6e77f]188static errno_t disp_window_resize(void *arg, sysarg_t wnd_id,
189 gfx_coord2_t *offs, gfx_rect_t *nbound)
190{
191 ds_client_t *client = (ds_client_t *) arg;
192 ds_window_t *wnd;
[c11ee605]193 errno_t rc;
194
195 ds_display_lock(client->display);
[0e6e77f]196
197 wnd = ds_client_find_window(client, wnd_id);
[c11ee605]198 if (wnd == NULL) {
199 ds_display_unlock(client->display);
[0e6e77f]200 return ENOENT;
[c11ee605]201 }
[0e6e77f]202
[195b7b3]203 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize()");
[c11ee605]204 rc = ds_window_resize(wnd, offs, nbound);
205 ds_display_unlock(client->display);
206 return rc;
[0e6e77f]207}
208
[9242ad9]209static errno_t disp_window_set_cursor(void *arg, sysarg_t wnd_id,
210 display_stock_cursor_t cursor)
211{
212 ds_client_t *client = (ds_client_t *) arg;
213 ds_window_t *wnd;
214 errno_t rc;
215
216 ds_display_lock(client->display);
217
218 wnd = ds_client_find_window(client, wnd_id);
219 if (wnd == NULL) {
220 ds_display_unlock(client->display);
221 return ENOENT;
222 }
223
[195b7b3]224 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_cursor()");
[9242ad9]225 rc = ds_window_set_cursor(wnd, cursor);
226 ds_display_unlock(client->display);
227 return rc;
228}
229
[38e5f36c]230static errno_t disp_get_event(void *arg, sysarg_t *wnd_id,
231 display_wnd_ev_t *event)
232{
233 ds_client_t *client = (ds_client_t *) arg;
234 ds_window_t *wnd;
235 errno_t rc;
236
237 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_event()");
238
[c11ee605]239 ds_display_lock(client->display);
240
[38e5f36c]241 rc = ds_client_get_event(client, &wnd, event);
[c11ee605]242 if (rc != EOK) {
243 ds_display_unlock(client->display);
[38e5f36c]244 return rc;
[c11ee605]245 }
[38e5f36c]246
247 *wnd_id = wnd->id;
[c11ee605]248 ds_display_unlock(client->display);
[38e5f36c]249 return EOK;
250}
251
[aeb3037]252static errno_t disp_get_info(void *arg, display_info_t *info)
253{
254 ds_client_t *client = (ds_client_t *) arg;
255
256 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_get_info()");
257
[c11ee605]258 ds_display_lock(client->display);
[aeb3037]259 ds_display_get_info(client->display, info);
[c11ee605]260 ds_display_unlock(client->display);
[aeb3037]261 return EOK;
262}
263
[38e5f36c]264/** @}
265 */
Note: See TracBrowser for help on using the repository browser.