This isn't really a bug or question even, but rather a discussion point that 
I'd be interested in hearing your opinion on.

I'm using FLTK to develop a trivial survey application for someone (for an HCI 
experiment for a University student) that grabs focus periodically. I'm using 
FLTK v1.1.10 to do this.

The program is complete, but I had some problems getting the desired behaviour 
under Windows Vista and Windows 7.

Whilst I suspect it depends on the window manager, under XFCE 4.8 on Arch 
Linux, the following code will grab focus even when the application in question 
is not currently active:

window.show()

i.e the process is bought to the foreground, which is what I want (damming the 
consequences if the person is typing at the time, please put aside your 
objection to that approach for the sake of this discussion).

Obviously this is very simple and convenient for me, and I was able to program 
the application in a few hours. However, on Windows Vista and Windows 7, focus 
stealing is banned without permission from the current foreground process. As 
described in this rather militant post:

See for example: 
http://blogs.msdn.com/b/oldnewthing/archive/2009/02/20/9435239.aspx

Disregarding whether or not focus stealing is a "sin", as I've no doubt some 
religious types believe it is, I am wondering whether FLTK is behaving 
correctly in its response to window.show() under Windows Vista and Windows 7.

Under these OSs, calling window.show() does not grab focus (although I have 
read reports that suggest that some installations of Vista and 7 inconsistently 
allow it).

Obviously this behaviour wasn't suitable for my application so I had to look to 
the windows API to work out how to solve it. I ended up doing this:

        HWND win = fl_xid(window);
        SetForegroundWindow(win);

And the effect of doing so is that when this code is executed, although the 
process still doesn't grab focus and come to the foreground, the taskbar entry 
flashes a wonderfully irritating orange, so it at least gets the users 
attention, which is what I want. I know that perhaps using a tray icon with 
notifications might be a better way to get attention, but I think the flashing 
orange will suffice.

My discussion point is: should FLTK by default include this code for 
window.show() when it is compiled under Windows Vista and Windows 7? I mean, 
what do users expect from window.show(), should it do the orange flashing by 
default? Or is the demand for background processes that pop into the foreground 
so little that the question isn't worth pondering?

A second point is that more generally we might ask, should FLTK offer more 
control of focus events such as this, i.e z-index among unrelated processes, 
than it currently does?

Regards

Ashley Mills
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to