[metacity] frame: cache borders
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] frame: cache borders
- Date: Wed, 13 Apr 2016 13:07:45 +0000 (UTC)
commit 3c6e269ba39c3dac99a38301fa9b799c3c202043
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Nov 15 17:37:50 2013 -0500
frame: cache borders
Cache the computed border size so we can fetch the border size at
any time without worrying that we'll be spending too much time in
the theme code (in some cases we might allocate a PangoFontDescription
or do other significant work.)
The main effort here is clearing the cache when various bits of window
state change that could potentially affect the computed borders.
https://bugzilla.gnome.org/show_bug.cgi?id=707194
src/core/core.c | 1 +
src/core/display.c | 2 ++
src/core/frame-private.h | 6 ++++++
src/core/frame.c | 26 +++++++++++++++++++++++---
src/core/window-private.h | 2 ++
src/core/window.c | 25 +++++++++++++++++++++++--
6 files changed, 57 insertions(+), 5 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index 38a62a1..b679ebf 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -232,6 +232,7 @@ meta_core_queue_frame_resize (Display *xdisplay,
MetaWindow *window = get_window (xdisplay, frame_xwindow);
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
+ meta_window_frame_size_changed (window);
}
void
diff --git a/src/core/display.c b/src/core/display.c
index 1cffd62..d83c7b3 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -4071,6 +4071,8 @@ meta_display_queue_retheme_all_windows (MetaDisplay *display)
MetaWindow *window = tmp->data;
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
+ meta_window_frame_size_changed (window);
+
if (window->frame)
{
window->frame->need_reapply_frame_shape = TRUE;
diff --git a/src/core/frame-private.h b/src/core/frame-private.h
index bae2616..ec94d4e 100644
--- a/src/core/frame-private.h
+++ b/src/core/frame-private.h
@@ -40,6 +40,9 @@ struct _MetaFrame
*/
MetaRectangle rect;
+ /* valid if borders_cached is set */
+ MetaFrameBorders cached_borders;
+
/* position of client, size of frame */
int child_x;
int child_y;
@@ -49,6 +52,7 @@ struct _MetaFrame
guint mapped : 1;
guint need_reapply_frame_shape : 1;
guint is_flashing : 1; /* used by the visual bell flash */
+ guint borders_cached : 1;
};
void meta_window_ensure_frame (MetaWindow *window);
@@ -62,6 +66,8 @@ gboolean meta_frame_sync_to_window (MetaFrame *frame,
gboolean need_move,
gboolean need_resize);
+void meta_frame_clear_cached_borders (MetaFrame *frame);
+
cairo_region_t *meta_frame_get_frame_bounds (MetaFrame *frame);
void meta_frame_set_screen_cursor (MetaFrame *frame,
diff --git a/src/core/frame.c b/src/core/frame.c
index 93ed884..03d4e66 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -83,6 +83,7 @@ meta_window_ensure_frame (MetaWindow *window)
frame->mapped = FALSE;
frame->need_reapply_frame_shape = TRUE;
frame->is_flashing = FALSE;
+ frame->borders_cached = FALSE;
meta_verbose ("Framing window %s: visual %s default, depth %d default depth %d\n",
window->desc,
@@ -340,9 +341,28 @@ void
meta_frame_calc_borders (MetaFrame *frame,
MetaFrameBorders *borders)
{
- meta_ui_get_frame_borders (frame->window->screen->ui,
- frame->xwindow,
- borders);
+ if (frame == NULL)
+ {
+ meta_frame_borders_clear (borders);
+ }
+ else
+ {
+ if (!frame->borders_cached)
+ {
+ meta_ui_get_frame_borders (frame->window->screen->ui,
+ frame->xwindow,
+ &frame->cached_borders);
+ frame->borders_cached = TRUE;
+ }
+
+ *borders = frame->cached_borders;
+ }
+}
+
+void
+meta_frame_clear_cached_borders (MetaFrame *frame)
+{
+ frame->borders_cached = FALSE;
}
static gboolean
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 1f201be..0d917b0 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -649,6 +649,8 @@ const char* meta_window_get_startup_id (MetaWindow *window);
void meta_window_recalc_features (MetaWindow *window);
void meta_window_recalc_window_type (MetaWindow *window);
+void meta_window_frame_size_changed (MetaWindow *window);
+
void meta_window_stack_just_above (MetaWindow *window,
MetaWindow *above_this_one);
void meta_window_stack_just_below (MetaWindow *window,
diff --git a/src/core/window.c b/src/core/window.c
index 7eac51c..07ed8af 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2828,6 +2828,8 @@ meta_window_make_above (MetaWindow *window)
meta_window_update_layer (window);
meta_window_raise (window);
set_net_wm_state (window);
+
+ meta_window_frame_size_changed (window);
}
void
@@ -2837,6 +2839,8 @@ meta_window_unmake_above (MetaWindow *window)
meta_window_raise (window);
meta_window_update_layer (window);
set_net_wm_state (window);
+
+ meta_window_frame_size_changed (window);
}
void
@@ -2961,7 +2965,8 @@ meta_window_shade (MetaWindow *window,
{
window->shaded = TRUE;
- meta_window_queue(window, META_QUEUE_MOVE_RESIZE | META_QUEUE_CALC_SHOWING);
+ meta_window_queue (window, META_QUEUE_MOVE_RESIZE | META_QUEUE_CALC_SHOWING);
+ meta_window_frame_size_changed (window);
/* After queuing the calc showing, since _focus flushes it,
* and we need to focus the frame
@@ -2984,7 +2989,9 @@ meta_window_unshade (MetaWindow *window,
if (window->shaded)
{
window->shaded = FALSE;
- meta_window_queue(window, META_QUEUE_MOVE_RESIZE | META_QUEUE_CALC_SHOWING);
+
+ meta_window_queue (window, META_QUEUE_MOVE_RESIZE | META_QUEUE_CALC_SHOWING);
+ meta_window_frame_size_changed (window);
/* focus the window */
meta_topic (META_DEBUG_FOCUS,
@@ -4437,6 +4444,8 @@ window_stick_impl (MetaWindow *window)
*/
window->on_all_workspaces = TRUE;
+ meta_window_frame_size_changed (window);
+
/* We do, however, change the MRU lists of all the workspaces
*/
tmp = window->screen->workspaces;
@@ -4467,6 +4476,8 @@ window_unstick_impl (MetaWindow *window)
window->on_all_workspaces = FALSE;
+ meta_window_frame_size_changed (window);
+
/* Remove window from MRU lists that it doesn't belong in */
tmp = window->screen->workspaces;
while (tmp)
@@ -5515,6 +5526,7 @@ static void
meta_window_appears_focused_changed (MetaWindow *window)
{
set_net_wm_state (window);
+ meta_window_frame_size_changed (window);
if (window->frame)
meta_frame_queue_draw (window->frame);
@@ -6297,6 +6309,13 @@ recalc_window_type (MetaWindow *window)
}
}
+void
+meta_window_frame_size_changed (MetaWindow *window)
+{
+ if (window->frame)
+ meta_frame_clear_cached_borders (window->frame);
+}
+
static void
set_allowed_actions_hint (MetaWindow *window)
{
@@ -6588,6 +6607,8 @@ recalc_window_features (MetaWindow *window)
old_always_sticky != window->always_sticky)
set_allowed_actions_hint (window);
+ meta_window_frame_size_changed (window);
+
/* FIXME perhaps should ensure if we don't have a shade func,
* we aren't shaded, etc.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]