|
@@ -1326,36 +1326,36 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|
|
|
|
|
if (xevent->xconfigure.x != data->last_xconfigure.x ||
|
|
|
xevent->xconfigure.y != data->last_xconfigure.y) {
|
|
|
- SDL_Window *w;
|
|
|
- int x = xevent->xconfigure.x;
|
|
|
- int y = xevent->xconfigure.y;
|
|
|
+ if (!data->disable_size_position_events) {
|
|
|
+ SDL_Window *w;
|
|
|
+ int x = xevent->xconfigure.x;
|
|
|
+ int y = xevent->xconfigure.y;
|
|
|
|
|
|
- data->pending_operation &= ~X11_PENDING_OP_MOVE;
|
|
|
- SDL_GlobalToRelativeForWindow(data->window, x, y, &x, &y);
|
|
|
- SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MOVED, x, y);
|
|
|
+ data->pending_operation &= ~X11_PENDING_OP_MOVE;
|
|
|
+ SDL_GlobalToRelativeForWindow(data->window, x, y, &x, &y);
|
|
|
+ SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MOVED, x, y);
|
|
|
|
|
|
#ifdef SDL_USE_IME
|
|
|
- if (SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
|
|
|
- /* Update IME candidate list position */
|
|
|
- SDL_IME_UpdateTextRect(NULL);
|
|
|
- }
|
|
|
+ if (SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) {
|
|
|
+ /* Update IME candidate list position */
|
|
|
+ SDL_IME_UpdateTextRect(NULL);
|
|
|
+ }
|
|
|
#endif
|
|
|
- for (w = data->window->first_child; w; w = w->next_sibling) {
|
|
|
- /* Don't update hidden child windows, their relative position doesn't change */
|
|
|
- if (!(w->flags & SDL_WINDOW_HIDDEN)) {
|
|
|
- X11_UpdateWindowPosition(w, SDL_TRUE);
|
|
|
+ for (w = data->window->first_child; w; w = w->next_sibling) {
|
|
|
+ /* Don't update hidden child windows, their relative position doesn't change */
|
|
|
+ if (!(w->flags & SDL_WINDOW_HIDDEN)) {
|
|
|
+ X11_UpdateWindowPosition(w, SDL_TRUE);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (xevent->xconfigure.width != data->last_xconfigure.width ||
|
|
|
xevent->xconfigure.height != data->last_xconfigure.height) {
|
|
|
- if (!data->skip_size_count) {
|
|
|
+ if (!data->disable_size_position_events) {
|
|
|
data->pending_operation &= ~X11_PENDING_OP_RESIZE;
|
|
|
SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESIZED,
|
|
|
xevent->xconfigure.width,
|
|
|
xevent->xconfigure.height);
|
|
|
- } else {
|
|
|
- data->skip_size_count--;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1653,9 +1653,28 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|
|
SDL_UpdateFullscreenMode(data->window, SDL_FALSE, SDL_TRUE);
|
|
|
}
|
|
|
|
|
|
- if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
|
|
- /* Skip the first resize event if the borders are being turned on/off. */
|
|
|
- data->skip_size_count = 1;
|
|
|
+ if ((flags & SDL_WINDOW_FULLSCREEN) &&
|
|
|
+ (data->border_top || data->border_left || data->border_bottom || data->border_right)) {
|
|
|
+ /* If the window is entering fullscreen and the borders are
|
|
|
+ * non-zero sized, turn off size events until the borders are
|
|
|
+ * shut off to avoid bogus window sizes and positions, and
|
|
|
+ * note that the old borders were non-zero for restoration.
|
|
|
+ */
|
|
|
+ data->disable_size_position_events = SDL_TRUE;
|
|
|
+ data->previous_borders_nonzero = SDL_TRUE;
|
|
|
+ } else if (!(flags & SDL_WINDOW_FULLSCREEN) &&
|
|
|
+ data->previous_borders_nonzero &&
|
|
|
+ (!data->border_top && !data->border_left && !data->border_bottom && !data->border_right)) {
|
|
|
+ /* If the window is leaving fullscreen and the current borders
|
|
|
+ * are zero sized, but weren't when entering fullscreen, turn
|
|
|
+ * off size events until the borders come back to avoid bogus
|
|
|
+ * window sizes and positions.
|
|
|
+ */
|
|
|
+ data->disable_size_position_events = SDL_TRUE;
|
|
|
+ data->previous_borders_nonzero = SDL_FALSE;
|
|
|
+ } else {
|
|
|
+ data->disable_size_position_events = SDL_FALSE;
|
|
|
+ data->previous_borders_nonzero = SDL_FALSE;
|
|
|
}
|
|
|
}
|
|
|
if ((changed & SDL_WINDOW_MAXIMIZED) && ((flags & SDL_WINDOW_MAXIMIZED) && !(flags & SDL_WINDOW_MINIMIZED))) {
|
|
@@ -1678,11 +1697,11 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|
|
/* Restore the last known floating state if leaving maximized mode */
|
|
|
if (!(flags & SDL_WINDOW_FULLSCREEN)) {
|
|
|
data->pending_operation |= X11_PENDING_OP_MOVE | X11_PENDING_OP_RESIZE;
|
|
|
- data->expected.x = data->window->floating.x;
|
|
|
- data->expected.y = data->window->floating.y;
|
|
|
+ data->expected.x = data->window->floating.x - data->border_left;
|
|
|
+ data->expected.y = data->window->floating.y - data->border_top;
|
|
|
data->expected.w = data->window->floating.w;
|
|
|
data->expected.h = data->window->floating.h;
|
|
|
- X11_XMoveWindow(display, data->xwindow, data->window->floating.x, data->window->floating.y);
|
|
|
+ X11_XMoveWindow(display, data->xwindow, data->window->floating.x - data->border_left, data->window->floating.y - data->border_top);
|
|
|
X11_XResizeWindow(display, data->xwindow, data->window->floating.w, data->window->floating.h);
|
|
|
}
|
|
|
}
|
|
@@ -1699,18 +1718,23 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent)
|
|
|
right approach, but it seems to work. */
|
|
|
X11_UpdateKeymap(_this, SDL_TRUE);
|
|
|
} else if (xevent->xproperty.atom == videodata->_NET_FRAME_EXTENTS) {
|
|
|
+ /* Re-enable size events if they were turned off waiting for the borders to come back
|
|
|
+ * when leaving fullscreen.
|
|
|
+ */
|
|
|
+ data->disable_size_position_events = SDL_FALSE;
|
|
|
X11_GetBorderValues(data);
|
|
|
if (data->border_top != 0 || data->border_left != 0 || data->border_right != 0 || data->border_bottom != 0) {
|
|
|
- /* Adjust if the window size changed to accommodate the borders. */
|
|
|
+ /* Adjust if the window size/position changed to accommodate the borders. */
|
|
|
if (data->window->flags & SDL_WINDOW_MAXIMIZED) {
|
|
|
data->pending_operation |= X11_PENDING_OP_RESIZE;
|
|
|
data->expected.w = data->window->windowed.w;
|
|
|
data->expected.h = data->window->windowed.h;
|
|
|
X11_XResizeWindow(display, data->xwindow, data->window->windowed.w, data->window->windowed.h);
|
|
|
} else {
|
|
|
- data->pending_operation |= X11_PENDING_OP_RESIZE;
|
|
|
+ data->pending_operation |= X11_PENDING_OP_RESIZE | X11_PENDING_OP_MOVE;
|
|
|
data->expected.w = data->window->floating.w;
|
|
|
data->expected.h = data->window->floating.h;
|
|
|
+ X11_XMoveWindow(display, data->xwindow, data->window->floating.x - data->border_left, data->window->floating.y - data->border_top);
|
|
|
X11_XResizeWindow(display, data->xwindow, data->window->floating.w, data->window->floating.h);
|
|
|
}
|
|
|
}
|