|
|
@@ -251,6 +251,7 @@ Graphics::Graphics(Context* context) :
|
|
|
externalWindow_(0),
|
|
|
width_(0),
|
|
|
height_(0),
|
|
|
+ position_(M_MAX_INT,M_MAX_INT),
|
|
|
multiSample_(1),
|
|
|
fullscreen_(false),
|
|
|
borderless_(false),
|
|
|
@@ -364,6 +365,8 @@ void Graphics::SetWindowPosition(const IntVector2& position)
|
|
|
{
|
|
|
if (impl_->window_)
|
|
|
SDL_SetWindowPosition(impl_->window_, position.x_, position.y_);
|
|
|
+ else
|
|
|
+ position_ = position; // Sets as initial position for OpenWindow()
|
|
|
}
|
|
|
|
|
|
void Graphics::SetWindowPosition(int x, int y)
|
|
|
@@ -2024,12 +2027,9 @@ bool Graphics::IsInitialized() const
|
|
|
|
|
|
IntVector2 Graphics::GetWindowPosition() const
|
|
|
{
|
|
|
- IntVector2 ret(IntVector2::ZERO);
|
|
|
-
|
|
|
if (impl_->window_)
|
|
|
- SDL_GetWindowPosition(impl_->window_, &ret.x_, &ret.y_);
|
|
|
-
|
|
|
- return ret;
|
|
|
+ return position_;
|
|
|
+ return IntVector2::ZERO;
|
|
|
}
|
|
|
|
|
|
PODVector<IntVector2> Graphics::GetResolutions() const
|
|
|
@@ -2223,6 +2223,30 @@ void Graphics::WindowResized()
|
|
|
SendEvent(E_SCREENMODE, eventData);
|
|
|
}
|
|
|
|
|
|
+void Graphics::WindowMoved()
|
|
|
+{
|
|
|
+ if (!impl_->device_ || !impl_->window_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ int newX, newY;
|
|
|
+
|
|
|
+ SDL_GetWindowPosition(impl_->window_, &newX, &newY);
|
|
|
+ if (newX == position_.x_ && newY == position_.y_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ position_.x_ = newX;
|
|
|
+ position_.y_ = newY;
|
|
|
+
|
|
|
+ LOGDEBUGF("Window was moved to %d,%d", position_.x_, position_.y_);
|
|
|
+
|
|
|
+ using namespace WindowPos;
|
|
|
+
|
|
|
+ VariantMap& eventData = GetEventDataMap();
|
|
|
+ eventData[P_X] = position_.x_;
|
|
|
+ eventData[P_Y] = position_.y_;
|
|
|
+ SendEvent(E_WINDOWPOS, eventData);
|
|
|
+}
|
|
|
+
|
|
|
void Graphics::Maximize()
|
|
|
{
|
|
|
if (!impl_->window_)
|
|
|
@@ -2453,7 +2477,10 @@ bool Graphics::OpenWindow(int width, int height, bool resizable, bool borderless
|
|
|
if (borderless)
|
|
|
flags |= SDL_WINDOW_BORDERLESS;
|
|
|
|
|
|
- impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
|
|
+ impl_->window_ = SDL_CreateWindow(windowTitle_.CString(),
|
|
|
+ (position_.x_ != M_MAX_INT ? position_.x_ : SDL_WINDOWPOS_UNDEFINED), (position_.y_ != M_MAX_INT ? position_.y_ : SDL_WINDOWPOS_UNDEFINED),
|
|
|
+ width, height, flags
|
|
|
+ );
|
|
|
}
|
|
|
else
|
|
|
impl_->window_ = SDL_CreateWindowFrom(externalWindow_, 0);
|
|
|
@@ -2464,6 +2491,8 @@ bool Graphics::OpenWindow(int width, int height, bool resizable, bool borderless
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ SDL_GetWindowPosition(impl_->window_, &position_.x_, &position_.y_);
|
|
|
+
|
|
|
CreateWindowIcon();
|
|
|
|
|
|
return true;
|