[gtk/present-toplevel: 18/54] Introduce GdkToplevelLayout
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel: 18/54] Introduce GdkToplevelLayout
- Date: Sun, 1 Mar 2020 19:35:13 +0000 (UTC)
commit c9e39f6a8224d83a98aa473e849282a2f91934df
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 29 10:31:22 2020 -0500
Introduce GdkToplevelLayout
This will be used in a new GdkTopleve interface in
the near future.
gdk/gdktoplevellayout.c | 277 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdktoplevellayout.h | 119 +++++++++++++++++++++
gdk/meson.build | 2 +
3 files changed, 398 insertions(+)
---
diff --git a/gdk/gdktoplevellayout.c b/gdk/gdktoplevellayout.c
new file mode 100644
index 0000000000..d42196837d
--- /dev/null
+++ b/gdk/gdktoplevellayout.c
@@ -0,0 +1,277 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2020 Red Hat
+ *
+ * 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 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/>.
+ *
+ */
+
+#include "config.h"
+
+#include "gdktoplevellayout.h"
+
+#include "gdkmonitor.h"
+
+struct _GdkToplevelLayout
+{
+ /* < private >*/
+ grefcount ref_count;
+
+ int min_width;
+ int min_height;
+ int max_width;
+ int max_height;
+ guint maximized : 1;
+ guint fullscreen : 1;
+ guint modal : 1;
+ guint raise : 1;
+ guint lower : 1;
+ GdkMonitor *fullscreen_monitor;
+ GdkSurfaceTypeHint type_hint;
+};
+
+G_DEFINE_BOXED_TYPE (GdkToplevelLayout, gdk_toplevel_layout,
+ gdk_toplevel_layout_ref,
+ gdk_toplevel_layout_unref)
+
+/**
+ * gdk_toplevel_layout_new: (constructor)
+ *
+ * Create a toplevel layout description. Used together with
+ * gdk_surface_present_toplevel() to describe how a toplevel surface
+ * should be placed and behave on-screen.
+ *
+ * Returns: (transfer full): newly created instance of #GdkToplevelLayout
+ */
+GdkToplevelLayout *
+gdk_toplevel_layout_new (int min_width,
+ int min_height,
+ int max_width,
+ int max_height)
+{
+ GdkToplevelLayout *layout;
+
+ layout = g_new0 (GdkToplevelLayout, 1);
+ g_ref_count_init (&layout->ref_count);
+ layout->min_width = min_width;
+ layout->min_height = min_height;
+ layout->max_width = max_width;
+ layout->max_height = max_height;
+ layout->type_hint = GDK_SURFACE_TYPE_HINT_NORMAL;
+ layout->maximized = FALSE;
+ layout->fullscreen = FALSE;
+ layout->fullscreen_monitor = NULL;
+ layout->raise = TRUE;
+ layout->lower = FALSE;
+
+ return layout;
+}
+
+/**
+ * gdk_toplevel_layout_ref:
+ * @layout: a #GdkToplevelLayout
+ *
+ * Increases the reference count of @layout.
+ *
+ * Returns: the same @layout
+ */
+GdkToplevelLayout *
+gdk_toplevel_layout_ref (GdkToplevelLayout *layout)
+{
+ g_ref_count_inc (&layout->ref_count);
+ return layout;
+}
+
+/**
+ * gdk_toplevel_layout_unref:
+ * @layout: a #GdkToplevelLayout
+ *
+ * Decreases the reference count of @layout.
+ */
+void
+gdk_toplevel_layout_unref (GdkToplevelLayout *layout)
+{
+ if (g_ref_count_dec (&layout->ref_count))
+ {
+ g_clear_object (&layout->fullscreen_monitor);
+ g_free (layout);
+ }
+}
+
+/**
+ * gdk_toplevel_layout_copy:
+ * @layout: a #GdkToplevelLayout
+ *
+ * Create a new #GdkToplevelLayout and copy the contents of @layout into it.
+ *
+ * Returns: (transfer full): a copy of @layout.
+ */
+GdkToplevelLayout *
+gdk_toplevel_layout_copy (GdkToplevelLayout *layout)
+{
+ GdkToplevelLayout *new_layout;
+
+ new_layout = g_new0 (GdkToplevelLayout, 1);
+ g_ref_count_init (&new_layout->ref_count);
+
+ new_layout->min_width = layout->min_width;
+ new_layout->min_height = layout->min_height;
+ new_layout->max_width = layout->max_width;
+ new_layout->max_height = layout->max_height;
+ new_layout->maximized = layout->maximized;
+ new_layout->fullscreen = layout->fullscreen;
+ if (layout->fullscreen_monitor)
+ new_layout->fullscreen_monitor = g_object_ref (layout->fullscreen_monitor);
+ new_layout->raise = layout->raise;
+ new_layout->lower = layout->lower;
+
+ return new_layout;
+}
+
+/**
+ * gdk_toplevel_layout_equal:
+ * @layout: a #GdkToplevelLayout
+ * @other: another #GdkToplevelLayout
+ *
+ * Check whether @layout and @other has identical layout properties.
+ *
+ * Returns: %TRUE if @layout and @other have identical layout properties,
+ * otherwise %FALSE.
+ */
+gboolean
+gdk_toplevel_layout_equal (GdkToplevelLayout *layout,
+ GdkToplevelLayout *other)
+{
+ g_return_val_if_fail (layout, FALSE);
+ g_return_val_if_fail (other, FALSE);
+
+ return layout->min_width == other->min_width &&
+ layout->min_height == other->min_height &&
+ layout->max_width == other->max_width &&
+ layout->max_height == other->max_height &&
+ layout->maximized == other->maximized &&
+ layout->fullscreen == other->fullscreen &&
+ layout->fullscreen_monitor == other->fullscreen_monitor;
+}
+
+
+void
+gdk_toplevel_layout_get_min_size (GdkToplevelLayout *layout,
+ int *width,
+ int *height)
+{
+ *width = layout->min_width;
+ *height = layout->min_height;
+}
+
+void
+gdk_toplevel_layout_get_max_size (GdkToplevelLayout *layout,
+ int *width,
+ int *height)
+{
+ *width = layout->max_width;
+ *height = layout->max_height;
+}
+
+void
+gdk_toplevel_layout_set_maximized (GdkToplevelLayout *layout,
+ gboolean maximized)
+{
+ layout->maximized = maximized;
+}
+
+
+gboolean
+gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout)
+{
+ return layout->maximized;
+}
+
+void
+gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
+ gboolean fullscreen,
+ GdkMonitor *monitor)
+{
+ layout->fullscreen = fullscreen;
+ if (monitor)
+ layout->fullscreen_monitor = g_object_ref (monitor);
+}
+
+gboolean
+gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout)
+{
+ return layout->fullscreen;
+}
+
+GdkMonitor *
+gdk_toplevel_layout_get_fullscreen_monitor (GdkToplevelLayout *layout)
+{
+ return layout->fullscreen_monitor;
+}
+
+void
+gdk_toplevel_layout_set_modal (GdkToplevelLayout *layout,
+ gboolean modal)
+{
+ layout->modal = modal;
+}
+
+
+gboolean
+gdk_toplevel_layout_get_modal (GdkToplevelLayout *layout)
+{
+ return layout->modal;
+}
+
+void
+gdk_toplevel_layout_set_type_hint (GdkToplevelLayout *layout,
+ GdkSurfaceTypeHint type_hint)
+{
+ layout->type_hint = type_hint;
+}
+
+
+GdkSurfaceTypeHint
+gdk_toplevel_layout_get_type_hint (GdkToplevelLayout *layout)
+{
+ return layout->type_hint;
+}
+
+void
+gdk_toplevel_layout_set_raise (GdkToplevelLayout *layout,
+ gboolean raise)
+{
+ layout->raise = raise;
+}
+
+
+gboolean
+gdk_toplevel_layout_get_raise (GdkToplevelLayout *layout)
+{
+ return layout->raise;
+}
+
+void
+gdk_toplevel_layout_set_lower (GdkToplevelLayout *layout,
+ gboolean lower)
+{
+ layout->lower = lower;
+}
+
+
+gboolean
+gdk_toplevel_layout_get_lower (GdkToplevelLayout *layout)
+{
+ return layout->lower;
+}
+
diff --git a/gdk/gdktoplevellayout.h b/gdk/gdktoplevellayout.h
new file mode 100644
index 0000000000..4817d07040
--- /dev/null
+++ b/gdk/gdktoplevellayout.h
@@ -0,0 +1,119 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2020 Red Hat
+ *
+ * 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 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/>.
+ *
+ */
+
+#ifndef __GDK_TOPLEVEL_LAYOUT_H__
+#define __GDK_TOPLEVEL_LAYOUT_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdkversionmacros.h>
+#include <gdk/gdktypes.h>
+#include <gdk/gdkmonitor.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GdkTopLevelLayout:
+ */
+typedef struct _GdkToplevelLayout GdkToplevelLayout;
+
+#define GDK_TYPE_TOPLEVEL_LAYOUT (gdk_toplevel_layout_get_type ())
+
+GDK_AVAILABLE_IN_ALL
+GType gdk_toplevel_layout_get_type (void);
+
+GDK_AVAILABLE_IN_ALL
+GdkToplevelLayout * gdk_toplevel_layout_new (int min_width,
+ int min_height,
+ int max_width,
+ int max_height);
+
+GDK_AVAILABLE_IN_ALL
+GdkToplevelLayout * gdk_toplevel_layout_ref (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_unref (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+GdkToplevelLayout * gdk_toplevel_layout_copy (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_equal (GdkToplevelLayout *layout,
+ GdkToplevelLayout *other);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_maximized (GdkToplevelLayout *layout,
+ gboolean maximized);
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
+ gboolean fullscreen,
+ GdkMonitor *monitor);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_get_min_size (GdkToplevelLayout *layout,
+ int *width,
+ int *height);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_get_max_size (GdkToplevelLayout *layout,
+ int *width,
+ int *height);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+GdkMonitor * gdk_toplevel_layout_get_fullscreen_monitor (GdkToplevelLayout *layout);
+
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_modal (GdkToplevelLayout *layout,
+ gboolean modal);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_get_modal (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_type_hint (GdkToplevelLayout *layout,
+ GdkSurfaceTypeHint hint);
+
+GDK_AVAILABLE_IN_ALL
+GdkSurfaceTypeHint gdk_toplevel_layout_get_type_hint (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_raise (GdkToplevelLayout *layout,
+ gboolean raise);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_get_raise (GdkToplevelLayout *layout);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_layout_set_lower (GdkToplevelLayout *layout,
+ gboolean lower);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gdk_toplevel_layout_get_lower (GdkToplevelLayout *layout);
+
+G_END_DECLS
+
+#endif /* __GDK_TOPLEVEL_LAYOUT_H__ */
diff --git a/gdk/meson.build b/gdk/meson.build
index 71d8393f92..27d1bc3cda 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -46,6 +46,7 @@ gdk_public_sources = files([
'gdkpopuplayout.c',
'gdkprofiler.c',
'gdkpopup.c',
+ 'gdktoplevellayout.c',
])
gdk_public_headers = files([
@@ -91,6 +92,7 @@ gdk_public_headers = files([
'gdksurface.h',
'gdkpopuplayout.h',
'gdkpopup.h',
+ 'gdktoplevellayout.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]