|
@@ -797,6 +797,7 @@ void X11_SetWindowPosition(_THIS, SDL_Window *window)
|
|
|
Window childReturn, root, parent;
|
|
|
Window *children;
|
|
|
XWindowAttributes attrs;
|
|
|
+ int x, y;
|
|
|
int orig_x, orig_y;
|
|
|
Uint32 timeout;
|
|
|
|
|
@@ -816,8 +817,6 @@ void X11_SetWindowPosition(_THIS, SDL_Window *window)
|
|
|
|
|
|
timeout = SDL_GetTicks() + 100;
|
|
|
while (SDL_TRUE) {
|
|
|
- int x, y;
|
|
|
-
|
|
|
caught_x11_error = SDL_FALSE;
|
|
|
X11_XSync(display, False);
|
|
|
X11_XGetWindowAttributes(display, data->xwindow, &attrs);
|
|
@@ -826,8 +825,6 @@ void X11_SetWindowPosition(_THIS, SDL_Window *window)
|
|
|
|
|
|
if (!caught_x11_error) {
|
|
|
if ((x != orig_x) || (y != orig_y)) {
|
|
|
- window->x = x;
|
|
|
- window->y = y;
|
|
|
break; /* window moved, time to go. */
|
|
|
} else if ((x == window->x) && (y == window->y)) {
|
|
|
break; /* we're at the place we wanted to be anyhow, drop out. */
|
|
@@ -841,6 +838,11 @@ void X11_SetWindowPosition(_THIS, SDL_Window *window)
|
|
|
SDL_Delay(10);
|
|
|
}
|
|
|
|
|
|
+ if (!caught_x11_error) {
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
|
|
+ }
|
|
|
+
|
|
|
X11_XSetErrorHandler(prev_handler);
|
|
|
caught_x11_error = SDL_FALSE;
|
|
|
}
|
|
@@ -970,8 +972,6 @@ void X11_SetWindowSize(_THIS, SDL_Window *window)
|
|
|
|
|
|
if (!caught_x11_error) {
|
|
|
if ((attrs.width != orig_w) || (attrs.height != orig_h)) {
|
|
|
- window->w = attrs.width;
|
|
|
- window->h = attrs.height;
|
|
|
break; /* window changed, time to go. */
|
|
|
} else if ((attrs.width == window->w) && (attrs.height == window->h)) {
|
|
|
break; /* we're at the place we wanted to be anyhow, drop out. */
|
|
@@ -980,15 +980,24 @@ void X11_SetWindowSize(_THIS, SDL_Window *window)
|
|
|
|
|
|
if (SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) {
|
|
|
/* Timeout occurred and window size didn't change
|
|
|
- * window manager likely denied the resize. */
|
|
|
- window->w = orig_w;
|
|
|
- window->h = orig_h;
|
|
|
+ * window manager likely denied the resize,
|
|
|
+ * or the new size is the same as the existing:
|
|
|
+ * - current width: is 'full width'.
|
|
|
+ * - try to set new width at 'full width + 1', which get truncated to 'full width'.
|
|
|
+ * - new width is/remains 'full width'
|
|
|
+ * So, even if we break here as a timeout, we can send an event, since the requested size isn't the same
|
|
|
+ * as the final size. (even if final size is same as original size).
|
|
|
+ */
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
SDL_Delay(10);
|
|
|
}
|
|
|
|
|
|
+ if (!caught_x11_error) {
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
|
|
+ }
|
|
|
+
|
|
|
X11_XSetErrorHandler(prev_handler);
|
|
|
caught_x11_error = SDL_FALSE;
|
|
|
}
|
|
@@ -1170,6 +1179,11 @@ void X11_ShowWindow(_THIS, SDL_Window *window)
|
|
|
X11_XSetInputFocus(display, data->xwindow, RevertToNone, CurrentTime);
|
|
|
X11_XFlush(display);
|
|
|
}
|
|
|
+
|
|
|
+ /* Get some valid border values, if we haven't them yet */
|
|
|
+ if (data->border_left == 0 && data->border_right == 0 && data->border_top == 0 && data->border_bottom == 0) {
|
|
|
+ X11_GetBorderValues(data);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void X11_HideWindow(_THIS, SDL_Window *window)
|
|
@@ -1305,6 +1319,8 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
Display *display = data->videodata->display;
|
|
|
Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
|
|
|
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
|
|
|
+ SDL_bool window_size_changed = SDL_FALSE;
|
|
|
+ int window_position_changed = 0;
|
|
|
|
|
|
if (X11_IsWindowMapped(_this, window)) {
|
|
|
XEvent e;
|
|
@@ -1314,6 +1330,7 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
Window childReturn, root, parent;
|
|
|
Window *children;
|
|
|
XWindowAttributes attrs;
|
|
|
+ int x, y;
|
|
|
int orig_w, orig_h, orig_x, orig_y;
|
|
|
Uint64 timeout;
|
|
|
|
|
@@ -1378,6 +1395,16 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
|
|
}
|
|
|
|
|
|
+ if (!fullscreen) {
|
|
|
+ int dest_x = 0, dest_y = 0;
|
|
|
+ dest_x = window->windowed.x - data->border_left;
|
|
|
+ dest_y = window->windowed.y - data->border_top;
|
|
|
+
|
|
|
+ /* Attempt to move the window */
|
|
|
+ X11_XMoveWindow(display, data->xwindow, dest_x, dest_y);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/* Wait a brief time to see if the window manager decided to let this happen.
|
|
|
If the window changes at all, even to an unexpected value, we break out. */
|
|
|
X11_XSync(display, False);
|
|
@@ -1385,7 +1412,6 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
|
|
|
timeout = SDL_GetTicks64() + 100;
|
|
|
while (SDL_TRUE) {
|
|
|
- int x, y;
|
|
|
|
|
|
caught_x11_error = SDL_FALSE;
|
|
|
X11_XSync(display, False);
|
|
@@ -1394,18 +1420,20 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
attrs.x, attrs.y, &x, &y, &childReturn);
|
|
|
|
|
|
if (!caught_x11_error) {
|
|
|
- SDL_bool window_changed = SDL_FALSE;
|
|
|
if ((x != orig_x) || (y != orig_y)) {
|
|
|
- SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
|
|
|
- window_changed = SDL_TRUE;
|
|
|
+ orig_x = x;
|
|
|
+ orig_y = y;
|
|
|
+ window_position_changed += 1;
|
|
|
}
|
|
|
|
|
|
if ((attrs.width != orig_w) || (attrs.height != orig_h)) {
|
|
|
- SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
|
|
- window_changed = SDL_TRUE;
|
|
|
+ orig_w = attrs.width;
|
|
|
+ orig_h = attrs.height;
|
|
|
+ window_size_changed = SDL_TRUE;
|
|
|
}
|
|
|
|
|
|
- if (window_changed) {
|
|
|
+ /* Wait for at least 2 moves + 1 size changed to have valid values */
|
|
|
+ if (window_position_changed >= 2 && window_size_changed) {
|
|
|
break; /* window changed, time to go. */
|
|
|
}
|
|
|
}
|
|
@@ -1417,6 +1445,11 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
|
|
|
SDL_Delay(10);
|
|
|
}
|
|
|
|
|
|
+ if (!caught_x11_error) {
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
|
|
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
|
|
+ }
|
|
|
+
|
|
|
X11_XSetErrorHandler(prev_handler);
|
|
|
caught_x11_error = SDL_FALSE;
|
|
|
} else {
|