x11: Only correct placement for border offset on the initial window mapping
Correcting it when it is subsequently hidden and re-mapped will cause the position to be double offset by the size of the borders.
(cherry picked from commit a71b2f0a93)
This commit is contained in:
1 parent
85012b6074
commit
49db06b604
1 file changed
+9
-6
@@ -1535,6 +1535,11 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
bool set_position = false;
|
bool set_position = false;
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|
||||||
|
// If the window was previously shown, pump events to avoid possible positioning issues.
|
||||||
|
if (data->was_shown) {
|
||||||
|
X11_PumpEvents(_this);
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_WINDOW_IS_POPUP(window)) {
|
if (SDL_WINDOW_IS_POPUP(window)) {
|
||||||
// Update the position in case the parent moved while we were hidden
|
// Update the position in case the parent moved while we were hidden
|
||||||
X11_ConstrainPopup(window, true);
|
X11_ConstrainPopup(window, true);
|
||||||
@@ -1577,14 +1582,12 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (set_position) {
|
if (set_position) {
|
||||||
// Apply the window position, accounting for offsets due to the borders appearing.
|
// Apply the window position, accounting for offsets due to the borders appearing, but only when initially mapping.
|
||||||
const int tx = data->pending_position ? window->pending.x : window->x;
|
const int tx = (data->pending_position ? window->pending.x : window->x) - (data->was_shown ? 0 : data->border_left);
|
||||||
const int ty = data->pending_position ? window->pending.y : window->y;
|
const int ty = (data->pending_position ? window->pending.y : window->y) - (data->was_shown ? 0 : data->border_top);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
SDL_RelativeToGlobalForWindow(window,
|
SDL_RelativeToGlobalForWindow(window, tx, ty, &x, &y);
|
||||||
tx - data->border_left, ty - data->border_top,
|
|
||||||
&x, &y);
|
|
||||||
|
|
||||||
data->pending_position = false;
|
data->pending_position = false;
|
||||||
X11_XMoveWindow(display, data->xwindow, x, y);
|
X11_XMoveWindow(display, data->xwindow, x, y);
|
||||||
|
|||||||
Reference in new issue
Block a user