Commit 0a066898 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

root: Add GtkRoot:get_display vfunc

And use it.
parent a658b220
......@@ -71,9 +71,18 @@ static void gtk_invisible_get_property (GObject *object,
GParamSpec *pspec);
static void gtk_invisible_constructed (GObject *object);
static GdkDisplay *
gtk_invisible_root_get_display (GtkRoot *root)
{
GtkInvisible *invisible = GTK_INVISIBLE (root);
return invisible->priv->display;
}
static void
gtk_invisible_root_interface_init (GtkRootInterface *iface)
{
iface->get_display = gtk_invisible_root_get_display;
}
G_DEFINE_TYPE_WITH_CODE (GtkInvisible, gtk_invisible, GTK_TYPE_WIDGET,
......@@ -210,22 +219,6 @@ gtk_invisible_set_display (GtkInvisible *invisible,
gtk_widget_realize (widget);
}
/**
* gtk_invisible_get_display:
* @invisible: a #GtkInvisible.
*
* Returns the #GdkDisplay object associated with @invisible
*
* Returns: (transfer none): the associated #GdkDisplay.
**/
GdkDisplay *
gtk_invisible_get_display (GtkInvisible *invisible)
{
g_return_val_if_fail (GTK_IS_INVISIBLE (invisible), NULL);
return invisible->priv->display;
}
static void
gtk_invisible_realize (GtkWidget *widget)
{
......
......@@ -74,8 +74,6 @@ GtkWidget* gtk_invisible_new_for_display(GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gtk_invisible_set_display (GtkInvisible *invisible,
GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkDisplay*gtk_invisible_get_display (GtkInvisible *invisible);
G_END_DECLS
......
......@@ -19,7 +19,7 @@
#include "config.h"
#include "gtkroot.h"
#include "gtkrootprivate.h"
/**
* SECTION:root
......@@ -37,8 +37,26 @@
G_DEFINE_INTERFACE (GtkRoot, gtk_root, GTK_TYPE_WIDGET)
static GdkDisplay *
gtk_root_default_get_display (GtkRoot *self)
{
return gdk_display_get_default ();
}
static void
gtk_root_default_init (GtkRootInterface *iface)
{
iface->get_display = gtk_root_default_get_display;
}
GdkDisplay *
gtk_root_get_display (GtkRoot *self)
{
GtkRootInterface *iface;
g_return_val_if_fail (GTK_IS_ROOT (self), NULL);
iface = GTK_ROOT_GET_IFACE (self);
return iface->get_display (self);
}
......@@ -45,6 +45,7 @@ struct _GtkRootInterface
GTypeInterface g_iface;
/*< public >*/
GdkDisplay * (* get_display) (GtkRoot *self);
};
......
#ifndef __GTK_ROOT_PRIVATE_H__
#define __GTK_ROOT_PRIVATE_H__
#include "gtkroot.h"
G_BEGIN_DECLS
GdkDisplay * gtk_root_get_display (GtkRoot *root);
G_END_DECLS
#endif /* __GTK_ROOT_PRIVATE_H__ */
......@@ -31,11 +31,10 @@
#include "gtkcontainer.h"
#include "gtkcsstypesprivate.h"
#include "gtkeventcontroller.h"
#include "gtkroot.h"
#include "gtkgesture.h"
#include "gtkrootprivate.h"
#include "gtksizerequestcacheprivate.h"
#include "gtkwindowprivate.h"
#include "gtkinvisible.h"
#include "gtkgesture.h"
G_BEGIN_DECLS
......@@ -429,17 +428,12 @@ _gtk_widget_get_root (GtkWidget *widget)
static inline GdkDisplay *
_gtk_widget_get_display (GtkWidget *widget)
{
GtkWidget *toplevel = _gtk_widget_get_toplevel (widget);
GtkRoot *root = _gtk_widget_get_root (widget);
if (_gtk_widget_is_toplevel (toplevel))
{
if (GTK_IS_WINDOW (toplevel))
return gtk_window_get_display (GTK_WINDOW (toplevel));
else if (GTK_IS_INVISIBLE (toplevel))
return gtk_invisible_get_display (GTK_INVISIBLE (widget));
}
if (root == NULL)
return gdk_display_get_default ();
return gdk_display_get_default ();
return gtk_root_get_display (root);
}
static inline GtkStyleContext *
......
......@@ -2520,9 +2520,19 @@ gtk_window_buildable_custom_finished (GtkBuildable *buildable,
}
}
static GdkDisplay *
gtk_window_root_get_display (GtkRoot *root)
{
GtkWindow *window = GTK_WINDOW (root);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
return priv->display;
}
static void
gtk_window_root_interface_init (GtkRootInterface *iface)
{
iface->get_display = gtk_window_root_get_display;
}
/**
......@@ -9901,14 +9911,6 @@ gtk_window_on_theme_variant_changed (GtkSettings *settings,
}
#endif
GdkDisplay *
gtk_window_get_display (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
return priv->display;
}
/**
* gtk_window_is_active:
* @window: a #GtkWindow
......
......@@ -121,8 +121,6 @@ void gtk_window_set_use_subsurface (GtkWindow *window,
void gtk_window_set_hardcoded_surface (GtkWindow *window,
GdkSurface *surface);
GdkDisplay *gtk_window_get_display (GtkWindow *window);
/* Exported handles */
typedef void (*GtkWindowHandleExported) (GtkWindow *window,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment