Changeset 26edcd6 in mainline
- Timestamp:
- 2026-02-18T16:29:36Z (42 hours ago)
- Branches:
- master
- Children:
- 39f67f1
- Parents:
- 2c12135
- git-author:
- Jiri Svoboda <jiri@…> (2026-02-18 18:29:31)
- git-committer:
- Jiri Svoboda <jiri@…> (2026-02-18 16:29:36)
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
-
private/window.h (modified) (2 diffs)
-
src/ui.c (modified) (1 diff)
-
src/window.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/private/window.h
r2c12135 r26edcd6 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 136 136 extern errno_t ui_window_size_change(ui_window_t *, gfx_rect_t *, 137 137 ui_wnd_sc_op_t); 138 extern void ui_window_update_placement(ui_window_t *); 138 139 extern ui_window_t *ui_window_get_active(ui_t *); 139 140 extern ui_window_t *ui_window_first(ui_t *); -
uspace/lib/ui/src/ui.c
r2c12135 r26edcd6 337 337 ui->rect = *rect; 338 338 339 /* Re size all fullscreenwindows */339 /* Reposition/resize windows */ 340 340 wnd = ui_window_first(ui); 341 341 while (wnd != NULL) { 342 if (wnd->placement == ui_wnd_place_full_screen) { 343 (void)ui_window_resize(wnd, rect); 344 ui_window_send_resize(wnd); 345 } 346 342 ui_window_update_placement(wnd); 347 343 wnd = ui_window_next(wnd); 348 344 } 349 345 346 /* 347 * XXX Resizing cleared console GC so we need to repaint the 348 * background. 349 */ 350 350 (void)ui_paint(ui); 351 351 } -
uspace/lib/ui/src/window.c
r2c12135 r26edcd6 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 171 171 * @param window Window 172 172 * @param drect Display rectangle 173 * @param wrect Window rectangle 174 * @param prect Parent rectangle for popup placement or @c NULL 175 * @param placement Window placement 173 176 * @param params Window parameters 174 177 * @param pos Place to store position of top-left corner 175 178 */ 176 179 static void ui_window_place(ui_window_t *window, gfx_rect_t *drect, 177 ui_wnd_params_t *params, gfx_coord2_t *pos) 180 gfx_rect_t *wrect, gfx_rect_t *prect, ui_wnd_placement_t placement, 181 gfx_coord2_t *pos) 178 182 { 179 183 gfx_coord2_t dims; … … 181 185 gfx_rect_t below_rect; 182 186 183 assert(p arams->placement != ui_wnd_place_default ||187 assert(placement != ui_wnd_place_default || 184 188 ui_is_fullscreen(window->ui)); 185 189 … … 187 191 pos->y = 0; 188 192 189 switch (p arams->placement) {193 switch (placement) { 190 194 case ui_wnd_place_default: 191 195 case ui_wnd_place_center: 192 assert(p arams->placement != ui_wnd_place_default ||196 assert(placement != ui_wnd_place_default || 193 197 ui_is_fullscreen(window->ui)); 194 198 /* Center window */ 195 gfx_rect_dims( ¶ms->rect, &dims);199 gfx_rect_dims(wrect, &dims); 196 200 pos->x = (drect->p0.x + drect->p1.x) / 2 - dims.x / 2; 197 201 pos->y = (drect->p0.y + drect->p1.y) / 2 - dims.y / 2; … … 199 203 case ui_wnd_place_top_left: 200 204 case ui_wnd_place_full_screen: 201 pos->x = drect->p0.x - params->rect.p0.x;202 pos->y = drect->p0.y - params->rect.p0.y;205 pos->x = drect->p0.x - wrect->p0.x; 206 pos->y = drect->p0.y - wrect->p0.y; 203 207 break; 204 208 case ui_wnd_place_top_right: 205 pos->x = drect->p1.x - params->rect.p1.x;206 pos->y = drect->p0.y - params->rect.p0.y;209 pos->x = drect->p1.x - wrect->p1.x; 210 pos->y = drect->p0.y - wrect->p0.y; 207 211 break; 208 212 case ui_wnd_place_bottom_left: 209 pos->x = drect->p0.x - params->rect.p0.x;210 pos->y = drect->p1.y - params->rect.p1.y;213 pos->x = drect->p0.x - wrect->p0.x; 214 pos->y = drect->p1.y - wrect->p1.y; 211 215 break; 212 216 case ui_wnd_place_bottom_right: 213 pos->x = drect->p1.x - params->rect.p1.x;214 pos->y = drect->p1.y - params->rect.p1.y;217 pos->x = drect->p1.x - wrect->p1.x; 218 pos->y = drect->p1.y - wrect->p1.y; 215 219 break; 216 220 case ui_wnd_place_popup: 217 221 /* Compute rectangle when placed below */ 218 below_pos.x = p arams->prect.p0.x;219 below_pos.y = p arams->prect.p1.y;220 gfx_rect_translate(&below_pos, ¶ms->rect, &below_rect);222 below_pos.x = prect->p0.x; 223 below_pos.y = prect->p1.y; 224 gfx_rect_translate(&below_pos, wrect, &below_rect); 221 225 222 226 /* Does below_rect fit within the display? */ 223 227 if (gfx_rect_is_inside(&below_rect, drect)) { 224 228 /* Place popup window below parent rectangle */ 225 pos->x = p arams->prect.p0.x - params->rect.p0.x;226 pos->y = p arams->prect.p1.y - params->rect.p0.y;229 pos->x = prect->p0.x - wrect->p0.x; 230 pos->y = prect->p1.y - wrect->p0.y; 227 231 } else { 228 232 /* Place popup window above parent rectangle */ 229 pos->x = p arams->prect.p0.x;230 pos->y = p arams->prect.p0.y -231 ( params->rect.p1.y - params->rect.p0.y);233 pos->x = prect->p0.x; 234 pos->y = prect->p0.y - 235 (wrect->p1.y - wrect->p0.y); 232 236 } 233 237 break; … … 384 388 if (params->placement != ui_wnd_place_default) { 385 389 /* Set initial display window position */ 386 ui_window_place(window, &info.rect, params,387 & dparams.pos);390 ui_window_place(window, &info.rect, ¶ms->rect, 391 ¶ms->prect, params->placement, &dparams.pos); 388 392 389 393 dparams.flags |= wndf_setpos; … … 477 481 #endif 478 482 if (ui->display == NULL) { 479 ui_window_place(window, &ui->rect, params, &window->dpos); 483 ui_window_place(window, &ui->rect, ¶ms->rect, ¶ms->prect, 484 params->placement, &window->dpos); 480 485 481 486 if (window->xgc != NULL) … … 536 541 free(window); 537 542 return rc; 543 } 544 545 /** Update window placement after screen resize (only in fullscreen UI). 546 * 547 * @param window UI window 548 */ 549 void ui_window_update_placement(ui_window_t *window) 550 { 551 if (window->placement != ui_wnd_place_popup) 552 ui_window_place(window, &window->ui->rect, &window->rect, 553 NULL, window->placement, &window->dpos); 554 555 if (window->xgc != NULL) 556 xlate_gc_set_off(window->xgc, &window->dpos); 557 558 if (window->placement == ui_wnd_place_full_screen) { 559 (void)ui_window_resize(window, &window->ui->rect); 560 ui_window_send_resize(window); 561 } 538 562 } 539 563
Note:
See TracChangeset
for help on using the changeset viewer.
