1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef __MOZ_CONTAINER_WAYLAND_H__
9 #define __MOZ_CONTAINER_WAYLAND_H__
14 #include "mozilla/Mutex.h"
15 #include "WindowSurface.h"
20 * This class serves three purposes in the nsIWidget implementation.
22 * - It provides objects to receive signals from GTK for events on native
25 * - It provides GdkWindow to draw content on Wayland or when Gtk+ renders
26 * client side decorations to mShell.
29 /* Workaround for bug at wayland-util.h,
30 * present in wayland-devel < 1.12
35 struct MozContainerWayland
{
36 struct wl_surface
* surface
= nullptr;
37 struct wl_subsurface
* subsurface
= nullptr;
38 int subsurface_dx
= 0;
39 int subsurface_dy
= 0;
40 struct wl_egl_window
* eglwindow
= nullptr;
41 struct wl_callback
* frame_callback_handler
= nullptr;
42 struct wp_viewport
* viewport
= nullptr;
43 struct wp_fractional_scale_v1
* fractional_scale
= nullptr;
44 gboolean opaque_region_needs_updates
= false;
45 int opaque_region_corner_radius
= 0;
46 gboolean opaque_region_used
= false;
47 gboolean ready_to_draw
= false;
48 gboolean commit_to_parent
= false;
49 gboolean before_first_size_alloc
= false;
50 gboolean waiting_to_show
= false;
51 // Zero means no fractional scale set.
52 double current_fractional_scale
= 0.0;
54 std::vector
<std::function
<void(void)>> initial_draw_cbs
;
55 // mozcontainer is used from Compositor and Rendering threads so we need to
56 // control access to mozcontainer where wayland internals are used directly.
57 mozilla::Mutex container_lock
{"MozContainerWayland::container_lock"};
61 struct _MozContainerClass
;
62 typedef struct _MozContainer MozContainer
;
63 typedef struct _MozContainerClass MozContainerClass
;
65 class MozContainerSurfaceLock
{
66 MozContainer
* mContainer
;
67 struct wl_surface
* mSurface
;
70 explicit MozContainerSurfaceLock(MozContainer
* aContainer
);
71 ~MozContainerSurfaceLock();
72 struct wl_surface
* GetSurface();
75 void moz_container_wayland_map(GtkWidget
*);
76 gboolean
moz_container_wayland_map_event(GtkWidget
*, GdkEventAny
*);
77 void moz_container_wayland_size_allocate(GtkWidget
*, GtkAllocation
*);
78 void moz_container_wayland_unmap(GtkWidget
*);
80 struct wl_egl_window
* moz_container_wayland_get_egl_window(
81 MozContainer
* container
, double scale
);
83 gboolean
moz_container_wayland_has_egl_window(MozContainer
* container
);
84 bool moz_container_wayland_egl_window_set_size(MozContainer
* container
,
85 nsIntSize aSize
, int aScale
);
86 void moz_container_wayland_set_scale_factor_locked(
87 const mozilla::MutexAutoLock
& aProofOfLock
, MozContainer
* container
,
89 bool moz_container_wayland_size_matches_scale_factor_locked(
90 const mozilla::MutexAutoLock
& aProofOfLock
, MozContainer
* container
,
91 int aWidth
, int aHeight
);
93 void moz_container_wayland_add_initial_draw_callback_locked(
94 MozContainer
* container
, const std::function
<void(void)>& initial_draw_cb
);
95 void moz_container_wayland_add_or_fire_initial_draw_callback(
96 MozContainer
* container
, const std::function
<void(void)>& initial_draw_cb
);
97 void moz_container_wayland_clear_initial_draw_callback(MozContainer
* container
);
99 wl_surface
* moz_gtk_widget_get_wl_surface(GtkWidget
* aWidget
);
100 void moz_container_wayland_update_opaque_region(MozContainer
* container
,
102 gboolean
moz_container_wayland_can_draw(MozContainer
* container
);
103 double moz_container_wayland_get_scale(MozContainer
* container
);
104 double moz_container_wayland_get_fractional_scale(MozContainer
* container
);
105 void moz_container_wayland_set_commit_to_parent(MozContainer
* container
);
106 bool moz_container_wayland_is_commiting_to_parent(MozContainer
* container
);
107 bool moz_container_wayland_is_waiting_to_show(MozContainer
* container
);
108 void moz_container_wayland_clear_waiting_to_show_flag(MozContainer
* container
);
110 #endif /* __MOZ_CONTAINER_WAYLAND_H__ */