[metacity] window: add window-type property



commit ba6655fba1e7c4026feaaf46386ec2544d1a12d3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Oct 19 19:00:35 2019 +0300

    window: add window-type property

 src/Makefile.am               | 23 +++++++++++++++++++++++
 src/core/meta-enum-types.c.in | 41 +++++++++++++++++++++++++++++++++++++++++
 src/core/meta-enum-types.h.in | 21 +++++++++++++++++++++
 src/core/window.c             | 13 +++++++++++++
 4 files changed, 98 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 76d7c02c..98f9a698 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -116,6 +116,7 @@ metacity_SOURCES=                           \
        include/tile-preview.h                  \
        ui/ui.c                                 \
        ui/ui-private.h                         \
+       $(BUILT_SOURCES) \
        $(NULL)
 
 if HAVE_VULKAN
@@ -139,4 +140,26 @@ noinst_PROGRAMS=testboxes testasyncgetprop
 testboxes_LDADD= @METACITY_LIBS@
 testasyncgetprop_LDADD= @METACITY_LIBS@
 
+ENUM_TYPES = \
+       core/window-private.h \
+       $(NULL)
+
+core/meta-enum-types.c: core/meta-enum-types.c.in core/meta-enum-types.h $(ENUM_TYPES)
+       $(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/core/meta-enum-types.c.in $(ENUM_TYPES) > \
+               meta-enum-types.c.tmp && mv meta-enum-types.c.tmp core/meta-enum-types.c
+
+core/meta-enum-types.h: core/meta-enum-types.h.in $(ENUM_TYPES)
+       $(AM_V_GEN) $(GLIB_MKENUMS) --template $(srcdir)/core/meta-enum-types.h.in $(ENUM_TYPES) > \
+               meta-enum-types.h.tmp && mv meta-enum-types.h.tmp core/meta-enum-types.h
+
+BUILT_SOURCES = \
+       core/meta-enum-types.c \
+       core/meta-enum-types.h \
+       $(NULL)
+
+EXTRA_DIST = \
+       core/meta-enum-types.c.in \
+       core/meta-enum-types.h.in \
+       $(NULL)
+
 -include $(top_srcdir)/git.mk
diff --git a/src/core/meta-enum-types.c.in b/src/core/meta-enum-types.c.in
new file mode 100644
index 00000000..03e8b8fa
--- /dev/null
+++ b/src/core/meta-enum-types.c.in
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+#include "meta-enum-types.h"
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+#include "@filename@"
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+
+GType
+@enum_name@_get_type (void)
+{
+  static volatile gsize g_enum_type_id;
+  static const G@Type@Value values[] =
+    {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+      { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+      { 0, NULL, NULL }
+    };
+
+  if (g_once_init_enter (&g_enum_type_id))
+    {
+      const gchar *string;
+      GType id;
+
+      string = g_intern_static_string ("@EnumName@");
+      id = g_@type@_register_static (string, values);
+
+      g_once_init_leave (&g_enum_type_id, id);
+    }
+
+  return g_enum_type_id;
+}
+/*** END value-tail ***/
diff --git a/src/core/meta-enum-types.h.in b/src/core/meta-enum-types.h.in
new file mode 100644
index 00000000..ce4fd1f2
--- /dev/null
+++ b/src/core/meta-enum-types.h.in
@@ -0,0 +1,21 @@
+/*** BEGIN file-header ***/
+#ifndef META_ENUM_TYPES_H
+#define META_ENUM_TYPES_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
+
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif
+/*** END file-tail ***/
diff --git a/src/core/window.c b/src/core/window.c
index f45374f7..08fd7996 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -43,6 +43,7 @@
 #include "window-props.h"
 #include "constraints.h"
 #include "meta-compositor.h"
+#include "meta-enum-types.h"
 #include "effects.h"
 
 #include <X11/Xatom.h>
@@ -137,6 +138,7 @@ enum
 
   PROP_APPEARS_FOCUSED,
   PROP_DECORATED,
+  PROP_WINDOW_TYPE,
   PROP_SHADED,
 
   LAST_PROP
@@ -6702,6 +6704,8 @@ recalc_window_type (MetaWindow *window)
 
       if (decorated != window->decorated)
         g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_DECORATED]);
+
+      g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_WINDOW_TYPE]);
     }
 }
 
@@ -9312,6 +9316,10 @@ meta_window_get_property (GObject    *object,
         g_value_set_boolean (value, window->decorated);
         break;
 
+      case PROP_WINDOW_TYPE:
+        g_value_set_enum (value, window->type);
+        break;
+
       case PROP_SHADED:
         g_value_set_boolean (value, window->shaded);
         break;
@@ -9333,6 +9341,11 @@ install_properties (GObjectClass *object_class)
     g_param_spec_boolean ("decorated", "decorated", "decorated",
                           TRUE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
+  properties[PROP_WINDOW_TYPE] =
+    g_param_spec_enum ("window-type", "window-type", "window-type",
+                       META_TYPE_WINDOW_TYPE, META_WINDOW_NORMAL,
+                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
   properties[PROP_SHADED] =
     g_param_spec_boolean ("shaded", "shaded", "shaded",
                           FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);


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