Changeset 8a9a41e in mainline for uspace/lib/ui/src/ui.c
- Timestamp:
- 2021-10-24T08:28:43Z (2 years ago)
- Children:
- f628215
- Parents:
- 2ce943a (diff), cd981f2a (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:
- Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
- git-committer:
- GitHub <noreply@…> (2021-10-24 08:28:43)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/ui.c
r2ce943a r8a9a41e 39 39 #include <errno.h> 40 40 #include <fibril.h> 41 #include <gfx/color.h> 42 #include <gfx/render.h> 41 43 #include <io/console.h> 42 44 #include <stdbool.h> … … 53 55 * 54 56 * Output specification has the form <proto>@<service> where proto is 55 * eiher 'disp' for display service or 'cons' for console. Service56 * is a location ID service name (e.g. hid/display).57 * eiher 'disp' for display service, 'cons' for console, 'null' 58 * for dummy output. Service is a location ID service name (e.g. hid/display). 57 59 * 58 60 * @param ospec Output specification … … 80 82 } else if (str_lcmp(ospec, "cons@", str_length("cons@")) == 0) { 81 83 *ws = ui_ws_console; 84 } else if (str_lcmp(ospec, "null@", str_length("null@")) == 0) { 85 *ws = ui_ws_null; 82 86 } else { 83 87 *ws = ui_ws_unknown; … … 97 101 * 98 102 * @param ospec Output specification or @c UI_DISPLAY_DEFAULT to use 99 * the default output 103 * the default display service, UI_CONSOLE_DEFAULT to use 104 * the default console service, UI_DISPLAY_NULL to use 105 * dummy output. 100 106 * @param rui Place to store pointer to new UI 101 107 * @return EOK on success or an error code … … 109 115 ui_winsys_t ws; 110 116 const char *osvc; 117 sysarg_t cols; 118 sysarg_t rows; 111 119 ui_t *ui; 112 120 … … 128 136 return EIO; 129 137 138 rc = console_get_size(console, &cols, &rows); 139 if (rc != EOK) { 140 console_done(console); 141 return rc; 142 } 143 144 console_cursor_visibility(console, false); 145 130 146 /* ws == ui_ws_console */ 131 147 rc = ui_create_cons(console, &ui); … … 143 159 144 160 ui->cgc = cgc; 161 ui->rect.p0.x = 0; 162 ui->rect.p0.y = 0; 163 ui->rect.p1.x = cols; 164 ui->rect.p1.y = rows; 165 166 (void) ui_paint(ui); 167 } else if (ws == ui_ws_null) { 168 rc = ui_create_disp(NULL, &ui); 169 if (rc != EOK) 170 return rc; 145 171 } else { 146 172 return EINVAL; … … 203 229 if (ui->cgc != NULL) 204 230 console_gc_delete(ui->cgc); 205 if (ui->console != NULL) 231 if (ui->console != NULL) { 232 console_cursor_visibility(ui->console, true); 206 233 console_done(ui->console); 234 } 207 235 if (ui->display != NULL) 208 236 display_close(ui->display); … … 216 244 ui_window_t *awnd; 217 245 ui_evclaim_t claim; 246 pos_event_t pos; 218 247 219 248 awnd = ui_window_get_active(ui); … … 226 255 break; 227 256 case CEV_POS: 228 claim = ui_wdecor_pos_event(awnd->wdecor, &event->ev.pos); 257 pos = event->ev.pos; 258 /* Translate event to window-relative coordinates */ 259 pos.hpos -= awnd->dpos.x; 260 pos.vpos -= awnd->dpos.y; 261 262 claim = ui_wdecor_pos_event(awnd->wdecor, &pos); 229 263 /* Note: If event is claimed, awnd might not be valid anymore */ 230 264 if (claim == ui_unclaimed) 231 ui_window_send_pos(awnd, &event->ev.pos); 265 ui_window_send_pos(awnd, &pos); 266 232 267 break; 233 268 } … … 280 315 { 281 316 errno_t rc; 317 gfx_context_t *gc; 282 318 ui_window_t *awnd; 319 gfx_color_t *color = NULL; 320 321 /* In case of null output */ 322 if (ui->cgc == NULL) 323 return EOK; 324 325 gc = console_gc_get_ctx(ui->cgc); 326 327 rc = gfx_color_new_ega(0x11, &color); 328 if (rc != EOK) 329 return rc; 330 331 rc = gfx_set_color(gc, color); 332 if (rc != EOK) { 333 gfx_color_delete(color); 334 return rc; 335 } 336 337 rc = gfx_fill_rect(gc, &ui->rect); 338 if (rc != EOK) { 339 gfx_color_delete(color); 340 return rc; 341 } 342 343 gfx_color_delete(color); 283 344 284 345 /* XXX Should repaint all windows */
Note:
See TracChangeset
for help on using the changeset viewer.