Changeset cf32dbd in mainline
- Timestamp:
- 2019-11-29T19:38:25Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fd777a2
- Parents:
- 38e5f36c
- Location:
- uspace/srv/hid/display
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/client.c
r38e5f36c rcf32dbd 39 39 #include "client.h" 40 40 #include "display.h" 41 #include "seat.h" 41 42 #include "window.h" 42 43 … … 112 113 void ds_client_remove_window(ds_window_t *wnd) 113 114 { 115 ds_seat_t *seat; 116 117 /* Make sure window is no longer focused in any seat */ 118 seat = ds_display_first_seat(wnd->client->display); 119 while (seat != NULL) { 120 ds_seat_evac_focus(seat, wnd); 121 seat = ds_display_next_seat(seat); 122 } 123 114 124 list_remove(&wnd->lwindows); 115 125 wnd->client = NULL; -
uspace/srv/hid/display/client.h
r38e5f36c rcf32dbd 37 37 #define CLIENT_H 38 38 39 #include <errno.h> 40 #include <io/kbd_event.h> 39 41 #include "types/display/client.h" 40 42 #include "types/display/display.h" -
uspace/srv/hid/display/display.c
r38e5f36c rcf32dbd 39 39 #include <stdlib.h> 40 40 #include "client.h" 41 #include "seat.h" 41 42 #include "window.h" 42 43 #include "display.h" … … 59 60 disp->gc = gc; 60 61 disp->next_wnd_id = 1; 62 list_initialize(&disp->seats); 61 63 *rdisp = disp; 62 64 return EOK; … … 70 72 { 71 73 assert(list_empty(&disp->clients)); 74 assert(list_empty(&disp->seats)); 72 75 free(disp); 73 76 } … … 76 79 * 77 80 * @param disp Display 78 * @param client client81 * @param client Client 79 82 */ 80 83 void ds_display_add_client(ds_display_t *disp, ds_client_t *client) … … 89 92 /** Remove client from display. 90 93 * 91 * @param client client94 * @param client Client 92 95 */ 93 96 void ds_display_remove_client(ds_client_t *client) … … 160 163 } 161 164 165 /** Post keyboard event to a display. 166 * 167 * The event is routed to the correct window by first determining the 168 * seat the keyboard device belongs to and then the event is sent to the 169 * window focused by that seat. 170 * 171 * @param display Display 172 * @param event Event 173 */ 162 174 errno_t ds_display_post_kbd_event(ds_display_t *display, kbd_event_t *event) 163 175 { 164 ds_client_t *client; 165 ds_window_t *wnd; 166 167 // XXX Correctly determine destination window 168 169 client = ds_display_first_client(display); 170 if (client == NULL) 176 ds_seat_t *seat; 177 178 // TODO Determine which seat the event belongs to 179 seat = ds_display_first_seat(display); 180 if (seat == NULL) 171 181 return EOK; 172 182 173 wnd = ds_client_first_window(client); 174 if (wnd == NULL) 175 return EOK; 176 177 return ds_client_post_kbd_event(client, wnd, event); 183 return ds_seat_post_kbd_event(seat, event); 184 } 185 186 /** Add seat to display. 187 * 188 * @param disp Display 189 * @param seat Seat 190 */ 191 void ds_display_add_seat(ds_display_t *disp, ds_seat_t *seat) 192 { 193 assert(seat->display == NULL); 194 assert(!link_used(&seat->lseats)); 195 196 seat->display = disp; 197 list_append(&seat->lseats, &disp->seats); 198 } 199 200 /** Remove seat from display. 201 * 202 * @param seat Seat 203 */ 204 void ds_display_remove_seat(ds_seat_t *seat) 205 { 206 list_remove(&seat->lseats); 207 seat->display = NULL; 208 } 209 210 /** Get first seat in display. 211 * 212 * @param disp Display 213 * @return First seat or @c NULL if there is none 214 */ 215 ds_seat_t *ds_display_first_seat(ds_display_t *disp) 216 { 217 link_t *link = list_first(&disp->seats); 218 219 if (link == NULL) 220 return NULL; 221 222 return list_get_instance(link, ds_seat_t, lseats); 223 } 224 225 /** Get next seat in display. 226 * 227 * @param seat Current seat 228 * @return Next seat or @c NULL if there is none 229 */ 230 ds_seat_t *ds_display_next_seat(ds_seat_t *seat) 231 { 232 link_t *link = list_next(&seat->lseats, &seat->display->seats); 233 234 if (link == NULL) 235 return NULL; 236 237 return list_get_instance(link, ds_seat_t, lseats); 178 238 } 179 239 -
uspace/srv/hid/display/display.h
r38e5f36c rcf32dbd 42 42 #include "types/display/client.h" 43 43 #include "types/display/display.h" 44 #include "types/display/seat.h" 44 45 45 46 extern errno_t ds_display_create(gfx_context_t *, ds_display_t **); … … 51 52 extern ds_window_t *ds_display_find_window(ds_display_t *, ds_wnd_id_t); 52 53 extern errno_t ds_display_post_kbd_event(ds_display_t *, kbd_event_t *); 54 extern void ds_display_add_seat(ds_display_t *, ds_seat_t *); 55 extern void ds_display_remove_seat(ds_seat_t *); 56 extern ds_seat_t *ds_display_first_seat(ds_display_t *); 57 extern ds_seat_t *ds_display_next_seat(ds_seat_t *); 53 58 54 59 #endif -
uspace/srv/hid/display/dsops.c
r38e5f36c rcf32dbd 38 38 #include <io/log.h> 39 39 #include "client.h" 40 #include "display.h" 41 #include "dsops.h" 42 #include "seat.h" 40 43 #include "window.h" 41 #include "dsops.h"42 44 43 45 static errno_t disp_window_create(void *, sysarg_t *); … … 55 57 errno_t rc; 56 58 ds_client_t *client = (ds_client_t *) arg; 59 ds_seat_t *seat; 57 60 ds_window_t *wnd; 58 61 … … 69 72 wnd->dpos.x = ((wnd->id - 1) & 1) * 400; 70 73 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300; 74 75 /* 76 * XXX This should be performed by window manager. It needs to determine 77 * whether the new window should get focus and which seat should 78 * focus on it. 79 */ 80 seat = ds_display_first_seat(client->display); 81 ds_seat_set_focus(seat, wnd); 71 82 72 83 *rwnd_id = wnd->id; -
uspace/srv/hid/display/main.c
r38e5f36c rcf32dbd 50 50 #include "main.h" 51 51 #include "output.h" 52 #include "seat.h" 52 53 #include "window.h" 53 54 … … 78 79 { 79 80 ds_display_t *disp = NULL; 81 ds_seat_t *seat = NULL; 80 82 gfx_context_t *gc = NULL; 81 83 errno_t rc; … … 84 86 85 87 rc = ds_display_create(NULL, &disp); 88 if (rc != EOK) 89 goto error; 90 91 rc = ds_seat_create(disp, &seat); 86 92 if (rc != EOK) 87 93 goto error; … … 121 127 if (gc != NULL) 122 128 gfx_context_delete(gc); 129 if (seat != NULL) 130 ds_seat_destroy(seat); 123 131 if (disp != NULL) 124 132 ds_display_destroy(disp); -
uspace/srv/hid/display/meson.build
r38e5f36c rcf32dbd 35 35 'main.c', 36 36 'output.c', 37 'seat.c', 37 38 'window.c', 38 39 ) … … 41 42 'client.c', 42 43 'display.c', 44 'seat.c', 43 45 'window.c', 44 46 'test/client.c', -
uspace/srv/hid/display/test/display.c
r38e5f36c rcf32dbd 34 34 #include "../client.h" 35 35 #include "../display.h" 36 #include "../seat.h" 36 37 #include "../window.h" 37 38 … … 130 131 } 131 132 133 /** Basic seat operation. */ 134 PCUT_TEST(display_seat) 135 { 136 ds_display_t *disp; 137 ds_seat_t *seat; 138 ds_seat_t *s0, *s1; 139 errno_t rc; 140 141 rc = ds_display_create(NULL, &disp); 142 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 143 144 rc = ds_seat_create(disp, &seat); 145 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 146 147 s0 = ds_display_first_seat(disp); 148 PCUT_ASSERT_EQUALS(s0, seat); 149 150 s1 = ds_display_next_seat(s0); 151 PCUT_ASSERT_NULL(s1); 152 153 ds_seat_destroy(seat); 154 ds_display_destroy(disp); 155 } 156 132 157 /** Test ds_display_post_kbd_event(). */ 133 158 PCUT_TEST(display_post_kbd_event) 134 159 { 135 160 ds_display_t *disp; 161 ds_seat_t *seat; 136 162 ds_client_t *client; 137 163 ds_window_t *wnd; … … 141 167 142 168 rc = ds_display_create(NULL, &disp); 169 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 170 171 rc = ds_seat_create(disp, &seat); 143 172 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 144 173 … … 162 191 ds_window_destroy(wnd); 163 192 ds_client_destroy(client); 193 ds_seat_destroy(seat); 164 194 ds_display_destroy(disp); 165 195 } -
uspace/srv/hid/display/types/display/display.h
r38e5f36c rcf32dbd 59 59 /** Input service */ 60 60 input_t *input; 61 62 /** Seats (of ds_seat_t) */ 63 list_t seats; 61 64 } ds_display_t; 62 65 -
uspace/srv/hid/display/window.h
r38e5f36c rcf32dbd 37 37 #define WINDOW_H 38 38 39 #include <display/event.h>40 39 #include <errno.h> 41 40 #include <types/gfx/context.h>
Note:
See TracChangeset
for help on using the changeset viewer.