[Libreoffice-commits] core.git: vcl/inc vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Mar 28 21:08:02 UTC 2019


 vcl/inc/unx/gtk/gtkframe.hxx  |    1 +
 vcl/unx/gtk/gtksalframe.cxx   |   16 ++++++++++++++++
 vcl/unx/gtk/gtksalmenu.cxx    |   14 ++------------
 vcl/unx/gtk3/gtk3gtkframe.cxx |   19 +++++++++++++++++++
 vcl/unx/gtk3/gtk3gtkinst.cxx  |    8 ++++++++
 5 files changed, 46 insertions(+), 12 deletions(-)

New commits:
commit d8064c1f50fca388d2701a9702be694330ff0bc5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Mar 28 16:40:43 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Mar 28 22:07:32 2019 +0100

    mapped tooltip before attempting to show a menu is a problem
    
    under wayland, see https://gitlab.gnome.org/GNOME/gtk/issues/1785
    
    Change-Id: I542fb9e81b49144508d5403b2d5ad68a10ed8afe
    Reviewed-on: https://gerrit.libreoffice.org/69897
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 9d4f458a75ae..f0d2bd96bc08 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -558,6 +558,7 @@ public:
     static sal_uInt16           GetKeyCode(guint nKeyVal);
     static guint                GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group);
     static sal_uInt16           GetKeyModCode(guint nState);
+    static GdkEvent*            makeFakeKeyPress(GtkWidget* pWidget);
 };
 
 #define OOO_TYPE_FIXED ooo_fixed_get_type()
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index cdb07829976e..cc95a9f94e51 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -3614,4 +3614,20 @@ sal_uIntPtr GtkSalFrame::GetNativeWindowHandle()
     return widget_get_xid(m_pWindow);
 }
 
+GdkEvent* GtkSalFrame::makeFakeKeyPress(GtkWidget* pWidget)
+{
+    GdkEvent *event = gdk_event_new(GDK_KEY_PRESS);
+    event->key.window = GDK_WINDOW(g_object_ref(gtk_widget_get_window(pWidget)));
+    event->key.send_event = 1 /* TRUE */;
+    event->key.time = gtk_get_current_event_time();
+    event->key.state = 0;
+    event->key.keyval = 0;
+    event->key.length = 0;
+    event->key.string = nullptr;
+    event->key.hardware_keycode = 0;
+    event->key.group = 0;
+    event->key.is_modifier = false;
+    return event;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
index 27ba8096bce8..2f85e0710043 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -771,18 +771,8 @@ bool GtkSalMenu::TakeFocus()
     //activated via the keyboard. Doesn't do anything except cause the gtk
     //menubar "keyboard_mode" member to get set to true, so typically mnemonics
     //are shown which will serve as indication that the menubar has focus
-    //(given that we wnt to show it with no menus popped down)
-    GdkEvent *event = gdk_event_new(GDK_KEY_PRESS);
-    event->key.window = GDK_WINDOW(g_object_ref(gtk_widget_get_window(mpMenuBarWidget)));
-    event->key.send_event = 1 /* TRUE */;
-    event->key.time = gtk_get_current_event_time();
-    event->key.state = 0;
-    event->key.keyval = 0;
-    event->key.length = 0;
-    event->key.string = nullptr;
-    event->key.hardware_keycode = 0;
-    event->key.group = 0;
-    event->key.is_modifier = false;
+    //(given that we want to show it with no menus popped down)
+    GdkEvent *event = GtkSalFrame::makeFakeKeyPress(mpMenuBarWidget);
     gtk_widget_event(mpMenuBarWidget, event);
     gdk_event_free(event);
 
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index b1311e207386..ed9895dabdd2 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -4374,4 +4374,23 @@ void GtkSalFrame::nopaint_container_resize_children(GtkContainer *pContainer)
     m_bSalObjectSetPosSize = false;
 }
 
+GdkEvent* GtkSalFrame::makeFakeKeyPress(GtkWidget* pWidget)
+{
+    GdkEvent *event = gdk_event_new(GDK_KEY_PRESS);
+    event->key.window = GDK_WINDOW(g_object_ref(gtk_widget_get_window(pWidget)));
+
+    GdkSeat *seat = gdk_display_get_default_seat(gtk_widget_get_display(pWidget));
+    gdk_event_set_device(event, gdk_seat_get_keyboard(seat));
+    event->key.send_event = 1 /* TRUE */;
+    event->key.time = gtk_get_current_event_time();
+    event->key.state = 0;
+    event->key.keyval = 0;
+    event->key.length = 0;
+    event->key.string = nullptr;
+    event->key.hardware_keycode = 0;
+    event->key.group = 0;
+    event->key.is_modifier = false;
+    return event;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 06f0836df779..3b740f7a8985 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4764,6 +4764,14 @@ public:
                                static_cast<int>(rRect.GetWidth()), static_cast<int>(rRect.GetHeight())};
             if (AllSettings::GetLayoutRTL())
                 aRect.x = gtk_widget_get_allocated_width(pWidget) - aRect.width - 1 - aRect.x;
+
+            // Send a keyboard event through gtk_main_do_event to toggle any active tooltip offs
+            // before trying to launch the menu
+            // https://gitlab.gnome.org/GNOME/gtk/issues/1785
+            GdkEvent *event = GtkSalFrame::makeFakeKeyPress(pWidget);
+            gtk_main_do_event(event);
+            gdk_event_free(event);
+
             gtk_menu_popup_at_rect(m_pMenu, gtk_widget_get_window(pWidget), &aRect, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, nullptr);
         }
         else


More information about the Libreoffice-commits mailing list