Changeset 0e6e77f in mainline for uspace/lib/display/src
- Timestamp:
- 2020-02-28T15:44:55Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a8eed5f
- Parents:
- 2a515dcd
- git-author:
- Jiri Svoboda <jiri@…> (2020-02-26 18:26:13)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-28 15:44:55)
- Location:
- uspace/lib/display/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/src/disp_srv.c
r2a515dcd r0e6e77f 43 43 #include <stdlib.h> 44 44 #include <stddef.h> 45 #include "../private/params.h" 45 46 46 47 static void display_callback_create_srv(display_srv_t *srv, ipc_call_t *call) … … 108 109 } 109 110 111 static void display_window_resize_srv(display_srv_t *srv, ipc_call_t *icall) 112 { 113 sysarg_t wnd_id; 114 ipc_call_t call; 115 display_wnd_move_t wmove; 116 size_t size; 117 errno_t rc; 118 119 wnd_id = ipc_get_arg1(icall); 120 121 if (!async_data_write_receive(&call, &size)) { 122 async_answer_0(&call, EREFUSED); 123 async_answer_0(icall, EREFUSED); 124 return; 125 } 126 127 if (size != sizeof(display_wnd_move_t)) { 128 async_answer_0(&call, EINVAL); 129 async_answer_0(icall, EINVAL); 130 return; 131 } 132 133 rc = async_data_write_finalize(&call, &wmove, size); 134 if (rc != EOK) { 135 async_answer_0(&call, rc); 136 async_answer_0(icall, rc); 137 return; 138 } 139 140 if (srv->ops->window_resize == NULL) { 141 async_answer_0(icall, ENOTSUP); 142 return; 143 } 144 145 rc = srv->ops->window_resize(srv->arg, wnd_id, &wmove.offs, 146 &wmove.nrect); 147 async_answer_0(icall, rc); 148 } 149 110 150 static void display_get_event_srv(display_srv_t *srv, ipc_call_t *icall) 111 151 { … … 175 215 case DISPLAY_WINDOW_DESTROY: 176 216 display_window_destroy_srv(srv, &call); 217 break; 218 case DISPLAY_WINDOW_RESIZE: 219 display_window_resize_srv(srv, &call); 177 220 break; 178 221 case DISPLAY_GET_EVENT: -
uspace/lib/display/src/display.c
r2a515dcd r0e6e77f 38 38 #include <mem.h> 39 39 #include <stdlib.h> 40 #include "../private/params.h" 40 41 41 42 static errno_t display_callback_create(display_t *); … … 237 238 238 239 *rgc = ipc_gc_get_ctx(gc); 240 return EOK; 241 } 242 243 /** Resize display window. 244 * 245 * It seems resizing windows should be easy with bounding rectangles. 246 * You have an old bounding rectangle and a new bounding rectangle (@a nrect). 247 * Change .p0 and top-left corner moves. Change .p1 and bottom-right corner 248 * moves. Piece of cake! 249 * 250 * There's always a catch, though. By series of resizes and moves .p0 could 251 * drift outside of the range of @c gfx_coord_t. Now what? @a offs to the 252 * rescue! @a offs moves the @em boundaries of the window with respect 253 * to the display, while keeping the @em contents of the window in the 254 * same place (with respect to the display). In other words, @a offs shifts 255 * the window's internal coordinate system. 256 * 257 * A few examples follow: 258 * 259 * Enlarge window by moving bottom-right corner 1 right, 1 down: 260 * 261 * bound = (0, 0, 10, 10) 262 * offs = (0, 0) 263 * nrect = (0, 0, 11, 11) 264 * 265 * Enlarge window by moving top-left corner, 1 up, 1 left, allowing the 266 * window-relative coordinate of the top-left corner to drift (undesirable) 267 * 268 * bound = (0, 0, 10, 10) 269 * offs = (0, 0) 270 * nrect = (-1, -1, 10, 10) <- this is the new bounding rectangle 271 * 272 * Enlarge window by moving top-left corner 1 up, 1 left, keeping top-left 273 * corner locked to (0,0) window-relative coordinates (desirable): 274 * 275 * bound = (0, 0, 10, 10) 276 * off = (-1,-1) <- top-left corner goes 1 up, 1 left 277 * nrect = (0, 0, 11, 11) <- window still starts at 0,0 window-relative 278 * 279 * @param window Window 280 * @param nrect New bounding rectangle 281 * @param offs 282 * @return EOK on success or an error code. In both cases @a window must 283 * not be accessed anymore 284 */ 285 errno_t display_window_resize(display_window_t *window, gfx_coord2_t *offs, 286 gfx_rect_t *nrect) 287 { 288 async_exch_t *exch; 289 aid_t req; 290 ipc_call_t answer; 291 display_wnd_move_t wmove; 292 errno_t rc; 293 294 wmove.offs = *offs; 295 wmove.nrect = *nrect; 296 297 exch = async_exchange_begin(window->display->sess); 298 req = async_send_1(exch, DISPLAY_WINDOW_RESIZE, window->id, &answer); 299 rc = async_data_write_start(exch, &wmove, sizeof (display_wnd_move_t)); 300 async_exchange_end(exch); 301 if (rc != EOK) { 302 async_forget(req); 303 return rc; 304 } 305 306 async_wait_for(req, &rc); 307 if (rc != EOK) 308 return rc; 309 239 310 return EOK; 240 311 }
Note:
See TracChangeset
for help on using the changeset viewer.