summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-11-25 12:37:40 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-11-25 15:05:08 +0100
commitd69b3007b6417395ac726c1c3ef1466f7cb2f829 (patch)
tree6bbedee75edb1509bcf8d294654072052fd78a71
parentrequired curl_multi_wakeup is only in >= curl 7.68.0 (diff)
downloadcore-d69b3007b6417395ac726c1c3ef1466f7cb2f829.tar.gz
core-d69b3007b6417395ac726c1c3ef1466f7cb2f829.zip
Resolves: tdf#145786 get the correct bounds with window scaling enabled
the per-window/app scaling as opposed to the global desktop one which wasn't affected. the menubutton thought it saw the mouse release happen outside the window it popped up when the combobox inside it was clicked, so popped down the popup from underneath the combobox. Change-Id: Iace9538073bb2380443d87600a872e88885934d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125807 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx53
1 files changed, 16 insertions, 37 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 0efca48a7312..523525e445a2 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -9856,22 +9856,20 @@ GtkPositionType show_menu(GtkWidget* pMenuButton, GtkWindow* pMenu, const GdkRec
namespace {
#if !GTK_CHECK_VERSION(4, 0, 0)
-bool button_release_is_outside(GtkWidget* pWidget, GtkWidget* pMenuHack, GdkEventButton* pEvent)
+bool button_event_is_outside(GtkWidget* pMenuHack, GdkEventButton* pEvent)
{
//we want to pop down if the button was released outside our popup
gdouble x = pEvent->x_root;
gdouble y = pEvent->y_root;
- gint xoffset, yoffset;
- gdk_window_get_root_origin(widget_get_surface(pWidget), &xoffset, &yoffset);
- GtkAllocation alloc;
- gtk_widget_get_allocation(pWidget, &alloc);
- xoffset += alloc.x;
- yoffset += alloc.y;
+ gint window_x, window_y;
+ GdkSurface* pWindow = widget_get_surface(pMenuHack);
+ gdk_window_get_position(pWindow, &window_x, &window_y);
+ GtkAllocation alloc;
gtk_widget_get_allocation(pMenuHack, &alloc);
- gint x1 = alloc.x + xoffset;
- gint y1 = alloc.y + yoffset;
+ gint x1 = window_x;
+ gint y1 = window_y;
gint x2 = x1 + alloc.width;
gint y2 = y1 + alloc.height;
@@ -10037,10 +10035,10 @@ private:
return false;
}
- static gboolean signalButtonRelease(GtkWidget* pWidget, GdkEventButton* pEvent, gpointer widget)
+ static gboolean signalButtonRelease(GtkWidget* /*pWidget*/, GdkEventButton* pEvent, gpointer widget)
{
GtkInstanceMenuButton* pThis = static_cast<GtkInstanceMenuButton*>(widget);
- if (pThis->m_nButtonPressSeen && button_release_is_outside(pWidget, GTK_WIDGET(pThis->m_pMenuHack), pEvent))
+ if (pThis->m_nButtonPressSeen && button_event_is_outside(GTK_WIDGET(pThis->m_pMenuHack), pEvent))
pThis->set_active(false);
return false;
}
@@ -20402,36 +20400,17 @@ private:
}
}
- static gboolean signalButtonPress(GtkWidget* pWidget, GdkEventButton* pEvent, gpointer widget)
+ static gboolean signalButtonPress(GtkWidget*, GdkEventButton* pEvent, gpointer widget)
{
GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
- return pThis->button_press(pWidget, pEvent);
+ return pThis->button_press(pEvent);
}
- bool button_press(GtkWidget* pWidget, GdkEventButton* pEvent)
+ bool button_press(GdkEventButton* pEvent)
{
//we want to pop down if the button was pressed outside our popup
- gdouble x = pEvent->x_root;
- gdouble y = pEvent->y_root;
- gint xoffset, yoffset;
- gdk_window_get_root_origin(widget_get_surface(pWidget), &xoffset, &yoffset);
-
- GtkAllocation alloc;
- gtk_widget_get_allocation(pWidget, &alloc);
- xoffset += alloc.x;
- yoffset += alloc.y;
-
- gtk_widget_get_allocation(GTK_WIDGET(m_pMenuWindow), &alloc);
- gint x1 = alloc.x + xoffset;
- gint y1 = alloc.y + yoffset;
- gint x2 = x1 + alloc.width;
- gint y2 = y1 + alloc.height;
-
- if (x > x1 && x < x2 && y > y1 && y < y2)
- return false;
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_pToggleButton), false);
-
+ if (button_event_is_outside(GTK_WIDGET(m_pMenuWindow), pEvent))
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_pToggleButton), false);
return false;
}
@@ -22028,10 +22007,10 @@ private:
return false;
}
- static gboolean signalButtonRelease(GtkWidget* pWidget, GdkEventButton* pEvent, gpointer widget)
+ static gboolean signalButtonRelease(GtkWidget* /*pWidget*/, GdkEventButton* pEvent, gpointer widget)
{
GtkInstancePopover* pThis = static_cast<GtkInstancePopover*>(widget);
- if (pThis->m_nButtonPressSeen && button_release_is_outside(pWidget, GTK_WIDGET(pThis->m_pMenuHack), pEvent))
+ if (pThis->m_nButtonPressSeen && button_event_is_outside(GTK_WIDGET(pThis->m_pMenuHack), pEvent))
pThis->popdown();
return false;
}