urho3d/Urho3D — pull request #503 by jonnenauha (2014-10-26 22:06:48+00:00)
Title: Graphics: Window position enhancements

Hello everyone,

We are working on a project that will be using Urho3D mostly in windowed mode (https://github.com/realXtend/tundra-urho3d). There will be options to go fullscreen etc. later. In any case, I was implementing storing window position and size to config file so that we can open the window with same pos/size when you reopen the application.

**Problems I encountered**
* `E_SCREENMODE` does not provide window position.
* Querying `Graphics::GetWindowPosition()` returns a `IntVector2::ZERO` if the SDL window has been destroyed.
* This is the case when I query the position on application exit if the user has closed the windows from the `[x]` button in the window frame.
* Related to above, there is no event to listen "window about to be destroyed" so that users app could query the pos/size prior to the window being destroyed.
* `SDL_WINDOWEVENT_MOVED` was not handled by the `Input` system to notify `Graphics` of pos changes.

**Proposed solution**

I have implemented all the missing parts. `GetWindowPosition()` will still return `ZERO` vec if windows has been destroyed. But the new event params in `E_SCREENMODE` and new event `E_WINDOWABOUTTOCLOSE` are there to get info about changes and let you query before window destruction.

I am new to Urho3D and don't know your coding convention and naming schema that well. I did my best to respect the existing code style. Here are parts that you might have input on, please give it and I'll fix issues. Or say this kind of feature is not needed, thats fine too :)

* Are the new `WindowPositionX/Y` Engine init param names ok?
* Are the new `P_POSITION_X/Y` param names in `E_SCREENMODE` ok (could also be `P_X/Y`)? Is `E_SCREENMODE` even the right message for this data?
* I changed `int width_/height_` to `IntVector2 size_` and added new `IntVector2 position_`, Saw no meaningful reason for not to be a vector, except readability?
* Is the new event `E_WINDOWABOUTTOCLOSE` name ok? Is it a problem in terms of the `Context*` etc. that this event is sent in dtor? Both GL and D3D9 Graphics do this if window is not closed from the `[x]` button in the window frame.

Would appreciate comments feedback if you need changes. Cheers...