|
99 | 99 |
|
100 | 100 | if (device == 0) {
|
101 | 101 | CGPoint point;
|
102 |
| - if (_properties.get_fullscreen()) { |
| 102 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
103 | 103 | point = CGPointMake(x, y + 1);
|
104 | 104 | } else {
|
105 | 105 | point = CGPointMake(x + _properties.get_x_origin(),
|
|
147 | 147 | CGLLockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]);
|
148 | 148 |
|
149 | 149 | // Set the drawable.
|
150 |
| - if (_properties.get_fullscreen()) { |
| 150 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
151 | 151 | // Fullscreen.
|
152 | 152 | CGLSetFullScreenOnDisplay((CGLContextObj) [cocoagsg->_context CGLContextObj], CGDisplayIDToOpenGLDisplayMask(_display));
|
153 | 153 | } else {
|
|
171 | 171 | }
|
172 | 172 |
|
173 | 173 | // Lock the view for drawing.
|
174 |
| - if (!_properties.get_fullscreen()) { |
| 174 | + if (!_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
175 | 175 | nassertr_always([_view lockFocusIfCanDraw], false);
|
176 | 176 | }
|
177 | 177 |
|
|
203 | 203 | end_frame_spam(mode);
|
204 | 204 | nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
205 | 205 |
|
206 |
| - if (!_properties.get_fullscreen()) { |
| 206 | + if (!_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
207 | 207 | [_view unlockFocus];
|
208 | 208 | }
|
209 | 209 | // Release the context.
|
|
335 | 335 | if (!_properties.has_size()) {
|
336 | 336 | _properties.set_size(100, 100);
|
337 | 337 | }
|
338 |
| - if (!_properties.has_fullscreen()) { |
339 |
| - _properties.set_fullscreen(false); |
340 |
| - } |
341 | 338 | if (!_properties.has_foreground()) {
|
342 | 339 | _properties.set_foreground(true);
|
343 | 340 | }
|
344 |
| - if (!_properties.has_undecorated()) { |
345 |
| - _properties.set_undecorated(false); |
346 |
| - } |
347 | 341 | if (!_properties.has_fixed_size()) {
|
348 | 342 | _properties.set_fixed_size(false);
|
349 | 343 | }
|
|
356 | 350 | if (!_properties.has_cursor_hidden()) {
|
357 | 351 | _properties.set_cursor_hidden(false);
|
358 | 352 | }
|
| 353 | + if (!_properties.has_window_mode()) { |
| 354 | + _properties.set_window_mode(WindowProperties::W_regular); |
| 355 | + } |
359 | 356 |
|
360 | 357 | // Check if we have a parent view.
|
361 | 358 | NSView *parent_nsview = nil;
|
|
423 | 420 | if (_parent_window_handle == (WindowHandle *)NULL) {
|
424 | 421 | // Content rectangle
|
425 | 422 | NSRect rect;
|
426 |
| - if (_properties.get_fullscreen()) { |
| 423 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
427 | 424 | rect = container;
|
428 | 425 | } else {
|
429 | 426 | rect = NSMakeRect(x, container.size.height - _properties.get_y_size() - y,
|
|
432 | 429 |
|
433 | 430 | // Configure the window decorations
|
434 | 431 | NSUInteger windowStyle;
|
435 |
| - if (_properties.get_undecorated() || _properties.get_fullscreen()) { |
| 432 | + if (_properties.get_window_mode() == WindowProperties::W_undecorated || |
| 433 | + _properties.get_window_mode() == WindowProperties::W_fullscreen) { |
436 | 434 | windowStyle = NSBorderlessWindowMask;
|
437 | 435 | } else if (_properties.get_fixed_size()) {
|
438 | 436 | // Fixed size windows should not show the resize button.
|
|
525 | 523 |
|
526 | 524 | [_window setShowsResizeIndicator: !_properties.get_fixed_size()];
|
527 | 525 |
|
528 |
| - if (_properties.get_fullscreen()) { |
| 526 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
529 | 527 | [_window makeKeyAndOrderFront:nil];
|
530 | 528 | } else if (_properties.get_minimized()) {
|
531 | 529 | [_window makeKeyAndOrderFront:nil];
|
|
536 | 534 | [_window orderBack:nil];
|
537 | 535 | }
|
538 | 536 |
|
539 |
| - if (_properties.get_fullscreen()) { |
| 537 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
540 | 538 | [_window setLevel: NSMainMenuWindowLevel + 1];
|
541 | 539 | } else {
|
542 | 540 | switch (_properties.get_z_order()) {
|
|
556 | 554 | }
|
557 | 555 | }
|
558 | 556 |
|
559 |
| - if (_properties.get_fullscreen()) { |
| 557 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
560 | 558 | // Change the display mode.
|
561 | 559 | #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
562 | 560 | CGDisplayModeRef mode;
|
|
700 | 698 | return;
|
701 | 699 | }
|
702 | 700 |
|
703 |
| - if (properties.has_fullscreen()) { |
704 |
| - if (_properties.get_fullscreen() != properties.get_fullscreen()) { |
705 |
| - if (properties.get_fullscreen()) { |
| 701 | + if (properties.has_window_mode()) { |
| 702 | + if (_properties.get_window_mode() != properties.get_window_mode()) { |
| 703 | + if (properties.get_window_mode() == WindowProperties::W_fullscreen) { |
706 | 704 | int width, height;
|
707 | 705 | if (properties.has_size()) {
|
708 | 706 | width = properties.get_x_size();
|
|
742 | 740 | _properties.set_size(width, height);
|
743 | 741 | properties.clear_origin();
|
744 | 742 | _properties.set_origin(0, 0);
|
745 |
| - properties.clear_fullscreen(); |
746 |
| - _properties.set_fullscreen(true); |
747 |
| - |
| 743 | + _properties.set_window_mode(WindowProperties::W_fullscreen); |
| 744 | + // Clear window_mode later |
748 | 745 | } else {
|
749 | 746 | cocoadisplay_cat.error()
|
750 | 747 | << "Failed to change display mode.\n";
|
751 | 748 | }
|
752 | 749 |
|
753 | 750 | } else {
|
754 | 751 | do_switch_fullscreen(NULL);
|
755 |
| - _properties.set_fullscreen(false); |
756 | 752 |
|
757 | 753 | // Force properties to be reset to their actual values
|
758 |
| - properties.set_undecorated(_properties.get_undecorated()); |
759 | 754 | properties.set_z_order(_properties.get_z_order());
|
760 |
| - properties.clear_fullscreen(); |
761 | 755 | }
|
762 | 756 | }
|
763 | 757 | _context_needs_update = true;
|
764 | 758 | }
|
765 | 759 |
|
766 |
| - if (properties.has_minimized() && !_properties.get_fullscreen() && _window != nil) { |
| 760 | + if (properties.has_minimized() && _properties.get_window_mode() != WindowProperties::W_fullscreen && _window != nil) { |
767 | 761 | _properties.set_minimized(properties.get_minimized());
|
768 | 762 | if (properties.get_minimized()) {
|
769 | 763 | [_window miniaturize:nil];
|
|
777 | 771 | int width = properties.get_x_size();
|
778 | 772 | int height = properties.get_y_size();
|
779 | 773 |
|
780 |
| - if (!_properties.get_fullscreen()) { |
| 774 | + if (_properties.get_window_mode() != WindowProperties::W_fullscreen) { |
781 | 775 | if (_window != nil) {
|
782 | 776 | [_window setContentSize:NSMakeSize(width, height)];
|
783 | 777 | }
|
|
817 | 811 | }
|
818 | 812 | }
|
819 | 813 |
|
820 |
| - if (properties.has_origin() && !_properties.get_fullscreen()) { |
| 814 | + if (properties.has_origin() && _properties.get_window_mode() != WindowProperties::W_fullscreen) { |
821 | 815 | int x = properties.get_x_origin();
|
822 | 816 | int y = properties.get_y_origin();
|
823 | 817 |
|
|
842 | 836 | }
|
843 | 837 | _properties.set_origin(x, y);
|
844 | 838 |
|
845 |
| - if (!_properties.get_fullscreen()) { |
| 839 | + if (_properties.get_window_mode() != WindowProperties::W_fullscreen) { |
846 | 840 | // Remember, Mac OS X coordinates are flipped in the vertical axis.
|
847 | 841 | frame.origin.x = x;
|
848 | 842 | frame.origin.y = container.size.height - y - frame.size.height;
|
|
869 | 863 | _properties.set_fixed_size(properties.get_fixed_size());
|
870 | 864 | [_window setShowsResizeIndicator:!properties.get_fixed_size()];
|
871 | 865 |
|
872 |
| - if (!_properties.get_fullscreen()) { |
| 866 | + if (_properties.get_window_mode() != WindowProperties::W_fullscreen) { |
873 | 867 | // If our window is decorated, change the style mask to show or hide the
|
874 | 868 | // resize button appropriately. However, if we're specifying the
|
875 | 869 | // 'undecorated' property also, then we'll be setting the style mask
|
876 | 870 | // about 25 LOC further down, so we won't need to bother setting it
|
877 | 871 | // here.
|
878 |
| - if (!properties.has_undecorated() && !_properties.get_undecorated() && |
| 872 | + if (!properties.has_window_mode() && |
| 873 | + _properties.get_window_mode() != WindowProperties::W_undecorated && |
879 | 874 | [_window respondsToSelector:@selector(setStyleMask:)]) {
|
880 | 875 | if (properties.get_fixed_size()) {
|
881 | 876 | [_window setStyleMask:NSTitledWindowMask | NSClosableWindowMask |
|
|
891 | 886 | properties.clear_fixed_size();
|
892 | 887 | }
|
893 | 888 |
|
894 |
| - if (properties.has_undecorated() && _window != nil && [_window respondsToSelector:@selector(setStyleMask:)]) { |
895 |
| - _properties.set_undecorated(properties.get_undecorated()); |
896 |
| - |
897 |
| - if (!_properties.get_fullscreen()) { |
898 |
| - if (properties.get_undecorated()) { |
| 889 | + if (properties.has_window_mode() && _window != nil && [_window respondsToSelector:@selector(setStyleMask:)]) { |
| 890 | + if (_properties.get_window_mode() != WindowProperties::W_fullscreen) { |
| 891 | + if (properties.get_window_mode() == WindowProperties::W_undecorated) { |
899 | 892 | [_window setStyleMask: NSBorderlessWindowMask];
|
900 | 893 | } else if (_properties.get_fixed_size()) {
|
901 | 894 | // Fixed size windows should not show the resize button.
|
|
907 | 900 | }
|
908 | 901 | [_window makeFirstResponder:_view];
|
909 | 902 | }
|
910 |
| - |
911 |
| - properties.clear_undecorated(); |
912 | 903 | }
|
913 | 904 |
|
914 |
| - if (properties.has_foreground() && !_properties.get_fullscreen() && _window != nil) { |
| 905 | + if (properties.has_foreground() && _properties.get_window_mode() != WindowProperties::W_fullscreen && _window != nil) { |
915 | 906 | _properties.set_foreground(properties.get_foreground());
|
916 | 907 | if (!_properties.get_minimized()) {
|
917 | 908 | if (properties.get_foreground()) {
|
|
988 | 979 | if (properties.has_z_order() && _window != nil) {
|
989 | 980 | _properties.set_z_order(properties.get_z_order());
|
990 | 981 |
|
991 |
| - if (!_properties.get_fullscreen()) { |
| 982 | + if (_properties.get_window_mode() != WindowProperties::W_fullscreen) { |
992 | 983 | switch (properties.get_z_order()) {
|
993 | 984 | case WindowProperties::Z_bottom:
|
994 | 985 | [_window setLevel: NSNormalWindowLevel - 1];
|
|
1022 | 1013 | break;
|
1023 | 1014 | }
|
1024 | 1015 | }
|
| 1016 | + |
| 1017 | + if (properties.has_window_mode()) { |
| 1018 | + switch (properties.get_window_mode()) { |
| 1019 | + case WindowProperties::W_regular: |
| 1020 | + case WindowProperties::W_undecorated: |
| 1021 | + case WindowProperties::W_fullscreen: |
| 1022 | + // Assume these were set |
| 1023 | + _properties.set_window_mode(properties.get_window_mode()); |
| 1024 | + properties.clear_window_mode(); |
| 1025 | + break; |
| 1026 | + } |
| 1027 | + } |
1025 | 1028 | }
|
1026 | 1029 |
|
1027 | 1030 | /**
|
|
1665 | 1668 | nx = std::max(0., std::min((double) get_x_size() - 1, nx));
|
1666 | 1669 | ny = std::max(0., std::min((double) get_y_size() - 1, ny));
|
1667 | 1670 |
|
1668 |
| - if (_properties.get_fullscreen()) { |
| 1671 | + if (_properties.get_window_mode() == WindowProperties::W_fullscreen) { |
1669 | 1672 | point = CGPointMake(nx, ny + 1);
|
1670 | 1673 | } else {
|
1671 | 1674 | point = CGPointMake(nx + _properties.get_x_origin(),
|
|
0 commit comments