|
For when a pint glass isn't big enough for a pint...
Last post 02-08-2013 6:50 PM by ender. 43 replies.
-
02-01-2013 11:51 AM
|
|
-
RaceProUK


- Joined on 06-24-2010
- Reality
- Posts 159
|
For when a pint glass isn't big enough for a pint...
Method signature is: public static void SetZIndex(UIElement element, Int32 value) The max value you can pass in is:
Int16.MaxValue – 1 = 32766 WTF1: You can pass out of range values without knowing. WTF2: The max is one less than Int16.MaxValue. Silverlight is a cluster of WTFs, but this is the most blatant I've ever seen.
[blakeyrat] NOBODY expects the Slashdot inquisition!
|
|
-
-
Someone You Know


- Joined on 06-08-2007
- Posts 769
|
Re: For when a pint glass isn't big enough for a pint...
Dare I ask what the minimum value you can pass in is?
|
|
-
-
JimLahey


- Joined on 09-30-2010
- Posts 87
|
Re: For when a pint glass isn't big enough for a pint...
For when a pint glass isn't big enough for a pint... If you're in Switzerland for example, a pint in a touristy English pub is only 500ml. It'll cost you over £7 as well, the bloody cheek of it.
|
|
-
-
blakeyrat


- Joined on 10-29-2008
- Posts 8,614
|
Re: For when a pint glass isn't big enough for a pint...
What happens if you pass in a too-big value? Exception or truncation? Also what's the MINIMUM value? Isn't that pretty important to know?
The "one less than Int16.MaxValue" doesn't seem like too big a deal... it just means they're using Int16.MaxValue as a flag or constant or something. Using Int32 in the function definition might mean the minimum value is Int32.MinValue = -2,147,483,648. For all we know.
 <- I couldn't make my shit work, so here's a Godzilla head. "There is no such thing as a diet." - Lorne Kates
|
|
-
-
MiffTheFox


- Joined on 07-03-2008
- Posts 978
|
Re: For when a pint glass isn't big enough for a pint...
This isn't a WTF, but it's a work around for a WTF in the CLR or maybe just C#: It doesn't like you working with integral types smaller then Int32.
Consider if it was an Int16 and you tried the following code:
SetZIndex(element, baseValue + 1)
Compilation error! baseValue + 5 is treated as in int, even if baseValue is a short.
Even if it's two shorts you're using, nope! The operator + is defined only on Int32 and not on anything smaller. C# will upcast shorts to ints all it wants, but won't downcast them implicitly. I learned this lesson working with some third party code (forgot which) that required me to use bytes and binary operations.
The takeaway: Don't muck around with shorts and bytes unless they're absolutely necessary. This is TRWTF, and why this example isn't a WTF by itself.
[Sanity Not Available until further notice. The trolls have won.]
|
|
-
-
BC_Programmer


- Joined on 10-08-2009
- Posts 230
|
Re: For when a pint glass isn't big enough for a pint...
There are no IL opcodes that perform short or byte addition. This is why it get's upcast. I think the reasoning for not having those operands was because it was unlikely that they would ever be faster than the 32-bit equivalent- most processors work with at least 32-bit register, and while the CLR is designed as a platform independent specification, there is an implicit assumption that the platform is relatively modern- eg. uses at least 32-bit operations.
|
|
-
-
RaceProUK


- Joined on 06-24-2010
- Reality
- Posts 159
|
Re: For when a pint glass isn't big enough for a pint...
blakeyrat:What happens if you pass in a too-big value? Exception or truncation? Also what's the MINIMUM value? Isn't that pretty important to know?
Exception, no documented minimum.
But let's focus on the core issue - someone chose that max value, when it would have been trivial to just say the value is Int32, avoiding all the problems described in my first post.
[blakeyrat] NOBODY expects the Slashdot inquisition!
|
|
-
-
FrostCat


- Joined on 02-21-2005
- Posts 338
|
Re: For when a pint glass isn't big enough for a pint...
GDI used to have limitations that windows couldn't be more than 32767 pixels wide, a holdover from win16. Of what value is a Z greater than that?
Doesn't answer why the limit here is 2^16 - 1 as opposed to one greater, of course.
|
|
-
-
flabdablet


- Joined on 04-09-2011
- Posts 448
|
Re: For when a pint glass isn't big enough for a pint...
FrostCat:Doesn't answer why the limit here is 2^16 - 1 as opposed to one greater, of course.
That's two off-by-one errors for the price of 2^1 - 1!
|
|
-
-
Cat


- Joined on 07-24-2010
- Posts 115
|
Re: For when a pint glass isn't big enough for a pint...
FrostCat:GDI used to have limitations that windows couldn't be more than 32767 pixels wide, a holdover from win16. Of what value is a Z greater than that?
Doesn't answer why the limit here is 2^16 - 1 as opposed to one greater, of course. Possible that the last value is reserved for overlays / "always on top" or some other special case.
|
|
-
-
flabdablet


- Joined on 04-09-2011
- Posts 448
|
Re: For when a pint glass isn't big enough for a pint...
How is "always on top" conceptually different from "has the highest possible Z index"?
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
flabdablet:How is "always on top" conceptually different from "has the highest possible Z index"? I asked your wife that. Apparently she doesn't know too much CSS.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
flabdablet:How is "always on top" conceptually different from "has the highest possible Z index"? You're confusing the desired result with an implementation detail.
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
FrostCat


- Joined on 02-21-2005
- Posts 338
|
Re: For when a pint glass isn't big enough for a pint...
flabdablet:How is "always on top" conceptually different from "has the highest possible Z index"?
Because "always on top" means just that. No other window can go higher than it. By contrast, two windows that are otherwise at the highest z-value would be at the same height.. That could be implemented by, for example, reserving Int16Max to mean "always on top."
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 1,143
|
Re: For when a pint glass isn't big enough for a pint...
FrostCat: flabdablet:How is "always on top" conceptually different from "has the highest possible Z index"?
Because "always on top" means just that. No other window can go higher than it. By contrast, two windows that are otherwise at the highest z-value would be at the same height.. That could be implemented by, for example, reserving Int16Max to mean "always on top."
How is that different than having two windows that are "always on top"?
I spend most of my life pressing buttons to make the pattern of lights change however I want.
|
|
-
-
Someone You Know


- Joined on 06-08-2007
- Posts 769
|
Re: For when a pint glass isn't big enough for a pint...
joe.edwards: FrostCat: flabdablet:How is "always on top" conceptually different from "has the highest possible Z index"?
Because "always on top" means just that. No other window can go higher than it. By contrast, two windows that are otherwise at the highest z-value would be at the same height.. That could be implemented by, for example, reserving Int16Max to mean "always on top."
How is that different than having two windows that are "always on top"?
Because a window that's at the highest possible z-index isn't necessarily "always on top". It may be a normal window that just happens to be on top (and there are no "always on top" windows present).
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 1,143
|
Re: For when a pint glass isn't big enough for a pint...
OK, let's say we have two windows that are "always on top". We'll call the first one Unstoppable Force and the second one Immovable Object. You move Unstoppable Force to the same position as Immovable Object. What happens?
Now, repeat this experiment with two windows that are not "always on top" but just have the highest possible z-index. Does something else happen?
Do they behave differently with windows that do not have maximum z-index or "always on top" bit set? These two scenarios seem functionally identical to me.
Edit: I would note that the context of this is a Silverlight application, in which I assume windows don't change z-index unless you programmatically change the z-index (ie not as a result of user interaction).
I spend most of my life pressing buttons to make the pattern of lights change however I want.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
joe.edwards:OK, let's say we have two windows that are "always on top". I'd have thought "always on top" was a property that could only be applied to one object, meaning nothing could overlap that.
|
|
-
-
Scarlet Manuka


- Joined on 09-23-2008
- Posts 622
|
Re: For when a pint glass isn't big enough for a pint...
joe.edwards:OK, let's say we have two windows that are "always on top". We'll call the first one Unstoppable Force and the second one Immovable Object. You move Unstoppable Force to the same position as Immovable Object. What happens?
Raymond Chen writes another article for his blog, and a year or two later when it reaches the front of the queue the rest of us see it.
|
|
-
-
DaveK


- Joined on 02-22-2006
- Posts 2,057
|
Re: For when a pint glass isn't big enough for a pint...
Scarlet Manuka: joe.edwards:OK, let's say we have two windows that are "always on top". We'll call the first one Unstoppable Force and the second one Immovable Object. You move Unstoppable Force to the same position as Immovable Object. What happens?
Raymond Chen writes another article for his blog, and a year or two later when it reaches the front of the queue the rest of us see it.
So... that already happened, nearly two years ago: We already know that
you can't create a window that is always on top, even in the presence
of other windows marked always-on-top.
An application of
the What if two programs did this? rule
demonstrates that it's not possible,
because whatever trick you use to be on-top-of-always-on-top,
another program can use the same trick,
and now you have two on-top-of-always-on-top windows,
and what happens?
|
|
-
-
PJH


- Joined on 02-14-2007
- Newcastle, UK
- Posts 3,140
|
Re: For when a pint glass isn't big enough for a pint...
DaveK:So... that already happened, nearly two years ago:
...quoting the main article that he wrote 8 years ago on exactly the same subject....
3 logicians go into a bar.; the barman says ‘Would you all like a drink?’. The first says 'I’m not sure', the second says 'I’m not sure', and the third says 'Yes'.
|
|
-
-
flabdablet


- Joined on 04-09-2011
- Posts 448
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:I'd have thought "always on top" was a property that could only be applied to one object, meaning nothing could overlap that.
I've never seen a system with that behavior. Everything I've ever used that allows you to mark a window "always on top" does nothing at all to the always-on-topness of other windows. The usual thing seems to be that any windows marked "always on top" get displayed over the top of any windows not so marked, and when multiple "always on top" windows conflict, they get stacked in order of gaining focus or order of creation or order of something - they don't just mash into each other.
I can't see how needing to work out which "always on top" window really is on top is any different from the need to work out which UI element wins in a contest between any pair that happen to share a given Z-index. So I still fail to understand why, in an API that allows for Z indexes, there needs to be any special provision made for an "always on top" state. What does that achieve that's different from simply using the highest possible Z index?
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 1,143
|
Re: For when a pint glass isn't big enough for a pint...
flabdablet: Cassidy:I'd have thought "always on top" was a property that could only be applied to one object, meaning nothing could overlap that.
I've never seen a system with that behavior. Everything I've ever used that allows you to mark a window "always on top" does nothing at all to the always-on-topness of other windows. The usual thing seems to be that any windows marked "always on top" get displayed over the top of any windows not so marked, and when multiple "always on top" windows conflict, they get stacked in order of gaining focus or order of creation or order of something - they don't just mash into each other.
I can't see how needing to work out which "always on top" window really is on top is any different from the need to work out which UI element wins in a contest between any pair that happen to share a given Z-index. So I still fail to understand why, in an API that allows for Z indexes, there needs to be any special provision made for an "always on top" state. What does that achieve that's different from simply using the highest possible Z index?
The addendum I made to my last post was because it occurred to me that they might have meant always-on-top is either a) a sticky bit that says "don't let the user decrease my z-index (by focusing another window)" or b) reserved in the sense that user interaction cannot raise the z-index this high.
I actually doubt it works this way though; rather, it seems more likely each distinct z-index value has a corresponding stacking context, and the z-index remains constant while the window gets shuffled around within this stacking context. In this case, always on top is the same as maximum z-index.
I spend most of my life pressing buttons to make the pattern of lights change however I want.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
flabdablet: Cassidy:I'd have thought "always on top" was a property that could only be applied to one object, meaning nothing could overlap that.
I've never seen a system with that behavior. No? Most graphical desktop systems have it: there can only be one window/dialogue in focus, the mouse can only lie in one region at a time, an ID in HTML must be unique, only one application can receive keyboard/mouse input (okay, not strictly true) but there are many systems where specific behaviour is treated as prime. (singleton behaviour?)
Whether or not "always on top" is the right term to refer to this property, I don't know. flabdablet:What does that achieve that's different from simply using the highest possible Z index?
I'm kinda with you on that, except that I feel only one object can take that value. When selecting another object, the values must be swapped to ensure that the one with the highest possible Z-index is still identifiable.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
Wow, it's like none of you have ever worked with always-on-top windows before. Try windows task manager, and enable it in something like a media player -- those usually have the option. Alway On Top is not some kind of well-defined mathematical concept that you can analyze with pure thought. It works in whatever way the OS author wants it to work. It just puts windows always on top of others. If two windows have always on top, they just interact like normal windows.
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
El_Heffe


- Joined on 11-08-2007
- Location: Unknown
- Posts 1,625
|
Re: For when a pint glass isn't big enough for a pint...
DaveK:We already know that
you can't create a window that is always on top, even in the presence
of other windows marked always-on-top.
An application of
the What if two programs did this? rule
demonstrates that it's not possible,
because whatever trick you use to be on-top-of-always-on-top,
another program can use the same trick,
and now you have two on-top-of-always-on-top windows,
and what happens?
"Sometimes I'm in a hurry, and
I want to make sure I am the next person to get served
at the deli counter.
To do this, I find whoever has the
lowest number, knock them unconscious, and steal their ticket.
But sometimes somebody else comes in who's also in a hurry.
That person knocks me
unconscious and steals my ticket.
My plan is to set my watch alarm to wake me up periodically,
and each time it wakes me up, I find the person with the
lowest number, knock them unconscious, and steal their ticket.
Is there a better way?"
|
|
-
-
FrostCat


- Joined on 02-21-2005
- Posts 338
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:No? Most graphical desktop systems have it: there can only be one window/dialogue in focus, the mouse can only lie in one region at a time, an ID in HTML must be unique, only one application can receive keyboard/mouse input (okay, not strictly true) but there are many systems where specific behaviour is treated as prime. (singleton behaviour?)
Whether or not "always on top" is the right term to refer to this property, I don't know.
Generally, it's not the right way to think of it; "always on top" means (in the absence of other "always on top" windows) that window is above all other windows. To demonstrate, you can arrange things so that a window that has the focus is hidden behind other windows. It's not particularly easy to do, but you can certainly do it.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
FrostCat:Generally, it's not the right way to think of it; "always on top" means (in the absence of other "always on top" windows) that window is above all other windows Was my thinking, yup. FrostCat:you can arrange things so that a window that has the focus is hidden behind other windows
A window in focus isn't necessarily the one that's always on top (that's two different things) but my "there can only be one window/dialogue in focus" still fits in with the "only one can have this property at a time" paradigm.
|
|
-
-
DescentJS


- Joined on 02-23-2009
- Posts 393
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy: FrostCat:Generally, it's not the right way to think of it; "always on top" means (in the absence of other "always on top" windows) that window is above all other windows Was my thinking, yup. FrostCat:you can arrange things so that a window that has the focus is hidden behind other windows
A window in focus isn't necessarily the one that's always on top (that's two different things) but my "there can only be one window/dialogue in focus" still fits in with the "only one can have this property at a time" paradigm.
The real thing here though is that on most os's like Windows, "Always on Top" really just means "Always on Top of normal windows". Which is obviously a property that multiple windows can have.
|
|
-
-
Salamander


- Joined on 08-13-2011
- Australia
- Posts 144
|
Re: For when a pint glass isn't big enough for a pint...
Curiously, there appears to be two different types of "always on top" in Windows 8.
There's the first kind with media players/etc, and then there's Task Manager.
It somehow manages to sit above literally everything else, including the start screen, win8 apps and other "always on top" windows.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
Salamander:It somehow manages to sit above literally everything else, including the start screen, win8 apps and other "always on top" windows. No, it does not.
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
Salamander:It somehow manages to sit above literally everything else, including the start screen, win8 apps and other "always on top" windows. Then - evidentially - those windows are not "always on top".
|
|
-
-
-
FrostCat


- Joined on 02-21-2005
- Posts 338
|
Re: For when a pint glass isn't big enough for a pint...
Salamander:Curiously, there appears to be two different types of "always on top" in Windows 8.
There's the first kind with media players/etc, and then there's Task Manager.
It somehow manages to sit above literally everything else, including the start screen, win8 apps and other "always on top" windows.
As Raymond Chen's linked articles point out, "what if two windows did this" shows that you can't, in general, guarantee any given window can really be absolutely topmost. Obviously, Microsoft can make one particular window always be topmost. You also have to check the menu item to force Task Manager to act that way, and I believe it's off by default in Win 8.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
Salamander:Clearly, I'm just imagining this then:
 I suppose VLC then uses a "not really always on top", because when I do the same in foobar2000, task manager nicely drops behind foobar.
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
Salamander:Clearly, I'm just imagining this then: No, you're looking at a window that claims to be "always on top" but clearly isn't. Only one can be topmost at any one time, so TRWTF is the term "always on top" not actually holding a true meaning.
|
|
-
-
boomzilla


- Joined on 12-11-2007
- NOVA
- Posts 3,769
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:
Salamander:
Clearly, I'm just imagining this then: No, you're looking at a window that claims to be "always on top" but clearly isn't. Only one can be topmost at any one time, so TRWTF is the term "always on top" not actually holding a true meaning what I think it should mean.
I don't know about you, but my monitor only displays things in a 2D format, so I could never understand why "always on top" didn't just tile the desktop in the obvious manner.
Just because you want something to disobey reality doesn't mean that it can or even that it was meant to.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
boomzilla:Just because you want something to disobey reality doesn't mean that it can or even that it was meant to. You've never met Steve Jobs then?
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:No, you're looking at a window that claims to be "always on top" but clearly isn't. Only one can be topmost at any one time, so TRWTF is the term "always on top" not actually holding a true meaning. For pete's sake, who cares? It's an option, not a platonic ideal.
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
dhromed


- Joined on 04-13-2005
- Dutchland
- Posts 10,111
|
Re: For when a pint glass isn't big enough for a pint...
dhromed: Salamander:Clearly, I'm just imagining this then:
 I suppose VLC then uses a "not really always on top", because when I do the same in foobar2000, task manager nicely drops behind foobar. I swear I had foobar on top of the task manager yesterday, I really do, but now I can't repro. YOU WIN THIS ROUND, SALAMANDER. *shakes quivering fist*
 boomzilla: I think the obvious answer is for everyone to just stop programming.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
dhromed:For pete's sake, who cares? Kindly stop diffusing our pedantic argument with your level-headedness. Anyone would think you a moderator, or something.
|
|
-
-
boomzilla


- Joined on 12-11-2007
- NOVA
- Posts 3,769
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:
boomzilla:
Just because you want something to disobey reality doesn't mean that it can or even that it was meant to.
You've never met Steve Jobs then?
Of course I haven't. But we were talking about you. And Apple's falling market cap is evidence that he was only really able to do that while he was alive.
|
|
-
-
Cassidy


- Joined on 01-09-2012
- Posts 2,821
|
Re: For when a pint glass isn't big enough for a pint...
boomzilla:But we were talking about you. Yeah, I can dream....
|
|
-
-
ender


- Joined on 04-27-2006
- Sunny side of the Alps
- Posts 1,139
|
Re: For when a pint glass isn't big enough for a pint...
Cassidy:Only one can be topmost at any one time, so TRWTF is the term "always on top" not actually holding a true meaning.
On Windows Always on top means a layer that's above the regular windows (but not above menus) - until Windows 8, there were 3 layers: regular, always on top, menu, each with it's own Z-order. Windows 8 apparently introduced another layer, which is above the menu layer, but only accessible to Task Manager (or maybe only to immersive processes - Task Manager seems to be one of them).
Because 10 billion years' time is so fragile, so ephemeral... it arouses such a bittersweet, almost heartbreaking fondness.
|
|
Page 1 of 1 (44 items)
|
|
|