Ticket #1317 (reopened defect)

Opened 13 months ago

Last modified 12 months ago

[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

AtlasUI-Stop-Stealing-Focus(1317).patch (638 bytes) - added by mk12 13 months ago.

Change History

comment:1 Changed 13 months ago by mk12

  • Cc mk12360@… added

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.

Changed 13 months ago by mk12

comment:7 Changed 13 months ago by mk12

  • Owner set to mk12
  • Status changed from new to assigned

comment:8 Changed 13 months ago by ben

  • Status changed from assigned to closed
  • Resolution set to fixed

In 11693:

Fixes Atlas stealing focus on OS X, based on patch by mk12. Fixes #1317.

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.

Last edited 13 months ago by historic_bruno (previous) (diff)

comment:10 Changed 13 months ago by k776

  • Keywords window removed
  • Milestone changed from Alpha 10 to Alpha 11

comment:11 Changed 12 months ago by k776

  • Priority changed from Should Have to If Time Permits

comment:12 Changed 12 months ago by historic_bruno

  • Milestone changed from Alpha 11 to Backlog
Note: See TracTickets for help on using tickets.