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

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

Maximizing/unmaximizing a window

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