mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
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
This commit is contained in:
parent
1079850621
commit
1f20e82a96
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user