wayland: Clarify the popup position restriction purpose

Child popups don't necessarily need to be within, but must intersect or be partially adjacent to the parent, per the xdg-positioner spec.
This commit is contained in:
Frank Praznik
2023-03-16 13:35:06 -04:00
parent c270d151b0
commit be70d9a9c7

View File

@@ -242,12 +242,14 @@ static void ConfigureWindowGeometry(SDL_Window *window)
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->drawable_width, data->drawable_height); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->drawable_width, data->drawable_height);
} }
static void EnsurePopupIsWithinParent(SDL_Window *window) static void EnsurePopupPositionIsValid(SDL_Window *window)
{ {
/* Per the spec, popup windows *must* overlap the parent window. /* Per the xdg-positioner spec, child popup windows must intersect or at
* Failure to do so on a compositor that enforces this restriction * least be partially adjacent to the parent window.
* will result in the window being spuriously closed at best, and *
* a protocol violation at worst. * Failure to ensure this on a compositor that enforces this restriction
* can result in behavior ranging from the window being spuriously closed
* to a protocol violation.
*/ */
if (window->x + window->w < 0) { if (window->x + window->w < 0) {
window->x = -window->w; window->x = -window->w;
@@ -1950,7 +1952,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
} }
if (SDL_WINDOW_IS_POPUP(window)) { if (SDL_WINDOW_IS_POPUP(window)) {
EnsurePopupIsWithinParent(window); EnsurePopupPositionIsValid(window);
} }
data->waylandData = c; data->waylandData = c;
@@ -2088,7 +2090,7 @@ void Wayland_SetWindowPosition(_THIS, SDL_Window *window)
xdg_popup_get_version(wind->shell_surface.xdg.roleobj.popup.popup) >= XDG_POPUP_REPOSITION_SINCE_VERSION) { xdg_popup_get_version(wind->shell_surface.xdg.roleobj.popup.popup) >= XDG_POPUP_REPOSITION_SINCE_VERSION) {
int x, y; int x, y;
EnsurePopupIsWithinParent(window); EnsurePopupPositionIsValid(window);
GetPopupPosition(window, window->x, window->y, &x, &y); GetPopupPosition(window, window->x, window->y, &x, &y);
xdg_positioner_set_offset(wind->shell_surface.xdg.roleobj.popup.positioner, x, y); xdg_positioner_set_offset(wind->shell_surface.xdg.roleobj.popup.positioner, x, y);
xdg_popup_reposition(wind->shell_surface.xdg.roleobj.popup.popup, xdg_popup_reposition(wind->shell_surface.xdg.roleobj.popup.popup,