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