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