Changeset ebb1489 in mainline for uspace/srv/hid/display/display.c
- Timestamp:
- 2024-10-13T08:23:40Z (8 weeks ago)
- Children:
- 0472cf17
- Parents:
- 2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
- git-committer:
- GitHub <noreply@…> (2024-10-13 08:23:40)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
r2a0c827c rebb1489 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <memgfx/memgc.h> 42 42 #include <stdlib.h> 43 #include <str.h> 43 44 #include "client.h" 44 45 #include "clonegc.h" … … 46 47 #include "cursor.h" 47 48 #include "display.h" 49 #include "idevcfg.h" 48 50 #include "seat.h" 49 51 #include "window.h" … … 100 102 list_initialize(&disp->cfgclients); 101 103 disp->next_wnd_id = 1; 104 disp->next_seat_id = 1; 102 105 list_initialize(&disp->ddevs); 103 106 list_initialize(&disp->idevcfgs); … … 137 140 gfx_color_delete(disp->bg_color); 138 141 free(disp); 142 } 143 144 /** Load display configuration from SIF file. 145 * 146 * @param display Display 147 * @param cfgpath Configuration file path 148 * 149 * @return EOK on success or an error code 150 */ 151 errno_t ds_display_load_cfg(ds_display_t *display, const char *cfgpath) 152 { 153 sif_doc_t *doc = NULL; 154 sif_node_t *rnode; 155 sif_node_t *ndisplay; 156 sif_node_t *nseats; 157 sif_node_t *nseat; 158 ds_seat_t *seat; 159 sif_node_t *nidevcfgs; 160 sif_node_t *nidevcfg; 161 const char *ntype; 162 ds_idevcfg_t *idevcfg; 163 errno_t rc; 164 165 rc = sif_load(cfgpath, &doc); 166 if (rc != EOK) 167 goto error; 168 169 rnode = sif_get_root(doc); 170 ndisplay = sif_node_first_child(rnode); 171 ntype = sif_node_get_type(ndisplay); 172 if (str_cmp(ntype, "display") != 0) { 173 rc = EIO; 174 goto error; 175 } 176 177 nseats = sif_node_first_child(ndisplay); 178 ntype = sif_node_get_type(nseats); 179 if (str_cmp(ntype, "seats") != 0) { 180 rc = EIO; 181 goto error; 182 } 183 184 /* Load individual seats */ 185 nseat = sif_node_first_child(nseats); 186 while (nseat != NULL) { 187 ntype = sif_node_get_type(nseat); 188 if (str_cmp(ntype, "seat") != 0) { 189 rc = EIO; 190 goto error; 191 } 192 193 rc = ds_seat_load(display, nseat, &seat); 194 if (rc != EOK) 195 goto error; 196 197 (void)seat; 198 nseat = sif_node_next_child(nseat); 199 } 200 201 nidevcfgs = sif_node_next_child(nseats); 202 ntype = sif_node_get_type(nidevcfgs); 203 if (str_cmp(ntype, "idevcfgs") != 0) { 204 rc = EIO; 205 goto error; 206 } 207 208 /* Load individual input device configuration entries */ 209 nidevcfg = sif_node_first_child(nidevcfgs); 210 while (nidevcfg != NULL) { 211 ntype = sif_node_get_type(nidevcfg); 212 if (str_cmp(ntype, "idevcfg") != 0) { 213 rc = EIO; 214 goto error; 215 } 216 217 /* 218 * Load device configuration entry. If the device 219 * is not currently connected (ENOENT), skip it. 220 */ 221 rc = ds_idevcfg_load(display, nidevcfg, &idevcfg); 222 if (rc != EOK && rc != ENOENT) 223 goto error; 224 225 (void)idevcfg; 226 nidevcfg = sif_node_next_child(nidevcfg); 227 } 228 229 sif_delete(doc); 230 return EOK; 231 error: 232 if (doc != NULL) 233 sif_delete(doc); 234 235 seat = ds_display_first_seat(display); 236 while (seat != NULL) { 237 ds_seat_destroy(seat); 238 seat = ds_display_first_seat(display); 239 } 240 return rc; 241 } 242 243 /** Save display configuration to SIF file. 244 * 245 * @param display Display 246 * @param cfgpath Configuration file path 247 * 248 * @return EOK on success or an error code 249 */ 250 errno_t ds_display_save_cfg(ds_display_t *display, const char *cfgpath) 251 { 252 sif_doc_t *doc = NULL; 253 sif_node_t *rnode; 254 sif_node_t *ndisplay; 255 sif_node_t *nseats; 256 sif_node_t *nseat; 257 ds_seat_t *seat; 258 sif_node_t *nidevcfgs; 259 sif_node_t *nidevcfg; 260 ds_idevcfg_t *idevcfg; 261 errno_t rc; 262 263 rc = sif_new(&doc); 264 if (rc != EOK) 265 goto error; 266 267 rnode = sif_get_root(doc); 268 rc = sif_node_append_child(rnode, "display", &ndisplay); 269 if (rc != EOK) 270 goto error; 271 272 rc = sif_node_append_child(ndisplay, "seats", &nseats); 273 if (rc != EOK) 274 goto error; 275 276 /* Save individual seats */ 277 seat = ds_display_first_seat(display); 278 while (seat != NULL) { 279 rc = sif_node_append_child(nseats, "seat", &nseat); 280 if (rc != EOK) 281 goto error; 282 283 rc = ds_seat_save(seat, nseat); 284 if (rc != EOK) 285 goto error; 286 287 seat = ds_display_next_seat(seat); 288 } 289 290 rc = sif_node_append_child(ndisplay, "idevcfgs", &nidevcfgs); 291 if (rc != EOK) 292 goto error; 293 294 /* Save individual input device configuration entries */ 295 idevcfg = ds_display_first_idevcfg(display); 296 while (idevcfg != NULL) { 297 rc = sif_node_append_child(nidevcfgs, "idevcfg", &nidevcfg); 298 if (rc != EOK) 299 goto error; 300 301 rc = ds_idevcfg_save(idevcfg, nidevcfg); 302 if (rc != EOK) 303 goto error; 304 305 idevcfg = ds_display_next_idevcfg(idevcfg); 306 } 307 308 rc = sif_save(doc, cfgpath); 309 if (rc != EOK) 310 goto error; 311 312 sif_delete(doc); 313 return EOK; 314 error: 315 if (doc != NULL) 316 sif_delete(doc); 317 return rc; 139 318 } 140 319
Note:
See TracChangeset
for help on using the changeset viewer.