2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2002-04-27 20:26:10 +04:00
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-12-10 20:37:36 +03:00
|
|
|
|
2001-12-04 19:58:04 +03:00
|
|
|
#ifndef __MOZ_CONTAINER_H__
|
|
|
|
#define __MOZ_CONTAINER_H__
|
|
|
|
|
2009-01-03 10:37:52 +03:00
|
|
|
#include <gtk/gtk.h>
|
2019-02-25 15:15:50 +03:00
|
|
|
#include <functional>
|
2001-12-04 19:58:04 +03:00
|
|
|
|
2009-05-15 06:14:45 +04:00
|
|
|
/*
|
|
|
|
* MozContainer
|
|
|
|
*
|
2017-10-24 15:06:29 +03:00
|
|
|
* This class serves three purposes in the nsIWidget implementation.
|
2009-05-15 06:14:45 +04:00
|
|
|
*
|
|
|
|
* - It provides objects to receive signals from GTK for events on native
|
|
|
|
* windows.
|
|
|
|
*
|
2017-10-24 15:06:29 +03:00
|
|
|
* - It provides GdkWindow to draw content on Wayland or when Gtk+ renders
|
|
|
|
* client side decorations to mShell.
|
|
|
|
*
|
2009-05-15 06:14:45 +04:00
|
|
|
* - It provides a container parent for GtkWidgets. The only GtkWidgets
|
|
|
|
* that need this in Mozilla are the GtkSockets for windowed plugins (Xt
|
|
|
|
* and XEmbed).
|
|
|
|
*
|
|
|
|
* Note that the window hierarchy in Mozilla differs from conventional
|
|
|
|
* GtkWidget hierarchies.
|
|
|
|
*
|
|
|
|
* Mozilla's hierarchy exists through the GdkWindow hierarchy, and all child
|
|
|
|
* GdkWindows (within a child nsIWidget hierarchy) belong to one MozContainer
|
|
|
|
* GtkWidget. If the MozContainer is unrealized or its GdkWindows are
|
|
|
|
* destroyed for some other reason, then the hierarchy no longer exists. (In
|
|
|
|
* conventional GTK clients, the hierarchy is recorded by the GtkWidgets, and
|
|
|
|
* so can be re-established after destruction of the GdkWindows.)
|
|
|
|
*
|
|
|
|
* One consequence of this is that the MozContainer does not know which of its
|
|
|
|
* GdkWindows should parent child GtkWidgets. (Conventional GtkContainers
|
|
|
|
* determine which GdkWindow to assign child GtkWidgets.)
|
|
|
|
*
|
|
|
|
* Therefore, when adding a child GtkWidget to a MozContainer,
|
|
|
|
* gtk_widget_set_parent_window should be called on the child GtkWidget before
|
|
|
|
* it is realized.
|
|
|
|
*/
|
2017-12-19 13:38:59 +03:00
|
|
|
|
2001-12-04 19:58:04 +03:00
|
|
|
#define MOZ_CONTAINER_TYPE (moz_container_get_type())
|
2009-02-02 20:49:58 +03:00
|
|
|
#define MOZ_CONTAINER(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj), MOZ_CONTAINER_TYPE, MozContainer))
|
|
|
|
#define MOZ_CONTAINER_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass), MOZ_CONTAINER_TYPE, MozContainerClass))
|
|
|
|
#define IS_MOZ_CONTAINER(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj), MOZ_CONTAINER_TYPE))
|
|
|
|
#define IS_MOZ_CONTAINER_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass), MOZ_CONTAINER_TYPE))
|
2017-07-19 11:01:59 +03:00
|
|
|
#define MOZ_CONTAINER_GET_CLASS(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS((obj), MOZ_CONTAINER_TYPE, MozContainerClass))
|
2001-12-04 19:58:04 +03:00
|
|
|
|
|
|
|
typedef struct _MozContainer MozContainer;
|
|
|
|
typedef struct _MozContainerClass MozContainerClass;
|
|
|
|
|
2017-10-24 15:06:29 +03:00
|
|
|
/* Workaround for bug at wayland-util.h,
|
|
|
|
* present in wayland-devel < 1.12
|
|
|
|
*/
|
|
|
|
#ifdef MOZ_WAYLAND
|
|
|
|
struct wl_surface;
|
|
|
|
struct wl_subsurface;
|
|
|
|
#endif
|
|
|
|
|
2001-12-04 19:58:04 +03:00
|
|
|
struct _MozContainer {
|
2002-04-27 20:26:10 +04:00
|
|
|
GtkContainer container;
|
2019-05-01 11:47:10 +03:00
|
|
|
GList* children;
|
2017-10-24 15:06:29 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_WAYLAND
|
2019-05-01 11:47:10 +03:00
|
|
|
struct wl_surface* surface;
|
|
|
|
struct wl_subsurface* subsurface;
|
|
|
|
struct wl_egl_window* eglwindow;
|
|
|
|
struct wl_callback* frame_callback_handler;
|
2019-03-18 16:16:42 +03:00
|
|
|
int frame_callback_handler_surface_id;
|
2018-12-03 16:06:21 +03:00
|
|
|
gboolean surface_needs_clear;
|
|
|
|
gboolean ready_to_draw;
|
2019-02-25 15:15:50 +03:00
|
|
|
std::function<void(void)> inital_draw_cb;
|
2017-10-24 15:06:29 +03:00
|
|
|
#endif
|
2019-01-23 15:36:25 +03:00
|
|
|
gboolean force_default_visual;
|
2001-12-04 19:58:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _MozContainerClass {
|
2002-04-27 20:26:10 +04:00
|
|
|
GtkContainerClass parent_class;
|
2001-12-04 19:58:04 +03:00
|
|
|
};
|
|
|
|
|
2009-02-02 20:49:58 +03:00
|
|
|
GType moz_container_get_type(void);
|
2019-05-01 11:47:10 +03:00
|
|
|
GtkWidget* moz_container_new(void);
|
|
|
|
void moz_container_put(MozContainer* container, GtkWidget* child_widget, gint x,
|
2002-04-27 20:26:10 +04:00
|
|
|
gint y);
|
2019-05-01 11:47:10 +03:00
|
|
|
void moz_container_force_default_visual(MozContainer* container);
|
2004-05-08 10:02:48 +04:00
|
|
|
|
2017-10-24 16:26:48 +03:00
|
|
|
#ifdef MOZ_WAYLAND
|
2019-05-01 11:47:10 +03:00
|
|
|
struct wl_surface* moz_container_get_wl_surface(MozContainer* container);
|
|
|
|
struct wl_egl_window* moz_container_get_wl_egl_window(MozContainer* container);
|
2018-12-06 14:02:46 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
gboolean moz_container_has_wl_egl_window(MozContainer* container);
|
|
|
|
gboolean moz_container_surface_needs_clear(MozContainer* container);
|
|
|
|
void moz_container_scale_changed(MozContainer* container,
|
|
|
|
GtkAllocation* aAllocation);
|
2019-02-25 15:15:50 +03:00
|
|
|
void moz_container_set_initial_draw_callback(
|
2019-05-01 11:47:10 +03:00
|
|
|
MozContainer* container, std::function<void(void)> inital_draw_cb);
|
2019-09-20 15:58:03 +03:00
|
|
|
void moz_container_set_opaque_region(MozContainer* container,
|
|
|
|
cairo_region_t* region);
|
2017-10-24 16:26:48 +03:00
|
|
|
#endif
|
|
|
|
|
2001-12-04 19:58:04 +03:00
|
|
|
#endif /* __MOZ_CONTAINER_H__ */
|