Changeset 62fbb7e in mainline
- Timestamp:
- 2014-01-16T20:43:22Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a3d0c7
- Parents:
- ba02baa
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vdemo/vdemo.c
rba02baa r62fbb7e 110 110 { 111 111 if (argc >= 2) { 112 window_t *main_window = window_open(argv[1], true, true, "vdemo" , 0, 0);112 window_t *main_window = window_open(argv[1], true, true, "vdemo"); 113 113 if (!main_window) { 114 114 printf("Cannot open main window.\n"); … … 150 150 grid->add(grid, &btn_confirm->widget, 0, 1, 1, 1); 151 151 grid->add(grid, &btn_cancel->widget, 1, 1, 1, 1); 152 window_resize(main_window, 200, 76); 152 window_resize(main_window, 0, 0, 200, 76, 153 WINDOW_PLACEMENT_CENTER); 153 154 154 155 window_exec(main_window); -
uspace/app/viewer/viewer.c
rba02baa r62fbb7e 166 166 } 167 167 168 main_window = window_open(argv[1], true, false, "viewer" , 0, 0);168 main_window = window_open(argv[1], true, false, "viewer"); 169 169 if (!main_window) { 170 170 printf("Cannot open main window.\n"); … … 192 192 } 193 193 194 window_resize(main_window, WINDOW_WIDTH, WINDOW_HEIGHT); 194 window_resize(main_window, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 195 WINDOW_PLACEMENT_ABSOLUTE); 195 196 window_exec(main_window); 196 197 -
uspace/app/vlaunch/vlaunch.c
rba02baa r62fbb7e 115 115 116 116 winreg = argv[1]; 117 window_t *main_window = window_open(argv[1], true, true, "vlaunch" , 0, 0);117 window_t *main_window = window_open(argv[1], true, true, "vlaunch"); 118 118 if (!main_window) { 119 119 printf("Cannot open main window.\n"); … … 159 159 grid->add(grid, &btn_vlaunch->widget, 0, 4, 1, 1); 160 160 161 window_resize(main_window, 210, 130 + LOGO_HEIGHT); 161 window_resize(main_window, 0, 0, 210, 130 + LOGO_HEIGHT, 162 WINDOW_PLACEMENT_RIGHT | WINDOW_PLACEMENT_TOP); 162 163 window_exec(main_window); 163 164 -
uspace/app/vterm/vterm.c
rba02baa r62fbb7e 49 49 } 50 50 51 window_t *main_window = window_open(argv[1], true, true, "vterm" , 0, 0);51 window_t *main_window = window_open(argv[1], true, true, "vterm"); 52 52 if (!main_window) { 53 53 printf("%s: Cannot open main window.\n", NAME); … … 55 55 } 56 56 57 window_resize(main_window, 648, 510);57 window_resize(main_window, 0, 0, 648, 510, WINDOW_PLACEMENT_ANY); 58 58 terminal_t *terminal_widget = 59 59 create_terminal(window_root(main_window), 640, 480); -
uspace/lib/c/generic/io/window.c
rba02baa r62fbb7e 40 40 #include <stdio.h> 41 41 42 int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out, 43 sysarg_t x_offset, sysarg_t y_offset) 42 int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out) 44 43 { 45 44 async_exch_t *exch = async_exchange_begin(sess); 46 int ret = async_req_ 2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);45 int ret = async_req_0_2(exch, WINDOW_REGISTER, in, out); 47 46 async_exchange_end(exch); 48 47 49 48 return ret; 50 49 } … … 92 91 } 93 92 94 int win_resize(async_sess_t *sess, sysarg_t width, sysarg_t height, void *cells) 93 int win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width, 94 sysarg_t height, window_placement_flags_t placement_flags, void *cells) 95 95 { 96 96 async_exch_t *exch = async_exchange_begin(sess); 97 97 98 98 ipc_call_t answer; 99 aid_t req = async_send_2(exch, WINDOW_RESIZE, width, height, &answer); 100 99 aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height, 100 (sysarg_t) placement_flags, &answer); 101 101 102 int rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE); 102 103 103 104 async_exchange_end(exch); 104 105 105 106 sysarg_t ret; 106 107 async_wait_for(req, &ret); 107 108 if (rc != EOK) {108 109 if (rc != EOK) 109 110 return rc; 110 } else if (ret != EOK) {111 else if (ret != EOK) 111 112 return ret; 112 } else { 113 return EOK; 114 } 113 114 return EOK; 115 115 } 116 116 -
uspace/lib/c/include/io/window.h
rba02baa r62fbb7e 43 43 #include <io/pos_event.h> 44 44 45 typedef enum { 46 GF_EMPTY = 0, 47 GF_MOVE_X = 1, 48 GF_MOVE_Y = 2, 49 GF_RESIZE_X = 4, 50 GF_RESIZE_Y = 8, 51 GF_SCALE_X = 16, 52 GF_SCALE_Y = 32 53 } window_grab_flags_t; 54 55 typedef enum { 56 WINDOW_PLACEMENT_ANY = 0, 57 WINDOW_PLACEMENT_CENTER_X = 1, 58 WINDOW_PLACEMENT_CENTER_Y = 2, 59 WINDOW_PLACEMENT_CENTER = 60 WINDOW_PLACEMENT_CENTER_X | WINDOW_PLACEMENT_CENTER_Y, 61 WINDOW_PLACEMENT_LEFT = 4, 62 WINDOW_PLACEMENT_RIGHT = 8, 63 WINDOW_PLACEMENT_TOP = 16, 64 WINDOW_PLACEMENT_BOTTOM = 32, 65 WINDOW_PLACEMENT_ABSOLUTE_X = 64, 66 WINDOW_PLACEMENT_ABSOLUTE_Y = 128, 67 WINDOW_PLACEMENT_ABSOLUTE = 68 WINDOW_PLACEMENT_ABSOLUTE_X | WINDOW_PLACEMENT_ABSOLUTE_Y 69 } window_placement_flags_t; 70 45 71 typedef struct { 46 72 sysarg_t object; 47 73 sysarg_t slot; 48 74 sysarg_t argument; 49 } sig _event_t;75 } signal_event_t; 50 76 51 77 typedef struct { 78 sysarg_t offset_x; 79 sysarg_t offset_y; 52 80 sysarg_t width; 53 81 sysarg_t height; 54 } rsz_event_t; 82 window_placement_flags_t placement_flags; 83 } resize_event_t; 55 84 56 85 typedef enum { … … 69 98 kbd_event_t kbd; 70 99 pos_event_t pos; 71 sig _event_t sig;72 r sz_event_t rsz;100 signal_event_t signal; 101 resize_event_t resize; 73 102 } window_event_data_t; 74 103 … … 79 108 } window_event_t; 80 109 81 typedef enum { 82 GF_EMPTY = 0, 83 GF_MOVE_X = 1, 84 GF_MOVE_Y = 2, 85 GF_RESIZE_X = 4, 86 GF_RESIZE_Y = 8, 87 GF_SCALE_X = 16, 88 GF_SCALE_Y = 32 89 } window_grab_flags_t; 90 91 extern int win_register(async_sess_t *, service_id_t *, service_id_t *, sysarg_t, sysarg_t); 110 extern int win_register(async_sess_t *, service_id_t *, service_id_t *); 92 111 93 112 extern int win_get_event(async_sess_t *, window_event_t *); … … 95 114 extern int win_damage(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t); 96 115 extern int win_grab(async_sess_t *, sysarg_t, sysarg_t); 97 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, void *); 116 extern int win_resize(async_sess_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 117 window_placement_flags_t, void *); 98 118 extern int win_close(async_sess_t *); 99 119 extern int win_close_request(async_sess_t *); -
uspace/lib/gui/connection.c
rba02baa r62fbb7e 210 210 link_initialize(&event->link); 211 211 event->type = ET_SIGNAL_EVENT; 212 event->data.sig .object = (sysarg_t) cur->widget;213 event->data.sig .slot = (sysarg_t) cur->slot;214 event->data.sig .argument = (sysarg_t) data_copy;212 event->data.signal.object = (sysarg_t) cur->widget; 213 event->data.signal.slot = (sysarg_t) cur->slot; 214 event->data.signal.argument = (sysarg_t) data_copy; 215 215 prodcons_produce(&cur->widget->window->events, &event->link); 216 216 } else { -
uspace/lib/gui/window.c
rba02baa r62fbb7e 352 352 } 353 353 354 static void handle_signal_event(window_t *win, sig _event_t event)354 static void handle_signal_event(window_t *win, signal_event_t event) 355 355 { 356 356 widget_t *widget = (widget_t *) event.object; … … 363 363 } 364 364 365 static void handle_resize(window_t *win, sysarg_t width, sysarg_t height) 366 { 367 int rc; 368 surface_t *old_surface; 369 surface_t *new_surface; 370 365 static void handle_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 366 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 367 { 371 368 if (width < 2 * border_thickness + header_min_width) { 372 369 win_damage(win->osess, 0, 0, 0, 0); 373 370 return; 374 371 } 375 372 376 373 if (height < 2 * border_thickness + header_height) { 377 374 win_damage(win->osess, 0, 0, 0, 0); 378 375 return; 379 376 } 380 377 381 378 /* Allocate resources for new surface. */ 382 new_surface = surface_create(width, height, NULL, SURFACE_FLAG_SHARED); 383 if (!new_surface) { 379 surface_t *new_surface = surface_create(width, height, NULL, 380 SURFACE_FLAG_SHARED); 381 if (!new_surface) 384 382 return; 385 } 386 383 387 384 /* Switch new and old surface. */ 388 385 fibril_mutex_lock(&win->guard); 389 old_surface = win->surface;386 surface_t *old_surface = win->surface; 390 387 win->surface = new_surface; 391 388 fibril_mutex_unlock(&win->guard); 392 393 /* Let all widgets in the tree alter their position and size. Widgets might 394 * also paint themselves onto the new surface. */ 389 390 /* 391 * Let all widgets in the tree alter their position and size. 392 * Widgets might also paint themselves onto the new surface. 393 */ 395 394 win->root.rearrange(&win->root, 0, 0, width, height); 396 395 397 396 fibril_mutex_lock(&win->guard); 398 397 surface_reset_damaged_region(win->surface); 399 398 fibril_mutex_unlock(&win->guard); 400 399 401 400 /* Inform compositor about new surface. */ 402 rc = win_resize(win->osess,403 width, height, surface_direct_access(new_surface));404 401 int rc = win_resize(win->osess, offset_x, offset_y, width, height, 402 placement_flags, surface_direct_access(new_surface)); 403 405 404 if (rc != EOK) { 406 405 /* Rollback to old surface. Reverse all changes. */ 407 406 408 407 sysarg_t old_width = 0; 409 408 sysarg_t old_height = 0; 410 if (old_surface) {409 if (old_surface) 411 410 surface_get_resolution(old_surface, &old_width, &old_height); 412 } 413 411 414 412 fibril_mutex_lock(&win->guard); 415 413 new_surface = win->surface; 416 414 win->surface = old_surface; 417 415 fibril_mutex_unlock(&win->guard); 418 416 419 417 win->root.rearrange(&win->root, 0, 0, old_width, old_height); 420 418 … … 424 422 fibril_mutex_unlock(&win->guard); 425 423 } 426 424 427 425 surface_destroy(new_surface); 428 return; 429 } 430 431 /* Finally deallocate old surface. */ 432 if (old_surface) { 433 surface_destroy(old_surface); 426 } else { 427 /* Deallocate old surface. */ 428 if (old_surface) 429 surface_destroy(old_surface); 434 430 } 435 431 } … … 513 509 break; 514 510 case ET_SIGNAL_EVENT: 515 handle_signal_event(win, event->data.sig );511 handle_signal_event(win, event->data.signal); 516 512 break; 517 513 case ET_WINDOW_RESIZE: 518 handle_resize(win, event->data.rsz.width, event->data.rsz.height); 514 handle_resize(win, event->data.resize.offset_x, 515 event->data.resize.offset_y, event->data.resize.width, 516 event->data.resize.height, event->data.resize.placement_flags); 519 517 break; 520 518 case ET_WINDOW_FOCUS: … … 590 588 591 589 window_t *window_open(const char *winreg, bool is_main, bool is_decorated, 592 const char *caption , sysarg_t x_offset, sysarg_t y_offset)590 const char *caption) 593 591 { 594 592 window_t *win = (window_t *) malloc(sizeof(window_t)); … … 630 628 service_id_t in_dsid; 631 629 service_id_t out_dsid; 632 rc = win_register(reg_sess, &in_dsid, &out_dsid , x_offset, y_offset);630 rc = win_register(reg_sess, &in_dsid, &out_dsid); 633 631 async_hangup(reg_sess); 634 632 if (rc != EOK) { … … 658 656 } 659 657 660 void window_resize(window_t *win, sysarg_t width, sysarg_t height) 658 void window_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y, 659 sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags) 661 660 { 662 661 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); … … 664 663 link_initialize(&event->link); 665 664 event->type = ET_WINDOW_RESIZE; 666 event->data.rsz.width = width; 667 event->data.rsz.height = height; 665 event->data.resize.offset_x = offset_x; 666 event->data.resize.offset_y = offset_y; 667 event->data.resize.width = width; 668 event->data.resize.height = height; 669 event->data.resize.placement_flags = placement_flags; 668 670 prodcons_produce(&win->events, &event->link); 669 671 } -
uspace/lib/gui/window.h
rba02baa r62fbb7e 66 66 * If the window is declared as main, its closure causes termination of the 67 67 * whole application. Note that opened window does not have any surface yet. */ 68 extern window_t *window_open(const char *, bool, bool, const char *, sysarg_t, 69 sysarg_t); 68 extern window_t *window_open(const char *, bool, bool, const char *); 70 69 71 70 /** … … 74 73 * and to paint themselves on the new surface (top-bottom order). Should be 75 74 * called also after opening new window to obtain surface. */ 76 extern void window_resize(window_t *, sysarg_t, sysarg_t); 75 extern void window_resize(window_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 76 window_placement_flags_t); 77 77 78 78 /** -
uspace/srv/hid/compositor/compositor.c
rba02baa r62fbb7e 166 166 } 167 167 168 static pointer_t *pointer_create( )168 static pointer_t *pointer_create(void) 169 169 { 170 170 pointer_t *p = (pointer_t *) malloc(sizeof(pointer_t)); … … 208 208 } 209 209 210 static window_t *window_create( sysarg_t x_offset, sysarg_t y_offset)210 static window_t *window_create(void) 211 211 { 212 212 window_t *win = (window_t *) malloc(sizeof(window_t)); … … 218 218 prodcons_initialize(&win->queue); 219 219 transform_identity(&win->transform); 220 transform_translate(&win->transform, 221 coord_origin + x_offset, coord_origin + y_offset); 222 win->dx = coord_origin + x_offset; 223 win->dy = coord_origin + y_offset; 220 transform_translate(&win->transform, coord_origin, coord_origin); 221 win->dx = coord_origin; 222 win->dy = coord_origin; 224 223 win->fx = 1; 225 224 win->fy = 1; … … 321 320 } 322 321 323 static void comp_ restrict_pointers(void)322 static void comp_update_viewport_bound_rect(void) 324 323 { 325 324 fibril_mutex_lock(&viewport_list_mtx); 326 325 327 326 sysarg_t x_res = coord_origin; 328 327 sysarg_t y_res = coord_origin; 329 328 sysarg_t w_res = 0; 330 329 sysarg_t h_res = 0; 331 330 332 331 if (!list_empty(&viewport_list)) { 333 332 viewport_t *vp = (viewport_t *) list_first(&viewport_list); … … 336 335 surface_get_resolution(vp->surface, &w_res, &h_res); 337 336 } 338 337 339 338 list_foreach(viewport_list, link, viewport_t, vp) { 340 339 sysarg_t w_vp, h_vp; 341 340 surface_get_resolution(vp->surface, &w_vp, &h_vp); 342 rectangle_union( 343 x_res, y_res, w_res, h_res, 341 rectangle_union(x_res, y_res, w_res, h_res, 344 342 vp->pos.x, vp->pos.y, w_vp, h_vp, 345 343 &x_res, &y_res, &w_res, &h_res); 346 344 } 347 345 348 346 viewport_bound_rect.x = x_res; 349 347 viewport_bound_rect.y = y_res; 350 348 viewport_bound_rect.w = w_res; 351 349 viewport_bound_rect.h = h_res; 352 350 353 351 fibril_mutex_unlock(&viewport_list_mtx); 354 352 } 353 354 static void comp_restrict_pointers(void) 355 { 356 comp_update_viewport_bound_rect(); 357 355 358 fibril_mutex_lock(&pointer_list_mtx); 356 359 357 360 list_foreach(pointer_list, link, pointer_t, ptr) { 358 361 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x; … … 363 366 ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h; 364 367 } 365 368 366 369 fibril_mutex_unlock(&pointer_list_mtx); 367 370 } … … 642 645 } 643 646 647 static void comp_recalc_transform(window_t *win) 648 { 649 transform_t translate; 650 transform_identity(&translate); 651 transform_translate(&translate, win->dx, win->dy); 652 653 transform_t scale; 654 transform_identity(&scale); 655 if ((win->fx != 1) || (win->fy != 1)) 656 transform_scale(&scale, win->fx, win->fy); 657 658 transform_t rotate; 659 transform_identity(&rotate); 660 if (win->angle != 0) 661 transform_rotate(&rotate, win->angle); 662 663 transform_t transform; 664 transform_t temp; 665 transform_identity(&transform); 666 temp = transform; 667 transform_multiply(&transform, &temp, &translate); 668 temp = transform; 669 transform_multiply(&transform, &temp, &rotate); 670 temp = transform; 671 transform_multiply(&transform, &temp, &scale); 672 673 win->transform = transform; 674 } 675 644 676 static void comp_window_resize(window_t *win, ipc_callid_t iid, ipc_call_t *icall) 645 677 { … … 662 694 663 695 /* Create new surface for the resized window. */ 664 surface_t *new_surface = surface_create(IPC_GET_ARG 1(*icall),665 IPC_GET_ARG 2(*icall), new_cell_storage, SURFACE_FLAG_SHARED);696 surface_t *new_surface = surface_create(IPC_GET_ARG3(*icall), 697 IPC_GET_ARG4(*icall), new_cell_storage, SURFACE_FLAG_SHARED); 666 698 if (!new_surface) { 667 699 as_area_destroy(new_cell_storage); … … 670 702 } 671 703 704 sysarg_t offset_x = IPC_GET_ARG1(*icall); 705 sysarg_t offset_y = IPC_GET_ARG2(*icall); 706 window_placement_flags_t placement_flags = 707 (window_placement_flags_t) IPC_GET_ARG5(*icall); 708 709 comp_update_viewport_bound_rect(); 710 672 711 /* Switch new surface with old surface and calculate damage. */ 673 712 fibril_mutex_lock(&window_list_mtx); … … 687 726 surface_get_resolution(win->surface, &new_width, &new_height); 688 727 728 if (placement_flags & WINDOW_PLACEMENT_CENTER_X) 729 win->dx = viewport_bound_rect.x + viewport_bound_rect.w / 2 - 730 new_width / 2; 731 732 if (placement_flags & WINDOW_PLACEMENT_CENTER_Y) 733 win->dy = viewport_bound_rect.y + viewport_bound_rect.h / 2 - 734 new_height / 2; 735 736 if (placement_flags & WINDOW_PLACEMENT_LEFT) 737 win->dx = viewport_bound_rect.x; 738 739 if (placement_flags & WINDOW_PLACEMENT_TOP) 740 win->dy = viewport_bound_rect.y; 741 742 if (placement_flags & WINDOW_PLACEMENT_RIGHT) 743 win->dx = viewport_bound_rect.x + viewport_bound_rect.w - 744 new_width; 745 746 if (placement_flags & WINDOW_PLACEMENT_BOTTOM) 747 win->dy = viewport_bound_rect.y + viewport_bound_rect.h - 748 new_height; 749 750 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_X) 751 win->dx = coord_origin + offset_x; 752 753 if (placement_flags & WINDOW_PLACEMENT_ABSOLUTE_Y) 754 win->dy = coord_origin + offset_y; 755 756 /* Transform the window and calculate damage. */ 757 sysarg_t x1; 758 sysarg_t y1; 759 sysarg_t width1; 760 sysarg_t height1; 761 762 comp_coord_bounding_rect(0, 0, old_width, old_height, win->transform, 763 &x1, &y1, &width1, &height1); 764 765 comp_recalc_transform(win); 766 767 sysarg_t x2; 768 sysarg_t y2; 769 sysarg_t width2; 770 sysarg_t height2; 771 772 comp_coord_bounding_rect(0, 0, new_width, new_height, win->transform, 773 &x2, &y2, &width2, &height2); 774 689 775 sysarg_t x; 690 776 sysarg_t y; 691 sysarg_t width = old_width > new_width ? old_width : new_width; 692 sysarg_t height = old_height > new_height ? old_height : new_height; 693 comp_coord_bounding_rect(0, 0, width, height, win->transform, &x, &y, 694 &width, &height); 777 sysarg_t width; 778 sysarg_t height; 779 780 rectangle_union(x1, y1, width1, height1, x2, y2, width2, height2, 781 &x, &y, &width, &height); 695 782 696 783 fibril_mutex_unlock(&window_list_mtx); … … 803 890 fibril_mutex_lock(&window_list_mtx); 804 891 805 window_t *win = window_create( IPC_GET_ARG1(call), IPC_GET_ARG2(call));892 window_t *win = window_create(); 806 893 if (!win) { 807 894 async_answer_2(callid, ENOMEM, 0, 0); … … 1173 1260 1174 1261 return vp; 1175 }1176 1177 static void comp_recalc_transform(window_t *win)1178 {1179 transform_t translate;1180 transform_identity(&translate);1181 transform_translate(&translate, win->dx, win->dy);1182 1183 transform_t scale;1184 transform_identity(&scale);1185 if ((win->fx != 1) || (win->fy != 1))1186 transform_scale(&scale, win->fx, win->fy);1187 1188 transform_t rotate;1189 transform_identity(&rotate);1190 if (win->angle != 0)1191 transform_rotate(&rotate, win->angle);1192 1193 transform_t transform;1194 transform_t temp;1195 transform_identity(&transform);1196 temp = transform;1197 transform_multiply(&transform, &temp, &translate);1198 temp = transform;1199 transform_multiply(&transform, &temp, &rotate);1200 temp = transform;1201 transform_multiply(&transform, &temp, &scale);1202 1203 win->transform = transform;1204 1262 } 1205 1263 … … 1247 1305 } 1248 1306 1249 if ( scale || resize) {1307 if ((scale) || (resize)) { 1250 1308 double _dx = dx; 1251 1309 double _dy = dy; … … 1445 1503 { 1446 1504 pointer_t *pointer = input_pointer(input); 1447 1505 1506 comp_update_viewport_bound_rect(); 1507 1448 1508 /* Update pointer position. */ 1449 1509 fibril_mutex_lock(&pointer_list_mtx); 1510 1450 1511 desktop_point_t old_pos = pointer->pos; 1512 1451 1513 sysarg_t cursor_width; 1452 1514 sysarg_t cursor_height; 1453 surface_get_resolution(pointer->cursor.states[pointer->state], 1515 surface_get_resolution(pointer->cursor.states[pointer->state], 1454 1516 &cursor_width, &cursor_height); 1455 if (pointer->pos.x + dx < viewport_bound_rect.x) { 1517 1518 if (pointer->pos.x + dx < viewport_bound_rect.x) 1456 1519 dx = -1 * (pointer->pos.x - viewport_bound_rect.x); 1457 }1458 if (pointer->pos.y + dy < viewport_bound_rect.y) {1520 1521 if (pointer->pos.y + dy < viewport_bound_rect.y) 1459 1522 dy = -1 * (pointer->pos.y - viewport_bound_rect.y); 1460 }1461 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) {1523 1524 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) 1462 1525 dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x); 1463 }1464 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) {1526 1527 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) 1465 1528 dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y); 1466 }1529 1467 1530 pointer->pos.x += dx; 1468 1531 pointer->pos.y += dy; … … 1470 1533 comp_damage(old_pos.x, old_pos.y, cursor_width, cursor_height); 1471 1534 comp_damage(old_pos.x + dx, old_pos.y + dy, cursor_width, cursor_height); 1472 1535 1473 1536 fibril_mutex_lock(&window_list_mtx); 1474 1537 fibril_mutex_lock(&pointer_list_mtx); … … 1631 1694 1632 1695 #if ANIMATE_WINDOW_TRANSFORMS == 0 1633 sysarg_t pre_x = 0; 1696 sysarg_t pre_x = 0; 1634 1697 sysarg_t pre_y = 0; 1635 1698 sysarg_t pre_width = 0; … … 1663 1726 link_initialize(&event_top->link); 1664 1727 event_top->type = ET_WINDOW_RESIZE; 1665 1728 1729 event_top->data.resize.offset_x = 0; 1730 event_top->data.resize.offset_y = 0; 1731 1666 1732 int dx = (int) (((double) width) * (scale_back_x - 1.0)); 1667 1733 int dy = (int) (((double) height) * (scale_back_y - 1.0)); 1668 1669 if (pointer->grab_flags & GF_RESIZE_X) { 1670 event_top->data.rsz.width = 1671 ((((int) width) + dx) >= 0) ? (width + dx) : 0; 1672 } else { 1673 event_top->data.rsz.width = width; 1674 } 1675 1676 if (pointer->grab_flags & GF_RESIZE_Y) { 1677 event_top->data.rsz.height = 1678 ((((int) height) + dy) >= 0) ? (height + dy) : 0; 1679 } else { 1680 event_top->data.rsz.height = height; 1681 } 1734 1735 if (pointer->grab_flags & GF_RESIZE_X) 1736 event_top->data.resize.width = 1737 ((((int) width) + dx) >= 0) ? (width + dx) : 0; 1738 else 1739 event_top->data.resize.width = width; 1740 1741 if (pointer->grab_flags & GF_RESIZE_Y) 1742 event_top->data.resize.height = 1743 ((((int) height) + dy) >= 0) ? (height + dy) : 0; 1744 else 1745 event_top->data.resize.height = height; 1746 1747 event_top->data.resize.placement_flags = 1748 WINDOW_PLACEMENT_ANY; 1682 1749 } 1683 1750 … … 1816 1883 return ENOMEM; 1817 1884 } 1818 1885 1819 1886 sysarg_t width, height; 1820 1887 surface_get_resolution(win->surface, &width, &height); 1821 1888 1822 1889 link_initialize(&event->link); 1823 1890 event->type = ET_WINDOW_RESIZE; 1824 1891 1892 event->data.resize.offset_x = 0; 1893 event->data.resize.offset_y = 0; 1894 1825 1895 switch (key) { 1826 1896 case KC_T: 1827 event->data.r sz.width = width;1828 event->data.r sz.height = (height >= 20) ? height - 20 : 0;1897 event->data.resize.width = width; 1898 event->data.resize.height = (height >= 20) ? height - 20 : 0; 1829 1899 break; 1830 1900 case KC_G: 1831 event->data.r sz.width = width;1832 event->data.r sz.height = height + 20;1901 event->data.resize.width = width; 1902 event->data.resize.height = height + 20; 1833 1903 break; 1834 1904 case KC_B: 1835 event->data.r sz.width = (width >= 20) ? width - 20 : 0;;1836 event->data.r sz.height = height;1905 event->data.resize.width = (width >= 20) ? width - 20 : 0;; 1906 event->data.resize.height = height; 1837 1907 break; 1838 1908 case KC_N: 1839 event->data.r sz.width = width + 20;1840 event->data.r sz.height = height;1909 event->data.resize.width = width + 20; 1910 event->data.resize.height = height; 1841 1911 break; 1842 1912 default: 1843 event->data.rsz.width = 0; 1844 event->data.rsz.height = 0; 1845 break; 1846 } 1847 1913 event->data.resize.width = 0; 1914 event->data.resize.height = 0; 1915 break; 1916 } 1917 1918 event->data.resize.placement_flags = WINDOW_PLACEMENT_ANY; 1919 1848 1920 fibril_mutex_unlock(&window_list_mtx); 1849 1921 comp_post_event_top(event);
Note:
See TracChangeset
for help on using the changeset viewer.