Make the X11 SetBordered event tapdancing more robust, restore focus, etc.
--HG-- extra : rebase_source : 9618675dc68a00d7f2dd6ddaf87ad73386f4a546
This commit is contained in:
parent
8835a0dacb
commit
30291cdd9a
2 changed files with 19 additions and 4 deletions
|
@ -89,6 +89,7 @@ SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return)
|
|||
SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return)
|
||||
SDL_X11_SYM(int,XSetInputFocus,(Display *a,Window b,int c,Time d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return)
|
||||
SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),)
|
||||
|
|
|
@ -734,6 +734,8 @@ static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
|
|||
void
|
||||
X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
||||
{
|
||||
const SDL_bool focused = ((window->flags & SDL_WINDOW_INPUT_FOCUS) != 0);
|
||||
const SDL_bool visible = ((window->flags & SDL_WINDOW_HIDDEN) == 0);
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
|
@ -741,13 +743,25 @@ X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
|||
XEvent event;
|
||||
|
||||
SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
|
||||
XFlush(display);
|
||||
XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
|
||||
|
||||
/* make sure these don't make it to the real event queue if they fired here. */
|
||||
while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
|
||||
while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
|
||||
if (visible) {
|
||||
XWindowAttributes attr;
|
||||
do {
|
||||
XSync(display, False);
|
||||
XGetWindowAttributes(display, data->xwindow, &attr);
|
||||
} while (attr.map_state != IsViewable);
|
||||
|
||||
XFlush(display);
|
||||
if (focused) {
|
||||
XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure these don't make it to the real event queue if they fired here. */
|
||||
XSync(display, False);
|
||||
XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
|
||||
XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue