[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - vcl/inc vcl/unx

Caolán McNamara caolanm at redhat.com
Sun Sep 11 08:00:43 UTC 2016


 vcl/inc/unx/gtk/gtksalmenu.hxx |    1 +
 vcl/unx/gtk/gtksalmenu.cxx     |    8 ++++++++
 2 files changed, 9 insertions(+)

New commits:
commit 571c187f0610f59573b5e2285b6bfc9589236532
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 8 16:36:59 2016 +0100

    Resolves: tdf#101881 gtk3 3.18 menubar doesn't grab keyboard...
    
    the same way gtk3 3.20 does with gtk_grab_add, so on gtk_menu_shell_deselect
    the keyboard focus doesn't remain in the menubar.
    
    bisecting gtk itself I find...
    
    commit 5cbbb90e311d95192d1b68ba89c3190cdb652868
    Author: Carlos Garnacho <carlosg at gnome.org>
    Date:   Thu Nov 26 19:54:31 2015 +0100
    
        GtkCellRendererAccel: Use gdk_seat_grab()
    
        https://bugzilla.gnome.org/show_bug.cgi?id=759309
    
    is the commit that makes it do what I want, so add an extra
    gtk_grab_add/gtk_grab_remove around our entry and exit of the menubar
    
    Change-Id: I5bf09834b4e1a14d30403208d03b3abd28a382a8
    (cherry picked from commit d45d8ae3c51606eb1d9e63396a0eab13c8742907)
    Reviewed-on: https://gerrit.libreoffice.org/28759
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 90fcb7d..08b4113 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -48,6 +48,7 @@ private:
     bool                            mbMenuBar;
     bool                            mbNeedsUpdate;
     bool                            mbReturnFocusToDocument;
+    bool                            mbAddedGrab;
     GtkWidget*                      mpMenuBarContainerWidget;
     GtkWidget*                      mpMenuBarWidget;
     GtkWidget*                      mpCloseButton;
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 2980ac0..c891cf3 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -423,6 +423,7 @@ GtkSalMenu::GtkSalMenu( bool bMenuBar ) :
     mbMenuBar( bMenuBar ),
     mbNeedsUpdate( false ),
     mbReturnFocusToDocument( false ),
+    mbAddedGrab( false ),
     mpMenuBarContainerWidget( nullptr ),
     mpMenuBarWidget( nullptr ),
     mpCloseButton( nullptr ),
@@ -602,6 +603,11 @@ void GtkSalMenu::ShowCloseButton(bool bShow)
 //focus to the next pane by itself.
 void GtkSalMenu::ReturnFocus()
 {
+    if (mbAddedGrab)
+    {
+        gtk_grab_remove(mpMenuBarWidget);
+        mbAddedGrab = false;
+    }
     if (!mbReturnFocusToDocument)
         gtk_widget_grab_focus(GTK_WIDGET(mpFrame->getEventBox()));
     else
@@ -661,6 +667,8 @@ bool GtkSalMenu::TakeFocus()
 
     //this pairing results in a menubar with keyboard focus with no menus
     //auto-popped down
+    gtk_grab_add(mpMenuBarWidget);
+    mbAddedGrab = true;
     gtk_menu_shell_select_first(GTK_MENU_SHELL(mpMenuBarWidget), false);
     gtk_menu_shell_deselect(GTK_MENU_SHELL(mpMenuBarWidget));
     mbReturnFocusToDocument = true;


More information about the Libreoffice-commits mailing list