Changeset cf32dbd in mainline for uspace/srv/hid/display/display.c


Ignore:
Timestamp:
2019-11-29T19:38:25Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd777a2
Parents:
38e5f36c
Message:

Introduce window focus, housed in a seat object

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/display.c

    r38e5f36c rcf32dbd  
    3939#include <stdlib.h>
    4040#include "client.h"
     41#include "seat.h"
    4142#include "window.h"
    4243#include "display.h"
     
    5960        disp->gc = gc;
    6061        disp->next_wnd_id = 1;
     62        list_initialize(&disp->seats);
    6163        *rdisp = disp;
    6264        return EOK;
     
    7072{
    7173        assert(list_empty(&disp->clients));
     74        assert(list_empty(&disp->seats));
    7275        free(disp);
    7376}
     
    7679 *
    7780 * @param disp Display
    78  * @param client client
     81 * @param client Client
    7982 */
    8083void ds_display_add_client(ds_display_t *disp, ds_client_t *client)
     
    8992/** Remove client from display.
    9093 *
    91  * @param client client
     94 * @param client Client
    9295 */
    9396void ds_display_remove_client(ds_client_t *client)
     
    160163}
    161164
     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 */
    162174errno_t ds_display_post_kbd_event(ds_display_t *display, kbd_event_t *event)
    163175{
    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)
    171181                return EOK;
    172182
    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 */
     191void 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 */
     204void 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 */
     215ds_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 */
     230ds_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);
    178238}
    179239
Note: See TracChangeset for help on using the changeset viewer.