6666 out[5 ] = (DisplayVertex){ { x0, y1 }, { u0, v1 } };
6767}
6868
69+ static float
70+ map_clip_coordinate ( float value, float min, float max )
71+ {
72+ return min + ( value + 1 .0f ) * 0 .5f * ( max - min );
73+ }
74+
6975/* Convert a full frame of 16-bit BGR5A1 pixels (Spectrum framebuffer
7076 format) to 32-bit BGRA8 packed in little-endian word order, suitable
7177 for direct upload to MTLPixelFormatBGRA8Unorm via -replaceRegion:. */
@@ -399,6 +405,11 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification
399405 if ( ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_release ( 0 );
400406}
401407
408+ - (void )windowDidEnterFullScreen : (NSNotification *)notification
409+ {
410+ [[self window ] makeFirstResponder: self ];
411+ }
412+
402413-(void ) loadPicture : (NSString *) name
403414 greenTex : (Texture*) greenTexture
404415 redTex : (Texture*) redTexture
@@ -422,6 +433,10 @@ -(void) loadPicture: (NSString *) name
422433
423434-(void ) encodeIcon : (Texture*)iconTexture
424435 encoder : (id <MTLRenderCommandEncoder >)encoder
436+ contentX0 : (float )contentX0
437+ contentY0 : (float )contentY0
438+ contentX1 : (float )contentX1
439+ contentY1 : (float )contentY1
425440{
426441 Cocoa_Texture* texture = [iconTexture getTexture ];
427442
@@ -435,6 +450,11 @@ -(void) encodeIcon:(Texture*)iconTexture
435450 float target_y2 = 1 .0f - ( texture->image_yoffset + texture->image_height )
436451 * 2 .0f / (float )DISPLAY_SCREEN_HEIGHT;
437452
453+ target_x1 = map_clip_coordinate ( target_x1, contentX0, contentX1 );
454+ target_x2 = map_clip_coordinate ( target_x2, contentX0, contentX1 );
455+ target_y1 = map_clip_coordinate ( target_y1, contentY1, contentY0 );
456+ target_y2 = map_clip_coordinate ( target_y2, contentY1, contentY0 );
457+
438458 DisplayVertex verts[6 ];
439459 fill_quad ( verts,
440460 target_x1, target_y1, target_x2, target_y2,
@@ -446,36 +466,46 @@ -(void) encodeIcon:(Texture*)iconTexture
446466}
447467
448468-(void ) encodeIconOverlay : (id <MTLRenderCommandEncoder >)encoder
469+ contentX0 : (float )contentX0
470+ contentY0 : (float )contentY0
471+ contentX1 : (float )contentX1
472+ contentY1 : (float )contentY1
449473{
450474 switch ( disk_state ) {
451475 case UI_STATUSBAR_STATE_ACTIVE:
452- [self encodeIcon: greenDisk encoder: encoder];
476+ [self encodeIcon: greenDisk encoder: encoder contentX0: contentX0
477+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
453478 break ;
454479 case UI_STATUSBAR_STATE_INACTIVE:
455- [self encodeIcon: redDisk encoder: encoder];
480+ [self encodeIcon: redDisk encoder: encoder contentX0: contentX0
481+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
456482 break ;
457483 case UI_STATUSBAR_STATE_NOT_AVAILABLE:
458484 break ;
459485 }
460486
461487 switch ( mdr_state ) {
462488 case UI_STATUSBAR_STATE_ACTIVE:
463- [self encodeIcon: greenMdr encoder: encoder];
489+ [self encodeIcon: greenMdr encoder: encoder contentX0: contentX0
490+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
464491 break ;
465492 case UI_STATUSBAR_STATE_INACTIVE:
466- [self encodeIcon: redMdr encoder: encoder];
493+ [self encodeIcon: redMdr encoder: encoder contentX0: contentX0
494+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
467495 break ;
468496 case UI_STATUSBAR_STATE_NOT_AVAILABLE:
469497 break ;
470498 }
471499
472500 switch ( tape_state ) {
473501 case UI_STATUSBAR_STATE_ACTIVE:
474- [self encodeIcon: greenCassette encoder: encoder];
502+ [self encodeIcon: greenCassette encoder: encoder contentX0: contentX0
503+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
475504 break ;
476505 case UI_STATUSBAR_STATE_INACTIVE:
477506 case UI_STATUSBAR_STATE_NOT_AVAILABLE:
478- [self encodeIcon: redCassette encoder: encoder];
507+ [self encodeIcon: redCassette encoder: encoder contentX0: contentX0
508+ contentY0: contentY0 contentX1: contentX1 contentY1: contentY1];
479509 break ;
480510 }
481511}
@@ -518,6 +548,29 @@ the vertical (top/bottom) margin in pixels and writes the horizontal
518548 &horizontal_margin );
519549
520550 Cocoa_Texture *cur = &screenTex[currentScreenTex];
551+ float contentX0 = -1 .0f ;
552+ float contentY0 = 1 .0f ;
553+ float contentX1 = 1 .0f ;
554+ float contentY1 = -1 .0f ;
555+
556+ if ( !settings_current.full_screen_panorama ) {
557+ static const float FULL_IMAGE_RATIO = 4 .0f / 3 .0f ;
558+ float viewRatio = rect.size .width / (float )rect.size .height ;
559+
560+ horizontal_margin = 0 .0f ;
561+ vertical_margin = 0 ;
562+
563+ if ( viewRatio > FULL_IMAGE_RATIO ) {
564+ float widthScale = FULL_IMAGE_RATIO / viewRatio;
565+ contentX0 = -widthScale;
566+ contentX1 = widthScale;
567+ } else if ( viewRatio < FULL_IMAGE_RATIO ) {
568+ float heightScale = viewRatio / FULL_IMAGE_RATIO;
569+ contentY0 = heightScale;
570+ contentY1 = -heightScale;
571+ }
572+ }
573+
521574 float fw = (float )cur->full_width ;
522575 float fh = (float )cur->full_height ;
523576 float u0 = (cur->image_xoffset - horizontal_margin) / fw;
@@ -526,7 +579,8 @@ the vertical (top/bottom) margin in pixels and writes the horizontal
526579 float v1 = (cur->image_height + cur->image_yoffset - vertical_margin) / fh;
527580
528581 DisplayVertex mainVerts[6 ];
529- fill_quad ( mainVerts, -1 .0f , 1 .0f , 1 .0f , -1 .0f , u0, v0, u1, v1 );
582+ fill_quad ( mainVerts, contentX0, contentY0, contentX1, contentY1,
583+ u0, v0, u1, v1 );
530584
531585 id <MTLCommandBuffer > cmdBuf = [commandQueue commandBuffer ];
532586 id <MTLRenderCommandEncoder > encoder =
@@ -537,7 +591,9 @@ the vertical (top/bottom) margin in pixels and writes the horizontal
537591 [encoder setFragmentTexture: screenTexMTL[currentScreenTex] atIndex: 0 ];
538592 [encoder drawPrimitives: MTLPrimitiveTypeTriangle vertexStart: 0 vertexCount: 6 ];
539593
540- if ( settings_current.statusbar ) [self encodeIconOverlay: encoder];
594+ if ( settings_current.statusbar )
595+ [self encodeIconOverlay: encoder contentX0: contentX0 contentY0: contentY0
596+ contentX1: contentX1 contentY1: contentY1];
541597
542598 [encoder endEncoding ];
543599 [cmdBuf presentDrawable: drawable];
@@ -1077,6 +1133,7 @@ -(void) mouseMoved:(NSEvent *)theEvent
10771133
10781134-(void ) mouseDown : (NSEvent *)theEvent
10791135{
1136+ [[self window ] makeFirstResponder: self ];
10801137 [proxy_emulator mouseDown: theEvent];
10811138}
10821139
0 commit comments