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