[gtk/present-toplevel-2: 15/71] Introduce GdkToplevel
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel-2: 15/71] Introduce GdkToplevel
- Date: Thu, 5 Mar 2020 02:27:50 +0000 (UTC)
commit 75b7f2e8bcd35d980a919c55b7dad6b063b1b441
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 29 10:07:43 2020 -0500
Introduce GdkToplevel
This is a new interface for toplevel surfaces.
gdk/gdk.h | 1 +
gdk/gdktoplevel.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdktoplevel.h | 45 +++++++++++++++++++++++++++
gdk/gdktoplevelprivate.h | 21 +++++++++++++
gdk/meson.build | 2 ++
5 files changed, 149 insertions(+)
---
diff --git a/gdk/gdk.h b/gdk/gdk.h
index a4f434511e..5f6b03f3eb 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -70,6 +70,7 @@
#include <gdk/gdksurface.h>
#include <gdk/gdkpopup.h>
#include <gdk/gdktoplevellayout.h>
+#include <gdk/gdktoplevel.h>
#include <gdk/gdk-autocleanup.h>
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
new file mode 100644
index 0000000000..c4155e860f
--- /dev/null
+++ b/gdk/gdktoplevel.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#include "config.h"
+
+#include "gdktoplevelprivate.h"
+
+/**
+ * SECTION:gdktoplevel
+ * @Short_description: Interface for toplevel surfaces
+ * @Title: Toplevels
+ *
+ * A #GdkToplevel is a freestanding toplevel surface.
+ */
+
+
+/* FIXME: this can't have GdkSurface as a prerequisite
+ * as long as GdkSurface implements this interface itself
+ */
+G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, G_TYPE_OBJECT)
+
+static gboolean
+gdk_toplevel_default_present (GdkToplevel *toplevel,
+ int width,
+ int height,
+ GdkToplevelLayout *layout)
+{
+ return FALSE;
+}
+
+static void
+gdk_toplevel_default_init (GdkToplevelInterface *iface)
+{
+ iface->present = gdk_toplevel_default_present;
+}
+
+/**
+ * gdk_toplevel_present:
+ * @toplevel: the #GdkToplevel to show
+ * @width: the unconstrained toplevel width to layout
+ * @height: the unconstrained toplevel height to layout
+ * @layout: the #GdkToplevelLayout object used to layout
+ *
+ * Present @toplevel after having processed the #GdkToplevelLayout rules.
+ * If the toplevel was previously now showing, it will be showed,
+ * otherwise it will change layout according to @layout.
+ *
+ * Presenting may fail.
+ *
+ * Returns: %FALSE if @toplevel failed to be presented, otherwise %TRUE.
+ */
+gboolean
+gdk_toplevel_present (GdkToplevel *toplevel,
+ int width,
+ int height,
+ GdkToplevelLayout *layout)
+{
+ g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
+ g_return_val_if_fail (width > 0, FALSE);
+ g_return_val_if_fail (height > 0, FALSE);
+ g_return_val_if_fail (layout != NULL, FALSE);
+
+ return GDK_TOPLEVEL_GET_IFACE (toplevel)->present (toplevel, width, height, layout);
+}
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
new file mode 100644
index 0000000000..eeb01582aa
--- /dev/null
+++ b/gdk/gdktoplevel.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen <mclasen redhat com>
+ */
+
+#ifndef __GDK_TOPLEVEL_H__
+#define __GDK_TOPLEVEL_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdksurface.h>
+#include <gdk/gdktoplevellayout.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_TOPLEVEL (gdk_toplevel_get_type ())
+
+GDK_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (GdkToplevel, gdk_toplevel, GDK, TOPLEVEL, GObject)
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_present (GdkToplevel *toplevel,
+ int width,
+ int height,
+ GdkToplevelLayout *layout);
+
+G_END_DECLS
+
+#endif /* __GDK_TOPLEVEL_H__ */
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
new file mode 100644
index 0000000000..bfa81c4282
--- /dev/null
+++ b/gdk/gdktoplevelprivate.h
@@ -0,0 +1,21 @@
+#ifndef __GDK_TOPLEVEL_PRIVATE_H__
+#define __GDK_TOPLEVEL_PRIVATE_H__
+
+#include "gdktoplevel.h"
+
+G_BEGIN_DECLS
+
+
+struct _GdkToplevelInterface
+{
+ GTypeInterface g_iface;
+
+ gboolean (* present) (GdkToplevel *toplevel,
+ int width,
+ int height,
+ GdkToplevelLayout *layout);
+};
+
+G_END_DECLS
+
+#endif /* __GDK_TOPLEVEL_PRIVATE_H__ */
diff --git a/gdk/meson.build b/gdk/meson.build
index 27d1bc3cda..0c1a277549 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -47,6 +47,7 @@ gdk_public_sources = files([
'gdkprofiler.c',
'gdkpopup.c',
'gdktoplevellayout.c',
+ 'gdktoplevel.c',
])
gdk_public_headers = files([
@@ -93,6 +94,7 @@ gdk_public_headers = files([
'gdkpopuplayout.h',
'gdkpopup.h',
'gdktoplevellayout.h',
+ 'gdktoplevel.h',
])
install_headers(gdk_public_headers, subdir: 'gtk-4.0/gdk/')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]