summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2013-11-15 17:37:50 -0500
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2016-04-13 16:08:58 +0300
commitde5024c666f7bc80e8d0657a8828efcc55310b73 (patch)
tree9681f6e4f5edfef55fd6e9dfbf63d39b792c5b41
parent020b48c84610a4238ff84a1d1251f3b5f2dffce1 (diff)
downloadmetacity-de5024c666f7bc80e8d0657a8828efcc55310b73.tar.gz
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
-rw-r--r--src/core/core.c1
-rw-r--r--src/core/display.c2
-rw-r--r--src/core/frame-private.h6
-rw-r--r--src/core/frame.c26
-rw-r--r--src/core/window-private.h2
-rw-r--r--src/core/window.c25
6 files changed, 57 insertions, 5 deletions
diff --git a/src/core/core.c b/src/core/core.c
index 38a62a1c..b679ebf8 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 1e552bb0..2ccb64a5 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 bae2616c..ec94d4e2 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 1258cefe..4542f638 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -120,6 +120,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,
@@ -386,9 +387,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 1f201bee..0d917b02 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 c8b10da9..57f82a17 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)
@@ -5516,6 +5527,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);
@@ -6298,6 +6310,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)
{
@@ -6584,6 +6603,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.
*/