[metacity] surface: add meta_surface_has_shadow



commit f18e07052f25d01d7b10a64d72c486ffd9f92a08
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Oct 19 22:26:24 2019 +0300

    surface: add meta_surface_has_shadow

 src/compositor/meta-surface.c | 50 +++++++++++++++++++++++++++++++++++++++++++
 src/compositor/meta-surface.h |  2 ++
 2 files changed, 52 insertions(+)
---
diff --git a/src/compositor/meta-surface.c b/src/compositor/meta-surface.c
index d3ead157..52d9114b 100644
--- a/src/compositor/meta-surface.c
+++ b/src/compositor/meta-surface.c
@@ -25,6 +25,7 @@
 #include "errors.h"
 #include "frame.h"
 #include "meta-compositor-private.h"
+#include "prefs.h"
 #include "window-private.h"
 
 typedef struct
@@ -624,6 +625,55 @@ meta_surface_get_image (MetaSurface *self)
   return META_SURFACE_GET_CLASS (self)->get_image (self);
 }
 
+gboolean
+meta_surface_has_shadow (MetaSurface *self)
+{
+  MetaSurfacePrivate *priv;
+
+  priv = meta_surface_get_instance_private (self);
+
+  /* Do not add shadows to fullscreen windows */
+  if (meta_window_is_fullscreen (priv->window))
+    return FALSE;
+
+  /* Do not add shadows to maximized windows */
+  if (meta_window_is_maximized (priv->window))
+    return FALSE;
+
+  /* Add shadows to windows with frame */
+  if (meta_window_get_frame (priv->window) != NULL)
+    {
+      /* Do not add shadows if GTK+ theme is used */
+      if (meta_prefs_get_theme_type () == META_THEME_TYPE_GTK)
+        return FALSE;
+
+      return TRUE;
+    }
+
+  /* Do not add shadows to non-opaque windows */
+  if (!meta_surface_is_opaque (self))
+    return FALSE;
+
+  /* Do not add shadows to client side decorated windows */
+  if (meta_window_is_client_decorated (priv->window))
+    return FALSE;
+
+  /* Never put a shadow around shaped windows */
+  if (priv->window->shape_region != None)
+    return FALSE;
+
+  /* Don't put shadow around DND icon windows */
+  if (priv->window->type == META_WINDOW_DND)
+    return FALSE;
+
+  /* Don't put shadow around desktop windows */
+  if (priv->window->type == META_WINDOW_DESKTOP)
+    return FALSE;
+
+  /* Add shadows to all other windows */
+  return TRUE;
+}
+
 gboolean
 meta_surface_is_opaque (MetaSurface *self)
 {
diff --git a/src/compositor/meta-surface.h b/src/compositor/meta-surface.h
index 9fc74ed8..60d9824b 100644
--- a/src/compositor/meta-surface.h
+++ b/src/compositor/meta-surface.h
@@ -47,6 +47,8 @@ XserverRegion    meta_surface_get_shape_region      (MetaSurface        *self);
 
 cairo_surface_t *meta_surface_get_image             (MetaSurface        *self);
 
+gboolean         meta_surface_has_shadow            (MetaSurface        *self);
+
 gboolean         meta_surface_is_opaque             (MetaSurface        *self);
 
 gboolean         meta_surface_is_visible            (MetaSurface        *self);


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