--- ori/src/osd/modules/render/drawogl.cpp 2016-02-24 08:58:58.000000000 +0100 +++ diff/src/osd/modules/render/drawogl.cpp 2016-06-06 11:34:40.260188197 +0200 @@ -2650,6 +2650,37 @@ } } +#ifdef SDLMAME_X11 +int set_mame_focus(SDL_Window * window) +{ + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + + if (strncmp(SDL_GetCurrentVideoDriver(),"x11",3)==0) + { + if(SDL_GetWindowWMInfo(window,&info)) + { + Window focus; + int revert = RevertToNone; + XGetInputFocus(info.info.x11.display, &focus, &revert); + + if ( focus != info.info.x11.window ) + { + osd_printf_verbose("FOCUS: possible loss of FocusIn event, force it to grab keyboard.\n"); + XSetInputFocus(info.info.x11.display, info.info.x11.window, RevertToNone, CurrentTime); + XFlush(info.info.x11.display); + XGetInputFocus(info.info.x11.display, &focus, &revert); + osd_printf_verbose("FOCUS: window handle is 0x%06x\n", (unsigned)focus); + } + } else { + osd_printf_error("FOCUS: error getting SDL window information.\n"); + return 1; + } + } + return 0; +} +#endif + ogl_texture_info * renderer_ogl::texture_update(const render_primitive *prim, int shaderIdx) { ogl_texture_info *texture = texture_find(prim); @@ -2659,6 +2690,9 @@ if (texture == nullptr && prim->texture.base != nullptr) { texture = texture_create(&prim->texture, prim->flags); +#ifdef SDLMAME_X11 + set_mame_focus(window().sdl_window()); +#endif } else if (texture != nullptr) { @@ -2775,3 +2809,4 @@ pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0); } } +