From 3d310c077c576415bec88db75da3ab2d6fd2792a Mon Sep 17 00:00:00 2001
From: Ben Avison <bavison@gitlab.riscosopen.org>
Date: Thu, 30 Mar 2000 14:38:39 +0000
Subject: [PATCH] System windows (eg STB command window) can now have window
 furniture but no 1-pixel borders.

Detail:
  The code that checked for a Wimp_Initialise version number of >= 380 before
  applying the new interpretation of title foreground colour &FF was broken:
  it was checking the current task handle instead of the task handle of the
  window's creator. A few other things needed tampering with in order to ensure
  that the window's task handle word is correctly set up at the time that the
  colour check is performed.
Admin:
  Tested in a desktop build, using STB resources.

Version 4.43. Tagged as 'Wimp-4_43'
---
 VersionASM |  8 ++++----
 VersionNum | 14 +++++++-------
 s/Iconbar  |  6 ++++--
 s/Wimp01   |  1 +
 s/Wimp02   |  8 +++++---
 s/Wimp05   |  7 ++++---
 6 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/VersionASM b/VersionASM
index 1a5765f..328adcd 100644
--- a/VersionASM
+++ b/VersionASM
@@ -6,9 +6,9 @@
                         GBLS    Module_MinorVersion
                         GBLS    Module_Date
                         GBLS    Module_FullVersion
-Module_MajorVersion     SETS    "4.42"
-Module_Version          SETA    442
+Module_MajorVersion     SETS    "4.43"
+Module_Version          SETA    443
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "29 Mar 2000"
-Module_FullVersion      SETS    "4.42"
+Module_Date             SETS    "30 Mar 2000"
+Module_FullVersion      SETS    "4.43"
                         END
diff --git a/VersionNum b/VersionNum
index b748ee2..f7524a8 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,15 +1,15 @@
-/* (4.42)
+/* (4.43)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        4.42
+#define Module_MajorVersion_CMHG        4.43
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                29 Mar 2000
+#define Module_Date_CMHG                30 Mar 2000
 
-#define Module_MajorVersion             "4.42"
-#define Module_Version                  442
+#define Module_MajorVersion             "4.43"
+#define Module_Version                  443
 #define Module_MinorVersion             ""
-#define Module_Date                     "29 Mar 2000"
+#define Module_Date                     "30 Mar 2000"
 
-#define Module_FullVersion              "4.42"
+#define Module_FullVersion              "4.43"
diff --git a/s/Iconbar b/s/Iconbar
index db24c02..f84d308 100644
--- a/s/Iconbar
+++ b/s/Iconbar
@@ -274,10 +274,12 @@ createsystemp
         Debug   systmpl,"Loading template to",userblk
 
         BLVC    int_load_template
+        MOVVC   R14, #0                 ; created window will be 'owned' by Wimp
+        STRVC   R14, createwindowtaskhandle
         BLVC    int_create_window       ; R0,handle = window handles (if V clr)
+        MOV     R14, #1                 ; subsequent windows are 'owned' by their creators
+        STR     R14, createwindowtaskhandle
 
-        MOVVC   R14,#0
-        STRVC   R14,[handle,#w_taskhandle]      ; 'owned' by Wimp
         MOVVC   R14,#1
         STRVC   R14,[handle,#w_areaCBptr]       ; use common sprite pool
 98
diff --git a/s/Wimp01 b/s/Wimp01
index ae54436..c7316be 100644
--- a/s/Wimp01
+++ b/s/Wimp01
@@ -943,6 +943,7 @@ polltaskhandle  #       4               ; task handle on entry to Wimp_Poll
 menutaskhandle  #       4               ; task handle of menu owner
 nulltaskhandle  #       4               ; for cycling null events
 singletaskhandle   #    4               ; single = taskhandle if 1-tasking
+createwindowtaskhandle # 4              ; if <= 0, this is used to fill in w_taskhandle (else current taskhandle is used)
 inithandle      #       4               ; "owner" slot if [freepool] = -1
 taskcount       #       4               ; number of active tasks
 tasknumber      #       4               ; global task number (monotonic)
diff --git a/s/Wimp02 b/s/Wimp02
index 7fd83a3..dd02dd4 100644
--- a/s/Wimp02
+++ b/s/Wimp02
@@ -3617,8 +3617,10 @@ crw5    LDR     R0,[R14],#4
         BLO     crw5
 crw5e
 
-        LDR     R14,taskhandle
-        STR     R14,[handle,#w_taskhandle]
+        LDR     R14, createwindowtaskhandle
+        CMP     R14, #0
+        LDRGT   R14, taskhandle
+        STR     R14, [handle, #w_taskhandle]
 
       [ ChildWindows
         ASSERT  lh_forwards=0 :LAND: lh_indicator=4 :LAND: lh_backwards=8
@@ -3747,7 +3749,7 @@ bodgewindowflags
         LDRNE   R14,[handle,#w_flags]           ; ... cancel all border bits
         BNE     %FT01
 
-        LDR     R14,taskhandle                  ; but only if task doesn't know about Wimp 3.80
+        LDR     R14,[handle,#w_taskhandle]      ; but only if task doesn't know about Wimp 3.80
         CMP     R14,#0
         MOVLE   R14,#380                        ; treat the system task as knowing what to do
         LDRGT   R14,[wsptr,R14]
diff --git a/s/Wimp05 b/s/Wimp05
index fc53d68..296af4c 100644
--- a/s/Wimp05
+++ b/s/Wimp05
@@ -3476,7 +3476,11 @@ int_create_menu_withscroll
 
 createsubmenu TraceL sc
         ADRL    userblk,menuwindow      ; window 'template'
+        MOV     R14, #-1                ; created window will be 'owned' by the Wimp
+        STR     R14, createwindowtaskhandle
         BL      int_create_window
+        MOV     R14, #1                 ; subsequent windows are 'owned' by their creators
+        STR     R14, createwindowtaskhandle
         STRVC   R0,menuhandle
         [       debug :LAND: debugmenuw
         BVS     createsubmenu_continue1
@@ -3486,9 +3490,6 @@ createsubmenu_continue1
         Trace   menuw, "not storing task handle -1 at w_taskhandle of window ", X, R0
 createsubmenu_continue2
         ]
-        MOVVC   R14,#-1                 ; menus have task handle -1
-        BIC     R0, R0, #3 ;make sure R0 is word aligned ; }
-        STRVC   R14, [R0, #w_taskhandle]                 ; } was STRVC   R14, [handle, #w_taskhandle]
 
 exitcrmenu
         Pull    "R1-R4,userblk,PC",VS   ; error
-- 
GitLab