trunk/src/osd/sdl/window.c
| r242608 | r242609 | |
| 101 | 101 | static sdl_draw_info draw; |
| 102 | 102 | |
| 103 | 103 | struct worker_param { |
| 104 | worker_param() |
| 105 | : m_window(NULL), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 106 | { |
| 107 | } |
| 108 | worker_param(running_machine &amachine, sdl_window_info *awindow) |
| 109 | : m_window(awindow), m_list(NULL), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0) |
| 110 | { |
| 111 | } |
| 112 | worker_param(running_machine &amachine, sdl_window_info *awindow, render_primitive_list *alist) |
| 113 | : m_window(awindow), m_list(alist), m_machine(&amachine), m_resize_new_width(0), m_resize_new_height(0) |
| 114 | { |
| 115 | } |
| 116 | worker_param(sdl_window_info *awindow, int anew_width, int anew_height) |
| 117 | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(anew_width), m_resize_new_height(anew_height) |
| 118 | { |
| 119 | } |
| 120 | worker_param(sdl_window_info *awindow) |
| 121 | : m_window(awindow), m_list(NULL), m_machine(NULL), m_resize_new_width(0), m_resize_new_height(0) |
| 122 | { |
| 123 | } |
| 104 | 124 | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 105 | | sdl_window_info *window; |
| 106 | | render_primitive_list *list; |
| 125 | sdl_window_info *window() const { assert(m_window != NULL); return m_window; } |
| 126 | render_primitive_list *list() const { return m_list; } |
| 127 | int new_width() const { return m_resize_new_width; } |
| 128 | int new_height() const { return m_resize_new_height; } |
| 129 | // FIXME: only needed for window set-up which returns an error. |
| 130 | void set_window(sdl_window_info *window) { m_window = window; } |
| 131 | private: |
| 132 | sdl_window_info *m_window; |
| 133 | render_primitive_list *m_list; |
| 107 | 134 | running_machine *m_machine; |
| 108 | | int resize_new_width; |
| 109 | | int resize_new_height; |
| 135 | int m_resize_new_width; |
| 136 | int m_resize_new_height; |
| 110 | 137 | }; |
| 111 | 138 | |
| 112 | 139 | |
| r242608 | r242609 | |
| 114 | 141 | // PROTOTYPES |
| 115 | 142 | //============================================================ |
| 116 | 143 | |
| 117 | | static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window); |
| 118 | 144 | static OSDWORK_CALLBACK( draw_video_contents_wt ); |
| 119 | 145 | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ); |
| 120 | 146 | static OSDWORK_CALLBACK( sdlwindow_resize_wt ); |
| r242608 | r242609 | |
| 122 | 148 | static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window); |
| 123 | 149 | static void sdlwindow_sync(void); |
| 124 | 150 | |
| 125 | | static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); |
| 126 | | static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); |
| 127 | | |
| 128 | 151 | static void *complete_create_wt(void *param, int threadid); |
| 129 | 152 | static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view); |
| 130 | 153 | |
| 131 | 154 | //============================================================ |
| 132 | | // clear the worker_param structure, inline - faster than memset |
| 133 | | //============================================================ |
| 134 | | |
| 135 | | INLINE void clear_worker_param(worker_param *wp) |
| 136 | | { |
| 137 | | wp->window=NULL; |
| 138 | | wp->list=NULL; |
| 139 | | wp->m_machine=NULL; |
| 140 | | wp->resize_new_width=0; |
| 141 | | wp->resize_new_height=0; |
| 142 | | } |
| 143 | | |
| 144 | | |
| 145 | | //============================================================ |
| 146 | 155 | // execute_async |
| 147 | 156 | //============================================================ |
| 148 | 157 | |
| 149 | 158 | |
| 150 | | INLINE void execute_async(osd_work_callback callback, worker_param *wp) |
| 159 | INLINE void execute_async(osd_work_callback callback, const worker_param &wp) |
| 151 | 160 | { |
| 152 | | worker_param *wp_temp = NULL; |
| 161 | worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 162 | *wp_temp = wp; |
| 153 | 163 | |
| 154 | | if (wp) |
| 155 | | { |
| 156 | | wp_temp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 157 | | *wp_temp = *wp; |
| 158 | | } |
| 159 | 164 | if (multithreading_enabled) |
| 160 | 165 | { |
| 161 | 166 | osd_work_item_queue(work_queue, callback, (void *) wp_temp, WORK_ITEM_FLAG_AUTO_RELEASE); |
| r242608 | r242609 | |
| 163 | 168 | callback((void *) wp_temp, 0); |
| 164 | 169 | } |
| 165 | 170 | |
| 171 | INLINE void execute_sync(osd_work_callback callback, const worker_param &wp) |
| 172 | { |
| 173 | worker_param *wp_temp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 174 | *wp_temp = wp; |
| 166 | 175 | |
| 176 | callback((void *) wp_temp, 0); |
| 177 | } |
| 178 | |
| 179 | |
| 167 | 180 | //============================================================ |
| 168 | 181 | // execute_async_wait |
| 169 | 182 | //============================================================ |
| 170 | 183 | |
| 171 | | INLINE void execute_async_wait(osd_work_callback callback, worker_param *wp) |
| 184 | INLINE void execute_async_wait(osd_work_callback callback, const worker_param &wp) |
| 172 | 185 | { |
| 173 | 186 | execute_async(callback, wp); |
| 174 | 187 | sdlwindow_sync(); |
| r242608 | r242609 | |
| 294 | 307 | |
| 295 | 308 | void sdl_osd_interface::window_exit() |
| 296 | 309 | { |
| 310 | worker_param wp_dummy; |
| 311 | |
| 297 | 312 | ASSERT_MAIN_THREAD(); |
| 298 | 313 | |
| 299 | 314 | osd_printf_verbose("Enter sdlwindow_exit\n"); |
| r242608 | r242609 | |
| 303 | 318 | { |
| 304 | 319 | sdl_window_info *temp = sdl_window_list; |
| 305 | 320 | sdl_window_list = temp->next; |
| 306 | | sdlwindow_video_window_destroy(machine(), temp); |
| 321 | temp->video_window_destroy(machine()); |
| 322 | // free the window itself |
| 323 | global_free(temp); |
| 307 | 324 | } |
| 308 | 325 | |
| 309 | 326 | // if we're multithreaded, clean up the window thread |
| r242608 | r242609 | |
| 315 | 332 | // kill the drawers |
| 316 | 333 | (*draw.exit)(); |
| 317 | 334 | |
| 318 | | execute_async_wait(&sdlwindow_exit_wt, NULL); |
| 335 | execute_async_wait(&sdlwindow_exit_wt, wp_dummy); |
| 319 | 336 | |
| 320 | 337 | if (multithreading_enabled) |
| 321 | 338 | { |
| r242608 | r242609 | |
| 338 | 355 | return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1; |
| 339 | 356 | } |
| 340 | 357 | |
| 341 | | void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height) |
| 358 | void sdl_window_info::blit_surface_size(int window_width, int window_height) |
| 342 | 359 | { |
| 343 | 360 | INT32 newwidth, newheight; |
| 344 | 361 | int xscale = 1, yscale = 1; |
| r242608 | r242609 | |
| 347 | 364 | INT32 target_height = window_height; |
| 348 | 365 | |
| 349 | 366 | // start with the minimum size |
| 350 | | window->target->compute_minimum_size(newwidth, newheight); |
| 367 | target->compute_minimum_size(newwidth, newheight); |
| 351 | 368 | |
| 352 | 369 | // compute the appropriate visible area if we're trying to keepaspect |
| 353 | 370 | if (video_config.keepaspect) |
| 354 | 371 | { |
| 355 | 372 | // make sure the monitor is up-to-date |
| 356 | | sdlvideo_monitor_refresh(window->monitor); |
| 357 | | window->target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(window->monitor), window->target->orientation(), target_width, target_height); |
| 373 | sdlvideo_monitor_refresh(m_monitor); |
| 374 | target->compute_visible_area(target_width, target_height, sdlvideo_monitor_get_aspect(m_monitor), target->orientation(), target_width, target_height); |
| 358 | 375 | desired_aspect = (float)target_width / (float)target_height; |
| 359 | 376 | } |
| 360 | 377 | |
| r242608 | r242609 | |
| 406 | 423 | } |
| 407 | 424 | |
| 408 | 425 | //FIXME: really necessary to distinguish for yuv_modes ? |
| 409 | | if (window->target->zoom_to_screen() |
| 426 | if (target->zoom_to_screen() |
| 410 | 427 | && (video_config.scale_mode == VIDEO_SCALE_MODE_NONE )) |
| 411 | 428 | newwidth = window_width; |
| 412 | 429 | |
| 413 | | if ((window->blitwidth != newwidth) || (window->blitheight != newheight)) |
| 414 | | sdlwindow_clear(window); |
| 430 | if ((blitwidth != newwidth) || (blitheight != newheight)) |
| 431 | window_clear(); |
| 415 | 432 | |
| 416 | | window->blitwidth = newwidth; |
| 417 | | window->blitheight = newheight; |
| 433 | blitwidth = newwidth; |
| 434 | blitheight = newheight; |
| 418 | 435 | } |
| 419 | 436 | |
| 420 | 437 | |
| r242608 | r242609 | |
| 426 | 443 | static OSDWORK_CALLBACK( sdlwindow_resize_wt ) |
| 427 | 444 | { |
| 428 | 445 | worker_param * wp = (worker_param *) param; |
| 429 | | sdl_window_info * window = wp->window; |
| 446 | sdl_window_info * window = wp->window(); |
| 430 | 447 | |
| 431 | 448 | ASSERT_WINDOW_THREAD(); |
| 432 | 449 | |
| 433 | 450 | window->destroy_all_textures(window); |
| 434 | | window->resize(window, wp->resize_new_width, wp->resize_new_height); |
| 451 | window->resize(window, wp->new_width(), wp->new_height()); |
| 435 | 452 | |
| 436 | | sdlwindow_blit_surface_size(window, wp->resize_new_width, wp->resize_new_height); |
| 453 | window->blit_surface_size(wp->new_width(), wp->new_height()); |
| 437 | 454 | |
| 438 | | sdlwindow_clear(window); |
| 455 | window->window_clear(); |
| 439 | 456 | |
| 440 | 457 | osd_free(wp); |
| 441 | 458 | return NULL; |
| 442 | 459 | } |
| 443 | 460 | |
| 444 | | void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height) |
| 461 | void sdl_window_info::window_resize(INT32 width, INT32 height) |
| 445 | 462 | { |
| 446 | | worker_param wp; |
| 447 | | |
| 448 | 463 | ASSERT_MAIN_THREAD(); |
| 449 | 464 | |
| 450 | | if (width == window->width && height == window->height) |
| 465 | if (width == this->width && height == this->height) |
| 451 | 466 | return; |
| 452 | 467 | |
| 453 | | clear_worker_param(&wp); |
| 454 | | wp.resize_new_width = width; |
| 455 | | wp.resize_new_height = height; |
| 456 | | wp.window = window; |
| 457 | | |
| 458 | | execute_async_wait(&sdlwindow_resize_wt, &wp); |
| 468 | execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height)); |
| 459 | 469 | } |
| 460 | 470 | |
| 461 | 471 | |
| r242608 | r242609 | |
| 467 | 477 | static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt ) |
| 468 | 478 | { |
| 469 | 479 | worker_param *wp = (worker_param *) param; |
| 470 | | sdl_window_info *window = wp->window; |
| 480 | sdl_window_info *window = wp->window(); |
| 471 | 481 | |
| 472 | 482 | ASSERT_WINDOW_THREAD(); |
| 473 | 483 | |
| r242608 | r242609 | |
| 476 | 486 | return NULL; |
| 477 | 487 | } |
| 478 | 488 | |
| 479 | | void sdlwindow_clear(sdl_window_info *window) |
| 489 | void sdl_window_info::window_clear() |
| 480 | 490 | { |
| 481 | | worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param)); |
| 491 | worker_param wp; |
| 482 | 492 | |
| 483 | | clear_worker_param(wp); |
| 484 | | wp->window = window; |
| 485 | | |
| 486 | 493 | if (SDL_ThreadID() == main_threadid) |
| 487 | 494 | { |
| 488 | | execute_async_wait(&sdlwindow_clear_surface_wt, wp); |
| 489 | | osd_free(wp); |
| 495 | execute_async_wait(&sdlwindow_clear_surface_wt, worker_param(this)); |
| 490 | 496 | } |
| 491 | 497 | else |
| 492 | | sdlwindow_clear_surface_wt( (void *) wp, 0); |
| 498 | execute_sync(&sdlwindow_clear_surface_wt, worker_param(this)); |
| 493 | 499 | } |
| 494 | 500 | |
| 495 | 501 | |
| r242608 | r242609 | |
| 501 | 507 | static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) |
| 502 | 508 | { |
| 503 | 509 | worker_param *wp = (worker_param *) param; |
| 504 | | sdl_window_info *window = wp->window; |
| 510 | sdl_window_info *window = wp->window(); |
| 505 | 511 | |
| 506 | 512 | ASSERT_WINDOW_THREAD(); |
| 507 | 513 | |
| r242608 | r242609 | |
| 510 | 516 | return NULL; |
| 511 | 517 | |
| 512 | 518 | // If we are going fullscreen (leaving windowed) remember our windowed size |
| 513 | | if (!window->fullscreen) |
| 519 | if (!window->fullscreen()) |
| 514 | 520 | { |
| 515 | 521 | window->windowed_width = window->width; |
| 516 | 522 | window->windowed_height = window->height; |
| r242608 | r242609 | |
| 520 | 526 | sdlinput_release_keys(wp->machine()); |
| 521 | 527 | |
| 522 | 528 | // toggle the window mode |
| 523 | | window->fullscreen = !window->fullscreen; |
| 529 | window->set_fullscreen(!window->fullscreen()); |
| 524 | 530 | |
| 525 | 531 | complete_create_wt(param, 0); |
| 526 | 532 | |
| 527 | 533 | return NULL; |
| 528 | 534 | } |
| 529 | 535 | |
| 530 | | void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window) |
| 536 | void sdl_window_info::toggle_full_screen(running_machine &machine) |
| 531 | 537 | { |
| 532 | | worker_param wp; |
| 533 | | |
| 534 | 538 | ASSERT_MAIN_THREAD(); |
| 535 | 539 | |
| 536 | | clear_worker_param(&wp); |
| 537 | | wp.window = window; |
| 538 | | wp.m_machine = &machine; |
| 539 | | |
| 540 | | execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp); |
| 540 | execute_async_wait(&sdlwindow_toggle_full_screen_wt, worker_param(machine, this)); |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | static OSDWORK_CALLBACK( destroy_all_textures_wt ) |
| 544 | 544 | { |
| 545 | 545 | worker_param *wp = (worker_param *) param; |
| 546 | 546 | |
| 547 | | sdl_window_info *window = wp->window; |
| 547 | sdl_window_info *window = wp->window(); |
| 548 | 548 | |
| 549 | 549 | window->destroy_all_textures(window); |
| 550 | 550 | |
| r242608 | r242609 | |
| 552 | 552 | return NULL; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | | void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir) |
| 555 | void sdl_window_info::modify_prescale(running_machine &machine, int dir) |
| 556 | 556 | { |
| 557 | | worker_param wp; |
| 558 | | int new_prescale = window->prescale; |
| 557 | worker_param wp = worker_param(machine, this); |
| 558 | int new_prescale = prescale; |
| 559 | 559 | |
| 560 | | clear_worker_param(&wp); |
| 560 | if (dir > 0 && prescale < 3) |
| 561 | new_prescale = prescale + 1; |
| 562 | if (dir < 0 && prescale > 1) |
| 563 | new_prescale = prescale - 1; |
| 561 | 564 | |
| 562 | | wp.window = window; |
| 563 | | wp.m_machine = &machine; |
| 564 | | |
| 565 | | if (dir > 0 && window->prescale < 3) |
| 566 | | new_prescale = window->prescale + 1; |
| 567 | | if (dir < 0 && window->prescale > 1) |
| 568 | | new_prescale = window->prescale - 1; |
| 569 | | |
| 570 | | if (new_prescale != window->prescale) |
| 565 | if (new_prescale != prescale) |
| 571 | 566 | { |
| 572 | | if (window->fullscreen && video_config.switchres) |
| 567 | if (m_fullscreen && video_config.switchres) |
| 573 | 568 | { |
| 574 | | execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); |
| 569 | execute_async_wait(&sdlwindow_video_window_destroy_wt, wp); |
| 575 | 570 | |
| 576 | | window->prescale = new_prescale; |
| 571 | prescale = new_prescale; |
| 577 | 572 | |
| 578 | | execute_async_wait(&complete_create_wt, &wp); |
| 573 | execute_async_wait(&complete_create_wt, wp); |
| 579 | 574 | |
| 580 | 575 | } |
| 581 | 576 | else |
| 582 | 577 | { |
| 583 | | execute_async_wait(destroy_all_textures_wt, &wp); |
| 584 | | window->prescale = new_prescale; |
| 578 | execute_async_wait(destroy_all_textures_wt, wp); |
| 579 | prescale = new_prescale; |
| 585 | 580 | } |
| 586 | | machine.ui().popup_time(1, "Prescale %d", window->prescale); |
| 581 | machine.ui().popup_time(1, "Prescale %d", prescale); |
| 587 | 582 | } |
| 588 | 583 | } |
| 589 | 584 | |
| r242608 | r242609 | |
| 611 | 606 | { |
| 612 | 607 | //FIXME: SDL1.3: really broken: the whole SDL code |
| 613 | 608 | // will only work correct with relative mouse movements ... |
| 614 | | if (!window->fullscreen && !sdlinput_should_hide_mouse(machine)) |
| 609 | if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine)) |
| 615 | 610 | { |
| 616 | 611 | SDL_ShowCursor(SDL_ENABLE); |
| 617 | 612 | if (SDL_GetWindowGrab(window->sdl_window )) |
| r242608 | r242609 | |
| 633 | 628 | // the possibility of losing control |
| 634 | 629 | if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) |
| 635 | 630 | { |
| 636 | | if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) |
| 631 | if ( window->fullscreen() || sdlinput_should_hide_mouse(machine) ) |
| 637 | 632 | { |
| 638 | 633 | SDL_ShowCursor(SDL_DISABLE); |
| 639 | 634 | if (!SDL_WM_GrabInput(SDL_GRAB_QUERY)) |
| r242608 | r242609 | |
| 659 | 654 | worker_param * wp = (worker_param *) param; |
| 660 | 655 | //sdl_window_info * window = wp->window; |
| 661 | 656 | |
| 662 | | sdlwindow_update_cursor_state(*wp->m_machine, wp->window); |
| 657 | sdlwindow_update_cursor_state(wp->machine(), wp->window()); |
| 663 | 658 | |
| 664 | 659 | return NULL; |
| 665 | 660 | } |
| r242608 | r242609 | |
| 678 | 673 | |
| 679 | 674 | ASSERT_MAIN_THREAD(); |
| 680 | 675 | |
| 681 | | clear_worker_param(wp); |
| 682 | | |
| 683 | 676 | // allocate a new window object |
| 684 | | window = global_alloc_clear(sdl_window_info); |
| 685 | | window->maxwidth = config->width; |
| 686 | | window->maxheight = config->height; |
| 687 | | window->depth = config->depth; |
| 688 | | window->refresh = config->refresh; |
| 689 | | window->monitor = monitor; |
| 690 | | window->m_machine = &machine; |
| 691 | | window->index = index; |
| 677 | window = global_alloc(sdl_window_info(&machine, monitor, index, config)); |
| 692 | 678 | |
| 693 | | //FIXME: these should be per_window in config-> or even better a bit set |
| 694 | | window->fullscreen = !video_config.windowed; |
| 695 | | window->prescale = video_config.prescale; |
| 696 | | |
| 697 | 679 | // set the initial maximized state |
| 698 | 680 | // FIXME: Does not belong here |
| 699 | 681 | sdl_options &options = downcast<sdl_options &>(machine.options()); |
| 700 | 682 | window->startmaximized = options.maximize(); |
| 701 | 683 | |
| 702 | | if (!window->fullscreen) |
| 703 | | { |
| 704 | | window->windowed_width = config->width; |
| 705 | | window->windowed_height = config->height; |
| 706 | | } |
| 707 | | |
| 708 | 684 | // add us to the list |
| 709 | 685 | *last_window_ptr = window; |
| 710 | 686 | last_window_ptr = &window->next; |
| r242608 | r242609 | |
| 726 | 702 | else |
| 727 | 703 | sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index); |
| 728 | 704 | |
| 729 | | wp->window = window; |
| 705 | wp->set_window(window); |
| 730 | 706 | |
| 707 | // FIXME: pass error back in a different way |
| 731 | 708 | if (multithreading_enabled) |
| 732 | 709 | { |
| 733 | 710 | osd_work_item *wi; |
| r242608 | r242609 | |
| 747 | 724 | return 0; |
| 748 | 725 | |
| 749 | 726 | error: |
| 750 | | sdlwindow_video_window_destroy(machine, window); |
| 727 | window->video_window_destroy(machine); |
| 728 | // free the window itself |
| 729 | global_free(window); |
| 751 | 730 | return 1; |
| 752 | 731 | } |
| 753 | 732 | |
| r242608 | r242609 | |
| 760 | 739 | static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ) |
| 761 | 740 | { |
| 762 | 741 | worker_param * wp = (worker_param *) param; |
| 763 | | sdl_window_info * window = wp->window; |
| 742 | sdl_window_info * window = wp->window(); |
| 764 | 743 | |
| 765 | 744 | ASSERT_WINDOW_THREAD(); |
| 766 | 745 | |
| r242608 | r242609 | |
| 775 | 754 | return NULL; |
| 776 | 755 | } |
| 777 | 756 | |
| 778 | | static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window) |
| 757 | void sdl_window_info::video_window_destroy(running_machine &machine) |
| 779 | 758 | { |
| 780 | 759 | sdl_window_info **prevptr; |
| 781 | | worker_param wp; |
| 782 | 760 | |
| 783 | 761 | ASSERT_MAIN_THREAD(); |
| 784 | 762 | if (multithreading_enabled) |
| r242608 | r242609 | |
| 790 | 768 | |
| 791 | 769 | // remove us from the list |
| 792 | 770 | for (prevptr = &sdl_window_list; *prevptr != NULL; prevptr = &(*prevptr)->next) |
| 793 | | if (*prevptr == window) |
| 771 | if (*prevptr == this) |
| 794 | 772 | { |
| 795 | | *prevptr = window->next; |
| 773 | *prevptr = this->next; |
| 796 | 774 | break; |
| 797 | 775 | } |
| 798 | 776 | |
| 799 | 777 | // free the textures etc |
| 800 | | clear_worker_param(&wp); |
| 801 | | wp.window = window; |
| 802 | | wp.m_machine = &machine; |
| 803 | | execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); |
| 778 | execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this)); |
| 804 | 779 | |
| 805 | 780 | // free the render target, after the textures! |
| 806 | | window->machine().render().target_free(window->target); |
| 781 | this->machine().render().target_free(target); |
| 807 | 782 | |
| 808 | 783 | // free the event |
| 809 | | osd_event_free(window->rendered_event); |
| 784 | osd_event_free(rendered_event); |
| 810 | 785 | |
| 811 | | // free the window itself |
| 812 | | global_free(window); |
| 813 | 786 | } |
| 814 | 787 | |
| 815 | 788 | |
| r242608 | r242609 | |
| 818 | 791 | //============================================================ |
| 819 | 792 | |
| 820 | 793 | #if SDLMAME_SDL2 |
| 821 | | static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight) |
| 794 | void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight) |
| 822 | 795 | { |
| 823 | 796 | int minimum_width, minimum_height, target_width, target_height; |
| 824 | 797 | int i; |
| r242608 | r242609 | |
| 826 | 799 | float size_score, best_score = 0.0f; |
| 827 | 800 | |
| 828 | 801 | // determine the minimum width/height for the selected target |
| 829 | | window->target->compute_minimum_size(minimum_width, minimum_height); |
| 802 | target->compute_minimum_size(minimum_width, minimum_height); |
| 830 | 803 | |
| 831 | 804 | // use those as the target for now |
| 832 | | target_width = minimum_width * MAX(1, window->prescale); |
| 833 | | target_height = minimum_height * MAX(1, window->prescale); |
| 805 | target_width = minimum_width * MAX(1, prescale); |
| 806 | target_height = minimum_height * MAX(1, prescale); |
| 834 | 807 | |
| 835 | 808 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 836 | 809 | { |
| r242608 | r242609 | |
| 838 | 811 | minimum_height -= 4; |
| 839 | 812 | } |
| 840 | 813 | |
| 841 | | num = SDL_GetNumDisplayModes(window->monitor->handle); |
| 814 | num = SDL_GetNumDisplayModes(m_monitor->handle); |
| 842 | 815 | |
| 843 | 816 | if (num == 0) |
| 844 | 817 | { |
| r242608 | r242609 | |
| 850 | 823 | for (i = 0; i < num; ++i) |
| 851 | 824 | { |
| 852 | 825 | SDL_DisplayMode mode; |
| 853 | | SDL_GetDisplayMode(window->monitor->handle, i, &mode); |
| 826 | SDL_GetDisplayMode(m_monitor->handle, i, &mode); |
| 854 | 827 | |
| 855 | 828 | // compute initial score based on difference between target and current |
| 856 | 829 | size_score = 1.0f / (1.0f + fabsf((INT32)mode.w - target_width) + fabsf((INT32)mode.h - target_height)); |
| r242608 | r242609 | |
| 864 | 837 | size_score *= 0.1f; |
| 865 | 838 | |
| 866 | 839 | // if we're looking for a particular mode, that's a winner |
| 867 | | if (mode.w == window->maxwidth && mode.h == window->maxheight) |
| 840 | if (mode.w == m_maxwidth && mode.h == m_maxheight) |
| 868 | 841 | size_score = 2.0f; |
| 869 | 842 | |
| 870 | 843 | // refresh adds some points |
| 871 | | if (window->refresh) |
| 872 | | size_score *= 1.0f / (1.0f + fabsf(window->refresh - mode.refresh_rate) / 10.0f); |
| 844 | if (refresh) |
| 845 | size_score *= 1.0f / (1.0f + fabsf(refresh - mode.refresh_rate) / 10.0f); |
| 873 | 846 | |
| 874 | 847 | osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score); |
| 875 | 848 | |
| r242608 | r242609 | |
| 885 | 858 | } |
| 886 | 859 | } |
| 887 | 860 | #else |
| 888 | | static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight) |
| 861 | void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight) |
| 889 | 862 | { |
| 890 | 863 | int minimum_width, minimum_height, target_width, target_height; |
| 891 | 864 | int i; |
| r242608 | r242609 | |
| 893 | 866 | SDL_Rect **modes; |
| 894 | 867 | |
| 895 | 868 | // determine the minimum width/height for the selected target |
| 896 | | window->target->compute_minimum_size(minimum_width, minimum_height); |
| 869 | target->compute_minimum_size(minimum_width, minimum_height); |
| 897 | 870 | |
| 898 | 871 | // use those as the target for now |
| 899 | | target_width = minimum_width * MAX(1, window->prescale); |
| 900 | | target_height = minimum_height * MAX(1, window->prescale); |
| 872 | target_width = minimum_width * MAX(1, prescale); |
| 873 | target_height = minimum_height * MAX(1, prescale); |
| 901 | 874 | |
| 902 | 875 | // if we're not stretching, allow some slop on the minimum since we can handle it |
| 903 | 876 | { |
| r242608 | r242609 | |
| 913 | 886 | */ |
| 914 | 887 | modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF); |
| 915 | 888 | #else |
| 916 | | modes = window->monitor->modes; |
| 889 | modes = window->m_monitor->modes; |
| 917 | 890 | #endif |
| 918 | 891 | |
| 919 | 892 | if (modes == (SDL_Rect **)0) |
| r242608 | r242609 | |
| 923 | 896 | } |
| 924 | 897 | else if (modes == (SDL_Rect **)-1) // all modes are possible |
| 925 | 898 | { |
| 926 | | *fswidth = window->maxwidth; |
| 927 | | *fsheight = window->maxheight; |
| 899 | *fswidth = m_maxwidth; |
| 900 | *fsheight = m_maxheight; |
| 928 | 901 | } |
| 929 | 902 | else |
| 930 | 903 | { |
| r242608 | r242609 | |
| 942 | 915 | size_score *= 0.1f; |
| 943 | 916 | |
| 944 | 917 | // if we're looking for a particular mode, that's a winner |
| 945 | | if (modes[i]->w == window->maxwidth && modes[i]->h == window->maxheight) |
| 918 | if (modes[i]->w == m_maxwidth && modes[i]->h == m_maxheight) |
| 946 | 919 | size_score = 2.0f; |
| 947 | 920 | |
| 948 | 921 | osd_printf_verbose("%4dx%4d -> %f\n", (int)modes[i]->w, (int)modes[i]->h, size_score); |
| r242608 | r242609 | |
| 965 | 938 | // (main thread) |
| 966 | 939 | //============================================================ |
| 967 | 940 | |
| 968 | | void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window) |
| 941 | void sdl_window_info::video_window_update(running_machine &machine) |
| 969 | 942 | { |
| 970 | 943 | osd_ticks_t event_wait_ticks; |
| 971 | 944 | ASSERT_MAIN_THREAD(); |
| r242608 | r242609 | |
| 973 | 946 | // adjust the cursor state |
| 974 | 947 | //sdlwindow_update_cursor_state(machine, window); |
| 975 | 948 | |
| 976 | | { |
| 977 | | worker_param wp; |
| 949 | execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this)); |
| 978 | 950 | |
| 979 | | clear_worker_param(&wp); |
| 980 | | wp.window = window; |
| 981 | | wp.m_machine = &machine; |
| 982 | | |
| 983 | | execute_async(&sdlwindow_update_cursor_state_wt, &wp); |
| 984 | | } |
| 985 | | |
| 986 | 951 | // if we're visible and running and not in the middle of a resize, draw |
| 987 | | if (window->target != NULL) |
| 952 | if (target != NULL) |
| 988 | 953 | { |
| 989 | 954 | int tempwidth, tempheight; |
| 990 | 955 | |
| 991 | 956 | // see if the games video mode has changed |
| 992 | | window->target->compute_minimum_size(tempwidth, tempheight); |
| 993 | | if (tempwidth != window->minwidth || tempheight != window->minheight) |
| 957 | target->compute_minimum_size(tempwidth, tempheight); |
| 958 | if (tempwidth != m_minwidth || tempheight != m_minheight) |
| 994 | 959 | { |
| 995 | | window->minwidth = tempwidth; |
| 996 | | window->minheight = tempheight; |
| 960 | m_minwidth = tempwidth; |
| 961 | m_minheight = tempheight; |
| 997 | 962 | |
| 998 | | if (!window->fullscreen) |
| 963 | if (!this->m_fullscreen) |
| 999 | 964 | { |
| 1000 | | sdlwindow_blit_surface_size(window, window->width, window->height); |
| 1001 | | sdlwindow_resize(window, window->blitwidth, window->blitheight); |
| 965 | blit_surface_size(width, height); |
| 966 | window_resize(blitwidth, blitheight); |
| 1002 | 967 | } |
| 1003 | 968 | else if (video_config.switchres) |
| 1004 | 969 | { |
| 1005 | | pick_best_mode(window, &tempwidth, &tempheight); |
| 1006 | | sdlwindow_resize(window, tempwidth, tempheight); |
| 970 | this->pick_best_mode(&tempwidth, &tempheight); |
| 971 | window_resize(tempwidth, tempheight); |
| 1007 | 972 | } |
| 1008 | 973 | } |
| 1009 | 974 | |
| r242608 | r242609 | |
| 1012 | 977 | else |
| 1013 | 978 | event_wait_ticks = 0; |
| 1014 | 979 | |
| 1015 | | if (osd_event_wait(window->rendered_event, event_wait_ticks)) |
| 980 | if (osd_event_wait(rendered_event, event_wait_ticks)) |
| 1016 | 981 | { |
| 1017 | | worker_param wp; |
| 1018 | | render_primitive_list *primlist; |
| 982 | // ensure the target bounds are up-to-date, and then get the primitives |
| 983 | render_primitive_list *primlist = &get_primitives(this); |
| 1019 | 984 | |
| 1020 | | clear_worker_param(&wp); |
| 1021 | | |
| 1022 | | // ensure the target bounds are up-to-date, and then get the primitives |
| 1023 | | primlist = &window->get_primitives(window); |
| 1024 | | |
| 1025 | 985 | // and redraw now |
| 1026 | 986 | |
| 1027 | | wp.list = primlist; |
| 1028 | | wp.window = window; |
| 1029 | | wp.m_machine = &machine; |
| 1030 | | |
| 1031 | | execute_async(&draw_video_contents_wt, &wp); |
| 987 | execute_async(&draw_video_contents_wt, worker_param(machine, this, primlist)); |
| 1032 | 988 | } |
| 1033 | 989 | } |
| 1034 | 990 | } |
| r242608 | r242609 | |
| 1066 | 1022 | static OSDWORK_CALLBACK( complete_create_wt ) |
| 1067 | 1023 | { |
| 1068 | 1024 | worker_param * wp = (worker_param *) param; |
| 1069 | | sdl_window_info * window = wp->window; |
| 1025 | sdl_window_info * window = wp->window(); |
| 1070 | 1026 | |
| 1071 | 1027 | int tempwidth, tempheight; |
| 1072 | 1028 | static int result[2] = {0,1}; |
| r242608 | r242609 | |
| 1074 | 1030 | ASSERT_WINDOW_THREAD(); |
| 1075 | 1031 | osd_free(wp); |
| 1076 | 1032 | |
| 1077 | | if (window->fullscreen) |
| 1033 | if (window->fullscreen()) |
| 1078 | 1034 | { |
| 1079 | 1035 | // default to the current mode exactly |
| 1080 | | tempwidth = window->monitor->monitor_width; |
| 1081 | | tempheight = window->monitor->monitor_height; |
| 1036 | tempwidth = window->monitor()->monitor_width; |
| 1037 | tempheight = window->monitor()->monitor_height; |
| 1082 | 1038 | |
| 1083 | 1039 | // if we're allowed to switch resolutions, override with something better |
| 1084 | 1040 | if (video_config.switchres) |
| 1085 | | pick_best_mode(window, &tempwidth, &tempheight); |
| 1041 | window->pick_best_mode(&tempwidth, &tempheight); |
| 1086 | 1042 | } |
| 1087 | 1043 | else if (window->windowed_width) |
| 1088 | 1044 | { |
| r242608 | r242609 | |
| 1095 | 1051 | if (window->startmaximized) |
| 1096 | 1052 | { |
| 1097 | 1053 | tempwidth = tempheight = 0; |
| 1098 | | get_max_bounds(window, &tempwidth, &tempheight, video_config.keepaspect ); |
| 1054 | window->get_max_bounds(&tempwidth, &tempheight, video_config.keepaspect ); |
| 1099 | 1055 | } |
| 1100 | 1056 | else |
| 1101 | 1057 | { |
| r242608 | r242609 | |
| 1103 | 1059 | instead of letting sdlwindow_blit_surface_size() resize it |
| 1104 | 1060 | this stops the window from "flashing" from the wrong aspect |
| 1105 | 1061 | size to the right one at startup. */ |
| 1106 | | tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640; |
| 1107 | | tempheight = (window->maxheight != 0) ? window->maxheight : 480; |
| 1062 | tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640; |
| 1063 | tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480; |
| 1108 | 1064 | |
| 1109 | | get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect ); |
| 1065 | window->get_min_bounds(&tempwidth, &tempheight, video_config.keepaspect ); |
| 1110 | 1066 | } |
| 1111 | 1067 | } |
| 1112 | 1068 | |
| r242608 | r242609 | |
| 1174 | 1130 | UINT32 dc = 0; |
| 1175 | 1131 | int update = 1; |
| 1176 | 1132 | worker_param *wp = (worker_param *) param; |
| 1177 | | sdl_window_info *window = wp->window; |
| 1133 | sdl_window_info *window = wp->window(); |
| 1178 | 1134 | |
| 1179 | 1135 | ASSERT_REDRAW_THREAD(); |
| 1180 | 1136 | |
| 1181 | 1137 | // Some configurations require events to be polled in the worker thread |
| 1182 | 1138 | sdlinput_process_events_buf(wp->machine()); |
| 1183 | 1139 | |
| 1184 | | window->primlist = wp->list; |
| 1140 | window->primlist = wp->list(); |
| 1185 | 1141 | |
| 1186 | 1142 | // if no bitmap, just fill |
| 1187 | 1143 | if (window->primlist == NULL) |
| r242608 | r242609 | |
| 1209 | 1165 | // (window thread) |
| 1210 | 1166 | //============================================================ |
| 1211 | 1167 | |
| 1212 | | static void constrain_to_aspect_ratio(sdl_window_info *window, int *window_width, int *window_height, int adjustment) |
| 1168 | void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment) |
| 1213 | 1169 | { |
| 1214 | 1170 | INT32 extrawidth = 0; |
| 1215 | 1171 | INT32 extraheight = 0; |
| r242608 | r242609 | |
| 1220 | 1176 | float pixel_aspect; |
| 1221 | 1177 | |
| 1222 | 1178 | // make sure the monitor is up-to-date |
| 1223 | | sdlvideo_monitor_refresh(window->monitor); |
| 1179 | sdlvideo_monitor_refresh(m_monitor); |
| 1224 | 1180 | |
| 1225 | 1181 | // get the pixel aspect ratio for the target monitor |
| 1226 | | pixel_aspect = sdlvideo_monitor_get_aspect(window->monitor); |
| 1182 | pixel_aspect = sdlvideo_monitor_get_aspect(m_monitor); |
| 1227 | 1183 | |
| 1228 | 1184 | // determine the proposed width/height |
| 1229 | 1185 | propwidth = *window_width - extrawidth; |
| r242608 | r242609 | |
| 1235 | 1191 | { |
| 1236 | 1192 | case WMSZ_BOTTOM: |
| 1237 | 1193 | case WMSZ_TOP: |
| 1238 | | window->target->compute_visible_area(10000, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight); |
| 1194 | target->compute_visible_area(10000, propheight, pixel_aspect, target->orientation(), propwidth, propheight); |
| 1239 | 1195 | break; |
| 1240 | 1196 | |
| 1241 | 1197 | case WMSZ_LEFT: |
| 1242 | 1198 | case WMSZ_RIGHT: |
| 1243 | | window->target->compute_visible_area(propwidth, 10000, pixel_aspect, window->target->orientation(), propwidth, propheight); |
| 1199 | target->compute_visible_area(propwidth, 10000, pixel_aspect, target->orientation(), propwidth, propheight); |
| 1244 | 1200 | break; |
| 1245 | 1201 | |
| 1246 | 1202 | default: |
| 1247 | | window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight); |
| 1203 | target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), propwidth, propheight); |
| 1248 | 1204 | break; |
| 1249 | 1205 | } |
| 1250 | 1206 | |
| 1251 | 1207 | // get the minimum width/height for the current layout |
| 1252 | | window->target->compute_minimum_size(minwidth, minheight); |
| 1208 | target->compute_minimum_size(minwidth, minheight); |
| 1253 | 1209 | |
| 1254 | 1210 | // clamp against the absolute minimum |
| 1255 | 1211 | propwidth = MAX(propwidth, MIN_WINDOW_DIM); |
| r242608 | r242609 | |
| 1260 | 1216 | propheight = MAX(propheight, minheight); |
| 1261 | 1217 | |
| 1262 | 1218 | // clamp against the maximum (fit on one screen for full screen mode) |
| 1263 | | if (window->fullscreen) |
| 1219 | if (this->m_fullscreen) |
| 1264 | 1220 | { |
| 1265 | | maxwidth = window->monitor->center_width - extrawidth; |
| 1266 | | maxheight = window->monitor->center_height - extraheight; |
| 1221 | maxwidth = m_monitor->center_width - extrawidth; |
| 1222 | maxheight = m_monitor->center_height - extraheight; |
| 1267 | 1223 | } |
| 1268 | 1224 | else |
| 1269 | 1225 | { |
| 1270 | | maxwidth = window->monitor->center_width - extrawidth; |
| 1271 | | maxheight = window->monitor->center_height - extraheight; |
| 1226 | maxwidth = m_monitor->center_width - extrawidth; |
| 1227 | maxheight = m_monitor->center_height - extraheight; |
| 1272 | 1228 | |
| 1273 | 1229 | // further clamp to the maximum width/height in the window |
| 1274 | | if (window->maxwidth != 0) |
| 1275 | | maxwidth = MIN(maxwidth, window->maxwidth + extrawidth); |
| 1276 | | if (window->maxheight != 0) |
| 1277 | | maxheight = MIN(maxheight, window->maxheight + extraheight); |
| 1230 | if (this->m_maxwidth != 0) |
| 1231 | maxwidth = MIN(maxwidth, this->m_maxwidth + extrawidth); |
| 1232 | if (this->m_maxheight != 0) |
| 1233 | maxheight = MIN(maxheight, this->m_maxheight + extraheight); |
| 1278 | 1234 | } |
| 1279 | 1235 | |
| 1280 | 1236 | // clamp to the maximum |
| r242608 | r242609 | |
| 1282 | 1238 | propheight = MIN(propheight, maxheight); |
| 1283 | 1239 | |
| 1284 | 1240 | // compute the visible area based on the proposed rectangle |
| 1285 | | window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), viswidth, visheight); |
| 1241 | target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), viswidth, visheight); |
| 1286 | 1242 | |
| 1287 | 1243 | *window_width = viswidth; |
| 1288 | 1244 | *window_height = visheight; |
| r242608 | r242609 | |
| 1294 | 1250 | // (window thread) |
| 1295 | 1251 | //============================================================ |
| 1296 | 1252 | |
| 1297 | | static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain) |
| 1253 | void sdl_window_info::get_min_bounds(int *window_width, int *window_height, int constrain) |
| 1298 | 1254 | { |
| 1299 | 1255 | INT32 minwidth, minheight; |
| 1300 | 1256 | |
| 1301 | 1257 | // get the minimum target size |
| 1302 | | window->target->compute_minimum_size(minwidth, minheight); |
| 1258 | this->target->compute_minimum_size(minwidth, minheight); |
| 1303 | 1259 | |
| 1304 | 1260 | // expand to our minimum dimensions |
| 1305 | 1261 | if (minwidth < MIN_WINDOW_DIM) |
| r242608 | r242609 | |
| 1315 | 1271 | |
| 1316 | 1272 | // first constrain with no height limit |
| 1317 | 1273 | test1w = minwidth; test1h = 10000; |
| 1318 | | constrain_to_aspect_ratio(window, &test1w, &test1h, WMSZ_BOTTOMRIGHT); |
| 1274 | this->constrain_to_aspect_ratio(&test1w, &test1h, WMSZ_BOTTOMRIGHT); |
| 1319 | 1275 | |
| 1320 | 1276 | // then constrain with no width limit |
| 1321 | 1277 | test2w = 10000; test2h = minheight; |
| 1322 | | constrain_to_aspect_ratio(window, &test2w, &test2h, WMSZ_BOTTOMRIGHT); |
| 1278 | this->constrain_to_aspect_ratio(&test2w, &test2h, WMSZ_BOTTOMRIGHT); |
| 1323 | 1279 | |
| 1324 | 1280 | // pick the larger |
| 1325 | 1281 | if ( test1w > test2w ) |
| r242608 | r242609 | |
| 1344 | 1300 | // (window thread) |
| 1345 | 1301 | //============================================================ |
| 1346 | 1302 | |
| 1347 | | static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain) |
| 1303 | void sdl_window_info::get_max_bounds(int *window_width, int *window_height, int constrain) |
| 1348 | 1304 | { |
| 1349 | 1305 | INT32 maxwidth, maxheight; |
| 1350 | 1306 | |
| 1351 | 1307 | // compute the maximum client area |
| 1352 | | maxwidth = window->monitor->center_width; |
| 1353 | | maxheight = window->monitor->center_height; |
| 1308 | maxwidth = m_monitor->center_width; |
| 1309 | maxheight = m_monitor->center_height; |
| 1354 | 1310 | |
| 1355 | 1311 | // clamp to the window's max |
| 1356 | | if (window->maxwidth != 0) |
| 1312 | if (this->m_maxwidth != 0) |
| 1357 | 1313 | { |
| 1358 | | int temp = window->maxwidth + WINDOW_DECORATION_WIDTH; |
| 1314 | int temp = this->m_maxwidth + WINDOW_DECORATION_WIDTH; |
| 1359 | 1315 | if (temp < maxwidth) |
| 1360 | 1316 | maxwidth = temp; |
| 1361 | 1317 | } |
| 1362 | | if (window->maxheight != 0) |
| 1318 | if (this->m_maxheight != 0) |
| 1363 | 1319 | { |
| 1364 | | int temp = window->maxheight + WINDOW_DECORATION_HEIGHT; |
| 1320 | int temp = this->m_maxheight + WINDOW_DECORATION_HEIGHT; |
| 1365 | 1321 | if (temp < maxheight) |
| 1366 | 1322 | maxheight = temp; |
| 1367 | 1323 | } |
| 1368 | 1324 | |
| 1369 | 1325 | // constrain to fit |
| 1370 | 1326 | if (constrain) |
| 1371 | | constrain_to_aspect_ratio(window, &maxwidth, &maxheight, WMSZ_BOTTOMRIGHT); |
| 1327 | this->constrain_to_aspect_ratio(&maxwidth, &maxheight, WMSZ_BOTTOMRIGHT); |
| 1372 | 1328 | //else |
| 1373 | 1329 | { |
| 1374 | 1330 | maxwidth -= WINDOW_DECORATION_WIDTH; |