From 2f772bc433df1700a1805d9b0b24e823b68dba53 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Jun 23 2015 09:19:57 +0000 Subject: Fix allegro apps which start fullscreen failing to start from gnome-shell with a "Can not grab keyboard" error message --- diff --git a/allegro-4.4.2-keybgrab-fix.patch b/allegro-4.4.2-keybgrab-fix.patch new file mode 100644 index 0000000..62e1c08 --- /dev/null +++ b/allegro-4.4.2-keybgrab-fix.patch @@ -0,0 +1,43 @@ +diff -up allegro-4.4.2/src/x/xwin.c~ allegro-4.4.2/src/x/xwin.c +--- allegro-4.4.2/src/x/xwin.c~ 2015-06-23 11:04:53.000000000 +0200 ++++ allegro-4.4.2/src/x/xwin.c 2015-06-23 11:09:33.010580738 +0200 +@@ -26,6 +26,7 @@ + #include "xwin.h" + + #include ++#include + #include + #include + #include +@@ -736,6 +736,8 @@ static void _xwin_private_setup_driver_d + static BITMAP *_xwin_private_create_screen(GFX_DRIVER *drv, int w, int h, + int vw, int vh, int depth, int fullscreen) + { ++ int i; ++ + if (_xwin.window == None) { + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("No window")); + return 0; +@@ -816,8 +818,20 @@ static BITMAP *_xwin_private_create_scre + XReparentWindow(_xwin.display, _xwin.window, _xwin.fs_window, 0, 0); + + /* Grab the keyboard and mouse. */ +- if (XGrabKeyboard(_xwin.display, XDefaultRootWindow(_xwin.display), False, +- GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) { ++ ++ /* ++ * Sometimes the window-manager has grabbed the keyboard while it is ++ * starting an allegro app, so if grabing fails retry for 2 seconds ++ * before giving up. ++ */ ++ for (i = 0; i < 20; i++) { ++ if (XGrabKeyboard(_xwin.display, XDefaultRootWindow(_xwin.display), False, ++ GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) ++ break; ++ ++ usleep(100000); /* Sleep 100 ms before retrying */ ++ } ++ if (i == 20) { + ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not grab keyboard")); + return 0; + } diff --git a/allegro.spec b/allegro.spec index dfde780..3e6e0fd 100644 --- a/allegro.spec +++ b/allegro.spec @@ -6,7 +6,7 @@ Name: allegro Version: 4.4.2 -Release: 12%{?dist} +Release: 13%{?dist} Summary: A game programming library Summary(es): Una libreria de programacion de juegos @@ -29,6 +29,8 @@ Patch7: allegro-4.4.2-doc-install.patch Patch8: allegro-4.4.2-mutex-fix.patch # Calling Xsync from the bg thread causes deadlock issues Patch9: allegro-4.4.2-no-xsync-from-thread.patch +# gnome-shell starts apps while gnome-shell has the keyb grabbed... +Patch10: allegro-4.4.2-keybgrab-fix.patch BuildRequires: texinfo cmake BuildRequires: xorg-x11-proto-devel libX11-devel libXpm-devel libXcursor-devel BuildRequires: libXxf86vm-devel libXxf86dga-devel libGL-devel libGLU-devel @@ -247,6 +249,7 @@ developing applications that use logg. %endif %patch8 -p1 %patch9 -p1 +%patch10 -p1 %build @@ -415,6 +418,10 @@ fi %changelog +* Tue Jun 23 2015 Hans de Goede - 4.4.2-13 +- Fix allegro apps which start fullscreen failing to start from gnome-shell + with a "Can not grab keyboard" error message + * Tue Jun 16 2015 Fedora Release Engineering - 4.4.2-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild