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