Implement SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED for X11
To match the focus stealing prevention logic from windows/osx. I didn't implement SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN as there is no standard mechanism for us to do so. In most cases marking a window as OverrideRedirect will cause to not acquire focus when mapped. And in steam we are doing that when appropriate. I still left a note in X11_ShowWindow() regarding this behaviour.main
parent
9351bf6dd1
commit
210c135f74
|
@ -1303,6 +1303,7 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
{
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, SDL_TRUE);
|
||||
XEvent event;
|
||||
|
||||
if (window->parent) {
|
||||
|
@ -1310,6 +1311,10 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
X11_UpdateWindowPosition(window);
|
||||
}
|
||||
|
||||
/* Whether XMapRaised focuses the window is based on the window type and it is
|
||||
* wm specific. There isn't much we can do here */
|
||||
(void)bActivate;
|
||||
|
||||
if (!X11_IsWindowMapped(_this, window)) {
|
||||
X11_XMapRaised(display, data->xwindow);
|
||||
/* Blocking wait for "MapNotify" event.
|
||||
|
@ -1408,9 +1413,12 @@ void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
{
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
SDL_bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, SDL_TRUE);
|
||||
|
||||
X11_XRaiseWindow(display, data->xwindow);
|
||||
X11_SetWindowActive(_this, window);
|
||||
if (bActivate) {
|
||||
X11_SetWindowActive(_this, window);
|
||||
}
|
||||
X11_XFlush(display);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue