diff options
author | Rui Matos <tiagomatos@gmail.com> | 2017-02-07 13:39:34 +0100 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2017-03-02 19:40:27 +0100 |
commit | 1f20e82a96eeb63207de9849b007a8da9f3002b5 (patch) | |
tree | 6c7084a5b80bdddfdb518df52e3857f833a41d97 /src/ui | |
parent | 1079850621fa283bb465d38334ddafbb73a2ee74 (diff) | |
download | mutter-1f20e82a96eeb63207de9849b007a8da9f3002b5.tar.gz |
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
Diffstat (limited to 'src/ui')
-rw-r--r-- | 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 6abe52ef6..271ed6b36 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; |