Ticket #1317 (reopened defect)
[PATCH] [ATLAS] Atlas window steals focus on mouseover
| Reported by: | mk12 | Owned by: | mk12 |
|---|---|---|---|
| Priority: | If Time Permits | Milestone: | Backlog |
| Component: | Atlas editor | Keywords: | patch atlas |
| Cc: | mk12360@… |
Description
On Mac OS X Lion 10.7.3 (and other OSs ?), mousing over the Atlas window when it is not currently in focus causes it to leap to second place in the window order, so the only window covering it is the currently focused one. Seemed to be random at first until I figured out this was what it was doing.
Attachments
Change History
comment:2 Changed 13 months ago by historic_bruno
Seems like an OS X only problem. I would guess it's a problem with SDL/wxWidgets since we don't handle focus changes directly.
comment:3 Changed 13 months ago by Philip
See ScenarioEditor.cpp GameCanvas::HandleMouseEvent, which calls SetFocus(), which is presumably triggering this behaviour.
The intent is that you can click some button or textbox on the Atlas sidebar, move the mouse back over the 3D window to begin positioning a unit or brush etc, and then use the arrow key to scroll the camera around. (Without the SetFocus, the arrow keys would get eaten by the button or textbox, and there's no way to explicitly focus the 3D window (since if you click on it to focus, you'll accidentally edit the world)).
Maybe it'd be best to restrict the SetFocus thing to only occur if the toplevel Atlas window is already focused (i.e. there's no other application on top of it)?
comment:4 follow-up: ↓ 5 Changed 13 months ago by mk12
Yes I can see that now—commenting that out does stop it from happening. The only problem is how to determine if the window is key/active/main/currently-top-focused. I tried (SDL_GetAppState & SDL_APPACTIVE) but it's not really clear what it does, and in any case it returns true when the window is not at the top. I can't find anything else.
comment:5 in reply to: ↑ 4 Changed 13 months ago by historic_bruno
Replying to mk12:
Yes I can see that now—commenting that out does stop it from happening. The only problem is how to determine if the window is key/active/main/currently-top-focused. I tried (SDL_GetAppState & SDL_APPACTIVE) but it's not really clear what it does, and in any case it returns true when the window is not at the top. I can't find anything else.
Per the SDL documentation, the SDL_APPACTIVE flag only indicates the window is visible (not minimized) and not necessarily in focus.
I think we should use the wxWidgets API if possible, would wxWindow::FindFocus work? What does it return if the app is not focused? We could also process focus change events if there's no way to query that.
comment:6 Changed 13 months ago by mk12
- Keywords patch, review, added
- Summary changed from [ATLAS] Atlas window steals focus on mouseover to [PATCH] [ATLAS] Atlas window steals focus on mouseover
- Milestone changed from Backlog to Alpha 10
Works :-) I just assumed SDL would be a level above wxWidgets and only work for this, I should have looked at wx myself.
comment:8 Changed 13 months ago by ben
- Status changed from assigned to closed
- Resolution set to fixed
In 11693:
comment:9 Changed 13 months ago by historic_bruno
- Keywords patch atlas added; patch, review, atlas, removed
- Status changed from closed to reopened
- Resolution fixed deleted
This breaks focus :( If a button was enabled but becomes disabled after clicking (like the simulation test buttons) then wxWindow::FindFocus() seems to return NULL, and you can no longer control the canvas. This is reproducible on wxMSW and wxGTK. Reverting until we have a better solution.
comment:10 Changed 13 months ago by k776
- Keywords window removed
- Milestone changed from Alpha 10 to Alpha 11
