diff options
| author | Victor Kareh <[email protected]> | 2025-09-09 15:52:30 -0400 |
|---|---|---|
| committer | Luke from DC <[email protected]> | 2025-11-01 18:55:54 +0000 |
| commit | b403cd0598e236825299050b665390e2aec32775 (patch) | |
| tree | 5c15fae1cc97b2fa19c494da0337fb0b12afeb0a /src/core/keybindings.c | |
| parent | 3261bbdce6cc0fa494c257849cb69c640f1aeade (diff) | |
| download | marco-b403cd0598e236825299050b665390e2aec32775.tar.bz2 marco-b403cd0598e236825299050b665390e2aec32775.tar.xz | |
keybindings: Fix move-to-center calculation
There was a 10px difference in the calculation between the (correct)
center-new-windows placement and the (incorrect) move-to-center
keybinding. By using the same function in both places we can make sure
the calculation is consistent.
Diffstat (limited to 'src/core/keybindings.c')
| -rw-r--r-- | src/core/keybindings.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c index fb3131c2..a00e0eaf 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -2703,23 +2703,34 @@ handle_move_to_center (MetaDisplay *display, const MetaXineramaScreenInfo* current; MetaRectangle work_area; MetaRectangle outer; - int orig_x, orig_y; - int frame_width, frame_height; + MetaFrameBorders borders; + int client_x, client_y; current = meta_screen_get_xinerama_for_window(screen, window); meta_window_get_work_area_for_xinerama (window, current->number, &work_area); meta_window_get_outer_rect (window, &outer); - meta_window_get_position (window, &orig_x, &orig_y); - frame_width = (window->frame ? window->frame->child_x : 0); - frame_height = (window->frame ? window->frame->child_y : 0); + center_rect_in_area (&outer, &work_area); + + /* Convert frame position to client position */ + if (window->frame) + { + meta_frame_calc_borders (window->frame, &borders); + client_x = outer.x + borders.visible.left; + client_y = outer.y + borders.visible.top; + } + else + { + client_x = outer.x; + client_y = outer.y; + } meta_window_move_resize (window, TRUE, - work_area.x + (work_area.width +frame_width -outer.width )/2, - work_area.y + (work_area.height+frame_height-outer.height)/2, + client_x, + client_y, window->rect.width, window->rect.height); } |
