488d12
diff -up firefox-91.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff firefox-91.0/widget/gtk/nsWindow.cpp
488d12
--- firefox-91.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2021-07-27 23:31:38.000000000 +0200
488d12
+++ firefox-91.0/widget/gtk/nsWindow.cpp	2021-07-30 15:47:22.031795569 +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),
488d12
@@ -4626,6 +4628,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() {
488d12
@@ -6880,6 +6895,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;
488d12
diff -up firefox-91.0/widget/gtk/nsWindow.h.D110204-fscreen.diff firefox-91.0/widget/gtk/nsWindow.h
488d12
--- firefox-91.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2021-07-27 23:31:38.000000000 +0200
488d12
+++ firefox-91.0/widget/gtk/nsWindow.h	2021-07-29 18:35:41.000639386 +0200
488d12
@@ -763,6 +763,7 @@ class nsWindow final : public nsBaseWidg
488d12
    * move-to-rect callback we store it to mNewSizeAfterMoveToRect.
488d12
    */
488d12
   bool mWaitingForMoveToRectCallback;
58cb8d
+  bool mPendingFullscreen;
488d12
   LayoutDeviceIntRect mNewSizeAfterMoveToRect;
58cb8d
 
58cb8d
   /**