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