forked from AuroraMiddleware/gtk
Add a GdkDragSurface interface
This will provide functionality specific to drag icons.
This commit is contained in:
parent
3a4e647b2d
commit
b25be8a42f
@ -44,6 +44,7 @@
|
||||
#include <gdk/gdkdisplay.h>
|
||||
#include <gdk/gdkdisplaymanager.h>
|
||||
#include <gdk/gdkdrag.h>
|
||||
#include <gdk/gdkdragsurface.h>
|
||||
#include <gdk/gdkdrawcontext.h>
|
||||
#include <gdk/gdkdrop.h>
|
||||
#include <gdk/gdkenumtypes.h>
|
||||
|
71
gdk/gdkdragsurface.c
Normal file
71
gdk/gdkdragsurface.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 "gdk-private.h"
|
||||
#include "gdkdragsurfaceprivate.h"
|
||||
#include "gdkintl.h"
|
||||
|
||||
/**
|
||||
* SECTION:gdkdragsurface
|
||||
* @Short_description: Interface for drag surface surfaces
|
||||
* @Title: Drag surfaces
|
||||
*
|
||||
* A #GdkDragSurface is a surface that is used during a
|
||||
* DND operation.
|
||||
*/
|
||||
|
||||
G_DEFINE_INTERFACE (GdkDragSurface, gdk_drag_surface, GDK_TYPE_SURFACE)
|
||||
|
||||
static gboolean
|
||||
gdk_drag_surface_default_present (GdkDragSurface *drag_surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drag_surface_default_init (GdkDragSurfaceInterface *iface)
|
||||
{
|
||||
iface->present = gdk_drag_surface_default_present;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drag_surface_present:
|
||||
* @drag_surface: the #GdkDragSurface to show
|
||||
* @width: the unconstrained drag_surface width to layout
|
||||
* @height: the unconstrained drag_surface height to layout
|
||||
*
|
||||
* Present @drag_surface.
|
||||
*
|
||||
* Returns: %FALSE if it failed to be presented, otherwise %TRUE.
|
||||
*/
|
||||
gboolean
|
||||
gdk_drag_surface_present (GdkDragSurface *drag_surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_DRAG_SURFACE (drag_surface), FALSE);
|
||||
g_return_val_if_fail (width > 0, FALSE);
|
||||
g_return_val_if_fail (height > 0, FALSE);
|
||||
|
||||
return GDK_DRAG_SURFACE_GET_IFACE (drag_surface)->present (drag_surface, width, height);
|
||||
}
|
43
gdk/gdkdragsurface.h
Normal file
43
gdk/gdkdragsurface.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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_DRAG_SURFACE_H__
|
||||
#define __GDK_DRAG_SURFACE_H__
|
||||
|
||||
#if !defined(__GDK_H_INSIDE__) && !defined(GTK_COMPILATION)
|
||||
#error "Only <gdk/gdk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdksurface.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GDK_TYPE_DRAG_SURFACE (gdk_drag_surface_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (GdkDragSurface, gdk_drag_surface, GDK, DRAG_SURFACE, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_drag_surface_present (GdkDragSurface *drag_icon,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DRAG_SURFACE_H__ */
|
20
gdk/gdkdragsurfaceprivate.h
Normal file
20
gdk/gdkdragsurfaceprivate.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __GDK_DRAG_SURFACE_PRIVATE_H__
|
||||
#define __GDK_DRAG_SURFACE_PRIVATE_H__
|
||||
|
||||
#include "gdkdragsurface.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
struct _GdkDragSurfaceInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
gboolean (* present) (GdkDragSurface *drag_surface,
|
||||
int width,
|
||||
int height);
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_DRAG_SURFACE_PRIVATE_H__ */
|
@ -32,6 +32,7 @@
|
||||
#include "gdk-private.h"
|
||||
#include "gdkdeviceprivate.h"
|
||||
#include "gdkdisplayprivate.h"
|
||||
#include "gdkdragsurfaceprivate.h"
|
||||
#include "gdkeventsprivate.h"
|
||||
#include "gdkframeclockidleprivate.h"
|
||||
#include "gdkglcontextprivate.h"
|
||||
@ -113,12 +114,15 @@ static GParamSpec *properties[LAST_PROP] = { NULL, };
|
||||
|
||||
static void gdk_surface_popup_init (GdkPopupInterface *iface);
|
||||
static void gdk_surface_toplevel_init (GdkToplevelInterface *iface);
|
||||
static void gdk_surface_drag_surface_init (GdkDragSurfaceInterface *iface);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GdkSurface, gdk_surface, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
|
||||
gdk_surface_popup_init)
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
|
||||
gdk_surface_toplevel_init))
|
||||
gdk_surface_toplevel_init)
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
|
||||
gdk_surface_drag_surface_init))
|
||||
|
||||
static gboolean
|
||||
gdk_surface_real_beep (GdkSurface *surface)
|
||||
@ -2176,6 +2180,27 @@ gdk_surface_toplevel_init (GdkToplevelInterface *iface)
|
||||
iface->show_window_menu = gdk_toplevel_surface_show_window_menu;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gdk_drag_surface_real_present (GdkDragSurface *drag_surface,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
GdkSurface *surface = GDK_SURFACE (drag_surface);
|
||||
|
||||
g_return_val_if_fail (surface->surface_type == GDK_SURFACE_TEMP, FALSE);
|
||||
|
||||
GDK_SURFACE_GET_CLASS (surface)->toplevel_resize (surface, width, height);
|
||||
gdk_surface_show_internal (surface, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_drag_surface_init (GdkDragSurfaceInterface *iface)
|
||||
{
|
||||
iface->present = gdk_drag_surface_real_present;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_surface_set_cursor_internal (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
|
@ -48,6 +48,7 @@ gdk_public_sources = files([
|
||||
'gdkpopup.c',
|
||||
'gdktoplevellayout.c',
|
||||
'gdktoplevel.c',
|
||||
'gdkdragsurface.c',
|
||||
])
|
||||
|
||||
gdk_public_headers = files([
|
||||
@ -95,6 +96,7 @@ gdk_public_headers = files([
|
||||
'gdkpopup.h',
|
||||
'gdktoplevellayout.h',
|
||||
'gdktoplevel.h',
|
||||
'gdkdragsurface.h',
|
||||
])
|
||||
install_headers(gdk_public_headers, subdir: 'gtk-4.0/gdk/')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user