Changeset cf32dbd in mainline for uspace/srv/hid/display/display.c
- Timestamp:
- 2019-11-29T19:38:25Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fd777a2
- Parents:
- 38e5f36c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.