Introduce GdkToplevel
This is a new interface for toplevel surfaces.
This commit is contained in:
@@ -69,6 +69,7 @@
|
||||
#include <gdk/gdkvulkancontext.h>
|
||||
#include <gdk/gdksurface.h>
|
||||
#include <gdk/gdkpopup.h>
|
||||
#include <gdk/gdktoplevel.h>
|
||||
|
||||
#include <gdk/gdk-autocleanup.h>
|
||||
|
||||
|
||||
80
gdk/gdktoplevel.c
Normal file
80
gdk/gdktoplevel.c
Normal file
@@ -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);
|
||||
}
|
||||
45
gdk/gdktoplevel.h
Normal file
45
gdk/gdktoplevel.h
Normal file
@@ -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__ */
|
||||
21
gdk/gdktoplevelprivate.h
Normal file
21
gdk/gdktoplevelprivate.h
Normal file
@@ -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__ */
|
||||
@@ -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/')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user