summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libwnck/meson.build2
-rw-r--r--libwnck/private.h3
-rw-r--r--libwnck/util.c29
-rw-r--r--libwnck/wnck-handle-private.h33
-rw-r--r--libwnck/wnck-handle.c137
-rw-r--r--meson.build2
6 files changed, 198 insertions, 8 deletions
diff --git a/libwnck/meson.build b/libwnck/meson.build
index 0cd68fc..04f30d6 100644
--- a/libwnck/meson.build
+++ b/libwnck/meson.build
@@ -37,6 +37,8 @@ sources = [
'util.c',
'window-action-menu.c',
'window.c',
+ 'wnck-handle-private.h',
+ 'wnck-handle.c',
'wnck-image-menu-item-private.h',
'wnck-image-menu-item.c',
'workspace.c',
diff --git a/libwnck/private.h b/libwnck/private.h
index 492fd2c..f1a4af2 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -30,6 +30,7 @@
#include "xutils.h"
#include "pager.h"
#include "util.h"
+#include "wnck-handle-private.h"
#ifdef HAVE_STARTUP_NOTIFICATION
#include <libsn/sn.h>
#endif
@@ -38,6 +39,8 @@ G_BEGIN_DECLS
#define WNCK_ACTIVATE_TIMEOUT 1
+WnckHandle *_wnck_get_handle (void);
+
WnckClientType _wnck_get_client_type (void);
gsize _wnck_get_default_icon_size (void);
diff --git a/libwnck/util.c b/libwnck/util.c
index c8e0e6e..b3d8750 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -655,16 +655,29 @@ wnck_set_client_type (WnckClientType ewmh_sourceindication_client_type)
client_type = ewmh_sourceindication_client_type;
}
+static WnckHandle *wnck_handle = NULL;
+
+WnckHandle *
+_wnck_get_handle (void)
+{
+ if (wnck_handle == NULL)
+ {
+ /* If the type hasn't been set yet, use the default--treat it as a
+ * normal application.
+ */
+ if (client_type == 0)
+ client_type = WNCK_CLIENT_TYPE_APPLICATION;
+
+ wnck_handle = _wnck_handle_new (client_type);
+ }
+
+ return wnck_handle;
+}
+
WnckClientType
_wnck_get_client_type (void)
{
- /* If the type hasn't been set yet, use the default--treat it as a
- * normal application.
- */
- if (client_type == 0)
- client_type = WNCK_CLIENT_TYPE_APPLICATION;
-
- return client_type;
+ return _wnck_handle_get_client_type (_wnck_get_handle ());
}
static gsize default_icon_size = WNCK_DEFAULT_ICON_SIZE;
@@ -844,6 +857,8 @@ wnck_shutdown (void)
_wnck_screen_shutdown_all ();
_wnck_window_shutdown_all ();
+ g_clear_object (&wnck_handle);
+
#ifdef HAVE_XRES
if (xres_removeid != 0)
g_source_remove (xres_removeid);
diff --git a/libwnck/wnck-handle-private.h b/libwnck/wnck-handle-private.h
new file mode 100644
index 0000000..156821a
--- /dev/null
+++ b/libwnck/wnck-handle-private.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WNCK_HANDLE_PRIVATE_H
+#define WNCK_HANDLE_PRIVATE_H
+
+#include "util.h"
+
+G_BEGIN_DECLS
+
+typedef struct _WnckHandle WnckHandle;
+
+WnckHandle *_wnck_handle_new (WnckClientType client_type);
+
+WnckClientType _wnck_handle_get_client_type (WnckHandle *self);
+
+G_END_DECLS
+
+#endif
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
new file mode 100644
index 0000000..c49a640
--- /dev/null
+++ b/libwnck/wnck-handle.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2021 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "wnck-handle-private.h"
+
+#include "wnck-enum-types.h"
+
+#define WNCK_TYPE_HANDLE (wnck_handle_get_type ())
+G_DECLARE_FINAL_TYPE (WnckHandle, wnck_handle, WNCK, HANDLE, GObject)
+
+struct _WnckHandle
+{
+ GObject parent;
+
+ WnckClientType client_type;
+};
+
+enum
+{
+ PROP_0,
+
+ PROP_CLIENT_TYPE,
+
+ LAST_PROP
+};
+
+static GParamSpec *handle_properties[LAST_PROP] = { NULL };
+
+G_DEFINE_TYPE (WnckHandle, wnck_handle, G_TYPE_OBJECT)
+
+static void
+wnck_handle_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ WnckHandle *self;
+
+ self = WNCK_HANDLE (object);
+
+ switch (property_id)
+ {
+ case PROP_CLIENT_TYPE:
+ g_value_set_enum (value, self->client_type);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+wnck_handle_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ WnckHandle *self;
+
+ self = WNCK_HANDLE (object);
+
+ switch (property_id)
+ {
+ case PROP_CLIENT_TYPE:
+ self->client_type = g_value_get_enum (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+install_properties (GObjectClass *object_class)
+{
+ handle_properties[PROP_CLIENT_TYPE] =
+ g_param_spec_enum ("client-type",
+ "client-type",
+ "client-type",
+ WNCK_TYPE_CLIENT_TYPE,
+ WNCK_CLIENT_TYPE_APPLICATION,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class,
+ LAST_PROP,
+ handle_properties);
+}
+
+static void
+wnck_handle_class_init (WnckHandleClass *self_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (self_class);
+
+ object_class->get_property = wnck_handle_get_property;
+ object_class->set_property = wnck_handle_set_property;
+
+ install_properties (object_class);
+}
+
+static void
+wnck_handle_init (WnckHandle *self)
+{
+}
+
+WnckHandle
+*_wnck_handle_new (WnckClientType client_type)
+{
+ return g_object_new (WNCK_TYPE_HANDLE,
+ "client-type", client_type,
+ NULL);
+}
+
+WnckClientType
+_wnck_handle_get_client_type (WnckHandle *self)
+{
+ return self->client_type;
+}
diff --git a/meson.build b/meson.build
index 11f7b3d..b2a1711 100644
--- a/meson.build
+++ b/meson.build
@@ -40,7 +40,7 @@ XRES_PACKAGE = 'xres'
pkg_deps = [
{'name': 'cairo-xlib-xrender', 'required': false},
- {'name': 'glib-2.0', 'version': '>= 2.34' },
+ {'name': 'glib-2.0', 'version': '>= 2.44' },
{'name': 'gobject-2.0', 'version': '>= 2.13.0' },
{'name': 'gtk+-3.0', 'version': '>= 3.22.0' },
{'name': STARTUP_NOTIFICATION_PACKAGE, 'version': '>= 0.4', 'required': get_option('startup_notification')},