[38e5f36c] | 1 | /*
|
---|
[b4b4dafe] | 2 | * Copyright (c) 2021 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] | 46 | static errno_t disp_window_create(void *, display_wnd_params_t *, sysarg_t *);
|
---|
[38e5f36c] | 47 | static errno_t disp_window_destroy(void *, sysarg_t);
|
---|
[a2e104e] | 48 | static errno_t disp_window_move_req(void *, sysarg_t, gfx_coord2_t *);
|
---|
[0680854] | 49 | static errno_t disp_window_move(void *, sysarg_t, gfx_coord2_t *);
|
---|
[6baab83] | 50 | static errno_t disp_window_get_pos(void *, sysarg_t, gfx_coord2_t *);
|
---|
[e022819] | 51 | static errno_t disp_window_resize_req(void *, sysarg_t,
|
---|
| 52 | display_wnd_rsztype_t, gfx_coord2_t *);
|
---|
[0e6e77f] | 53 | static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
|
---|
| 54 | gfx_rect_t *);
|
---|
[9242ad9] | 55 | static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
|
---|
[38e5f36c] | 56 | static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *);
|
---|
[aeb3037] | 57 | static errno_t disp_get_info(void *, display_info_t *);
|
---|
[38e5f36c] | 58 |
|
---|
| 59 | display_ops_t display_srv_ops = {
|
---|
| 60 | .window_create = disp_window_create,
|
---|
| 61 | .window_destroy = disp_window_destroy,
|
---|
[a2e104e] | 62 | .window_move_req = disp_window_move_req,
|
---|
[0680854] | 63 | .window_move = disp_window_move,
|
---|
[6baab83] | 64 | .window_get_pos = disp_window_get_pos,
|
---|
[e022819] | 65 | .window_resize_req = disp_window_resize_req,
|
---|
[0e6e77f] | 66 | .window_resize = disp_window_resize,
|
---|
[9242ad9] | 67 | .window_set_cursor = disp_window_set_cursor,
|
---|
[aeb3037] | 68 | .get_event = disp_get_event,
|
---|
| 69 | .get_info = disp_get_info
|
---|
[38e5f36c] | 70 | };
|
---|
| 71 |
|
---|
[4d9c807] | 72 | static errno_t disp_window_create(void *arg, display_wnd_params_t *params,
|
---|
| 73 | sysarg_t *rwnd_id)
|
---|
[38e5f36c] | 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 |
|
---|
[c11ee605] | 81 | ds_display_lock(client->display);
|
---|
| 82 |
|
---|
[3434233] | 83 | rc = ds_window_create(client, params, &wnd);
|
---|
[38e5f36c] | 84 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
|
---|
[c11ee605] | 85 | if (rc != EOK) {
|
---|
| 86 | ds_display_unlock(client->display);
|
---|
[38e5f36c] | 87 | return rc;
|
---|
[c11ee605] | 88 | }
|
---|
[38e5f36c] | 89 |
|
---|
| 90 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
|
---|
| 91 | wnd->id);
|
---|
| 92 |
|
---|
[c11ee605] | 93 | ds_display_unlock(client->display);
|
---|
| 94 |
|
---|
[38e5f36c] | 95 | *rwnd_id = wnd->id;
|
---|
| 96 | return EOK;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | static 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 |
|
---|
[c11ee605] | 104 | ds_display_lock(client->display);
|
---|
| 105 |
|
---|
[38e5f36c] | 106 | wnd = ds_client_find_window(client, wnd_id);
|
---|
[c11ee605] | 107 | if (wnd == NULL) {
|
---|
| 108 | ds_display_unlock(client->display);
|
---|
[38e5f36c] | 109 | return ENOENT;
|
---|
[c11ee605] | 110 | }
|
---|
[38e5f36c] | 111 |
|
---|
| 112 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
|
---|
| 113 | ds_window_destroy(wnd);
|
---|
[c11ee605] | 114 | ds_display_unlock(client->display);
|
---|
[38e5f36c] | 115 | return EOK;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[a2e104e] | 118 | static 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 |
|
---|
[c11ee605] | 124 | ds_display_lock(client->display);
|
---|
| 125 |
|
---|
[a2e104e] | 126 | wnd = ds_client_find_window(client, wnd_id);
|
---|
[c11ee605] | 127 | if (wnd == NULL) {
|
---|
| 128 | ds_display_unlock(client->display);
|
---|
[a2e104e] | 129 | return ENOENT;
|
---|
[c11ee605] | 130 | }
|
---|
[a2e104e] | 131 |
|
---|
[195b7b3] | 132 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move_req()");
|
---|
[a2e104e] | 133 | ds_window_move_req(wnd, pos);
|
---|
[c11ee605] | 134 | ds_display_unlock(client->display);
|
---|
[a2e104e] | 135 | return EOK;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[0680854] | 138 | static 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 |
|
---|
[c11ee605] | 143 | ds_display_lock(client->display);
|
---|
| 144 |
|
---|
[0680854] | 145 | wnd = ds_client_find_window(client, wnd_id);
|
---|
[c11ee605] | 146 | if (wnd == NULL) {
|
---|
| 147 | ds_display_unlock(client->display);
|
---|
[0680854] | 148 | return ENOENT;
|
---|
[c11ee605] | 149 | }
|
---|
[0680854] | 150 |
|
---|
[195b7b3] | 151 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_move()");
|
---|
[0680854] | 152 | ds_window_move(wnd, pos);
|
---|
[c11ee605] | 153 | ds_display_unlock(client->display);
|
---|
[0680854] | 154 | return EOK;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[6baab83] | 157 | static 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 |
|
---|
[e022819] | 177 | static 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 |
|
---|
[9901f267] | 183 | if (!display_wndrsz_valid(rsztype))
|
---|
| 184 | return EINVAL;
|
---|
| 185 |
|
---|
[c11ee605] | 186 | ds_display_lock(client->display);
|
---|
| 187 |
|
---|
[e022819] | 188 | wnd = ds_client_find_window(client, wnd_id);
|
---|
[c11ee605] | 189 | if (wnd == NULL) {
|
---|
| 190 | ds_display_unlock(client->display);
|
---|
[e022819] | 191 | return ENOENT;
|
---|
[c11ee605] | 192 | }
|
---|
[e022819] | 193 |
|
---|
[195b7b3] | 194 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize_req()");
|
---|
[e022819] | 195 | ds_window_resize_req(wnd, rsztype, pos);
|
---|
[c11ee605] | 196 | ds_display_unlock(client->display);
|
---|
[e022819] | 197 | return EOK;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[0e6e77f] | 200 | static 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;
|
---|
[c11ee605] | 205 | errno_t rc;
|
---|
| 206 |
|
---|
| 207 | ds_display_lock(client->display);
|
---|
[0e6e77f] | 208 |
|
---|
| 209 | wnd = ds_client_find_window(client, wnd_id);
|
---|
[c11ee605] | 210 | if (wnd == NULL) {
|
---|
| 211 | ds_display_unlock(client->display);
|
---|
[0e6e77f] | 212 | return ENOENT;
|
---|
[c11ee605] | 213 | }
|
---|
[0e6e77f] | 214 |
|
---|
[195b7b3] | 215 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_resize()");
|
---|
[c11ee605] | 216 | rc = ds_window_resize(wnd, offs, nbound);
|
---|
| 217 | ds_display_unlock(client->display);
|
---|
| 218 | return rc;
|
---|
[0e6e77f] | 219 | }
|
---|
| 220 |
|
---|
[9242ad9] | 221 | static 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 |
|
---|
[195b7b3] | 236 | log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_set_cursor()");
|
---|
[9242ad9] | 237 | rc = ds_window_set_cursor(wnd, cursor);
|
---|
| 238 | ds_display_unlock(client->display);
|
---|
| 239 | return rc;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[38e5f36c] | 242 | static 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 |
|
---|
[c11ee605] | 251 | ds_display_lock(client->display);
|
---|
| 252 |
|
---|
[38e5f36c] | 253 | rc = ds_client_get_event(client, &wnd, event);
|
---|
[c11ee605] | 254 | if (rc != EOK) {
|
---|
| 255 | ds_display_unlock(client->display);
|
---|
[38e5f36c] | 256 | return rc;
|
---|
[c11ee605] | 257 | }
|
---|
[38e5f36c] | 258 |
|
---|
| 259 | *wnd_id = wnd->id;
|
---|
[c11ee605] | 260 | ds_display_unlock(client->display);
|
---|
[38e5f36c] | 261 | return EOK;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
[aeb3037] | 264 | static 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 |
|
---|
[c11ee605] | 270 | ds_display_lock(client->display);
|
---|
[aeb3037] | 271 | ds_display_get_info(client->display, info);
|
---|
[c11ee605] | 272 | ds_display_unlock(client->display);
|
---|
[aeb3037] | 273 | return EOK;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[38e5f36c] | 276 | /** @}
|
---|
| 277 | */
|
---|