Commit a05bafff authored by Tobias Bading's avatar Tobias Bading Committed by Robert Pluim

Fix incorrect GTK menus on HiDPI monitors with scaling factor > 1

This should fix Bug#31223, Bug#28106, Bug#23672 as well as Ubuntu bug
https://bugs.launchpad.net/ubuntu/+source/emacs25/+bug/1695228

Also fixes the formerly unscaled Y value returned by
frame-monitor-workarea (and display-monitor-attributes-list).

For details on why some GTK menus were empty please see thread
https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg01061.html

* src/gtkutil.c (menubar_map_cb, xg_update_frame_menubar): Scale up
req.height so that the menu bar's height is in device pixels as
expected.
(xg_event_is_for_menubar): Scale down rec.x and rec.y so that
gtk_widget_intersect() works as intended.
* src/xfns.c (Fx_display_monitor_attributes_list): Scale work.x and
work.y up to be in device pixels.

Copyright-paperwork-exempt: yes
parent 16ce6dbe
Pipeline #4225 failed with stage
in 56 minutes and 50 seconds
......@@ -3471,6 +3471,7 @@ menubar_map_cb (GtkWidget *w, gpointer user_data)
GtkRequisition req;
struct frame *f = user_data;
gtk_widget_get_preferred_size (w, NULL, &req);
req.height *= xg_get_scale (f);
if (FRAME_MENUBAR_HEIGHT (f) != req.height)
{
FRAME_MENUBAR_HEIGHT (f) = req.height;
......@@ -3502,7 +3503,7 @@ xg_update_frame_menubar (struct frame *f)
g_signal_connect (x->menubar_widget, "map", G_CALLBACK (menubar_map_cb), f);
gtk_widget_show_all (x->menubar_widget);
gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req);
req.height *= xg_get_scale (f);
if (FRAME_MENUBAR_HEIGHT (f) != req.height)
{
FRAME_MENUBAR_HEIGHT (f) = req.height;
......@@ -3568,8 +3569,9 @@ xg_event_is_for_menubar (struct frame *f, const XEvent *event)
list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget));
if (! list) return 0;
rec.x = event->xbutton.x;
rec.y = event->xbutton.y;
int scale = xg_get_scale (f);
rec.x = event->xbutton.x / scale;
rec.y = event->xbutton.y / scale;
rec.width = 1;
rec.height = 1;
......
......@@ -5093,6 +5093,8 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
#endif
rec.width *= scale;
rec.height *= scale;
work.x *= scale;
work.y *= scale;
work.width *= scale;
work.height *= scale;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment