Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / widget / gtk / WaylandSurfaceLock.cpp
blobf4deb4d84d909d4a67b307d244ac690e5197bfc3
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
3 */
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 #include "WaylandSurfaceLock.h"
9 #ifdef MOZ_WAYLAND
10 # include "WaylandSurface.h"
11 #endif
12 #include "MozContainer.h"
13 #include "WidgetUtilsGtk.h"
15 namespace mozilla::widget {
17 WaylandSurfaceLock::WaylandSurfaceLock(RefPtr<WaylandSurface> aWaylandSurface,
18 bool aForceCommit) {
19 #ifdef MOZ_WAYLAND
20 mWaylandSurface = std::move(aWaylandSurface);
21 mForceCommit = aForceCommit;
22 if (GdkIsWaylandDisplay()) {
23 MOZ_DIAGNOSTIC_ASSERT(mWaylandSurface);
24 // mSurface can be nullptr if we lock hidden MozContainer and
25 // that's correct, MozContainer is still locked.
26 mSurface = mWaylandSurface->Lock(this);
28 #endif
31 WaylandSurfaceLock::~WaylandSurfaceLock() {
32 #ifdef MOZ_WAYLAND
33 if (GdkIsWaylandDisplay()) {
34 mWaylandSurface->Commit(this, mForceCommit,
35 /* flush display */ false);
36 mWaylandSurface->Unlock(&mSurface, this);
38 #endif
41 WaylandSurface* WaylandSurfaceLock::GetWaylandSurface() {
42 #ifdef MOZ_WAYLAND
43 return mWaylandSurface.get();
44 #else
45 return nullptr;
46 #endif
49 } // namespace mozilla::widget