From 47cf950fe83da10df44fda8f31ed73569d1232da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 7 Mar 2016 16:48:46 +0000 Subject: [PATCH] gtk3: popover positions come pre-computed i.e. the position provided is the location where the popover is to be drawn, not the bounds of the thing to be pointed to, so adapt them so gtk will point to the desired place. e.g. the slide names/numbers in the presentation slide view sidebar Change-Id: I8c87d5dba32e27f9e627b3282f34d87a8ee460ca --- vcl/unx/gtk3/gtk3gtkframe.cxx | 45 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index cfb856b6b9fc..4cfa4b3020c8 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -2468,6 +2468,33 @@ bool GtkSalFrame::ShowTooltip(const OUString& rHelpText, const Rectangle& rHelpA return true; } +namespace +{ + void set_pointing_to(GtkPopover *pPopOver, const Rectangle& rHelpArea) + { + GdkRectangle aRect; + aRect.x = rHelpArea.Left(); + aRect.y = rHelpArea.Top(); + aRect.width = 1; + aRect.height = 1; + + GtkPositionType ePos = gtk_popover_get_position(pPopOver); + switch (ePos) + { + case GTK_POS_BOTTOM: + case GTK_POS_TOP: + aRect.width = rHelpArea.GetWidth(); + break; + case GTK_POS_RIGHT: + case GTK_POS_LEFT: + aRect.height = rHelpArea.GetHeight(); + break; + } + + gtk_popover_set_pointing_to(pPopOver, &aRect); + } +} + sal_uIntPtr GtkSalFrame::ShowPopover(const OUString& rHelpText, const Rectangle& rHelpArea, QuickHelpFlags nFlags) { #if GTK_CHECK_VERSION(3,12,0) @@ -2476,14 +2503,6 @@ sal_uIntPtr GtkSalFrame::ShowPopover(const OUString& rHelpText, const Rectangle& GtkWidget *pLabel = gtk_label_new(sUTF.getStr()); gtk_container_add(GTK_CONTAINER(pWidget), pLabel); - GdkRectangle aRect; - aRect.x = rHelpArea.Left(); - aRect.y = rHelpArea.Top(); - aRect.width = rHelpArea.GetWidth(); - aRect.height = rHelpArea.GetHeight(); - - gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &aRect); - if (nFlags & QuickHelpFlags::Top) gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_BOTTOM); else if (nFlags & QuickHelpFlags::Bottom) @@ -2493,6 +2512,8 @@ sal_uIntPtr GtkSalFrame::ShowPopover(const OUString& rHelpText, const Rectangle& else if (nFlags & QuickHelpFlags::Right) gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_LEFT); + set_pointing_to(GTK_POPOVER(pWidget), rHelpArea); + gtk_popover_set_modal(GTK_POPOVER(pWidget), false); gtk_widget_show_all(pWidget); @@ -2511,13 +2532,7 @@ bool GtkSalFrame::UpdatePopover(sal_uIntPtr nId, const OUString& rHelpText, cons #if GTK_CHECK_VERSION(3,12,0) GtkWidget *pWidget = reinterpret_cast(nId); - GdkRectangle aRect; - aRect.x = rHelpArea.Left(); - aRect.y = rHelpArea.Top(); - aRect.width = rHelpArea.GetWidth(); - aRect.height = rHelpArea.GetHeight(); - - gtk_popover_set_pointing_to(GTK_POPOVER(pWidget), &aRect); + set_pointing_to(GTK_POPOVER(pWidget), rHelpArea); GtkWidget *pLabel = gtk_bin_get_child(GTK_BIN(pWidget)); OString sUTF = OUStringToOString(rHelpText, RTL_TEXTENCODING_UTF8);