mate-desktop / marco

MATE default window manager
https://mate-desktop.org
GNU General Public License v2.0
196 stars 87 forks source link

menu: avoid deprecated gtk_menu_popup #709

Open tormodvolden opened 2 years ago

tormodvolden commented 2 years ago

Adapted from metacity commit 37fa0d19 by Alberts Muktupāvels

Unsure about the handling of atom__GTK_SHOW_WINDOW_MENU xclient message in meta_window_client_message() in src/core/window.c - whether more gdk_event fields must be filled in, or if we could use button_press_event_new() from display.c instead. Also unsure on how to test this path.

lukefromdc commented 2 years ago

If I click around on the titlebar with the right-click mouse button, it appears that this menu is coming up exactly twice as far right and exactly twice as far down from the top left corner as it should. This implies the window scaling factor may be getting applied twice in calculating the menu's position. If it is 1 this has no effect of course

tormodvolden commented 2 years ago

Thanks for testing! I didn't see this as I likely have scaling factor 1. We should probably add the follow-up commits ca73ad5c and af0bbde from metacity.

tormodvolden commented 2 years ago

Hmm, ca73ad5c requires 2a7e7be - starting to smell rabbit hole.

lukefromdc commented 2 years ago

Still has problems with window-scaling-factor=2 and worse than before. Now the menu position depends on the distance of the clicked on point from the top left corner of the entire screen, not just the window

tormodvolden commented 2 years ago

A missing root/frame coordinate calculation? Is this the META_ACTION_TITLEBAR_MENU case in ui/frames.c? This part looks a bit odd now, and maybe needs scaling.

The first commit introduces get_window_scaling_factor() in display.c used for button events, and the second commit introduces another get_window_scaling_factor() in ui.c. The third commit removes the one from display.c and introduces meta_ui_get_scale() in ui.c, but this one is no longer used after the fourth commit. It is there, but not used, in current metacity as well. So if we pick something from here we could omit that. And also suggest removing it in metacity.

However, in metacity there is also a call in meta_ui_init() to "disable the automatic scale handling", and this was removed from marco in commit f6e3326a. Maybe more importantly, this commit introduced scaling in meta_window_menu_popup() which I removed in the first commit here because I thought it was no longer needed. I think the code has diverged so much from metacity that simple cherry-picking can no longer work, and it requires better understanding and a determination about which direction to take.