summaryrefslogtreecommitdiffstats
path: root/widget/gtk/MozContainerWayland.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /widget/gtk/MozContainerWayland.h
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--widget/gtk/MozContainerWayland.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/widget/gtk/MozContainerWayland.h b/widget/gtk/MozContainerWayland.h
new file mode 100644
index 0000000000..369d40a552
--- /dev/null
+++ b/widget/gtk/MozContainerWayland.h
@@ -0,0 +1,108 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
+/* 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/. */
+
+#ifndef __MOZ_CONTAINER_WAYLAND_H__
+#define __MOZ_CONTAINER_WAYLAND_H__
+
+#include <gtk/gtk.h>
+#include <functional>
+#include <vector>
+#include "mozilla/Mutex.h"
+#include "WindowSurface.h"
+
+/*
+ * MozContainer
+ *
+ * This class serves three purposes in the nsIWidget implementation.
+ *
+ * - It provides objects to receive signals from GTK for events on native
+ * windows.
+ *
+ * - It provides GdkWindow to draw content on Wayland or when Gtk+ renders
+ * client side decorations to mShell.
+ */
+
+/* Workaround for bug at wayland-util.h,
+ * present in wayland-devel < 1.12
+ */
+struct wl_surface;
+struct wl_subsurface;
+
+struct MozContainerWayland {
+ struct wl_surface* surface;
+ struct wl_subsurface* subsurface;
+ int subsurface_dx, subsurface_dy;
+ struct wl_egl_window* eglwindow;
+ struct wl_callback* frame_callback_handler;
+ struct wp_viewport* viewport;
+ gboolean opaque_region_needs_updates;
+ int opaque_region_corner_radius;
+ gboolean opaque_region_used;
+ gboolean ready_to_draw;
+ gboolean commit_to_parent;
+ gboolean before_first_size_alloc;
+ gboolean waiting_to_show;
+ int buffer_scale;
+ std::vector<std::function<void(void)>> initial_draw_cbs;
+ // mozcontainer is used from Compositor and Rendering threads
+ // so we need to control access to mozcontainer where wayland internals
+ // are used directly.
+ mozilla::Mutex* container_lock;
+};
+
+struct _MozContainer;
+struct _MozContainerClass;
+typedef struct _MozContainer MozContainer;
+typedef struct _MozContainerClass MozContainerClass;
+
+class MozContainerSurfaceLock {
+ MozContainer* mContainer;
+ struct wl_surface* mSurface;
+
+ public:
+ explicit MozContainerSurfaceLock(MozContainer* aContainer);
+ ~MozContainerSurfaceLock();
+ struct wl_surface* GetSurface();
+};
+
+void moz_container_wayland_class_init(MozContainerClass* klass);
+void moz_container_wayland_init(MozContainerWayland* container);
+void moz_container_wayland_unmap(GtkWidget* widget);
+
+struct wl_egl_window* moz_container_wayland_get_egl_window(
+ MozContainer* container, double scale);
+
+gboolean moz_container_wayland_has_egl_window(MozContainer* container);
+void moz_container_wayland_egl_window_set_size(MozContainer* container,
+ nsIntSize aSize);
+bool moz_container_wayland_egl_window_needs_size_update(MozContainer* container,
+ nsIntSize aSize,
+ int scale);
+void moz_container_wayland_set_scale_factor(MozContainer* container);
+void moz_container_wayland_set_scale_factor_locked(
+ const mozilla::MutexAutoLock& aProofOfLock, MozContainer* container);
+bool moz_container_wayland_size_matches_scale_factor_locked(
+ const mozilla::MutexAutoLock& aProofOfLock, MozContainer* container,
+ int aWidth, int aHeight);
+
+void moz_container_wayland_add_initial_draw_callback_locked(
+ MozContainer* container, const std::function<void(void)>& initial_draw_cb);
+void moz_container_wayland_add_or_fire_initial_draw_callback(
+ MozContainer* container, const std::function<void(void)>& initial_draw_cb);
+void moz_container_wayland_clear_initial_draw_callback(MozContainer* container);
+
+wl_surface* moz_gtk_widget_get_wl_surface(GtkWidget* aWidget);
+void moz_container_wayland_update_opaque_region(MozContainer* container,
+ int corner_radius);
+gboolean moz_container_wayland_can_draw(MozContainer* container);
+double moz_container_wayland_get_scale(MozContainer* container);
+void moz_container_wayland_set_commit_to_parent(MozContainer* container);
+bool moz_container_wayland_is_commiting_to_parent(MozContainer* container);
+bool moz_container_wayland_is_waiting_to_show(MozContainer* container);
+void moz_container_wayland_clear_waiting_to_show_flag(MozContainer* container);
+
+#endif /* __MOZ_CONTAINER_WAYLAND_H__ */