From: Tobias Bading <tbading@web.de>
To: 31223@debbugs.gnu.org
Subject: bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1
Date: Wed, 27 Nov 2019 17:03:32 +0100 [thread overview]
Message-ID: <0425bcb6-97ee-4845-3571-9db492966a34@web.de> (raw)
In-Reply-To: <vu7c70k1t285s5.fsf@chaotikum.eu>
[-- Attachment #1: Type: text/plain, Size: 771 bytes --]
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): properly scale req.height so that the menu bar's
height is in device pixels as expected
(xg_update_frame_menubar): dito
(xg_event_is_for_menubar): properly scale rec.x and rec.y so that
gtk_widget_intersect() works as intended
* src/xfns.c
(Fx_display_monitor_attributes_list): properly scale work.x and work.y
[-- Attachment #2: 0001-Fix-empty-incorrect-GTK-menus-on-HiDPI-monitors.patch --]
[-- Type: text/x-patch, Size: 2765 bytes --]
From ee5855067f50f6e208a960994eec7184d44d324e Mon Sep 17 00:00:00 2001
From: Tobias Bading <tbading@web.de>
Date: Wed, 27 Nov 2019 16:51:26 +0100
Subject: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window
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): properly scale req.height so that the menu bar's
height is in device pixels as expected
(xg_update_frame_menubar): dito
(xg_event_is_for_menubar): properly scale rec.x and rec.y so that
gtk_widget_intersect() works as intended
* src/xfns.c
(Fx_display_monitor_attributes_list): properly scale work.x and work.y
---
src/gtkutil.c | 8 +++++---
src/xfns.c | 2 ++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/gtkutil.c b/src/gtkutil.c
index cf5c31aa20..7e6db57c9d 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -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;
diff --git a/src/xfns.c b/src/xfns.c
index b1b40702c2..47aa19607f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5093,6 +5093,8 @@ DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list,
#endif
rec.width *= scale;
rec.height *= scale;
+ work.x *= scale;
+ work.y *= scale;
work.width *= scale;
work.height *= scale;
--
2.20.1
next prev parent reply other threads:[~2019-11-27 16:03 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 11:40 bug#31223: 25.3; New menus are empty with GTK3 Thomas Schneider
[not found] ` <handler.31223.B.15242361664927.ack@debbugs.gnu.org>
2018-05-01 16:16 ` Thomas Schneider
2018-05-01 16:48 ` Eli Zaretskii
2018-05-01 17:01 ` Thomas Schneider
2018-05-01 17:08 ` Eli Zaretskii
2018-05-01 17:20 ` Thomas Schneider
2018-05-01 18:43 ` Eli Zaretskii
2018-05-03 8:36 ` Thomas Schneider
2018-05-03 17:52 ` Eli Zaretskii
2018-07-20 22:44 ` Noam Postavsky
2018-05-01 23:18 ` Noam Postavsky
2019-11-27 16:03 ` Tobias Bading [this message]
2019-11-28 8:20 ` bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1 Robert Pluim
2019-11-28 9:32 ` Tobias Bading
2019-11-28 9:44 ` Robert Pluim
2019-12-02 10:35 ` Robert Pluim
2019-12-02 15:53 ` Eli Zaretskii
2019-12-03 8:22 ` Robert Pluim
2019-12-17 14:43 ` Robert Pluim
2020-01-07 16:15 ` Robert Pluim
2020-01-07 16:22 ` Eli Zaretskii
2020-01-07 16:31 ` Robert Pluim
2019-11-28 12:04 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0425bcb6-97ee-4845-3571-9db492966a34@web.de \
--to=tbading@web.de \
--cc=31223@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).