Subject: Re: bug#24084: 25.1; GTK3 mode-line drop down menu partially off-screen

From: Alex <[email-masked]>
Date: Thu, 15 Jun 2017 23:31:51 -0600

Sebastian Schueppel <[email-masked]> writes:

> This is related to a multi monitor setup: I have 3 monitors set from left to
> right. The middle monitor has a vertical orientation therefore the pixels
> available on that one is swapped. The monitors have the following resolutions:
> (1680x1050)(1050x1680)(1680x1050)
> If I do the following on one of the horizontal/normal oriented monitors the mode-line drop down menu disappears partially off-screen.
>
> starting from 'emacs -Q'
>
> maximize the frame on one of the monitors with normal orientation (1680x1050)
> and click in the mode-line on the line number or column number. The
> popup/dropdown menu will partially disappear at the bottom of the monitor.
>
> --
> My debug/quickfix so far: 
>
> The popup menus like this are defined in emacs/src/xmenu.c 
> Since I'm using GTK3 the 'menu_position_func' function is always used to define the position of the popup menu. Which is certainly the correct thing to do, otherwise GTK3 does sometimes some funky stuff. Now in my 3 monitor set-up, the function within 'menu_position_func' called 'x_display_pixel_height' always thinks the height of my screen is 1680 and therefore thinks there is room to display the menu below. It doesn't take into account that one monitor is vertical oriented and has a height of 1680, but the other 2 monitor are set up normal with a height of 1080. 
>
> I have used the following quickfix using GTK3 build in functions using monitors rather than the whole screen information. Adding the following to 'menu_position_func' to get the geometry of the monitor the frame is on. I understand that this might not be generic enough, but it works for me. 
>
> <code>
> #include <gdk/gdk.h>
>
> GdkRectangle workarea;
> // get the monitor the current frame is on
> gint widgetMonitor = gdk_screen_get_monitor_at_point(gtk_widget_get_screen(FRAME_GTK_OUTER_WIDGET (data->f)),*x,*y);
> gdk_screen_get_monitor_workarea(gtk_widget_get_screen(FRAME_GTK_OUTER_WIDGET (data->f)),widgetMonitor,&workarea);
> // now instead of using disp_width and disp_height we use a combination of monitor absolut position and monitor working area.
> // monitor absolute position being  workarea.x workarea.y and monitor size being workarea.height and workarea.width
> </code>
>
> I'm omitting the rest of the code here where those values are used as it should be obvious. Hope this will help to get a more generic solution out there. 

I believe this is fixed in the latest master. Can you confirm? It should
work for any GTK version.