[metacity] ui: avoid meta_prefs_get_compositing_manager



commit aaf6910efec7f3d741a42c5c021232a053757e61
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Mar 11 01:04:27 2017 +0200

    ui: avoid meta_prefs_get_compositing_manager

 src/compositor/meta-compositor.c |    6 ++++++
 src/core/display.c               |    4 ++++
 src/core/screen.c                |    4 +++-
 src/include/meta-compositor.h    |    2 ++
 src/include/ui.h                 |    6 +++++-
 src/ui/frames.c                  |   34 ++++++++++------------------------
 src/ui/frames.h                  |    2 ++
 src/ui/ui-private.h              |    4 +++-
 src/ui/ui.c                      |   35 ++++++++++++++++++++++++++++-------
 9 files changed, 63 insertions(+), 34 deletions(-)
---
diff --git a/src/compositor/meta-compositor.c b/src/compositor/meta-compositor.c
index 1c7f5c0..3c89340 100644
--- a/src/compositor/meta-compositor.c
+++ b/src/compositor/meta-compositor.c
@@ -379,6 +379,12 @@ meta_compositor_is_our_xwindow (MetaCompositor *compositor,
 }
 
 gboolean
+meta_compositor_is_composited (MetaCompositor *compositor)
+{
+  return !META_IS_COMPOSITOR_NONE (compositor);
+}
+
+gboolean
 meta_compositor_check_extensions (MetaCompositor  *compositor,
                                   GError         **error)
 {
diff --git a/src/core/display.c b/src/core/display.c
index b148608..421afb4 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -248,6 +248,7 @@ update_compositor (MetaDisplay *display,
 {
   const gchar *compositor;
   MetaCompositorType type;
+  gboolean composited;
 
   if (display->compositor != NULL)
     g_object_unref (display->compositor);
@@ -274,6 +275,9 @@ update_compositor (MetaDisplay *display,
 
   if (composite_windows)
     meta_screen_composite_all_windows (display->screen);
+
+  composited = meta_compositor_is_composited (display->compositor);
+  meta_ui_set_composited (display->screen->ui, composited);
 }
 
 /**
diff --git a/src/core/screen.c b/src/core/screen.c
index 316e936..9f4c193 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -342,6 +342,7 @@ meta_screen_new (MetaDisplay *display,
   char buf[128];
   guint32 manager_timestamp;
   gulong current_workspace;
+  gboolean composited;
 
   replace_current_wm = meta_get_replace_current_wm ();
 
@@ -580,7 +581,8 @@ meta_screen_new (MetaDisplay *display,
   screen->keys_grabbed = FALSE;
   meta_screen_grab_keys (screen);
 
-  screen->ui = meta_ui_new (screen->display->xdisplay);
+  composited = meta_compositor_is_composited (screen->display->compositor);
+  screen->ui = meta_ui_new (screen->display->xdisplay, composited);
 
   screen->tab_popup = NULL;
   screen->tile_preview = NULL;
diff --git a/src/include/meta-compositor.h b/src/include/meta-compositor.h
index 2e5c08d..4b8f114 100644
--- a/src/include/meta-compositor.h
+++ b/src/include/meta-compositor.h
@@ -96,6 +96,8 @@ void             meta_compositor_sync_stack             (MetaCompositor     *com
 gboolean         meta_compositor_is_our_xwindow         (MetaCompositor     *compositor,
                                                          Window              xwindow);
 
+gboolean         meta_compositor_is_composited          (MetaCompositor     *compositor);
+
 G_END_DECLS
 
 #endif
diff --git a/src/include/ui.h b/src/include/ui.h
index a536272..c0f677f 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -53,9 +53,13 @@ void meta_ui_remove_event_func (Display       *xdisplay,
                                 MetaEventFunc  func,
                                 gpointer       data);
 
-MetaUI* meta_ui_new (Display *xdisplay);
+MetaUI* meta_ui_new (Display  *xdisplay,
+                     gboolean  composited);
 void    meta_ui_free (MetaUI *ui);
 
+void meta_ui_set_composited (MetaUI   *ui,
+                             gboolean  composited);
+
 void meta_ui_theme_get_frame_borders (MetaUI           *ui,
                                       MetaFrameType     type,
                                       MetaFrameFlags    flags,
diff --git a/src/ui/frames.c b/src/ui/frames.c
index d143326..07f05fb 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -83,8 +83,6 @@ static void invalidate_all_caches (MetaFrames *frames);
 static void invalidate_whole_window (MetaFrames *frames,
                                      MetaUIFrame *frame);
 
-static void meta_frames_composited_changed (MetaFrames *frames);
-
 struct _MetaFrames
 {
   GtkWindow    parent;
@@ -425,9 +423,7 @@ static void
 prefs_changed_callback (MetaPreference pref,
                         void          *data)
 {
-  if (pref == META_PREF_COMPOSITING_MANAGER)
-    meta_frames_composited_changed (META_FRAMES (data));
-  else if (pref == META_PREF_TITLEBAR_FONT)
+  if (pref == META_PREF_TITLEBAR_FONT)
     meta_frames_font_changed (META_FRAMES (data));
   else if (pref == META_PREF_BUTTON_LAYOUT)
     meta_frames_button_layout_changed (META_FRAMES (data));
@@ -646,19 +642,6 @@ reattach_style_func (gpointer key, gpointer value, gpointer data)
 }
 
 static void
-meta_frames_composited_changed (MetaFrames *frames)
-{
-  MetaTheme *theme;
-  gboolean compositing_manager;
-
-  theme = meta_ui_get_theme (frames->ui);
-  compositing_manager = meta_prefs_get_compositing_manager ();
-
-  meta_theme_set_composited (theme, compositing_manager);
-  g_hash_table_foreach (frames->frames, queue_recalc_func, frames);
-}
-
-static void
 meta_frames_style_updated (GtkWidget *widget)
 {
   MetaFrames *frames;
@@ -1073,7 +1056,6 @@ meta_frames_apply_shapes (MetaFrames *frames,
   MetaUIFrame *frame;
   MetaFrameGeometry fgeom;
   cairo_region_t *window_region;
-  gboolean compositing_manager;
 
   frame = meta_frames_lookup_window (frames, xwindow);
   g_return_if_fail (frame != NULL);
@@ -1091,9 +1073,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
 
   meta_frames_calc_geometry (frames, frame, &fgeom);
 
-  compositing_manager = meta_prefs_get_compositing_manager ();
-
-  if (!window_has_shape && compositing_manager)
+  if (!window_has_shape && meta_ui_is_composited (frames->ui))
     return;
 
   window_region = get_visible_region (frames,
@@ -1161,7 +1141,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
                                          new_window_width,
                                          new_window_height);
 
-      tmp_region = compositing_manager ? frame_region : window_region;
+      tmp_region = meta_ui_is_composited (frames->ui) ? frame_region : window_region;
 
       cairo_region_subtract (tmp_region, client_region);
 
@@ -1189,7 +1169,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
                   "Frame 0x%lx has shaped corners\n",
                   frame->xwindow);
 
-      if (!compositing_manager)
+      if (!meta_ui_is_composited (frames->ui))
         apply_cairo_region_to_window (frames->xdisplay,
                                       frame->xwindow, window_region,
                                       ShapeSet);
@@ -2794,3 +2774,9 @@ invalidate_whole_window (MetaFrames *frames,
   gdk_window_invalidate_rect (frame->window, NULL, FALSE);
   invalidate_cache (frames, frame);
 }
+
+void
+meta_frames_composited_changed (MetaFrames *frames)
+{
+  g_hash_table_foreach (frames->frames, queue_recalc_func, frames);
+}
diff --git a/src/ui/frames.h b/src/ui/frames.h
index c5ba632..68d868c 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -131,4 +131,6 @@ void meta_frames_notify_menu_hide (MetaFrames *frames);
 void meta_frames_push_delay_exposes (MetaFrames *frames);
 void meta_frames_pop_delay_exposes  (MetaFrames *frames);
 
+void meta_frames_composited_changed (MetaFrames *frames);
+
 #endif
diff --git a/src/ui/ui-private.h b/src/ui/ui-private.h
index 15edc28..d5e9e2d 100644
--- a/src/ui/ui-private.h
+++ b/src/ui/ui-private.h
@@ -23,7 +23,9 @@
 
 G_BEGIN_DECLS
 
-MetaTheme *meta_ui_get_theme (MetaUI *ui);
+MetaTheme *meta_ui_get_theme     (MetaUI *ui);
+
+gboolean   meta_ui_is_composited (MetaUI *ui);
 
 G_END_DECLS
 
diff --git a/src/ui/ui.c b/src/ui/ui.c
index b88203a..f62f5c9 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -42,6 +42,7 @@ static void meta_ui_accelerator_parse (const char      *accel,
 struct _MetaUI
 {
   Display *xdisplay;
+  gboolean composited;
 
   MetaTheme *theme;
   MetaFrames *frames;
@@ -276,13 +277,15 @@ meta_ui_remove_event_func (Display       *xdisplay,
 }
 
 MetaUI*
-meta_ui_new (Display *xdisplay)
+meta_ui_new (Display  *xdisplay,
+             gboolean  composited)
 {
   GdkDisplay *gdisplay;
   MetaUI *ui;
 
   ui = g_new0 (MetaUI, 1);
   ui->xdisplay = xdisplay;
+  ui->composited = composited;
 
   gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
   g_assert (gdisplay == gdk_display_get_default ());
@@ -319,6 +322,19 @@ meta_ui_free (MetaUI *ui)
 }
 
 void
+meta_ui_set_composited (MetaUI   *ui,
+                        gboolean  composited)
+{
+  if (ui->composited == composited)
+    return;
+
+  ui->composited = composited;
+
+  meta_theme_set_composited (ui->theme, composited);
+  meta_frames_composited_changed (ui->frames);
+}
+
+void
 meta_ui_get_frame_mask (MetaUI  *ui,
                         Window   frame_xwindow,
                         guint    width,
@@ -698,6 +714,12 @@ meta_ui_get_theme (MetaUI *ui)
   return ui->theme;
 }
 
+gboolean
+meta_ui_is_composited (MetaUI *ui)
+{
+  return ui->composited;
+}
+
 static gchar *
 get_theme_name (MetaThemeType theme_type)
 {
@@ -720,11 +742,11 @@ get_theme_name (MetaThemeType theme_type)
 }
 
 static MetaTheme *
-load_theme (MetaThemeType  theme_type,
+load_theme (MetaUI        *ui,
+            MetaThemeType  theme_type,
             const gchar   *theme_name)
 {
   MetaTheme *theme;
-  gboolean compositing_manager;
   const PangoFontDescription *titlebar_font;
   GError *error;
   const gchar *button_layout;
@@ -732,8 +754,7 @@ load_theme (MetaThemeType  theme_type,
 
   theme = meta_theme_new (theme_type);
 
-  compositing_manager = meta_prefs_get_compositing_manager ();
-  meta_theme_set_composited (theme, compositing_manager);
+  meta_theme_set_composited (theme, ui->composited);
 
   titlebar_font = meta_prefs_get_titlebar_font ();
   meta_theme_set_titlebar_font (theme, titlebar_font);
@@ -766,13 +787,13 @@ meta_ui_reload_theme (MetaUI *ui)
   theme_type = meta_prefs_get_theme_type ();
   theme_name = get_theme_name (theme_type);
 
-  theme = load_theme (theme_type, theme_name);
+  theme = load_theme (ui, theme_type, theme_name);
   g_free (theme_name);
 
   if (theme == NULL)
     {
       g_warning (_("Falling back to default GTK+ theme - Adwaita"));
-      theme = load_theme (META_THEME_TYPE_GTK, "Adwaita");
+      theme = load_theme (ui, META_THEME_TYPE_GTK, "Adwaita");
     }
 
   g_set_object (&ui->theme, theme);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]