-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
base: master
Are you sure you want to change the base?
menu: avoid deprecated gtk_menu_popup #709
Conversation
Use gtk_menu_popup_at_rect() instead. Adapted from metacity commit 37fa0d19 by Alberts Muktupāvels Signed-off-by: Tormod Volden <[email protected]>
There was a problem hiding this 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.
If I set window-scaling-factor=1 these menus come up where I would expect them to, looking the same as with master.
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 |
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]>
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 |
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. |
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.