Changes in uspace/srv/hid/display/display.c [6fbd1f9:5d380b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
r6fbd1f9 r5d380b6 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <memgfx/memgc.h> 42 42 #include <stdlib.h> 43 #include <str.h>44 43 #include "client.h" 45 44 #include "clonegc.h" … … 47 46 #include "cursor.h" 48 47 #include "display.h" 49 #include "idevcfg.h"50 48 #include "seat.h" 51 49 #include "window.h" … … 102 100 list_initialize(&disp->cfgclients); 103 101 disp->next_wnd_id = 1; 104 disp->next_seat_id = 1;105 102 list_initialize(&disp->ddevs); 106 103 list_initialize(&disp->idevcfgs); 107 list_initialize(&disp->ievents);108 fibril_condvar_initialize(&disp->ievent_cv);109 104 list_initialize(&disp->seats); 110 105 list_initialize(&disp->windows); … … 131 126 assert(list_empty(&disp->ddevs)); 132 127 assert(list_empty(&disp->idevcfgs)); 133 assert(list_empty(&disp->ievents));134 128 assert(list_empty(&disp->seats)); 135 129 assert(list_empty(&disp->windows)); … … 143 137 gfx_color_delete(disp->bg_color); 144 138 free(disp); 145 }146 147 /** Load display configuration from SIF file.148 *149 * @param display Display150 * @param cfgpath Configuration file path151 *152 * @return EOK on success or an error code153 */154 errno_t ds_display_load_cfg(ds_display_t *display, const char *cfgpath)155 {156 sif_doc_t *doc = NULL;157 sif_node_t *rnode;158 sif_node_t *ndisplay;159 sif_node_t *nseats;160 sif_node_t *nseat;161 ds_seat_t *seat;162 sif_node_t *nidevcfgs;163 sif_node_t *nidevcfg;164 const char *ntype;165 ds_idevcfg_t *idevcfg;166 errno_t rc;167 168 rc = sif_load(cfgpath, &doc);169 if (rc != EOK)170 goto error;171 172 rnode = sif_get_root(doc);173 ndisplay = sif_node_first_child(rnode);174 ntype = sif_node_get_type(ndisplay);175 if (str_cmp(ntype, "display") != 0) {176 rc = EIO;177 goto error;178 }179 180 nseats = sif_node_first_child(ndisplay);181 ntype = sif_node_get_type(nseats);182 if (str_cmp(ntype, "seats") != 0) {183 rc = EIO;184 goto error;185 }186 187 /* Load individual seats */188 nseat = sif_node_first_child(nseats);189 while (nseat != NULL) {190 ntype = sif_node_get_type(nseat);191 if (str_cmp(ntype, "seat") != 0) {192 rc = EIO;193 goto error;194 }195 196 rc = ds_seat_load(display, nseat, &seat);197 if (rc != EOK)198 goto error;199 200 (void)seat;201 nseat = sif_node_next_child(nseat);202 }203 204 nidevcfgs = sif_node_next_child(nseats);205 ntype = sif_node_get_type(nidevcfgs);206 if (str_cmp(ntype, "idevcfgs") != 0) {207 rc = EIO;208 goto error;209 }210 211 /* Load individual input device configuration entries */212 nidevcfg = sif_node_first_child(nidevcfgs);213 while (nidevcfg != NULL) {214 ntype = sif_node_get_type(nidevcfg);215 if (str_cmp(ntype, "idevcfg") != 0) {216 rc = EIO;217 goto error;218 }219 220 /*221 * Load device configuration entry. If the device222 * is not currently connected (ENOENT), skip it.223 */224 rc = ds_idevcfg_load(display, nidevcfg, &idevcfg);225 if (rc != EOK && rc != ENOENT)226 goto error;227 228 (void)idevcfg;229 nidevcfg = sif_node_next_child(nidevcfg);230 }231 232 sif_delete(doc);233 return EOK;234 error:235 if (doc != NULL)236 sif_delete(doc);237 238 seat = ds_display_first_seat(display);239 while (seat != NULL) {240 ds_seat_destroy(seat);241 seat = ds_display_first_seat(display);242 }243 return rc;244 }245 246 /** Save display configuration to SIF file.247 *248 * @param display Display249 * @param cfgpath Configuration file path250 *251 * @return EOK on success or an error code252 */253 errno_t ds_display_save_cfg(ds_display_t *display, const char *cfgpath)254 {255 sif_doc_t *doc = NULL;256 sif_node_t *rnode;257 sif_node_t *ndisplay;258 sif_node_t *nseats;259 sif_node_t *nseat;260 ds_seat_t *seat;261 sif_node_t *nidevcfgs;262 sif_node_t *nidevcfg;263 ds_idevcfg_t *idevcfg;264 errno_t rc;265 266 rc = sif_new(&doc);267 if (rc != EOK)268 goto error;269 270 rnode = sif_get_root(doc);271 rc = sif_node_append_child(rnode, "display", &ndisplay);272 if (rc != EOK)273 goto error;274 275 rc = sif_node_append_child(ndisplay, "seats", &nseats);276 if (rc != EOK)277 goto error;278 279 /* Save individual seats */280 seat = ds_display_first_seat(display);281 while (seat != NULL) {282 rc = sif_node_append_child(nseats, "seat", &nseat);283 if (rc != EOK)284 goto error;285 286 rc = ds_seat_save(seat, nseat);287 if (rc != EOK)288 goto error;289 290 seat = ds_display_next_seat(seat);291 }292 293 rc = sif_node_append_child(ndisplay, "idevcfgs", &nidevcfgs);294 if (rc != EOK)295 goto error;296 297 /* Save individual input device configuration entries */298 idevcfg = ds_display_first_idevcfg(display);299 while (idevcfg != NULL) {300 rc = sif_node_append_child(nidevcfgs, "idevcfg", &nidevcfg);301 if (rc != EOK)302 goto error;303 304 rc = ds_idevcfg_save(idevcfg, nidevcfg);305 if (rc != EOK)306 goto error;307 308 idevcfg = ds_display_next_idevcfg(idevcfg);309 }310 311 rc = sif_save(doc, cfgpath);312 if (rc != EOK)313 goto error;314 315 sif_delete(doc);316 return EOK;317 error:318 if (doc != NULL)319 sif_delete(doc);320 return rc;321 139 } 322 140
Note:
See TracChangeset
for help on using the changeset viewer.