f3b160
diff -up firefox-91.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff firefox-91.0/widget/gtk/nsWindow.cpp
f3b160
--- firefox-91.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2021-07-27 23:31:38.000000000 +0200
f3b160
+++ firefox-91.0/widget/gtk/nsWindow.cpp	2021-07-30 15:47:22.031795569 +0200
f3b160
@@ -91,6 +91,7 @@
f3b160
 #include "SystemTimeConverter.h"
f3b160
 #include "WidgetUtilsGtk.h"
f3b160
 #include "mozilla/X11Util.h"
72d64d
+#include "nsIBrowserHandler.h"
72d64d
 
f3b160
 #ifdef ACCESSIBILITY
f3b160
 #  include "mozilla/a11y/LocalAccessible.h"
f3b160
@@ -441,6 +442,7 @@ nsWindow::nsWindow()
f3b160
       mHasMappedToplevel(false),
f3b160
       mRetryPointerGrab(false),
f3b160
       mSizeState(nsSizeMode_Normal),
f3b160
+      mPendingFullscreen(false),
f3b160
       mAspectRatio(0.0f),
f3b160
       mAspectRatioSaved(0.0f),
f3b160
       mLastScrollEventTime(GDK_CURRENT_TIME),
f3b160
@@ -4626,6 +4628,19 @@ void nsWindow::OnWindowStateEvent(GtkWid
f3b160
       ClearTransparencyBitmap();
72d64d
     }
72d64d
   }
72d64d
+
72d64d
+  // Hack to ensure window switched to fullscreen - avoid to fail when starting
72d64d
+  // in kiosk mode
72d64d
+  if (mPendingFullscreen &&
72d64d
+      !(aEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
72d64d
+    LOG(
72d64d
+        ("  Window should be fullscreen, but it's not, retrying set to "
72d64d
+         "fullscreen.\n"));
72d64d
+    MakeFullScreen(true);
72d64d
+  } else {
72d64d
+    LOG(("  Window successfully switched to fullscreen, happy now\n"));
72d64d
+    mPendingFullscreen = false;
72d64d
+  }
72d64d
 }
72d64d
 
f3b160
 void nsWindow::OnDPIChanged() {
f3b160
@@ -6880,6 +6895,19 @@ nsresult nsWindow::MakeFullScreen(bool a
72d64d
       }
72d64d
     }
72d64d
 
72d64d
+    // if in kiosk, ensure the fullscreen is called
72d64d
+    nsCOMPtr<nsIBrowserHandler> browserHandler =
72d64d
+        do_GetService("@mozilla.org/browser/clh;1");
72d64d
+    if (browserHandler) {
72d64d
+      bool isKiosk;
72d64d
+      browserHandler->GetKiosk(&isKiosk);
72d64d
+      if (isKiosk) {
72d64d
+        LOG(("  is kiosk, ensure the window switch to fullscreen\n"));
72d64d
+        mPendingFullscreen = true;
72d64d
+      }
72d64d
+    } else {
72d64d
+      LOG(("  Cannot find the browserHandler service.\n"));
72d64d
+    }
72d64d
     gtk_window_fullscreen(GTK_WINDOW(mShell));
72d64d
   } else {
72d64d
     mSizeMode = mLastSizeMode;
f3b160
diff -up firefox-91.0/widget/gtk/nsWindow.h.D110204-fscreen.diff firefox-91.0/widget/gtk/nsWindow.h
f3b160
--- firefox-91.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2021-07-27 23:31:38.000000000 +0200
f3b160
+++ firefox-91.0/widget/gtk/nsWindow.h	2021-07-29 18:35:41.000639386 +0200
f3b160
@@ -763,6 +763,7 @@ class nsWindow final : public nsBaseWidg
f3b160
    * move-to-rect callback we store it to mNewSizeAfterMoveToRect.
f3b160
    */
f3b160
   bool mWaitingForMoveToRectCallback;
72d64d
+  bool mPendingFullscreen;
f3b160
   LayoutDeviceIntRect mNewSizeAfterMoveToRect;
72d64d
 
72d64d
   /**