Changeset 1bebc906 in mainline
- Timestamp:
- 2021-06-10T12:51:21Z (3 years ago)
- Parents:
- 4b72e81
- git-author:
- Jiri Svoboda <jiri@…> (2021-06-09 18:51:04)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-06-10 12:51:21)
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/types/display/wndparams.h
r4b72e81 r1bebc906 41 41 typedef enum { 42 42 /** Popup window (capture events, no focus) */ 43 wndf_popup = 0x1 43 wndf_popup = 0x1, 44 /** Set specific initial window position */ 45 wndf_setpos = 0x2 44 46 } display_wnd_flags_t; 45 47 … … 56 58 /** Minimum size (when being resized) */ 57 59 gfx_coord2_t min_size; 60 /** Initial position (if flag wndf_setpos is set) */ 61 gfx_coord2_t pos; 58 62 /** Flags */ 59 63 display_wnd_flags_t flags; -
uspace/lib/ui/src/window.c
r4b72e81 r1bebc906 109 109 } 110 110 111 static errno_t ui_window_place(ui_window_t *window, display_t *display, 112 display_info_t *info, ui_wnd_params_t *params) 113 { 114 gfx_coord2_t pos; 115 errno_t rc; 116 111 /** Compute where window should be placed on the screen. 112 * 113 * This only applies to windows that do not use default placement. 114 * 115 * @param window Window 116 * @param display Display 117 * @param info Display info 118 * @param params Window parameters 119 * @param pos Place to store position of top-left corner 120 */ 121 static void ui_window_place(ui_window_t *window, display_t *display, 122 display_info_t *info, ui_wnd_params_t *params, gfx_coord2_t *pos) 123 { 117 124 assert(params->placement != ui_wnd_place_default); 118 125 119 pos.x = 0; 120 pos.y = 0; 126 pos->x = 0; 127 pos->y = 0; 128 121 129 switch (params->placement) { 122 130 case ui_wnd_place_default: … … 124 132 case ui_wnd_place_top_left: 125 133 case ui_wnd_place_full_screen: 126 pos .x = info->rect.p0.x - params->rect.p0.x;127 pos .y = info->rect.p0.y - params->rect.p0.y;134 pos->x = info->rect.p0.x - params->rect.p0.x; 135 pos->y = info->rect.p0.y - params->rect.p0.y; 128 136 break; 129 137 case ui_wnd_place_top_right: 130 pos .x = info->rect.p1.x - params->rect.p1.x;131 pos .y = info->rect.p0.y - params->rect.p0.y;138 pos->x = info->rect.p1.x - params->rect.p1.x; 139 pos->y = info->rect.p0.y - params->rect.p0.y; 132 140 break; 133 141 case ui_wnd_place_bottom_left: 134 pos .x = info->rect.p0.x - params->rect.p0.x;135 pos .y = info->rect.p1.y - params->rect.p1.y;142 pos->x = info->rect.p0.x - params->rect.p0.x; 143 pos->y = info->rect.p1.y - params->rect.p1.y; 136 144 break; 137 145 case ui_wnd_place_bottom_right: 138 pos .x = info->rect.p1.x - params->rect.p1.x;139 pos .y = info->rect.p1.y - params->rect.p1.y;146 pos->x = info->rect.p1.x - params->rect.p1.x; 147 pos->y = info->rect.p1.y - params->rect.p1.y; 140 148 break; 141 149 case ui_wnd_place_popup: 142 150 /* Place popup window below parent rectangle */ 143 pos .x = params->prect.p0.x;144 pos .y = params->prect.p1.y;151 pos->x = params->prect.p0.x; 152 pos->y = params->prect.p1.y; 145 153 break; 146 154 } 147 148 rc = display_window_move(window->dwindow, &pos);149 if (rc != EOK)150 goto error;151 152 return EOK;153 error:154 return rc;155 155 } 156 156 … … 205 205 } 206 206 207 if (params->placement != ui_wnd_place_default) { 208 /* Set initial display window position */ 209 ui_window_place(window, ui->display, &info, 210 params, &dparams.pos); 211 212 dparams.flags |= wndf_setpos; 213 } 214 207 215 rc = display_window_create(ui->display, &dparams, &dwnd_cb, 208 216 (void *) window, &window->dwindow); 209 217 if (rc != EOK) 210 218 goto error; 211 212 if (params->placement != ui_wnd_place_default) {213 rc = ui_window_place(window, ui->display, &info,214 params);215 if (rc != EOK)216 goto error;217 }218 219 219 220 rc = display_window_get_gc(window->dwindow, &gc); -
uspace/srv/hid/display/window.c
r4b72e81 r1bebc906 119 119 wnd->flags = params->flags; 120 120 121 wnd->dpos.x = ((wnd->id - 1) & 1) * 400; 122 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300; 121 if ((params->flags & wndf_setpos) != 0) { 122 /* Specific window position */ 123 wnd->dpos = params->pos; 124 } else { 125 /* Automatic window placement */ 126 wnd->dpos.x = ((wnd->id - 1) & 1) * 400; 127 wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300; 128 } 123 129 124 130 seat = ds_display_first_seat(client->display);
Note:
See TracChangeset
for help on using the changeset viewer.