summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-03-28 16:40:43 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-03-28 22:07:32 +0100
commitd8064c1f50fca388d2701a9702be694330ff0bc5 (patch)
tree0f4202faece90cf12edf57a79c64dbf7590bed1c /vcl
parent3e078e17ee2144fb976a7e6b9227152113cea0d4 (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx1
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx16
-rw-r--r--vcl/unx/gtk/gtksalmenu.cxx14
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx19
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx8
5 files changed, 46 insertions, 12 deletions
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