9e2646
--- firefox-91.11.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2022-06-20 21:18:51.000000000 +0200
9e2646
+++ firefox-91.11.0/widget/gtk/nsWindow.cpp	2022-06-21 12:21:44.892706641 +0200
488d12
@@ -91,6 +91,7 @@
488d12
 #include "SystemTimeConverter.h"
488d12
 #include "WidgetUtilsGtk.h"
488d12
 #include "mozilla/X11Util.h"
58cb8d
+#include "nsIBrowserHandler.h"
58cb8d
 
488d12
 #ifdef ACCESSIBILITY
488d12
 #  include "mozilla/a11y/LocalAccessible.h"
488d12
@@ -441,6 +442,7 @@ nsWindow::nsWindow()
488d12
       mHasMappedToplevel(false),
488d12
       mRetryPointerGrab(false),
488d12
       mSizeState(nsSizeMode_Normal),
488d12
+      mPendingFullscreen(false),
488d12
       mAspectRatio(0.0f),
488d12
       mAspectRatioSaved(0.0f),
488d12
       mLastScrollEventTime(GDK_CURRENT_TIME),
9e2646
@@ -4618,6 +4620,19 @@ void nsWindow::OnWindowStateEvent(GtkWid
488d12
       ClearTransparencyBitmap();
58cb8d
     }
58cb8d
   }
58cb8d
+
58cb8d
+  // Hack to ensure window switched to fullscreen - avoid to fail when starting
58cb8d
+  // in kiosk mode
58cb8d
+  if (mPendingFullscreen &&
58cb8d
+      !(aEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)) {
58cb8d
+    LOG(
58cb8d
+        ("  Window should be fullscreen, but it's not, retrying set to "
58cb8d
+         "fullscreen.\n"));
58cb8d
+    MakeFullScreen(true);
58cb8d
+  } else {
58cb8d
+    LOG(("  Window successfully switched to fullscreen, happy now\n"));
58cb8d
+    mPendingFullscreen = false;
58cb8d
+  }
58cb8d
 }
58cb8d
 
488d12
 void nsWindow::OnDPIChanged() {
9e2646
@@ -6860,6 +6875,19 @@ nsresult nsWindow::MakeFullScreen(bool a
58cb8d
       }
58cb8d
     }
58cb8d
 
58cb8d
+    // if in kiosk, ensure the fullscreen is called
58cb8d
+    nsCOMPtr<nsIBrowserHandler> browserHandler =
58cb8d
+        do_GetService("@mozilla.org/browser/clh;1");
58cb8d
+    if (browserHandler) {
58cb8d
+      bool isKiosk;
58cb8d
+      browserHandler->GetKiosk(&isKiosk);
58cb8d
+      if (isKiosk) {
58cb8d
+        LOG(("  is kiosk, ensure the window switch to fullscreen\n"));
58cb8d
+        mPendingFullscreen = true;
58cb8d
+      }
58cb8d
+    } else {
58cb8d
+      LOG(("  Cannot find the browserHandler service.\n"));
58cb8d
+    }
58cb8d
     gtk_window_fullscreen(GTK_WINDOW(mShell));
58cb8d
   } else {
58cb8d
     mSizeMode = mLastSizeMode;
9e2646
--- firefox-91.11.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2022-06-21 12:21:44.894706636 +0200
9e2646
+++ firefox-91.11.0/widget/gtk/nsWindow.h	2022-06-21 12:25:20.985209461 +0200
9e2646
@@ -767,6 +767,7 @@ class nsWindow final : public nsBaseWidg
9e2646
    * move-to-rect callback we set mResizedAfterMoveToRect.
488d12
    */
488d12
   bool mWaitingForMoveToRectCallback;
58cb8d
+  bool mPendingFullscreen;
9e2646
   bool mResizedAfterMoveToRect;
58cb8d
 
58cb8d
   /**