all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: Brian Zwahr <echosa@echosa.net>, 31880@debbugs.gnu.org
Subject: bug#31880: 26.1; VC mode line popup when clicked is off screen
Date: Wed, 20 Jun 2018 16:31:32 +0200	[thread overview]
Message-ID: <87vaad4ji3.fsf@gmail.com> (raw)
In-Reply-To: <5B2A40B2.4020600@gmx.at> (martin rudalics's message of "Wed, 20 Jun 2018 13:55:30 +0200")

martin rudalics <rudalics@gmx.at> writes:

>> It should, but it doesnʼt. I see similar problems here, but I donʼt
>> understand why (unless this is another instance of "Mixing X and GTK
>> calls will bite your arse eventually").
>
> What happens when you move a frame to the bottom of your screen and
> open a menu bar entry?  Does it also get hidden?

No, menu bar menus are fine.

>> GTK tooltips seem to appear in the right place, so Iʼll look for
>> inspiration there.
>
> It's up to GTK to decide whether a menu fits on the screen so maybe it
> messes up the height of menu bar text when scaling is in effect.  Does
> scaling affect the height of menus in the first place?  Does it affect
> the height of tooltips?
>

Yes and yes, because it affects the size of the font used to display
them.

> Thanks for looking into this, martin

Yet another instance of a disagreement between how GTK and X calculate
pixels. Who will rid me of this turbulent mix?

Brian, would it be possible for you to try out the following patch? It
fixes things for me here.

diff --git i/src/xmenu.c w/src/xmenu.c
index e7ef31ac56..3a245771e1 100644
--- i/src/xmenu.c
+++ w/src/xmenu.c
@@ -1162,11 +1162,16 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
   GtkRequisition req;
   int max_x = -1;
   int max_y = -1;
+  int scale = 1;
 
   Lisp_Object frame, workarea;
 
   XSETFRAME (frame, data->f);
 
+#ifdef HAVE_GTK3
+  scale = xg_get_scale (data->f);
+#endif
+
   /* TODO: Get the monitor workarea directly without calculating other
      items in x-display-monitor-attributes-list. */
   workarea = call3 (Qframe_monitor_workarea,
@@ -1192,11 +1197,18 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
       max_y = x_display_pixel_height (dpyinfo);
     }
 
+  /* frame-monitor-workarea and {x,y}_display_pixel_width/height all
+     return device pixels, but GTK wants scaled pixels.  The positions
+     passed in via data were already scaled for us.  */
+  max_x /= scale;
+  max_y /= scale;
   *x = data->x;
   *y = data->y;
 
   /* Check if there is room for the menu.  If not, adjust x/y so that
-     the menu is fully visible.  */
+     the menu is fully visible.  gtk_widget_get_preferred_size returns
+     scaled pixels, so there is no need to apply the scaling
+     factor.  */
   gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
   if (data->x + req.width > max_x)
     *x -= data->x + req.width - max_x;







  reply	other threads:[~2018-06-20 14:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 14:59 bug#31880: 26.1; VC mode line popup when clicked is off screen Brian Zwahr
2018-06-19  7:17 ` martin rudalics
     [not found]   ` <380133793885a54af49bbc8715cfea4ced525342.camel@echosa.net>
2018-06-20  7:42     ` martin rudalics
2018-06-20  9:52       ` Robert Pluim
2018-06-20 11:55         ` martin rudalics
2018-06-20 14:31           ` Robert Pluim [this message]
2018-06-20 20:15             ` Brian Zwahr
2018-06-21  8:08               ` Robert Pluim
2018-06-21 14:41                 ` Brian Zwahr
2018-06-21 15:05                   ` Robert Pluim
2018-06-21 15:39                     ` Eli Zaretskii
2018-06-22  8:04                       ` Robert Pluim
2018-06-22  8:56                     ` martin rudalics
2018-06-21  7:15             ` martin rudalics
2018-06-21  8:31               ` Robert Pluim
2018-06-21  8:56                 ` martin rudalics
2018-06-25 10:33   ` João Távora
2018-06-27  7:33     ` martin rudalics
2018-06-27  8:24       ` João Távora
2018-06-27  9:56         ` Robert Pluim
2018-06-27 11:16           ` João Távora

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vaad4ji3.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=31880@debbugs.gnu.org \
    --cc=echosa@echosa.net \
    --cc=rudalics@gmx.at \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.