Categories
Coding Experience Technical

A background window

Greetings everybody. Welcome to yet another blog post for this week’s work, before starting I would like to express that since my university is started, progress is slowed down! So expect fewer PRs than in previous weeks! (Although trying to catch up on weekends)

So what’s in for this week? This week I am highlighting my work on MacWindows and explaining this new thing implemented that is called “background window”

To understand this, let’s start from the very basics, what is the window for Director Engine?

MacWindows – Why, What are they?

Director engine was first created for Pre-OSX Macintosh computers, thereby the headline being “MacWindows”, so basically, In director we say a window is a place where things happen (ie animations, object movie, you click things) this is like any other typical window that you encounter but with a catch!

They are mac window! Since the original director was built for Machintosh computers, We at scummvm needed to build a subsystem of graphics that wholly dedicate to Mac GUI and elements (ie we simulate a mac-desktop-experience), So we have separate code that mimics the look and feel of MacGUI (buttons, menu, borders etc), these are in “graphics/macgui” folder!

And while simulating the behavior, I mean we build everything from scratch, ie mac styled windows, a window manager that takes care of focusing, switching of windows (for example you click a window and it comes to foreground, etc), We even implement borders and other macgui components, Cool right? I’d say complex!

Now how is this all information even related to Director Engine?

Well… because

Window in Director Engine

Window in director engine uses a derived version of macwindow, and it uses the macgui codepaths for all its events handling/etc related to it! That’s why you can say that our director engine is fully dependent upon macgui for it to work! But what was the problem with existing code?

Well, the problem was…. like any window in machintosh computers, if you click outside window, it will lose it’s focus, if you have two overlapping windows and you click one of those, then one window will come foreground and hide another window! And that exactly was our problem!

There were some lingo commands where multiple windows were to be created in game, now it was all good and fine when there’s only one active window, however the moment we switch to multi-window environment we observed a peculiarity, that is: the hiding of windows due to director engine!

Since both director engine and the newly created window are same kind of windows, therefore if you click on director window anywhere except newly created window, then it will hide in the background (Couldn’t understand? See the gif below!)

 

The Fix? It was simple, to declare the main director window as a kind of background window, so when you click anywhere in background window, it doesn’t make it comes front of other windows on screen! This simple change fixed it all and the final result was:

See how the window is no longer hiding when clicking on title “ball” button? Well, there ya got it!

Link to PR – #5221

More work this week

Scoped and Scopeless Lingo Score

This was a problem with old (pre D4) created movies when used in Director 4, since previously there was scopeless lingo commands, and now director have scoped window, therefore there was some behaviour mismatch, It was fixed with some debugging.

Link to PR – #5216

Improve checking for recursive enterFrame

This was a problem with how checks for how many recursive enterFrame is called was performed, in director 4, you can have at most depth of 2 enterFrame calls, any more and it will ignore the handler! This was previously implemented with counting frozen lingo states, which was not enough to identify since lingo can be frozen for other situations as well.

Fixed it by having proper checking and counting of number of enterFrames in callstack.

Link to PR – #5233

The End

Thank you for reading so far, I hope it was a good read! As usual apologies for any grammatical/writing mistake, do comment our your honest suggestions/thoughts on this and with that being said, see you next week!

4 replies on “A background window”

Hey, observe closely, the videos look identical but they are not! In first one when you click on somewhere outside the opened window it minimise, whereas in second one, it doesn’t minimise even after clicking outside!

no, they are indeed identical. You uploaded the same video twice.
The linked Videos have the same filename, with a “-1” added to one of them.
Downloading both shows the same crc32.
They are identical.

Leave a Reply

Your email address will not be published. Required fields are marked *