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