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

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

Resizing windows

  • Property mode set to 100644
File size: 4.9 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 *);
[e022819]49static errno_t disp_window_resize_req(void *, sysarg_t,
50 display_wnd_rsztype_t, gfx_coord2_t *);
[0e6e77f]51static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
52 gfx_rect_t *);
[38e5f36c]53static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *);
54
55display_ops_t display_srv_ops = {
56 .window_create = disp_window_create,
57 .window_destroy = disp_window_destroy,
[a2e104e]58 .window_move_req = disp_window_move_req,
[e022819]59 .window_resize_req = disp_window_resize_req,
[0e6e77f]60 .window_resize = disp_window_resize,
[38e5f36c]61 .get_event = disp_get_event
62};
63
[4d9c807]64static errno_t disp_window_create(void *arg, display_wnd_params_t *params,
65 sysarg_t *rwnd_id)
[38e5f36c]66{
67 errno_t rc;
68 ds_client_t *client = (ds_client_t *) arg;
[cf32dbd]69 ds_seat_t *seat;
[38e5f36c]70 ds_window_t *wnd;
71
72 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create()");
73
[3434233]74 rc = ds_window_create(client, params, &wnd);
[38e5f36c]75 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() - ds_window_create -> %d", rc);
76 if (rc != EOK)
77 return rc;
78
79 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_create() -> EOK, id=%zu",
80 wnd->id);
81
[cc90846]82 /* XXX All the below should probably be part of ds_window_create() */
[38e5f36c]83 wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
84 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
85
[cf32dbd]86 seat = ds_display_first_seat(client->display);
87 ds_seat_set_focus(seat, wnd);
[cc90846]88 (void) ds_display_paint(wnd->display, NULL);
[cf32dbd]89
[38e5f36c]90 *rwnd_id = wnd->id;
91 return EOK;
92}
93
94static errno_t disp_window_destroy(void *arg, sysarg_t wnd_id)
95{
96 ds_client_t *client = (ds_client_t *) arg;
97 ds_window_t *wnd;
98
99 wnd = ds_client_find_window(client, wnd_id);
100 if (wnd == NULL)
101 return ENOENT;
102
103 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_destroy()");
104 ds_client_remove_window(wnd);
105 ds_window_destroy(wnd);
106 return EOK;
107}
108
[a2e104e]109static errno_t disp_window_move_req(void *arg, sysarg_t wnd_id,
110 gfx_coord2_t *pos)
111{
112 ds_client_t *client = (ds_client_t *) arg;
113 ds_window_t *wnd;
114
115 wnd = ds_client_find_window(client, wnd_id);
116 if (wnd == NULL)
117 return ENOENT;
118
119 log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_move_req()");
120 ds_window_move_req(wnd, pos);
121 return EOK;
122}
123
[e022819]124static errno_t disp_window_resize_req(void *arg, sysarg_t wnd_id,
125 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
126{
127 ds_client_t *client = (ds_client_t *) arg;
128 ds_window_t *wnd;
129
130 wnd = ds_client_find_window(client, wnd_id);
131 if (wnd == NULL)
132 return ENOENT;
133
134 log_msg(LVL_NOTE, LVL_DEBUG, "disp_window_resize_req()");
135 ds_window_resize_req(wnd, rsztype, pos);
136 return EOK;
137}
138
[0e6e77f]139static errno_t disp_window_resize(void *arg, sysarg_t wnd_id,
140 gfx_coord2_t *offs, gfx_rect_t *nbound)
141{
142 ds_client_t *client = (ds_client_t *) arg;
143 ds_window_t *wnd;
144
145 wnd = ds_client_find_window(client, wnd_id);
146 if (wnd == NULL)
147 return ENOENT;
148
149 log_msg(LOG_DEFAULT, LVL_NOTE, "disp_window_resize()");
150 return ds_window_resize(wnd, offs, nbound);
151}
152
[38e5f36c]153static errno_t disp_get_event(void *arg, sysarg_t *wnd_id,
154 display_wnd_ev_t *event)
155{
156 ds_client_t *client = (ds_client_t *) arg;
157 ds_window_t *wnd;
158 errno_t rc;
159
160 log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_get_event()");
161
162 rc = ds_client_get_event(client, &wnd, event);
163 if (rc != EOK)
164 return rc;
165
166 *wnd_id = wnd->id;
167 return EOK;
168}
169
170/** @}
171 */
Note: See TracBrowser for help on using the repository browser.