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