GNOME Bugzilla – Bug 661256
windows doesn't remember their positions when moved by keyboard shortcuts
Last modified: 2012-03-13 16:20:41 UTC
When I use a keyboard shortcuts set in gconf to move a window (move_to_{e,n,s,w}), it moves as expected but when I then use shortcut to drag it to another workspace (shift+ctrl+alt+up/down) it is back in it's previous position. Similar thing happens when I use toggle_shaded shortcut - window is back at it's previous position.
Ok, so handle_move_to_corner_backend (responsible for move_to_{e,n,s,w} actions) calls meta_window_move_resize with user_op set to FALSE. This causes meta_window_move_resize_internal to call save_user_window_placement. So I changed handle_move_to_corner_backend to set user_op to TRUE, as handle_move_to_center is doing (which is behaving correctly), and that fixed the problem of remembering window position after move_to_{e,n,s,w}. But now windows that I move using these shortcuts are no longer positioned correctly. I mean they are few pixels off screen and doesn't respect top bar. Why is this broken?
It seems constrain_to_single_monitor as well as constrain_fully_onscreen exits early because is_user_action == true. In result do_screen_and_monitor_relative_constraints, which probably would fix window placement, is not executed. Any chance of fixing this?
Created attachment 205806 [details] [review] A fix for this bug This makes windows save their placement after move_to_side_* actions by passing additional flag to meta_window_move_resize_internal telling it to call save_user_window_placement. Now it works as expected.
Review of attachment 205806 [details] [review]: Good job tracking down this problem. In general, functions with boolean parameters should be looked at with suspicion, since it makes callers hard to read - the function of a TRUE or FALSE is not obvious to someone reading the code. Functions with multiple booleans are basically always wrong, so I don't want to add an extra boolean to meta_window_move_resize() An alternative would be make meta_window_move_resize() take flags like meta_window_move_resize_internal() - this is a better way to do a function with options. Still, I'm a little reluctant to make that change: * I don't want to make meta_window_move_resize() different from other members of the family - meta_window_move(), meta_window_resize(), etc, which currently take the user_op boolean, so we'd need to change all of them. * But these other functions are public and used in gnome-shell extensions, etc, so changing them would be a bit of a compatibility headache. So, I'm more inclined to look around for another solution. I think the basic problem you were seeing wasn't that the constraint was needed, but rather that the logic in handle_move_to_corner_backend() isn't quite right with the addition of invisible borders. Will attach my attempt at a fix. Testing appreciated!
Created attachment 209533 [details] [review] Fix move-to-corner keybindings The move-to-corner keybindings weren't treated as user actions, which resulted in them not affecting the saved position - they weren't always being treated as sticky. Marking them as a user action revealed bugs in the positioning logic that were hidden by the constraint code applied to automated moves. Fix those as well. Bug tracked down by Mariusz Libera.
Review of attachment 209533 [details] [review]: LGTM (and works in testing)
Thanks for looking into it. I tried that patch with mutter 3.2.2 but results weren't good - http://www.youtube.com/watch?v=i3yUdnJFBds Is version from git required for it to work properly?
(In reply to comment #7) > I tried that patch with mutter 3.2.2 but results weren't > good - http://www.youtube.com/watch?v=i3yUdnJFBds Looks like bug 659643.
(In reply to comment #8) > (In reply to comment #7) > > I tried that patch with mutter 3.2.2 but results weren't > > good - http://www.youtube.com/watch?v=i3yUdnJFBds > > Looks like bug 659643. Yeah, at least the fix for that is going to be needed to make this patch work.
Attachment 209533 [details] pushed as 047b9de - Fix move-to-corner keybindings