Changeset 3c3657c in mainline
- Timestamp:
- 2021-09-04T08:04:36Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7896f23
- Parents:
- 81d3612
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/private/window.h
r81d3612 r3c3657c 74 74 /** Window rectangle */ 75 75 gfx_rect_t rect; 76 /** Display position (if fullscreen mode) */ 77 gfx_coord2_t dpos; 76 78 /** Application area bitmap */ 77 79 gfx_bitmap_t *app_bmp; -
uspace/lib/ui/src/ui.c
r81d3612 r3c3657c 236 236 ui_window_t *awnd; 237 237 ui_evclaim_t claim; 238 pos_event_t pos; 238 239 239 240 awnd = ui_window_get_active(ui); … … 246 247 break; 247 248 case CEV_POS: 248 claim = ui_wdecor_pos_event(awnd->wdecor, &event->ev.pos); 249 pos = event->ev.pos; 250 #ifdef CONFIG_UI_CS_RENDER 251 /* 252 * TODO Enable translation for server-side rendering 253 * once we can translate rendering operations in this 254 * case. 255 */ 256 pos.hpos -= awnd->dpos.x; 257 pos.vpos -= awnd->dpos.y; 258 #endif 259 260 claim = ui_wdecor_pos_event(awnd->wdecor, &pos); 249 261 /* Note: If event is claimed, awnd might not be valid anymore */ 250 262 if (claim == ui_unclaimed) 251 ui_window_send_pos(awnd, &event->ev.pos); 263 ui_window_send_pos(awnd, &pos); 264 252 265 break; 253 266 } -
uspace/lib/ui/src/window.c
r81d3612 r3c3657c 132 132 /** Compute where window should be placed on the screen. 133 133 * 134 * This only applies to windows that do not use default placement .135 * 136 * @param window Window137 * @param display Display138 * @param info Display info134 * This only applies to windows that do not use default placement or 135 * if we are running in full-screen mode. 136 * 137 * @param window Window 138 * @param drect Display rectangle 139 139 * @param params Window parameters 140 140 * @param pos Place to store position of top-left corner 141 141 */ 142 static void ui_window_place(ui_window_t *window, display_t *display, 143 display_info_t *info, ui_wnd_params_t *params, gfx_coord2_t *pos) 144 { 145 assert(params->placement != ui_wnd_place_default); 142 static void ui_window_place(ui_window_t *window, gfx_rect_t *drect, 143 ui_wnd_params_t *params, gfx_coord2_t *pos) 144 { 145 gfx_coord2_t dims; 146 147 assert(params->placement != ui_wnd_place_default || 148 ui_is_fullscreen(window->ui)); 146 149 147 150 pos->x = 0; … … 150 153 switch (params->placement) { 151 154 case ui_wnd_place_default: 152 assert(false); 155 assert(ui_is_fullscreen(window->ui)); 156 /* Center window */ 157 gfx_rect_dims(¶ms->rect, &dims); 158 pos->x = (drect->p0.x + drect->p1.x) / 2 - dims.x / 2; 159 pos->y = (drect->p0.y + drect->p1.y) / 2 - dims.y / 2; 160 break; 153 161 case ui_wnd_place_top_left: 154 162 case ui_wnd_place_full_screen: 155 pos->x = info->rect.p0.x - params->rect.p0.x;156 pos->y = info->rect.p0.y - params->rect.p0.y;163 pos->x = drect->p0.x - params->rect.p0.x; 164 pos->y = drect->p0.y - params->rect.p0.y; 157 165 break; 158 166 case ui_wnd_place_top_right: 159 pos->x = info->rect.p1.x - params->rect.p1.x;160 pos->y = info->rect.p0.y - params->rect.p0.y;167 pos->x = drect->p1.x - params->rect.p1.x; 168 pos->y = drect->p0.y - params->rect.p0.y; 161 169 break; 162 170 case ui_wnd_place_bottom_left: 163 pos->x = info->rect.p0.x - params->rect.p0.x;164 pos->y = info->rect.p1.y - params->rect.p1.y;171 pos->x = drect->p0.x - params->rect.p0.x; 172 pos->y = drect->p1.y - params->rect.p1.y; 165 173 break; 166 174 case ui_wnd_place_bottom_right: 167 pos->x = info->rect.p1.x - params->rect.p1.x;168 pos->y = info->rect.p1.y - params->rect.p1.y;175 pos->x = drect->p1.x - params->rect.p1.x; 176 pos->y = drect->p1.y - params->rect.p1.y; 169 177 break; 170 178 case ui_wnd_place_popup: … … 204 212 return ENOMEM; 205 213 214 window->ui = ui; 215 206 216 display_wnd_params_init(&dparams); 207 217 dparams.rect = params->rect; … … 228 238 if (params->placement != ui_wnd_place_default) { 229 239 /* Set initial display window position */ 230 ui_window_place(window, ui->display, &info,231 params,&dparams.pos);240 ui_window_place(window, &info.rect, params, 241 &dparams.pos); 232 242 233 243 dparams.flags |= wndf_setpos; … … 293 303 window->gc = gc; 294 304 #endif 305 if (ui->display == NULL) 306 ui_window_place(window, &ui->rect, params, &window->dpos); 295 307 296 308 rc = ui_resource_create(window->gc, ui_is_textmode(ui), &res); … … 308 320 ui_resource_set_expose_cb(res, ui_window_expose_cb, (void *) window); 309 321 310 window->ui = ui;311 322 window->rect = dparams.rect; 312 313 323 window->res = res; 314 324 window->wdecor = wdecor; … … 594 604 return rc; 595 605 } else { 596 pos->x = 0; 597 pos->y = 0; 606 *pos = window->dpos; 598 607 } 599 608 … … 1014 1023 ui_window_t *window = (ui_window_t *) arg; 1015 1024 1016 if (!gfx_rect_is_empty(&window->dirty_rect)) 1017 (void) gfx_bitmap_render(window->bmp, &window->dirty_rect, NULL); 1025 if (!gfx_rect_is_empty(&window->dirty_rect)) { 1026 (void) gfx_bitmap_render(window->bmp, &window->dirty_rect, 1027 &window->dpos); 1028 } 1018 1029 1019 1030 window->dirty_rect.p0.x = 0; … … 1031 1042 { 1032 1043 ui_window_t *window = (ui_window_t *) arg; 1033 1034 return gfx_cursor_get_pos(window->realgc, pos); 1044 gfx_coord2_t cpos; 1045 errno_t rc; 1046 1047 rc = gfx_cursor_get_pos(window->realgc, &cpos); 1048 if (rc != EOK) 1049 return rc; 1050 1051 pos->x = cpos.x - window->dpos.x; 1052 pos->y = cpos.y - window->dpos.y; 1053 return EOK; 1035 1054 } 1036 1055 … … 1043 1062 { 1044 1063 ui_window_t *window = (ui_window_t *) arg; 1045 1046 return gfx_cursor_set_pos(window->realgc, pos); 1064 gfx_coord2_t cpos; 1065 1066 cpos.x = pos->x + window->dpos.x; 1067 cpos.y = pos->y + window->dpos.y; 1068 1069 return gfx_cursor_set_pos(window->realgc, &cpos); 1047 1070 } 1048 1071
Note:
See TracChangeset
for help on using the changeset viewer.