@@ -291,6 +291,21 @@ void WindowGeometryOverlay::start_or_stop_move_to_tile_overlay_animation(TileWin
291
291
}
292
292
}
293
293
294
+ Gfx::IntRect WindowGeometryOverlay::calculate_ideal_overlay_rect () const
295
+ {
296
+ auto rect = calculate_frame_rect (m_label_rect).centered_within (m_window->frame ().rect ());
297
+ auto desktop_rect = WindowManager::the ().desktop_rect (ScreenInput::the ().cursor_location_screen ());
298
+ if (rect.left () < desktop_rect.left ())
299
+ rect.set_left (desktop_rect.left ());
300
+ if (rect.top () < desktop_rect.top ())
301
+ rect.set_top (desktop_rect.top ());
302
+ if (rect.right () > desktop_rect.right ())
303
+ rect.set_right_without_resize (desktop_rect.right ());
304
+ if (rect.bottom () > desktop_rect.bottom ())
305
+ rect.set_bottom_without_resize (desktop_rect.bottom ());
306
+ return rect;
307
+ }
308
+
294
309
void WindowGeometryOverlay::window_rect_changed ()
295
310
{
296
311
if (auto * window = m_window.ptr ()) {
@@ -310,17 +325,7 @@ void WindowGeometryOverlay::window_rect_changed()
310
325
}
311
326
m_label_rect = Gfx::IntRect { 0 , 0 , static_cast <int >(ceilf (wm.font ().width (m_label))) + 16 , wm.font ().pixel_size_rounded_up () + 10 };
312
327
313
- auto rect = calculate_frame_rect (m_label_rect).centered_within (window->frame ().rect ());
314
- auto desktop_rect = wm.desktop_rect (ScreenInput::the ().cursor_location_screen ());
315
- if (rect.left () < desktop_rect.left ())
316
- rect.set_left (desktop_rect.left ());
317
- if (rect.top () < desktop_rect.top ())
318
- rect.set_top (desktop_rect.top ());
319
- if (rect.right () > desktop_rect.right ())
320
- rect.set_right_without_resize (desktop_rect.right ());
321
- if (rect.bottom () > desktop_rect.bottom ())
322
- rect.set_bottom_without_resize (desktop_rect.bottom ());
323
- m_ideal_overlay_rect = rect;
328
+ m_ideal_overlay_rect = calculate_ideal_overlay_rect ();
324
329
set_actual_rect ();
325
330
invalidate_content (); // Needed in case the rectangle itself doesn't change, but the contents did.
326
331
}
0 commit comments