mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
compositor: Don't emit size-changed when only position changes
Waking up gnome-shell and triggering JavaScript listeners of `size-changed` every time a window was only moved was wasting a lot of CPU. This cuts the CPU requirement for dragging windows by around 22%. https://gitlab.gnome.org/GNOME/mutter/merge_requests/568
This commit is contained in:
parent
b0b1ff36ae
commit
01e20a6ba9
@ -1134,7 +1134,11 @@ meta_compositor_sync_window_geometry (MetaCompositor *compositor,
|
|||||||
gboolean did_placement)
|
gboolean did_placement)
|
||||||
{
|
{
|
||||||
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (meta_window_get_compositor_private (window));
|
||||||
meta_window_actor_sync_actor_geometry (window_actor, did_placement);
|
MetaWindowActorChanges changes;
|
||||||
|
|
||||||
|
changes = meta_window_actor_sync_actor_geometry (window_actor, did_placement);
|
||||||
|
|
||||||
|
if (changes & META_WINDOW_ACTOR_CHANGE_SIZE)
|
||||||
meta_plugin_manager_event_size_changed (compositor->plugin_mgr, window_actor);
|
meta_plugin_manager_event_size_changed (compositor->plugin_mgr, window_actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,12 @@ struct _MetaWindowActorClass
|
|||||||
void (*queue_destroy) (MetaWindowActor *actor);
|
void (*queue_destroy) (MetaWindowActor *actor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
META_WINDOW_ACTOR_CHANGE_SIZE = 1 << 0,
|
||||||
|
META_WINDOW_ACTOR_CHANGE_POSITION = 1 << 1
|
||||||
|
} MetaWindowActorChanges;
|
||||||
|
|
||||||
void meta_window_actor_queue_destroy (MetaWindowActor *self);
|
void meta_window_actor_queue_destroy (MetaWindowActor *self);
|
||||||
|
|
||||||
void meta_window_actor_show (MetaWindowActor *self,
|
void meta_window_actor_show (MetaWindowActor *self,
|
||||||
@ -59,8 +65,10 @@ void meta_window_actor_set_unredirected (MetaWindowActor *self,
|
|||||||
gboolean unredirected);
|
gboolean unredirected);
|
||||||
|
|
||||||
gboolean meta_window_actor_effect_in_progress (MetaWindowActor *self);
|
gboolean meta_window_actor_effect_in_progress (MetaWindowActor *self);
|
||||||
void meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
|
||||||
|
MetaWindowActorChanges meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
||||||
gboolean did_placement);
|
gboolean did_placement);
|
||||||
|
|
||||||
void meta_window_actor_update_shape (MetaWindowActor *self);
|
void meta_window_actor_update_shape (MetaWindowActor *self);
|
||||||
void meta_window_actor_update_opacity (MetaWindowActor *self);
|
void meta_window_actor_update_opacity (MetaWindowActor *self);
|
||||||
void meta_window_actor_mapped (MetaWindowActor *self);
|
void meta_window_actor_mapped (MetaWindowActor *self);
|
||||||
|
@ -1120,13 +1120,15 @@ meta_window_actor_queue_destroy (MetaWindowActor *self)
|
|||||||
clutter_actor_destroy (CLUTTER_ACTOR (self));
|
clutter_actor_destroy (CLUTTER_ACTOR (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
MetaWindowActorChanges
|
||||||
meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
||||||
gboolean did_placement)
|
gboolean did_placement)
|
||||||
{
|
{
|
||||||
MetaWindowActorPrivate *priv =
|
MetaWindowActorPrivate *priv =
|
||||||
meta_window_actor_get_instance_private (self);
|
meta_window_actor_get_instance_private (self);
|
||||||
MetaRectangle window_rect;
|
MetaRectangle window_rect;
|
||||||
|
ClutterActor *actor = CLUTTER_ACTOR (self);
|
||||||
|
MetaWindowActorChanges changes = 0;
|
||||||
|
|
||||||
meta_window_get_buffer_rect (priv->window, &window_rect);
|
meta_window_get_buffer_rect (priv->window, &window_rect);
|
||||||
|
|
||||||
@ -1144,15 +1146,42 @@ meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
|
|||||||
* updates.
|
* updates.
|
||||||
*/
|
*/
|
||||||
if (is_frozen (self) && !did_placement)
|
if (is_frozen (self) && !did_placement)
|
||||||
return;
|
return META_WINDOW_ACTOR_CHANGE_POSITION | META_WINDOW_ACTOR_CHANGE_SIZE;
|
||||||
|
|
||||||
if (meta_window_actor_effect_in_progress (self))
|
if (meta_window_actor_effect_in_progress (self))
|
||||||
return;
|
return META_WINDOW_ACTOR_CHANGE_POSITION | META_WINDOW_ACTOR_CHANGE_SIZE;
|
||||||
|
|
||||||
clutter_actor_set_position (CLUTTER_ACTOR (self),
|
if (clutter_actor_has_allocation (actor))
|
||||||
window_rect.x, window_rect.y);
|
{
|
||||||
clutter_actor_set_size (CLUTTER_ACTOR (self),
|
ClutterActorBox box;
|
||||||
window_rect.width, window_rect.height);
|
float old_x, old_y;
|
||||||
|
float old_width, old_height;
|
||||||
|
|
||||||
|
clutter_actor_get_allocation_box (actor, &box);
|
||||||
|
|
||||||
|
old_x = box.x1;
|
||||||
|
old_y = box.y1;
|
||||||
|
old_width = box.x2 - box.x1;
|
||||||
|
old_height = box.y2 - box.y1;
|
||||||
|
|
||||||
|
if (old_x != window_rect.x || old_y != window_rect.y)
|
||||||
|
changes |= META_WINDOW_ACTOR_CHANGE_POSITION;
|
||||||
|
|
||||||
|
if (old_width != window_rect.width || old_height != window_rect.height)
|
||||||
|
changes |= META_WINDOW_ACTOR_CHANGE_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changes = META_WINDOW_ACTOR_CHANGE_POSITION | META_WINDOW_ACTOR_CHANGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes & META_WINDOW_ACTOR_CHANGE_POSITION)
|
||||||
|
clutter_actor_set_position (actor, window_rect.x, window_rect.y);
|
||||||
|
|
||||||
|
if (changes & META_WINDOW_ACTOR_CHANGE_SIZE)
|
||||||
|
clutter_actor_set_size (actor, window_rect.width, window_rect.height);
|
||||||
|
|
||||||
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user