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 | |
| 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')
| -rw-r--r-- | src/core/keybindings.c | 25 | ||||
| -rw-r--r-- | src/core/place.c | 2 | ||||
| -rw-r--r-- | src/core/place.h | 3 |
3 files changed, 22 insertions, 8 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); } diff --git a/src/core/place.c b/src/core/place.c index 1aafff79..854469a9 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -528,7 +528,7 @@ center_tile_rect_in_area (MetaRectangle *rect, rect->y = work_area->y + fluff; } -static void +void center_rect_in_area (MetaRectangle *rect, MetaRectangle *work_area) { diff --git a/src/core/place.h b/src/core/place.h index 468e3a39..6a2d0ff4 100644 --- a/src/core/place.h +++ b/src/core/place.h @@ -34,4 +34,7 @@ void meta_window_place (MetaWindow *window, int *new_x, int *new_y); +void center_rect_in_area (MetaRectangle *rect, + MetaRectangle *work_area); + #endif |
