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

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

Move windows by dragging decoration

Or dragging anywhere with button 2. Need to add Ctrl/Alt/Shift state
to pos_event_t and change the latter to Alt-drag/Shift-drag.

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