2c691f
--- firefox-91.11.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2022-06-20 21:18:51.000000000 +0200
2c691f
+++ firefox-91.11.0/widget/gtk/nsWindow.cpp	2022-06-21 12:21:44.892706641 +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),
2c691f
@@ -4618,6 +4620,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() {
2c691f
@@ -6860,6 +6875,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;
2c691f
--- firefox-91.11.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2022-06-21 12:21:44.894706636 +0200
2c691f
+++ firefox-91.11.0/widget/gtk/nsWindow.h	2022-06-21 12:25:20.985209461 +0200
2c691f
@@ -767,6 +767,7 @@ class nsWindow final : public nsBaseWidg
2c691f
    * move-to-rect callback we set mResizedAfterMoveToRect.
13404b
    */
13404b
   bool mWaitingForMoveToRectCallback;
3262b1
+  bool mPendingFullscreen;
2c691f
   bool mResizedAfterMoveToRect;
3262b1
 
3262b1
   /**