From ac4dd020bfde516f2b468f43f239cb22e3dfe7c5 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 20 Feb 2021 10:55:40 +0300 Subject: [PATCH] OpenCanopy: Fix switching to graphics mode when entering canopy closes acidanthera/bugtracker#1512 --- Changelog.md | 1 + Platform/OpenCanopy/OcBootstrap.c | 65 +++++++++++++++++++++--------- Platform/OpenCanopy/OpenCanopy.inf | 1 + 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Changelog.md b/Changelog.md index 59a7176e..3f32d1c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ OpenCore Changelog - Added workaround for firmware not specifying DeviceHandle at bootstrap - Added support for R/O page tables in `SetupVirtualMap` quirk - Added OEM preservation for certain Apple SMBIOS tables +- Fixed switching to graphics mode when entering OpenCanopy #### v0.6.6 - Added keyboard and pointer entry scroll support in OpenCanopy diff --git a/Platform/OpenCanopy/OcBootstrap.c b/Platform/OpenCanopy/OcBootstrap.c index bb125a0c..d19d2b67 100644 --- a/Platform/OpenCanopy/OcBootstrap.c +++ b/Platform/OpenCanopy/OcBootstrap.c @@ -33,9 +33,48 @@ extern BOOT_PICKER_GUI_CONTEXT mGuiContext; extern CONST GUI_IMAGE mBackgroundImage; +STATIC GUI_DRAWING_CONTEXT mDrawContext; +STATIC EFI_CONSOLE_CONTROL_SCREEN_MODE mPreviousMode; + +STATIC +EFI_STATUS +OcShowMenyByOcEnter ( + IN OC_BOOT_CONTEXT *BootContext + ) +{ + EFI_STATUS Status; + + Status = GuiLibConstruct ( + BootContext->PickerContext, + mGuiContext.CursorDefaultX, + mGuiContext.CursorDefaultY + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Extension for OpenCore builtin renderer to mark that we control text output here. + // + gST->ConOut->TestString (gST->ConOut, OC_CONSOLE_MARK_CONTROLLED); + mPreviousMode = OcConsoleControlSetMode (EfiConsoleControlScreenGraphics); + + return EFI_SUCCESS; +} + STATIC -GUI_DRAWING_CONTEXT -mDrawContext; +VOID +OcShowMenyByOcLeave ( + VOID + ) +{ + GuiLibDestruct (); + // + // Extension for OpenCore builtin renderer to mark that we no longer control text output here. + // + gST->ConOut->TestString (gST->ConOut, OC_CONSOLE_MARK_UNCONTROLLED); + OcConsoleControlSetMode (mPreviousMode); +} EFI_STATUS EFIAPI @@ -56,20 +95,11 @@ OcShowMenuByOc ( mGuiContext.PickerContext = BootContext->PickerContext; mGuiContext.AudioPlaybackTimeout = -1; - Status = GuiLibConstruct ( - BootContext->PickerContext, - mGuiContext.CursorDefaultX, - mGuiContext.CursorDefaultY - ); + Status = OcShowMenyByOcEnter (BootContext); if (EFI_ERROR (Status)) { return Status; } - // - // Extension for OpenCore builtin renderer to mark that we control text output here. - // - gST->ConOut->TestString (gST->ConOut, OC_CONSOLE_MARK_CONTROLLED); - // // Do not play intro animation for blind. // @@ -83,7 +113,7 @@ OcShowMenuByOc ( InternalGetCursorImage ); if (EFI_ERROR (Status)) { - GuiLibDestruct (); + OcShowMenyByOcLeave (); return Status; } @@ -95,7 +125,7 @@ OcShowMenuByOc ( Index == BootContext->DefaultEntry->EntryIndex - 1 ); if (EFI_ERROR (Status)) { - GuiLibDestruct (); + OcShowMenyByOcLeave (); return Status; } } @@ -138,12 +168,7 @@ OcShowMenuByOc ( // GuiClearScreen (&mDrawContext, mBackgroundImage.Buffer); BootPickerViewDeinitialize (&mDrawContext, &mGuiContext); - GuiLibDestruct (); - - // - // Extension for OpenCore builtin renderer to mark that we no longer control text output here. - // - gST->ConOut->TestString (gST->ConOut, OC_CONSOLE_MARK_UNCONTROLLED); + OcShowMenyByOcLeave (); *ChosenBootEntry = mGuiContext.BootEntry; BootContext->PickerContext->HideAuxiliary = mGuiContext.HideAuxiliary; diff --git a/Platform/OpenCanopy/OpenCanopy.inf b/Platform/OpenCanopy/OpenCanopy.inf index 64d1bc62..4654b756 100644 --- a/Platform/OpenCanopy/OpenCanopy.inf +++ b/Platform/OpenCanopy/OpenCanopy.inf @@ -71,6 +71,7 @@ MtrrLib OcAppleKeyMapLib OcCompressionLib + OcConsoleLib OcGuardLib OcMiscLib OcPngLib -- GitLab