481763
diff -up firefox-102.2.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff firefox-102.2.0/widget/gtk/nsWindow.cpp
481763
--- firefox-102.2.0/widget/gtk/nsWindow.cpp.D110204-fscreen.diff	2022-08-18 21:54:09.000000000 +0200
481763
+++ firefox-102.2.0/widget/gtk/nsWindow.cpp	2022-09-02 15:55:18.023843940 +0200
481763
@@ -96,6 +96,7 @@
481763
 #include "ScreenHelperGTK.h"
488d12
 #include "SystemTimeConverter.h"
488d12
 #include "WidgetUtilsGtk.h"
58cb8d
+#include "nsIBrowserHandler.h"
58cb8d
 
488d12
 #ifdef ACCESSIBILITY
488d12
 #  include "mozilla/a11y/LocalAccessible.h"
481763
@@ -169,7 +170,8 @@ const gint kEvents = GDK_TOUCHPAD_GESTUR
481763
                      GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
481763
                      GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
481763
                      GDK_SMOOTH_SCROLL_MASK | GDK_TOUCH_MASK | GDK_SCROLL_MASK |
481763
-                     GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK;
481763
+                     GDK_POINTER_MOTION_MASK | GDK_PROPERTY_CHANGE_MASK |
481763
+                     GDK_FOCUS_CHANGE_MASK;
481763
 
481763
 /* utility functions */
481763
 static bool is_mouse_in_window(GdkWindow* aWindow, gdouble aMouseX,
481763
@@ -408,7 +410,8 @@ nsWindow::nsWindow()
481763
       mMovedAfterMoveToRect(false),
481763
       mResizedAfterMoveToRect(false),
481763
       mConfiguredClearColor(false),
481763
-      mGotNonBlankPaint(false) {
481763
+      mGotNonBlankPaint(false),
481763
+      mPendingFullscreen(false) {
481763
   mWindowType = eWindowType_child;
481763
   mSizeConstraints.mMaxSize = GetSafeWindowSize(mSizeConstraints.mMaxSize);
481763
 
481763
@@ -4814,6 +4817,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(
481763
+        "  Window should be fullscreen, but it's not, retrying set to "
481763
+         "fullscreen.\n");
58cb8d
+    MakeFullScreen(true);
58cb8d
+  } else {
481763
+    LOG("  Window successfully switched to fullscreen, happy now\n");
58cb8d
+    mPendingFullscreen = false;
58cb8d
+  }
58cb8d
 }
58cb8d
 
488d12
 void nsWindow::OnDPIChanged() {
481763
@@ -7042,6 +7058,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) {
481763
+        LOG("  is kiosk, ensure the window switch to fullscreen\n");
58cb8d
+        mPendingFullscreen = true;
58cb8d
+      }
58cb8d
+    } else {
481763
+      LOG("  Cannot find the browserHandler service.\n");
58cb8d
+    }
58cb8d
     gtk_window_fullscreen(GTK_WINDOW(mShell));
58cb8d
   } else {
58cb8d
     mSizeMode = mLastSizeMode;
481763
diff -up firefox-102.2.0/widget/gtk/nsWindow.h.D110204-fscreen.diff firefox-102.2.0/widget/gtk/nsWindow.h
481763
--- firefox-102.2.0/widget/gtk/nsWindow.h.D110204-fscreen.diff	2022-08-18 21:53:52.000000000 +0200
481763
+++ firefox-102.2.0/widget/gtk/nsWindow.h	2022-09-02 08:17:07.606010905 +0200
481763
@@ -712,6 +712,7 @@ class nsWindow final : public nsBaseWidg
481763
    * move-to-rect callback we set mMovedAfterMoveToRect/mResizedAfterMoveToRect.
488d12
    */
481763
   bool mWaitingForMoveToRectCallback : 1;
481763
+  bool mPendingFullscreen : 1;
481763
   bool mMovedAfterMoveToRect : 1;
481763
   bool mResizedAfterMoveToRect : 1;
58cb8d