[mutter] ui/frames: Simplify client area control computation



commit 1f20e82a96eeb63207de9849b007a8da9f3002b5
Author: Rui Matos <tiagomatos gmail com>
Date:   Tue Feb 7 13:39:34 2017 +0100

    ui/frames: Simplify client area control computation
    
    Ungrabbed pointer motion events over a client window area don't even
    reach mutter in X compositor mode, but as a wayland compositor we
    process those events which ends up in a call stack like:
    
    - meta_window_handle_ungrabbed_event
     - meta_ui_frame_handle_event
      - handle_motion_notify_event
       - get_control
        - meta_ui_frame_calc_geometry
    
    Computing frame geometry is a relatively CPU expensive operation and
    doing it on every motion event over a client window is pointless work
    since we aren't going to change the cursor or prelight any frame
    widget.
    
    This commit special cases the determination of
    META_FRAME_CONTROL_CLIENT_AREA using a much faster method. When
    continuously moving the pointer over an X (client) window, it results
    in a ~40% decrease in mutter cpu usage.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779436

 src/ui/frames.c |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 6abe52e..271ed6b 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -574,19 +574,6 @@ meta_ui_frame_get_borders (MetaUIFrame *frame,
                                 borders);
 }
 
-/* The client rectangle surrounds client window; it subtracts both
- * the visible and invisible borders from the frame window's size.
- */
-static void
-get_client_rect (MetaFrameGeometry     *fgeom,
-                 cairo_rectangle_int_t *rect)
-{
-  rect->x = fgeom->borders.total.left;
-  rect->y = fgeom->borders.total.top;
-  rect->width = fgeom->width - fgeom->borders.total.right - rect->x;
-  rect->height = fgeom->height - fgeom->borders.total.bottom - rect->y;
-}
-
 /* The visible frame rectangle surrounds the visible portion of the
  * frame window; it subtracts only the invisible borders from the frame
  * window's size.
@@ -1609,12 +1596,12 @@ get_control (MetaUIFrame *frame, int root_x, int root_y)
   x = root_x - win_x;
   y = root_y - win_y;
 
-  meta_ui_frame_calc_geometry (frame, &fgeom);
-  get_client_rect (&fgeom, &client);
-
+  meta_window_get_client_area_rect (frame->meta_window, &client);
   if (POINT_IN_RECT (x, y, client))
     return META_FRAME_CONTROL_CLIENT_AREA;
 
+  meta_ui_frame_calc_geometry (frame, &fgeom);
+
   if (POINT_IN_RECT (x, y, fgeom.close_rect.clickable))
     return META_FRAME_CONTROL_DELETE;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]