From f3473495d0ecc61e4d768e88759e9a7f9a263770 Mon Sep 17 00:00:00 2001
From: Andrew <18502096+classicrocker883@users.noreply.github.com>
Date: Wed, 22 Nov 2023 03:19:29 -0500
Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Fixes=20for=20ProUI=20popup,=20a?=
 =?UTF-8?q?bort=20(#26308)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/core/serial_hook.h                     |  4 ++--
 Marlin/src/lcd/e3v2/proui/dwin.cpp                | 15 ++++++++++++++-
 Marlin/src/lcd/e3v2/proui/dwin_popup.h            |  8 +++++++-
 Marlin/src/lcd/e3v2/proui/menus.h                 |  2 +-
 Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp     |  2 +-
 .../src/sd/usb_flashdrive/lib-uhs2/parsetools.h   |  2 +-
 buildroot/tests/STM32F103RE_creality              |  2 +-
 7 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h
index 65c553c7025..06efce1dc5f 100644
--- a/Marlin/src/core/serial_hook.h
+++ b/Marlin/src/core/serial_hook.h
@@ -179,7 +179,7 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
   // Append Hookable for this class
   SerialFeature features(serial_index_t index) const  { return SerialFeature::Hookable | CALL_IF_EXISTS(SerialFeature, static_cast<const SerialT*>(this), features, index);  }
 
-  void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) {
+  void setHook(WriteHook writeHook=0, EndOfMessageHook eofHook=0, void * userPointer=0) {
     // Order is important here as serial code can be called inside interrupts
     // When setting a hook, the user pointer must be set first so if writeHook is called as soon as it's set, it'll be valid
     if (userPointer) this->userPointer = userPointer;
@@ -292,7 +292,7 @@ struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME)
   #define _S_REFS(N) Serial##N##T & serial##N,
   #define _S_INIT(N) ,serial##N (serial##N)
 
-  MultiSerial(REPEAT(NUM_SERIAL, _S_REFS) const SerialMask mask = ALL, const bool e = false)
+  MultiSerial(REPEAT(NUM_SERIAL, _S_REFS) const SerialMask mask=ALL, const bool e=false)
     : BaseClassT(e), portMask(mask) REPEAT(NUM_SERIAL, _S_INIT) {}
 
 };
diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp
index a6cc1613ef0..341521ee84f 100644
--- a/Marlin/src/lcd/e3v2/proui/dwin.cpp
+++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp
@@ -1713,6 +1713,18 @@ void dwinPrintFinished() {
 
 // Print was aborted
 void dwinPrintAborted() {
+  #ifndef EVENT_GCODE_SD_ABORT
+    if (all_axes_homed()) {
+      queue.inject(
+        #if ENABLED(NOZZLE_PARK_FEATURE)
+          F("G27")
+        #else
+          TS(F("G0Z"), float(_MIN(current_position.z + (Z_POST_CLEARANCE), Z_MAX_POS)), F("\nG0F2000Y"), Y_MAX_POS);
+        #endif
+      );
+    }
+  #endif
+  hostui.notify("Print Aborted");
   dwinPrintFinished();
 }
 
@@ -2226,7 +2238,8 @@ void setMoveZ() { hmiValue.axis = Z_AXIS; setPFloatOnClick(Z_MIN_POS, Z_MAX_POS,
 #endif
 
 #if LCD_BACKLIGHT_TIMEOUT_MINS
-  void setTimer() { setPIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max); }
+  void applyTimer() { ui.backlight_timeout_minutes = menuData.value; }
+  void setTimer() { setIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max, ui.backlight_timeout_minutes, applyTimer); }
 #endif
 
 #if HAS_FILAMENT_SENSOR
diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h
index ee8664e874d..d970cbfef47 100644
--- a/Marlin/src/lcd/e3v2/proui/dwin_popup.h
+++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h
@@ -50,9 +50,15 @@ inline void drawPopupBkgd() {
 
 template<typename T, typename U>
 void dwinDrawPopup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
+  xy_uint8_t pos;
+  switch (icon) {
+    default: pos.set(81, 90); break;          // Icon  1 -  8, 90 - 91; (110 x 100)
+    case 17 ... 24: pos.set(96, 90); break;   // Icon 17 - 24;          ( 80 x 100)
+    case 78 ... 81: pos.set(100, 107); break; // Icon 78 - 81;          ( 73 x  66)
+  }
   DWINUI::clearMainArea();
   drawPopupBkgd();
-  if (icon) DWINUI::drawIcon(icon, 101, 105);
+  if (icon) DWINUI::drawIcon(icon, pos.x, pos.y);
   if (amsg1) DWINUI::drawCenteredString(hmiData.colorPopupTxt, 210, amsg1);
   if (amsg2) DWINUI::drawCenteredString(hmiData.colorPopupTxt, 240, amsg2);
   if (button) DWINUI::drawButton(button, 86, 280);
diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h
index be0c8817600..d1f5cdb698b 100644
--- a/Marlin/src/lcd/e3v2/proui/menus.h
+++ b/Marlin/src/lcd/e3v2/proui/menus.h
@@ -93,7 +93,7 @@ public:
   MenuItem(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
   MenuItem(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr);
   void setFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
-  void setCaption(const char * const text = nullptr);
+  void setCaption(const char * const text=nullptr);
 };
 
 class MenuItemPtr: public MenuItem {
diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp
index 75421f4482a..889b8560aa0 100644
--- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp
+++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp
@@ -215,7 +215,7 @@ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *
   return InTransfer(pep, nak_limit, nbytesptr, data, bInterval);
 }
 
-uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) {
+uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval/*=0*/) {
   uint8_t rcode = 0;
   uint8_t pktsize;
 
diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h
index 403766da8ff..21c6cd49517 100644
--- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h
+++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h
@@ -141,5 +141,5 @@ public:
     theParser.Initialize(p);
   }
 
-  bool Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = nullptr);
+  bool Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me=nullptr);
 };
diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality
index 09206c10503..ad80605e61f 100755
--- a/buildroot/tests/STM32F103RE_creality
+++ b/buildroot/tests/STM32F103RE_creality
@@ -24,7 +24,7 @@ opt_enable DWIN_MARLINUI_LANDSCAPE LCD_ENDSTOP_TEST AUTO_BED_LEVELING_UBL BLTOUC
 exec_test $1 $2 "Ender-3 v2 - MarlinUI (UBL+BLTOUCH, MPCTEMP, LCD_ENDSTOP_TEST)" "$3"
 
 use_example_configs "Creality/Ender-3 S1/STM32F1"
-opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CANCEL_OBJECTS FWRETRACT
+opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CANCEL_OBJECTS FWRETRACT EVENT_GCODE_SD_ABORT
 opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT STATUS_MESSAGE_SCROLLING \
            SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \
            BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU LCD_BED_TRAMMING \