diff --git a/Chapters/ch05-does-order-matter.xml b/Chapters/ch05-does-order-matter.xml index 85342b1..ec1c639 100644 --- a/Chapters/ch05-does-order-matter.xml +++ b/Chapters/ch05-does-order-matter.xml @@ -83,7 +83,6 @@ SYS "Wimp_OpenWindow",,toolbox%

The full code for our new PROChandle_pane_windows() can be seen in , and it’s a lot simpler than the version seen in .

- DEF PROChandle_pane_windows(main%) LOCAL toolbar% @@ -112,7 +111,14 @@ toolbar%!28 = main%!28 SYS "Wimp_OpenWindow",,toolbar% ENDPROC -

A complete copy of the new application can be found in . When run, it might perform in a very similar way to from the previous chapter... or it might not.

+

Now that PROChandle_pane_windows() doesn’t open the main window, we will also need to make a small change to PROCopen_main_window so that it does that task for itself. The change is simply adding a call to Wimp_OpenWindow before the call to PROChandle_pane_windows(), at the end of the procedure.

+ +q%!28 = -1 : REM Window to open behind (-1 is top of stack) + +SYS "Wimp_OpenWindow",,q% +PROChandle_pane_windows(q%) + +

With all of these changes in place, a complete copy of the new application can be found in . When run, it might perform in a very similar way to from the previous chapter... or it might not.

@@ -152,9 +158,9 @@ ENDPROC
-A question of optimisation +A question of efficiency -

The small difference described in the previous section matters, because of a small change introduced as part of the Nested Wimp. A couple of the changes documented in the Nested Window Manager Functional Specification are “Redraw Optimisation” and improvements to the “Invalid Rectangle Handling”. Between them, these have a big impact on the handling of panes.

+

The difference described in the previous section matters, because of a small improvement introduced as part of the Nested Wimp. A couple of the changes documented in the Nested Window Manager Functional Specification are “Redraw Optimisation” and improvements to the “Invalid Rectangle Handling”. Between them, these have a big impact on the handling of panes.

When an application calls Wimp_OpenWindow, the window in question isn’t immediately opened. Instead, the details are logged in a list of pending updates along with any other windows to be opened or closed – which are all actioned after the application next calls Wimp_Poll. This means that when our application opens its main window and toolbar pane, both windows will be updated together after control has returned to the Wimp.

@@ -162,6 +168,27 @@ ENDPROC

What this means in practice is that the Nested Wimp will notice that despite the toolbar pane ending up behind the main window in , it ends up back in from in – and so there’s no point redrawing the main window during the short period that it is on top.

+

On earlier versions of the Wimp, however, our new optimised approach will result in the main window and its toolbar pane following the sequence shown in on every Open_Window_Request event. This produces a very visible flickering effect.

+ + +
+ + +
+Is it any use? + +

Given all of this, is the optimisation described in this chapter of any use? The answer is “yes,” but probably not in all circumstances.

+ +

If an application needs the Nested Wimp for some other reason, and will not run without it, then there’s no harm in relying on the redraw optimisation in order to simplify the pane handling code. However, it’s also worth remembering that the Nested Wimp will deal with many pane requirements – including those in this chapter – directly, with no need for any custom event handling; we’ll see how this works in the next chapter. The main omission is for panes which fall outside the outline of the parent window, such as the side toolbox that we created in .

+ +

For applications which do not need the Nested Wimp for other reasons, and would otherwise work fine back to RISC OS 3 or earlier, it seems a shame to restrict their compatibility for no good reason. Save for the situation when the window first opens, the more compatible solution is no less efficient than this optimised one: they both call Wimp_OpenWindow once for the main window and once for each pane.

+ +

If you do use the optimisation, though, it’s a good idea to check for its presence in the !Run of the application using an *RMEnsure.

+ +RMEnsure WindowManager 3.80 Error PaneDemo requires the Nested Window Manager. + + +
\ No newline at end of file diff --git a/Downloads/Chapter05/ColHead3/!PaneDemo/!RunImage,ffb b/Downloads/Chapter05/ColHead3/!PaneDemo/!RunImage,ffb index bc4dc16..700ef6e 100644 Binary files a/Downloads/Chapter05/ColHead3/!PaneDemo/!RunImage,ffb and b/Downloads/Chapter05/ColHead3/!PaneDemo/!RunImage,ffb differ diff --git a/Images/Chapter05/order-pane-switch.png b/Images/Chapter05/order-pane-switch.png new file mode 100644 index 0000000..77ef576 Binary files /dev/null and b/Images/Chapter05/order-pane-switch.png differ