Tiny fix or...?

I’m looking at the small apps included with haiku source (ActivityMonitor and MediaPlayer the most) and learning how to program the OS.
The reason for my curiosity was born from this:

as I needed to tweak the monitor settings and I think new windows should not appear off screen.

On a side this is a very trivial issue to fix (the dialog has fixed coordinates) but on the other hand should an OS aim towards a general solution?
I mean, should the BScreen class include some methods to easily check and move new windows/dialogs before showing them?
(so to have a workflow “create a rectangle for a new window” → “ask the current Screen to check the coordinates and move the window into visible area” → “fill the windowwith widgets/whatever”)

3 Likes

There are already various CenterOnScreen and MoveOnScreen functions in BWindow which you can use for this.

https://cgit.haiku-os.org/haiku/tree/headers/os/interface/Window.h#n176

In this case it makes sense to use CenterIn() with the parent window’s frame, or maybe the specific graph’s view frame converted to screen coordinates.

1 Like

Great, thanks!