[haiku-development] Re: BWindow fShowLevel vs window_info.show_hide_level

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 14 Aug 2012 11:48:47 -0400

On Tue, Aug 14, 2012 at 3:07 AM, Simon Taylor <simontaylor1@xxxxxxxxxxxx> wrote:
>
> I find the show_hide_level/AS_SHOW_HIDE_WINDOW naming very confusing.

Well the first name is something which we inherited from BeOS, and
really it better represents what the variable is than show_level.

I decided to make one AS_SHOW_HIDE_WINDOW message because both
messages were sending BWindow's fShowLevel, and the actual hiding and
showing of the window is based on that value. If you see the code it
will make more sense. Would AS_SHOW_OR_HIDE_WINDOW make more sense?

> Additionally with your changes when fShowLevel in BWindow is positive the
> window is hidden? That's definitely backwards. I have no intuition about
> what is forward and backward when a variable name includes two completely
> opposite terms!

This was my first thought too. If you read back to the start of this
thread I was confused about the show_hide_level in the app_server
being opposite of fShowLevel in BWindow. Having tested on BeOS, this
is indeed how it works, 0 or less is shown, 1 or more is hidden. Also
as noted in my last email in this thread, BView has a similar variable
fShowLevel which is also seemingly backwards in the same way (the
Haiku BView has done it this way for a while I think.) At this point
this may just be what we have to deal with for BeOS compatibility. But
overall the only things which will see the actual value of this
variable from BWindow are Deskbar and other internal applications
because the get_window_info function is a private API.

Though for BView the fShowLevel is archived as _show, so in a sense we
are stuck with that to maintain archive compatibility. I think it is
more important to be internally consistent than to make the variable
behave in a more sensible way. I'm not sure what the BeOS guys were
thinking, but for now I think we just have to deal with it.

> Can we change the name of the one in app_server without
> affecting binary compatability?

If you mean the fShowLevel I introduced in app_server's window class,
yes it could be changed to fHideLevel or maybe fVisibilityLevel.
Though having understood the code I don't think it matters that much,
and if we rename it in the app_server I'd like to rename it in BWindow
and Bview too. If it helps I've added comments in a few places which
should help future Haiku developers figure this out faster. But
overall I don't expect this to need to be changed until after R1 when
we could choose to reverse its meaning and break compatibility.

-- 
Regards,
Ryan

Other related posts: