Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menu: avoid deprecated gtk_menu_popup #709

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tormodvolden
Copy link
Contributor

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.

Use gtk_menu_popup_at_rect() instead.

Adapted from metacity commit 37fa0d19 by Alberts Muktupāvels

Signed-off-by: Tormod Volden <[email protected]>
Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds fine and mostly runs as expected in a quick test except for one thing, which seems to be a problem ONLY on hidpi displays or otherwise with window-scaling-factor=2 : menus shown on right-clicking the title bar (if that option has been selected) or clicking the title bar menu icon usually get rendered out of position.
Marco_PR_Menu_Placement_Error_12-14-2021
If I set window-scaling-factor=1 these menus come up where I would expect them to, looking the same as with master.

@lukefromdc
Copy link
Member

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
Copy link
Contributor Author

tormodvolden commented Dec 14, 2021

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
Copy link
Contributor Author

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

Adapted from metacity commit 2a7e7be by Alberts Muktupāvels

Signed-off-by: Tormod Volden <[email protected]>
Adapted from metacity commit ca73ad5c by Alberts Muktupāvels

Signed-off-by: Tormod Volden <[email protected]>
Adapted from metacity commit af0bbded by Alberts Muktupāvels

Commit 37fa0d19f35a replaced gtk_menu_popup with gtk_menu_popup_at_rect
to avoid deprecated warning making it more complicated then needed.

gtk_menu_popup_at_rect requires two parameters that are not always
available. For example we don't have GdkWindow for CSD windows. And
next commit will popup menu in response of ClientMessage event where
we don't have any info about key and/or button press events.

Simplify code by creating fake event in menu.c with minimal data
needed for gtk_menu_popup_at_rect. GdkEvent is used to get GdkDevice,
button and time. For GdkWindow we can use root window.

Signed-off-by: Tormod Volden <[email protected]>
@lukefromdc
Copy link
Member

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
Copy link
Contributor Author

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 f6e3326. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants